#include <Factory.hxx>
To define a factory for your types you should create your own factory subclass.
// MyFactory.hxx class MyFactory : public CLAM::Factory<MyAbstractProduct> { public: static MyFactory& GetInstance(); };
You must define GetInstance() method in a .cxx
// MyFactory.cxx #include "MyFactory.hxx" MyFactory& MyFactory::GetInstance() { static MyFactory theInstance; return theInstance; }
To automatically register concrete products into the factory at program loading time (before "main()"), declare a registrator object like this:
// put this in a .cxx (not in a header) static CLAM::FactoryRegistrator<MyFactory, MyConcreteProduct> regMyConcreteProduct("MyConcreteProduct");
Definition at line 69 of file Factory.hxx.
Public Types | |
typedef AbstractProductType | AbstractProduct |
typedef std::string | RegistryKey |
typedef std::list< Key > | Keys |
typedef std::list< std::string > | Values |
typedef std::list< Pair > | Pairs |
typedef AbstractProduct *(* | CreatorMethod )(void) |
Public Member Functions | |
Factory () | |
~Factory () | |
AbstractProduct * | Create (const RegistryKey name) |
Gives ownership of the new created Product registered with the given name. | |
AbstractProduct * | CreateSafe (const RegistryKey name) throw (ErrFactory) |
Gives ownership of the new created Product registered with the given name. | |
void | Clear () |
void | AddCreator (const RegistryKey name, Creator *creator) |
void | AddCreatorWarningRepetitions (const RegistryKey name, Creator *creator) |
void | AddCreatorSafe (const RegistryKey name, Creator *creator) throw (ErrFactory) |
void | DeleteCreator (const RegistryKey name) |
void | GetRegisteredNames (std::list< std::string > &namesList) |
bool | KeyExists (const RegistryKey &key) |
bool | AttributeExists (const std::string &key, const std::string &attribute) |
Keys | GetKeys (const std::string &attribute, const std::string &value) |
Get all keys that have attribute==value in its metadata. | |
Keys | GetKeys () |
Get all keys in the factory. | |
Pairs | GetPairsFromKey (const std::string &key) |
Return all the metadata available for a product key. | |
Values | GetSetOfValues (const std::string &attribute) |
Get the set of all values present for a given metadata attribute. Example GetSetOfValues("category") could return ["modulators","generators","reverbs"] without repeated items. | |
Values | GetValuesFromAttribute (const std::string &key, const std::string &attribute) |
Return the list of values for a metadata attribute for a product key. | |
Value | GetValueFromAttribute (const std::string &key, const std::string &attribute) |
Return the value for a metadata attribute of product key. If multiple values exist returns the first value. | |
void | AddAttribute (const std::string &key, const std::string &attribute, const std::string &value) |
int | Count () |
Classes | |
class | Creator |
Abstract class for Creator objects which are stored in the Factory::Registry. More... | |
struct | Pair |
class | Registry |
This class is an implementation class of the Factory. More... |
typedef AbstractProductType CLAM::Factory< AbstractProductType >::AbstractProduct |
Definition at line 72 of file Factory.hxx.
typedef std::string CLAM::Factory< AbstractProductType >::RegistryKey |
Definition at line 73 of file Factory.hxx.
typedef std::list<Key> CLAM::Factory< AbstractProductType >::Keys |
Definition at line 86 of file Factory.hxx.
typedef std::list<std::string> CLAM::Factory< AbstractProductType >::Values |
Definition at line 87 of file Factory.hxx.
typedef std::list<Pair> CLAM::Factory< AbstractProductType >::Pairs |
Definition at line 88 of file Factory.hxx.
typedef AbstractProduct*(* CLAM::Factory< AbstractProductType >::CreatorMethod)(void) |
CLAM::Factory< AbstractProductType >::Factory | ( | ) | [inline] |
Definition at line 100 of file Factory.hxx.
CLAM::Factory< AbstractProductType >::~Factory | ( | ) | [inline] |
Definition at line 101 of file Factory.hxx.
AbstractProduct* CLAM::Factory< AbstractProductType >::Create | ( | const RegistryKey | name | ) | [inline] |
Gives ownership of the new created Product registered with the given name.
It asserts that the name is in the registry.
Definition at line 113 of file Factory.hxx.
AbstractProduct* CLAM::Factory< AbstractProductType >::CreateSafe | ( | const RegistryKey | name | ) | throw (ErrFactory) [inline] |
Gives ownership of the new created Product registered with the given name.
It throws an ErrFactory if the name isn't found in the registry.
Definition at line 125 of file Factory.hxx.
Referenced by CLAM::FlattenedNetwork::AddProcessing(), and CLAM::ProcessingDefinitionAdapter::LoadFrom().
void CLAM::Factory< AbstractProductType >::Clear | ( | ) | [inline] |
Definition at line 131 of file Factory.hxx.
void CLAM::Factory< AbstractProductType >::AddCreator | ( | const RegistryKey | name, | |
Creator * | creator | |||
) | [inline] |
Definition at line 136 of file Factory.hxx.
void CLAM::Factory< AbstractProductType >::AddCreatorWarningRepetitions | ( | const RegistryKey | name, | |
Creator * | creator | |||
) | [inline] |
Definition at line 141 of file Factory.hxx.
Referenced by RunTimeLadspaLibraryLoader::SetupLibrary(), and RunTimeFaustLibraryLoader::SetupLibrary().
void CLAM::Factory< AbstractProductType >::AddCreatorSafe | ( | const RegistryKey | name, | |
Creator * | creator | |||
) | throw (ErrFactory) [inline] |
Definition at line 146 of file Factory.hxx.
void CLAM::Factory< AbstractProductType >::DeleteCreator | ( | const RegistryKey | name | ) | [inline] |
void CLAM::Factory< AbstractProductType >::GetRegisteredNames | ( | std::list< std::string > & | namesList | ) | [inline] |
Definition at line 156 of file Factory.hxx.
bool CLAM::Factory< AbstractProductType >::KeyExists | ( | const RegistryKey & | key | ) | [inline] |
Definition at line 161 of file Factory.hxx.
bool CLAM::Factory< AbstractProductType >::AttributeExists | ( | const std::string & | key, | |
const std::string & | attribute | |||
) | [inline] |
Definition at line 166 of file Factory.hxx.
Referenced by RunTimeFaustLibraryLoader::SetupLibrary().
Keys CLAM::Factory< AbstractProductType >::GetKeys | ( | const std::string & | attribute, | |
const std::string & | value | |||
) | [inline] |
Get all keys that have attribute==value in its metadata.
Definition at line 172 of file Factory.hxx.
Referenced by RunTimeLibraryLoader::ReLoad().
Keys CLAM::Factory< AbstractProductType >::GetKeys | ( | ) | [inline] |
Get all keys in the factory.
Definition at line 177 of file Factory.hxx.
Referenced by CLAM::Factory< CLAM::Processing >::GetKeys().
Pairs CLAM::Factory< AbstractProductType >::GetPairsFromKey | ( | const std::string & | key | ) | [inline] |
Values CLAM::Factory< AbstractProductType >::GetSetOfValues | ( | const std::string & | attribute | ) | [inline] |
Get the set of all values present for a given metadata attribute. Example GetSetOfValues("category") could return ["modulators","generators","reverbs"] without repeated items.
Definition at line 188 of file Factory.hxx.
Referenced by RunTimeLibraryLoader::GetUsedLibraries().
Values CLAM::Factory< AbstractProductType >::GetValuesFromAttribute | ( | const std::string & | key, | |
const std::string & | attribute | |||
) | [inline] |
Return the list of values for a metadata attribute for a product key.
Definition at line 193 of file Factory.hxx.
Referenced by CLAM::Factory< CLAM::Processing >::GetValueFromAttribute().
Value CLAM::Factory< AbstractProductType >::GetValueFromAttribute | ( | const std::string & | key, | |
const std::string & | attribute | |||
) | [inline] |
Return the value for a metadata attribute of product key. If multiple values exist returns the first value.
Definition at line 199 of file Factory.hxx.
void CLAM::Factory< AbstractProductType >::AddAttribute | ( | const std::string & | key, | |
const std::string & | attribute, | |||
const std::string & | value | |||
) | [inline] |
Definition at line 204 of file Factory.hxx.
Referenced by RunTimeLadspaLibraryLoader::SetupLibrary(), and RunTimeFaustLibraryLoader::SetupLibrary().
int CLAM::Factory< AbstractProductType >::Count | ( | ) | [inline] |
Definition at line 505 of file Factory.hxx.