#include <LOW_deviceFactory.h>
Public Types | |
typedef LOW_device *(* | newInstanceFkt_t )(LOW_netSegment &, const LOW_deviceID &) |
Function type for static pseudo constructors. More... | |
Public Methods | |
class_DERIVE_FROM_EXCEPTION (deviceFactory_error, LOW_exception) | |
Exception base class for all exceptions thrown by LOW_deviceFactory. More... | |
Static Public Methods | |
LOW_device * | new_SpecificDevice (LOW_netSegment &inSegment, const LOW_deviceID &inDevID) |
Create new dynamic instance of specific device class. More... | |
void | registerSpecificCtor (const LOW_deviceIDRaw::devFamCode_t inFamCode, newInstanceFkt_t inPseudoCnstr) |
Register a static pseudo constructor. More... | |
Private Types | |
typedef map< LOW_deviceIDRaw::devFamCode_t, newInstanceFkt_t > | ctorFktMap_t |
Map type for registered family types and constructors. More... | |
Static Private Attributes | |
ctorFktMap_t * | deviceCtorsSingleton = 0 |
Map holding registered family types and associated constructors. More... |
Any class derived from LOW_device must register with this factory. After that, this factory can create "the right" instance of LOW_device subclasses on the fly.
To learn how to statically register at program initialization, see an already implemented subclass, e.g. LOW_devDS1820.
Definition at line 38 of file LOW_deviceFactory.h.
|
Map type for registered family types and constructors.
Definition at line 96 of file LOW_deviceFactory.h. Referenced by registerSpecificCtor(). |
|
Function type for static pseudo constructors.
|
|
Exception base class for all exceptions thrown by LOW_deviceFactory.
|
|
Create new dynamic instance of specific device class. The created instance is disposable with the "delete" operator.
Definition at line 28 of file LOW_deviceFactory.cpp. References deviceCtorsSingleton, and LOW_deviceIDRaw::getFamilyCode(). Referenced by LOW_netSegment::addDevice(). |
|
Register a static pseudo constructor.
Definition at line 39 of file LOW_deviceFactory.cpp. References LOW_device::anyDev_famCode, ctorFktMap_t, LOW_deviceIDRaw::devFamCode_t, and deviceCtorsSingleton. Referenced by LOW_devDS2406::initialize(), LOW_devDS2405::initialize(), and LOW_devDS1820::initialize(). |
|
Map holding registered family types and associated constructors. Note: Singleton design pattern is important here, because order of static initialization produced by the compiler cannot be assured. Definition at line 63 of file LOW_deviceFactory.cpp. Referenced by new_SpecificDevice(), and registerSpecificCtor(). |