FREEDM DGI
CDevice.hpp
Go to the documentation of this file.
1 
23 #ifndef C_DEVICE_HPP
24 #define C_DEVICE_HPP
25 
26 #include "IAdapter.hpp"
27 
28 #include <set>
29 #include <iosfwd>
30 #include <string>
31 
32 #include <boost/shared_ptr.hpp>
33 #include <boost/noncopyable.hpp>
34 
35 namespace freedm {
36 namespace broker {
37 namespace device {
38 
40 struct DeviceInfo
41 {
43  std::set<std::string> s_type;
44 
46  std::set<std::string> s_state;
47 
49  std::set<std::string> s_command;
50 };
51 
53 std::ostream & operator<<(std::ostream & os, const DeviceInfo & info);
54 
72 class CDevice
73  : private boost::noncopyable
74 {
75 public:
77  typedef boost::shared_ptr<CDevice> Pointer;
78 
80  CDevice(std::string id, DeviceInfo info, IAdapter::Pointer adapter);
81 
83  std::string GetID() const;
84 
86  bool HasType(std::string type) const;
87 
89  bool HasState(std::string signal) const;
90 
92  bool HasCommand(std::string signal) const;
93 
95  SignalValue GetState(std::string signal) const;
96 
98  std::set<std::string> GetStateSet() const;
99 
101  std::set<std::string> GetCommandSet() const;
102 
104  void SetCommand(std::string signal, SignalValue value);
105 
106 private:
108  std::string m_devid;
109 
112 
115 };
116 
117 } // namespace device
118 } // namespace broker
119 } // namespace freedm
120 
121 #endif // C_DEVICE_HPP
Defines the interface used to access physical hardware.
Definition: CDevice.hpp:72
Stores the internal structure of a device object.
Definition: CDevice.hpp:40
std::set< std::string > s_type
Set of types a device recognizes.
Definition: CDevice.hpp:43
std::set< std::string > s_command
Set of command signals a device recognizes.
Definition: CDevice.hpp:49
std::set< std::string > s_state
Set of state signals a device recognizes.
Definition: CDevice.hpp:46
IAdapter::Pointer m_adapter
Adapter that handles the storage for this device.
Definition: CDevice.hpp:114
DeviceInfo m_devinfo
Internal structure of this device.
Definition: CDevice.hpp:111
float SignalValue
Type of the value for device signals.
Definition: IAdapter.hpp:42
boost::shared_ptr< CDevice > Pointer
Pointer to physical device interface.
Definition: CDevice.hpp:77
std::string m_devid
Unique identifier for this device.
Definition: CDevice.hpp:108
General FREEDM Namespace.
Definition: CBroker.cpp:53
boost::shared_ptr< IAdapter > Pointer
Pointer to a physical adapter.
Definition: IAdapter.hpp:72
std::ostream & operator<<(std::ostream &os, const DeviceInfo &info)
Outputs the device information to the passed output stream.
Definition: CDevice.cpp:57