#include <LOW_deviceFactory.h>
Public Types | |
typedef LOW_device *(* | newInstanceFkt_t )(LOW_netSegment &, const LOW_deviceID &) |
Function type for static pseudo constructors. | |
Public Member Functions | |
class_DERIVE_FROM_EXCEPTION (deviceFactory_error, LOW_exception) | |
Exception base class for all exceptions thrown by LOW_deviceFactory. | |
Static Public Member Functions | |
LOW_device * | new_SpecificDevice (LOW_netSegment &inSegment, const LOW_deviceID &inDevID) |
Create new dynamic instance of specific device class. | |
void | registerSpecificCtor (const LOW_deviceIDRaw::devFamCode_t inFamCode, newInstanceFkt_t inPseudoCnstr) |
Register a static pseudo constructor. | |
Private Types | |
typedef std::map< LOW_deviceIDRaw::devFamCode_t, newInstanceFkt_t > | ctorFktMap_t |
Map type for registered family types and constructors. | |
Private Member Functions | |
LOW_deviceFactory () | |
Constructor. | |
virtual | ~LOW_deviceFactory () |
Destructor. | |
Static Private Attributes | |
ctorFktMap_t * | deviceCtorsSingleton = 0 |
Map holding registered family types and associated constructors. | |
newInstanceFkt_t | unknownDevCtor = 0 |
Pseudo constructor for unknown device types. |
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.
Definition at line 58 of file LOW_deviceFactory.h. |
|
Constructor. Private to prevent instaciation as this is a static factory. Definition at line 28 of file LOW_deviceFactory.cpp. |
|
Destructor. Private to prevent instaciation as this is a static factory. Definition at line 33 of file LOW_deviceFactory.cpp. |
|
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 43 of file LOW_deviceFactory.cpp. References deviceCtorsSingleton, LOW_deviceIDRaw::getFamilyCode(), and unknownDevCtor. Referenced by LOW_netSegment::addDevice(). |
|
Register a static pseudo constructor.
Definition at line 57 of file LOW_deviceFactory.cpp. References LOW_device::anyDev_famCode, ctorFktMap_t, deviceCtorsSingleton, LOW_device::unknownDev_famCode, and unknownDevCtor. Referenced by LOW_devUnknown::initialize(), LOW_devDS2890::initialize(), LOW_devDS2406::initialize(), LOW_devDS2405::initialize(), LOW_devDS2401::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 87 of file LOW_deviceFactory.cpp. Referenced by new_SpecificDevice(), and registerSpecificCtor(). |
|
Pseudo constructor for unknown device types. This constructor is used when no specific constructor is found. Definition at line 89 of file LOW_deviceFactory.cpp. Referenced by new_SpecificDevice(), and registerSpecificCtor(). |