24 #ifndef C_ADAPTER_FACTORY_HPP 25 #define C_ADAPTER_FACTORY_HPP 37 #include <boost/thread.hpp> 38 #include <boost/noncopyable.hpp> 39 #include <boost/asio/ip/tcp.hpp> 40 #include <boost/asio/io_service.hpp> 41 #include <boost/asio/deadline_timer.hpp> 42 #include <boost/property_tree/ptree_fwd.hpp> 55 :
private boost::noncopyable
80 void CreateDevice(
const std::string name,
const std::string type,
85 const boost::property_tree::ptree & p);
94 void HandleRead(
const boost::system::error_code & e);
97 void Timeout(
const boost::system::error_code & e);
127 #endif // C_ADAPTER_FACTORY_HPP CAdapterFactory()
Constructs the factory.
Definition: CAdapterFactory.cpp:74
Handles construction of all device objects used by the DGI.
Definition: CDeviceBuilder.hpp:47
boost::thread m_thread
Thread for the adapter i/o service.
Definition: CAdapterFactory.hpp:109
void InitializeAdapter(IAdapter::Pointer adapter, const boost::property_tree::ptree &p)
Initializes the devices stored on an adapter.
Definition: CAdapterFactory.cpp:329
CDeviceBuilder m_builder
Constructs the structure of devices.
Definition: CAdapterFactory.hpp:118
void StartSession()
Handles one plug and play device session.
Definition: CAdapterFactory.cpp:545
void SessionProtocol()
Session layer protocol for plug-and-play devices.
Definition: CAdapterFactory.cpp:628
void Timeout(const boost::system::error_code &e)
Disconnects plug and play devices that timeout.
Definition: CAdapterFactory.cpp:591
CTcpServer::Pointer m_server
TCP server to accept plug-and-play devices.
Definition: CAdapterFactory.hpp:106
static CAdapterFactory & Instance()
Gets the static instance of the factory.
Definition: CAdapterFactory.cpp:148
void Stop()
Stop everything!
Definition: CAdapterFactory.cpp:192
void CreateAdapter(const boost::property_tree::ptree &p)
Creates a new adapter and its associated devices.
Definition: CAdapterFactory.cpp:235
void CreateDevice(const std::string name, const std::string type, IAdapter::Pointer adapter)
Clones a device prototype and registers it with the system.
Definition: CAdapterFactory.cpp:492
void RunService()
Runs the adapter i/o service.
Definition: CAdapterFactory.cpp:162
Handles the creation of adapters and their associated devices.
Definition: CAdapterFactory.hpp:54
boost::shared_ptr< CTcpServer > Pointer
Convenience type for a shared pointer to self.
Definition: CTcpServer.hpp:46
void StartSessionProtocol(unsigned short port)
Starts the session TCP server.
Definition: CAdapterFactory.cpp:522
General FREEDM Namespace.
Definition: CBroker.cpp:53
boost::asio::io_service m_ios
I/O service shared by the adapters.
Definition: CAdapterFactory.hpp:103
boost::shared_ptr< IAdapter > Pointer
Pointer to a physical adapter.
Definition: IAdapter.hpp:72
Provides an interface for communicating with an MQTT broker.
Definition: CMqttAdapter.hpp:56
void HandleRead(const boost::system::error_code &e)
Handles plug and play devices that send a session packet.
Definition: CAdapterFactory.cpp:568
boost::asio::streambuf m_buffer
Packet received from plug and play device.
Definition: CAdapterFactory.hpp:112
void RemoveAdapter(const std::string identifier)
Removes an adapter and its associated devices.
Definition: CAdapterFactory.cpp:296
boost::asio::deadline_timer m_timeout
Timer for bad plug and play sessions.
Definition: CAdapterFactory.hpp:115
std::map< std::string, IAdapter::Pointer > m_adapters
Set of device adapters managed by the factory.
Definition: CAdapterFactory.hpp:100