Handles construction of all device objects used by the DGI.
More...
#include <CDeviceBuilder.hpp>
|
struct | BuildVars |
| Stores the variables required to populate the device information map. More...
|
|
|
void | ExpandInfo (std::string target, std::set< std::string > path, BuildVars &vars) |
| Recursive function to populate the device information map. More...
|
|
The device builder class handles the assignment of device type information to new device objects. It stores a map of device types and their associated DeviceInfo structures that is populated when the builder is constructed. Each new device receives a copy of some DeviceInfo stored by the builder which restricts how the device can be used by the DGI.
- Limitations:
- None.
freedm::broker::device::CDeviceBuilder::CDeviceBuilder |
( |
| ) |
|
|
inline |
freedm::broker::device::CDeviceBuilder::CDeviceBuilder |
( |
std::string |
filename | ) |
|
The CDeviceBuilder constructor populates the m_type_to_info variable using data read from the passed XML file. Each device specification in the XML is converted to a DeviceInfo structure that is stored in m_type_to_info. Then the ExpandInfo member function is called on each type.
- Error Handling:
- Throws a std::runtime_error if there is a problem with the XML specification.
- Precondition:
- None.
- Postcondition:
- Calls ExpandInfo once for each device type read from the XML.
- Parameters
-
filename | The name of the XML file for the device specification. |
- Limitations:
- None.
Creates a new device object with the device information for the given type.
- Error Handling:
- Throws a std::exception if the builder does not recognize the specified device type.
- Precondition:
- The passed type must be a valid key for the m_type_to_info map.
- Postcondition:
- Creates a new CDevice instance and returns a shared pointer to it.
- Parameters
-
id | The unique identifier for the new device. |
type | The device type to assign to the new device. |
adapter | The adapter that handles data for the new device. |
- Returns
- A shared pointer to the new device instance.
- Limitations:
- None.
void freedm::broker::device::CDeviceBuilder::ExpandInfo |
( |
std::string |
target, |
|
|
std::set< std::string > |
path, |
|
|
BuildVars & |
vars |
|
) |
| |
|
private |
Generates and stores device information for a target over a series of recursive calls. This function should always be called with an empty set for the path variable.
- Error Handling:
- Throws a std::runtime_error if the specification file has either a cyclic extend or duplicate signal names.
- Precondition:
- path must be empty for the initial call to the recursive function.
- Postcondition:
- Device information is assigned to m_type_to_info[target].
- Postcondition:
- Makes a recursive call to each device type the target extends from.
- Parameters
-
target | The device type to construct device information for. |
path | An empty set that will be populated over recursive calls. |
vars | The build variables used during construction of the builder. |
- Limitations:
- None.
DeviceInfo freedm::broker::device::CDeviceBuilder::GetDeviceInfo |
( |
std::string |
type | ) |
|
Gets the device information structure for some device type.
- Error Handling:
- Throws a std::out_of_range exception if the builder does not recognize the specified device type.
- Precondition:
- The passed string must be a valid key for the m_type_to_info map.
- Postcondition:
- Returns the device information structure mapped to the passed string.
- Parameters
-
type | The string identifier for a device type. |
- Returns
- m_type_to_info[type]
- Limitations:
- None.
std::map<std::string, DeviceInfo> freedm::broker::device::CDeviceBuilder::m_type_to_info |
|
private |
The documentation for this class was generated from the following files:
- /home/docs/checkouts/readthedocs.org/user_builds/freedm/checkouts/opnet-ecn/Broker/src/device/CDeviceBuilder.hpp
- /home/docs/checkouts/readthedocs.org/user_builds/freedm/checkouts/opnet-ecn/Broker/src/device/CDeviceBuilder.cpp