CLAM::Factory< AbstractProductType > Class Template Reference

#include <Factory.hxx>

Inheritance diagram for CLAM::Factory< AbstractProductType >:

CLAM::ProcessingFactory

List of all members.


Detailed Description

template<typename AbstractProductType>
class CLAM::Factory< AbstractProductType >

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()"), 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 ()
AbstractProductCreate (const RegistryKey name)
 Gives ownership of the new created Product registered with the given name.
AbstractProductCreateSafe (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...

Member Typedef Documentation

template<typename AbstractProductType>
typedef AbstractProductType CLAM::Factory< AbstractProductType >::AbstractProduct

Definition at line 72 of file Factory.hxx.

template<typename AbstractProductType>
typedef std::string CLAM::Factory< AbstractProductType >::RegistryKey

Definition at line 73 of file Factory.hxx.

template<typename AbstractProductType>
typedef std::list<Key> CLAM::Factory< AbstractProductType >::Keys

Definition at line 86 of file Factory.hxx.

template<typename AbstractProductType>
typedef std::list<std::string> CLAM::Factory< AbstractProductType >::Values

Definition at line 87 of file Factory.hxx.

template<typename AbstractProductType>
typedef std::list<Pair> CLAM::Factory< AbstractProductType >::Pairs

Definition at line 88 of file Factory.hxx.

template<typename AbstractProductType>
typedef AbstractProduct*(* CLAM::Factory< AbstractProductType >::CreatorMethod)(void)


Constructor & Destructor Documentation

template<typename AbstractProductType>
CLAM::Factory< AbstractProductType >::Factory (  )  [inline]

Definition at line 100 of file Factory.hxx.

template<typename AbstractProductType>
CLAM::Factory< AbstractProductType >::~Factory (  )  [inline]

Definition at line 101 of file Factory.hxx.


Member Function Documentation

template<typename AbstractProductType>
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.

template<typename AbstractProductType>
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().

template<typename AbstractProductType>
void CLAM::Factory< AbstractProductType >::Clear (  )  [inline]

Definition at line 131 of file Factory.hxx.

template<typename AbstractProductType>
void CLAM::Factory< AbstractProductType >::AddCreator ( const RegistryKey  name,
Creator creator 
) [inline]

Definition at line 136 of file Factory.hxx.

template<typename AbstractProductType>
void CLAM::Factory< AbstractProductType >::AddCreatorWarningRepetitions ( const RegistryKey  name,
Creator creator 
) [inline]

template<typename AbstractProductType>
void CLAM::Factory< AbstractProductType >::AddCreatorSafe ( const RegistryKey  name,
Creator creator 
) throw (ErrFactory) [inline]

Definition at line 146 of file Factory.hxx.

template<typename AbstractProductType>
void CLAM::Factory< AbstractProductType >::DeleteCreator ( const RegistryKey  name  )  [inline]

Definition at line 151 of file Factory.hxx.

Referenced by RunTimeLibraryLoader::ReLoad().

template<typename AbstractProductType>
void CLAM::Factory< AbstractProductType >::GetRegisteredNames ( std::list< std::string > &  namesList  )  [inline]

Definition at line 156 of file Factory.hxx.

template<typename AbstractProductType>
bool CLAM::Factory< AbstractProductType >::KeyExists ( const RegistryKey key  )  [inline]

Definition at line 161 of file Factory.hxx.

template<typename AbstractProductType>
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().

template<typename AbstractProductType>
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().

template<typename AbstractProductType>
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().

template<typename AbstractProductType>
Pairs CLAM::Factory< AbstractProductType >::GetPairsFromKey ( const std::string &  key  )  [inline]

Return all the metadata available for a product key.

Definition at line 182 of file Factory.hxx.

template<typename AbstractProductType>
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().

template<typename AbstractProductType>
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().

template<typename AbstractProductType>
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.

template<typename AbstractProductType>
void CLAM::Factory< AbstractProductType >::AddAttribute ( const std::string &  key,
const std::string &  attribute,
const std::string &  value 
) [inline]

template<typename AbstractProductType>
int CLAM::Factory< AbstractProductType >::Count (  )  [inline]

Definition at line 505 of file Factory.hxx.


The documentation for this class was generated from the following file:

Generated on Tue Aug 12 22:33:46 2008 for CLAM by  doxygen 1.5.5