PTLib Version 2.12.9

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Macros | Typedefs
pfactory.h File Reference
`#include <ptlib.h>`
`#include <typeinfo>`
`#include <string>`
`#include <map>`
`#include <vector>`
Include dependency graph for pfactory.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Classes
class | PFactoryBase
| Base class for generic factories. More...
class | PFactoryBase::FactoryMap
class | PFactoryTemplate< AbstractClass, ParamType, KeyType >
| Template class for generic factories of an abstract class. More...
class | PFactoryTemplate< AbstractClass, ParamType, KeyType >::WorkerBase
class | PFactory< AbstractClass, KeyType >
| Class for a factory to create concrete class instances without parameters during construction. More...
class | PFactory< AbstractClass, KeyType >::Worker< ConcreteClass >
class | PParamFactory< AbstractClass, ParamType, KeyType >
| Class for a factory to create concrete class instances which have a single parameter during construction. More...
class | PParamFactory< AbstractClass, ParamType, KeyType >::Worker< ConcreteClass >

## Macros
#define | PFACTORY_STATICS(cls)
#define | PFACTORY_CREATE(factory, ConcreteClass,...)
| This macro is used to create a factory. More...
#define | PFACTORY_CREATE_SINGLETON(factory, ConcreteClass) PFACTORY_CREATE(factory, ConcreteClass, typeid(ConcreteClass).name(), true)
#define | PFACTORY_GET_SINGLETON(factory, ConcreteClass)
#define | PFACTORY_LOAD(ConcreteType)

## Typedefs
typedef std::string | PDefaultPFactoryKey
| this define the default class to be used for keys into PFactories More...

## Macro Definition Documentation

#define PFACTORY_CREATE | ( |  | factory,
|  |  | ConcreteClass,
|  |  | ...
| ) |  |

Value:
namespace PFactoryLoader { \
int ConcreteClass##_link() { return 0; } \
factory::Worker<ConcreteClass> ConcreteClass##_instance(__VA_ARGS__); \
}

This macro is used to create a factory.

This is mainly used for factories that exist inside a library and works in conjunction with the PFACTORY_LOAD() macro.

When a factory is contained wholly within a single compilation module of a library, it is typical that a linker does not include ANY of the code in that module. To avoid this the header file that declares the abstract type should include a PFACTORY_LOAD() macro call for all concrete classes that are in the library. Then whan an application includes the abstract types header, it will force the load of all the possible concrete classes.

#define PFACTORY_CREATE_SINGLETON | ( |  | factory,
|  |  | ConcreteClass
| ) |  | PFACTORY_CREATE(factory, ConcreteClass, typeid(ConcreteClass).name(), true)

#define PFACTORY_GET_SINGLETON | ( |  | factory,
|  |  | ConcreteClass
| ) |  |

Value:
static ConcreteClass & GetInstance() { \
return *factory::CreateInstanceAs<ConcreteClass>(typeid(ConcreteClass).name()); \
}

#define PFACTORY_LOAD | ( |  | ConcreteType | ) |

Value:
namespace PFactoryLoader { \
extern int ConcreteType##_link(); \
int const ConcreteType##_loader = ConcreteType##_link(); \
}

#define PFACTORY_STATICS | ( |  | cls | ) |

Value:
static cls & GetFactory() { return PFactoryBase::GetFactoryAs<cls>(); } \
static bool Register(const Key_T & k, WorkerBase_T * w) { return GetFactory().InternalRegister(k, w); } \
static bool Register(const Key_T & k, Abstract_T * i, bool a = true) { return GetFactory().InternalRegister(k, i, a); } \
static bool RegisterAs(const Key_T & synonym, const Key_T & original){ return GetFactory().InternalRegisterAs(synonym, original); } \
static void Unregister(const Key_T & k) { GetFactory().InternalUnregister(k); } \
static void Unregister(WorkerBase_T * a) { GetFactory().InternalUnregister(a); } \
static void UnregisterAll() { GetFactory().InternalUnregisterAll(); } \
static bool IsRegistered(const Key_T & k) { return GetFactory().InternalIsRegistered(k); } \
static bool IsSingleton(const Key_T & k) { return GetFactory().InternalIsSingleton(k); } \
static typename Base_T::KeyList_T GetKeyList() { return GetFactory().InternalGetKeyList(); } \
static PMutex & GetMutex() { return GetFactory().m_mutex; } \

## Typedef Documentation

typedef std::string PDefaultPFactoryKey

this define the default class to be used for keys into PFactories