1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#ifndef LV2Library_hxx
#define LV2Library_hxx
#include <vector>
#include <lv2.h>
#include <map>
#include <cstring>
class LV2Library
{
std::vector<LV2_Descriptor * > _descriptors;
static void CleanUpDescriptor(LV2_Descriptor *& descriptor)
{
if (not descriptor) return;
delete[] descriptor->URI;
delete descriptor;
descriptor = 0;
}
public:
LV2Library()
{
}
~LV2Library()
{
for (unsigned i=0; i<_descriptors.size(); i++)
CleanUpDescriptor(_descriptors[i]);
}
void AddPluginType(LV2_Descriptor * descriptor,const std::string & networkContent)
{
_descriptors.push_back(descriptor);
addUri(descriptor->URI,networkContent);
}
LV2_Descriptor * pluginAt(unsigned long i)
{
if (i>=_descriptors.size()) return 0;
return _descriptors[i];
}
static char *dupstr( char const *args )
{
const size_t v = strlen(args) + 1;
char * s = new char[v];
memcpy( s, args, v);
return s;
}
static void addUri(const std::string & uri,const std::string & network)
{
uri2network()[uri] = network;
}
static std::string & getNetwork(const std::string & uri)
{
return uri2network()[uri];
}
private:
static std::map<std::string,std::string> & uri2network()
{
static std::map<std::string,std::string> map;
return map;
}
};
#endif//LV2Library_hxx
|