FREEDM DGI
CFakeAdapter.hpp
Go to the documentation of this file.
1 
23 #ifndef C_FAKE_ADAPTER_HPP
24 #define C_FAKE_ADAPTER_HPP
25 
26 #include "IAdapter.hpp"
27 
28 #include <map>
29 #include <string>
30 
31 #include <boost/thread.hpp>
32 #include <boost/property_tree/ptree_fwd.hpp>
33 
34 namespace freedm {
35 namespace broker {
36 namespace device {
37 
48  : public IAdapter
49 {
50 public:
52  typedef boost::shared_ptr<CFakeAdapter> Pointer;
53 
55  static Pointer Create();
56 
58  void Start();
59 
61  void Stop();
62 
64  SignalValue GetState(const std::string device, const std::string key) const;
65 
67  void SetCommand(const std::string device, const std::string key,
68  const SignalValue value);
69 
70 private:
72  CFakeAdapter();
73 
75  typedef std::map<std::string, SignalValue> KeyMap;
76 
78  typedef std::map<std::string, KeyMap> DeviceMap;
79 
81  mutable DeviceMap m_registry;
82 
84  bool m_stopped;
85 
87  boost::mutex m_stopMutex;
88 };
89 
90 } // namespace device
91 } // namespace broker
92 } // namespace freedm
93 
94 #endif /* C_FAKE_ADAPTER_HPP */
95 
Physical adapter device interface.
Definition: IAdapter.hpp:67
void Start()
Start the fake adapter.
Definition: CFakeAdapter.cpp:63
void Stop()
Stop the fake adapter.
Definition: CFakeAdapter.cpp:75
CFakeAdapter()
Constructor.
Definition: CFakeAdapter.cpp:42
std::map< std::string, KeyMap > DeviceMap
Map of devices of KeyMaps.
Definition: CFakeAdapter.hpp:78
std::map< std::string, SignalValue > KeyMap
Map of device setting keys to values.
Definition: CFakeAdapter.hpp:75
void SetCommand(const std::string device, const std::string key, const SignalValue value)
Sets a value on a device.
Definition: CFakeAdapter.cpp:127
bool m_stopped
Is the adapter stopped?
Definition: CFakeAdapter.hpp:84
static Pointer Create()
Creates a new fake adapter.
Definition: CFakeAdapter.cpp:50
SignalValue GetState(const std::string device, const std::string key) const
Retrieves a value from a device.
Definition: CFakeAdapter.cpp:94
Physical adapter device interface that stores settings in itself.
Definition: CFakeAdapter.hpp:47
boost::mutex m_stopMutex
Protects m_stopped.
Definition: CFakeAdapter.hpp:87
float SignalValue
Type of the value for device signals.
Definition: IAdapter.hpp:42
boost::shared_ptr< CFakeAdapter > Pointer
Type of a fake adapter pointer.
Definition: CFakeAdapter.hpp:52
General FREEDM Namespace.
Definition: CBroker.cpp:53
DeviceMap m_registry
Registry of device keys and values.
Definition: CFakeAdapter.hpp:81