|
CLAM-Development
1.3
|
Factory usage example. More...
#include <Factory.hxx>
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... | |
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 |
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 () |
Factory usage example.
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()" starts), 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 70 of file Factory.hxx.
| typedef AbstractProductType CLAM::Factory< AbstractProductType >::AbstractProduct |
Definition at line 73 of file Factory.hxx.
| typedef std::list<Key> CLAM::Factory< AbstractProductType >::Keys |
Definition at line 87 of file Factory.hxx.
| typedef std::list<Pair> CLAM::Factory< AbstractProductType >::Pairs |
Definition at line 89 of file Factory.hxx.
| typedef std::string CLAM::Factory< AbstractProductType >::RegistryKey |
Definition at line 74 of file Factory.hxx.
| typedef std::list<std::string> CLAM::Factory< AbstractProductType >::Values |
Definition at line 88 of file Factory.hxx.
| CLAM::Factory< AbstractProductType >::Factory | ( | ) | [inline] |
Definition at line 99 of file Factory.hxx.
| CLAM::Factory< AbstractProductType >::~Factory | ( | ) | [inline] |
Definition at line 100 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 203 of file Factory.hxx.
Referenced by RunTimeLadspaLibraryLoader::SetupLibrary(), and RunTimeFaustLibraryLoader::SetupLibrary().
| void CLAM::Factory< AbstractProductType >::AddCreator | ( | const RegistryKey | name, |
| Creator * | creator | ||
| ) | [inline] |
Definition at line 135 of file Factory.hxx.
| void CLAM::Factory< AbstractProductType >::AddCreatorSafe | ( | const RegistryKey | name, |
| Creator * | creator | ||
| ) | throw (ErrFactory) [inline] |
Definition at line 145 of file Factory.hxx.
| void CLAM::Factory< AbstractProductType >::AddCreatorWarningRepetitions | ( | const RegistryKey | name, |
| Creator * | creator | ||
| ) | [inline] |
Definition at line 140 of file Factory.hxx.
Referenced by RunTimeLadspaLibraryLoader::SetupLibrary(), and RunTimeFaustLibraryLoader::SetupLibrary().
| bool CLAM::Factory< AbstractProductType >::AttributeExists | ( | const std::string & | key, |
| const std::string & | attribute | ||
| ) | [inline] |
Definition at line 165 of file Factory.hxx.
Referenced by RunTimeFaustLibraryLoader::SetupLibrary().
| void CLAM::Factory< AbstractProductType >::Clear | ( | ) | [inline] |
Definition at line 130 of file Factory.hxx.
| int CLAM::Factory< AbstractProductType >::Count | ( | ) | [inline] |
Definition at line 504 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 112 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 124 of file Factory.hxx.
Referenced by CLAM::Network::AddProcessing(), and CLAM::ProcessingDefinitionAdapter::LoadFrom().
| void CLAM::Factory< AbstractProductType >::DeleteCreator | ( | const RegistryKey | name | ) | [inline] |
Definition at line 150 of file Factory.hxx.
Referenced by RunTimeLibraryLoader::ReLoad().
| 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 171 of file Factory.hxx.
Referenced by RunTimeLibraryLoader::ReLoad().
| Keys CLAM::Factory< AbstractProductType >::GetKeys | ( | ) | [inline] |
Get all keys in the factory.
Definition at line 176 of file Factory.hxx.
Referenced by CLAM::Factory< Processing >::GetKeys().
| Pairs CLAM::Factory< AbstractProductType >::GetPairsFromKey | ( | const std::string & | key | ) | [inline] |
Return all the metadata available for a product key.
Definition at line 181 of file Factory.hxx.
| void CLAM::Factory< AbstractProductType >::GetRegisteredNames | ( | std::list< std::string > & | namesList | ) | [inline] |
Definition at line 155 of file Factory.hxx.
| 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 187 of file Factory.hxx.
Referenced by RunTimeLibraryLoader::GetUsedLibraries().
| 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 198 of file Factory.hxx.
| 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 192 of file Factory.hxx.
Referenced by CLAM::Factory< Processing >::GetValueFromAttribute().
| bool CLAM::Factory< AbstractProductType >::KeyExists | ( | const RegistryKey & | key | ) | [inline] |
Definition at line 160 of file Factory.hxx.
1.7.6.1