Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

LOW_deviceFactory Class Reference

Factory class for creating instances of classes derived from LOW_device. More...

#include <LOW_deviceFactory.h>

List of all members.

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_devicenew_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_tdeviceCtorsSingleton = 0
 Map holding registered family types and associated constructors. More...


Detailed Description

Factory class for creating instances of classes derived from LOW_device.

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.

Author:
Harald Roelle, Helmut Reiser

Definition at line 38 of file LOW_deviceFactory.h.


Member Typedef Documentation

typedef map< LOW_deviceIDRaw::devFamCode_t, newInstanceFkt_t> LOW_deviceFactory::ctorFktMap_t [private]
 

Map type for registered family types and constructors.

Definition at line 96 of file LOW_deviceFactory.h.

Referenced by registerSpecificCtor().

typedef LOW_device*(* LOW_deviceFactory::newInstanceFkt_t)( LOW_netSegment&, const LOW_deviceID&)
 

Function type for static pseudo constructors.


Member Function Documentation

LOW_deviceFactory::class_DERIVE_FROM_EXCEPTION deviceFactory_error   ,
LOW_exception   
 

Exception base class for all exceptions thrown by LOW_deviceFactory.

LOW_device * LOW_deviceFactory::new_SpecificDevice LOW_netSegment   inSegment,
const LOW_deviceID   inDevID
[static]
 

Create new dynamic instance of specific device class.

The created instance is disposable with the "delete" operator.

Parameters:
inSegment  Reference to network segment the device is on.
inDevID  Reference to device's ID.
Returns:
New dynamic instance of specific device class.
Exceptions:
deviceFactory_error  Thrown when device type is not registered.

Definition at line 28 of file LOW_deviceFactory.cpp.

References deviceCtorsSingleton, and LOW_deviceIDRaw::getFamilyCode().

Referenced by LOW_netSegment::addDevice().

void LOW_deviceFactory::registerSpecificCtor const LOW_deviceIDRaw::devFamCode_t    inFamCode,
newInstanceFkt_t    inPseudoCnstr
[static]
 

Register a static pseudo constructor.

Parameters:
inFamCode  Family code of the specific class.
inPseudoCnstr  Static pseudo constructor to register.
Exceptions:
deviceFactory_error  Thrown when family type is already registered.

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().


Member Data Documentation

LOW_deviceFactory::ctorFktMap_t * LOW_deviceFactory::deviceCtorsSingleton = 0 [static, private]
 

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().


The documentation for this class was generated from the following files:
Generated on Sun Jan 12 21:07:55 2003 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001