Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
DeviceFactory Class Reference

A Factory for the devices. More...

#include <devicefactory.h>

Public Types

typedef unsigned int DeviceTypeId
 Provides the device type ID as unsigned int. More...
 
typedef XsDevice *(* MasterConstructFunc) (DeviceFactory &deviceFactory, Communicator *comm)
 A function prototype that provides the device factory and communicator. More...
 
typedef XsDevice *(* StandaloneConstructFunc) (Communicator *comm)
 A function prototype that provides the communicator. More...
 

Public Member Functions

virtual XsDevicecreateMasterDevice (Communicator *communicator, bool doInitialize=true)
 Creates and initializes a master device with a specified communicator. The type of the new device is retrieved from the device id if the communicator. After construction the device will be initialized. More...
 
 DeviceFactory ()
 Default constructor. More...
 
virtual DeviceTypeId deviceToTypeId (XsDeviceId const &deviceId) const
 converts an XsDeviceId to an DeviceTypeId More...
 
bool initializeDevice (XsDevice &device) const
 Initializes a device (if not already initialized) More...
 
virtual void registerDevices ()
 register all known device types More...
 
bool registerMasterDeviceType (DeviceTypeId deviceTypeId, MasterConstructFunc constructFunc)
 Registers a master device type. After registration, the factory is able to cerate an instance of the specified type using the deviceTypeId. A master device is not (yet) owned by an object. More...
 
bool registerStandaloneDeviceType (DeviceTypeId deviceTypeId, StandaloneConstructFunc constructFunc)
 Registers a standalone device type. After registration, the factory is able to cerate an instance of the specified type using the deviceTypeId. A master device is not (yet) owned by an object. More...
 
virtual void removeExistingDevice (XsDeviceId const &deviceId)
 Tell our device manager to remove any devices matching deviceId. More...
 
virtual ~DeviceFactory ()
 

Protected Member Functions

virtual XsDeviceconstructDevice (DeviceTypeId deviceTypeId, Communicator *comm)
 Constructs a master device of a specified deviceTypeId with a specified communicator. The created device takes ownership of the Communicator. More...
 
virtual bool initializeDevice (XsDevice *device) const
 Initializes a device. Calls initialize(m_loadedScenarioFile) on the device. More...
 

Private Attributes

std::map< DeviceTypeId, MasterConstructFuncm_masterConstructors
 
std::map< DeviceTypeId, StandaloneConstructFuncm_standaloneConstructors
 

Detailed Description

A Factory for the devices.

Definition at line 75 of file devicefactory.h.

Member Typedef Documentation

◆ DeviceTypeId

typedef unsigned int DeviceFactory::DeviceTypeId

Provides the device type ID as unsigned int.

Definition at line 82 of file devicefactory.h.

◆ MasterConstructFunc

typedef XsDevice*(* DeviceFactory::MasterConstructFunc) (DeviceFactory &deviceFactory, Communicator *comm)

A function prototype that provides the device factory and communicator.

Definition at line 85 of file devicefactory.h.

◆ StandaloneConstructFunc

typedef XsDevice*(* DeviceFactory::StandaloneConstructFunc) (Communicator *comm)

A function prototype that provides the communicator.

Definition at line 88 of file devicefactory.h.

Constructor & Destructor Documentation

◆ DeviceFactory()

DeviceFactory::DeviceFactory ( )

Default constructor.

Definition at line 87 of file devicefactory.cpp.

◆ ~DeviceFactory()

virtual DeviceFactory::~DeviceFactory ( )
inlinevirtual

Definition at line 79 of file devicefactory.h.

Member Function Documentation

◆ constructDevice()

XsDevice * DeviceFactory::constructDevice ( DeviceTypeId  deviceTypeId,
Communicator comm 
)
protectedvirtual

Constructs a master device of a specified deviceTypeId with a specified communicator. The created device takes ownership of the Communicator.

Parameters
[in]deviceTypeIdthe unique identifier for this device type
[in]commThe communicator to used for this device
Returns
the newly created device or null when the device was not created.

Definition at line 127 of file devicefactory.cpp.

◆ createMasterDevice()

XsDevice * DeviceFactory::createMasterDevice ( Communicator communicator,
bool  doInitialize = true 
)
virtual

Creates and initializes a master device with a specified communicator. The type of the new device is retrieved from the device id if the communicator. After construction the device will be initialized.

Parameters
[in]communicatorThe communicator, the function always takes ownership of this pointer
[in]doInitializeIf false, the device will not be initialized
Returns
the newly created device or null when the device was not created or could not be initialized
Note
the initializeDevice method should be overridden in derived classes.
when a created device can not be initialized, it will be deleted again along with the supplied communicator

Definition at line 160 of file devicefactory.cpp.

◆ deviceToTypeId()

DeviceFactory::DeviceTypeId DeviceFactory::deviceToTypeId ( XsDeviceId const &  deviceId) const
virtual

converts an XsDeviceId to an DeviceTypeId

Parameters
[in]deviceIdthe deviceId
Returns
the DeviceTypeId

Definition at line 189 of file devicefactory.cpp.

◆ initializeDevice() [1/2]

bool DeviceFactory::initializeDevice ( XsDevice device) const

Initializes a device (if not already initialized)

Parameters
[in]deviceThe device to initialize
Returns
true when the device is properly initialized or already initialized, false if initialization failed

Definition at line 239 of file devicefactory.cpp.

◆ initializeDevice() [2/2]

bool DeviceFactory::initializeDevice ( XsDevice dev) const
protectedvirtual

Initializes a device. Calls initialize(m_loadedScenarioFile) on the device.

Parameters
[in]devThe device to initialize.
Returns
true if initialization is successful.

Definition at line 228 of file devicefactory.cpp.

◆ registerDevices()

void DeviceFactory::registerDevices ( )
virtual

register all known device types

Definition at line 246 of file devicefactory.cpp.

◆ registerMasterDeviceType()

bool DeviceFactory::registerMasterDeviceType ( DeviceTypeId  deviceTypeId,
MasterConstructFunc  constructFunc 
)

Registers a master device type. After registration, the factory is able to cerate an instance of the specified type using the deviceTypeId. A master device is not (yet) owned by an object.

Parameters
[in]deviceTypeIdthe unique identifier for this device type
[in]constructFuncthe function used to create an instance of the required type
Returns
true when registration was successful

Definition at line 98 of file devicefactory.cpp.

◆ registerStandaloneDeviceType()

bool DeviceFactory::registerStandaloneDeviceType ( DeviceTypeId  deviceTypeId,
StandaloneConstructFunc  constructFunc 
)

Registers a standalone device type. After registration, the factory is able to cerate an instance of the specified type using the deviceTypeId. A master device is not (yet) owned by an object.

Parameters
[in]deviceTypeIdthe unique identifier for this device type
[in]constructFuncthe function used to create an instance of the required type
Returns
true when registration was successful

Definition at line 113 of file devicefactory.cpp.

◆ removeExistingDevice()

void DeviceFactory::removeExistingDevice ( XsDeviceId const &  deviceId)
virtual

Tell our device manager to remove any devices matching deviceId.

Definition at line 218 of file devicefactory.cpp.

Member Data Documentation

◆ m_masterConstructors

std::map<DeviceTypeId, MasterConstructFunc> DeviceFactory::m_masterConstructors
private

Definition at line 108 of file devicefactory.h.

◆ m_standaloneConstructors

std::map<DeviceTypeId, StandaloneConstructFunc> DeviceFactory::m_standaloneConstructors
private

Definition at line 109 of file devicefactory.h.


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


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:21