The interface between broker modules and the device architecture.
More...
#include <CDeviceManager.hpp>
CDeviceManager is a singleton class used by broker modules to interface with the device architecture. This class is used to access devices attached to the DGI.
Devices are "stored" here after they are constructed by CAdapterFactory.
- Limitations:
- None directly, but be aware of the important limitations specificed in the IDevice class.
freedm::broker::device::CDeviceManager::CDeviceManager |
( |
| ) |
|
|
private |
Constructor for the device manager
- Precondition:
- None
- Postcondition:
- DeviceManager is ready to accept & distribute devices.
- Limitations:
- None.
void freedm::broker::device::CDeviceManager::AddDevice |
( |
CDevice::Pointer |
device | ) |
|
|
private |
Registers a device with the physical device manager.
- Error Handling:
- Throws a std::runtime_error of another device has been registered with the same device identifier.
- Shared Memory Blocks:
- Stores a shared pointer to the given device.
- Precondition:
- There must not be a device registered with the same identifier.
- Postcondition:
- The device is stored in the device set m_devices.
- Parameters
-
device | The device pointer to store in the manager. |
- Limitations:
- None.
std::size_t freedm::broker::device::CDeviceManager::DeviceCount |
( |
| ) |
const |
Returns a count of the number of devices stored by the device manager.
- Precondition:
- None
- Postcondition:
- Returns the size of m_devices.
- Returns
- The number of devices currently stored.
- Limitations:
- None.
bool freedm::broker::device::CDeviceManager::DeviceExists |
( |
std::string |
devid | ) |
const |
Tests to see if the device exists in the devices manager.
- Precondition:
- None
- Postcondition:
- Searches m_device for the device.
- Parameters
-
devid | The identifier of the device to find. |
- Returns
- True if the device is in the device manager, false otherwise
- Limitations:
- None.
CDevice::Pointer freedm::broker::device::CDeviceManager::GetDevice |
( |
std::string |
devid | ) |
|
Returns a shared pointer to the requested device.
- Error Handling:
- Will output a warning if the device cannot be found.
- Precondition:
- The device must be stored in the device manager.
- Postcondition:
- Searches m_devices for a device with the passed identifier.
- Parameters
-
devid | the ID of the device to get. |
- Returns
- A shared pointer to the device, or NULL if it wasn't found.
- Limitations:
- We cannot implement a const version of this function unless we provide a boost::shared_ptr<const DeviceType> typedef for each device class. The previous implementation of const IDevice::Pointer was incorrect because the syntax made the pointer, not the shared object, constant.
Creates a set that contains the stored devices of the given type.
- Precondition:
- None.
- Postcondition:
- Places each device that recognizes the type in the result set.
- Parameters
-
type | The string identifier for the type of device to retrieve. |
- Returns
- A set that contains the matching subset of m_devices.
- Limitations:
- None.
SignalValue freedm::broker::device::CDeviceManager::GetNetValue |
( |
std::string |
type, |
|
|
std::string |
signal |
|
) |
| |
Aggregates a set of device signals using the given binary operation.
- Precondition:
- The devices of the specified type must recognize the given signal.
- Postcondition:
- Performs a binary mathematical operation on a subset of m_devices.
- Parameters
-
type | The device type that should perform the operation. |
signal | The signal of the device to aggregate. |
- Returns
- The aggregate value obtained by applying the binary operation.
- Limitations:
- None.
std::multiset< SignalValue > freedm::broker::device::CDeviceManager::GetValues |
( |
std::string |
type, |
|
|
std::string |
signal |
|
) |
| |
Retrieves a multiset of values for the specified device signal.
- Precondition:
- The signal must be recognized by the specified device.
- Postcondition:
- Iterates through the devices collecting device signals.
- Parameters
-
type | The type of the device to collect signals from. |
signal | The signal of the device to collect. |
- Returns
- A multiset of values that contains each matching device signal.
- Limitations:
- None.
Retrieves the singleton device manager instance.
- Precondition:
- None.
- Postcondition:
- Creates a new device manager on the first call.
- Returns
- The global instance of CDeviceManager.
- Limitations:
- None.
bool freedm::broker::device::CDeviceManager::RemoveDevice |
( |
std::string |
devid | ) |
|
|
private |
Removes a device from the manager.
- Error Handling:
- Will output a warning if the device cannot be found.
- Precondition:
- None.
- Postcondition:
- The device with the matching identifier is removed from m_devices.
- Parameters
-
devid | The identifier of the device to remove. |
- Returns
- True if a device has been removed, false otherwise.
- Limitations:
- None.
void freedm::broker::device::CDeviceManager::RevealDevice |
( |
std::string |
devid | ) |
|
|
private |
Reveals a hidden device.
- Error Handling:
- Throws a std::runtime_error if no such device exists.
- Precondition:
- m_hidden_devices stores the passed identifier.
- Postcondition:
- Moves a pointer from m_hidden_devices into m_devices.
- Parameters
-
devid | The identifier of the device pointer to move. |
- Limitations:
- None.
boost::shared_mutex freedm::broker::device::CDeviceManager::m_mutex |
|
mutableprivate |
The documentation for this class was generated from the following files:
- /home/docs/checkouts/readthedocs.org/user_builds/freedm/checkouts/latest/Broker/src/device/CDeviceManager.hpp
- /home/docs/checkouts/readthedocs.org/user_builds/freedm/checkouts/latest/Broker/src/device/CDeviceManager.cpp