ifw-core  5.0.0-pre2
commFactory.hpp
Go to the documentation of this file.
1 
10 #ifndef CORE_PROTOCOL_BASE_COMMFACTORY_HPP
11 #define CORE_PROTOCOL_BASE_COMMFACTORY_HPP
12 
13 #include <map>
14 #include <string>
15 
18 
19 namespace protocol {
20  namespace base {
21 
22  // Abstract-Factory Pattern Implementation
24  {
25  public:
26  // Factory is implemented as a Singleton
27  static CommFactory& Instance();
28 
29  // Adds new device maker with given key
30  void RegisterMaker(const std::string& key, ICommMaker * maker);
31 
32  // Creates new IComm
33  std::shared_ptr<IComm> Create(const std::string& filename,
34  const std::string& name,
35  const std::string& interface) const;
36 
37  private:
38  CommFactory() {}
39 
40  // Disable copying and assignment
41  CommFactory(const CommFactory& other);
42  CommFactory& operator=(const CommFactory& other);
43 
44 
46  std::map<std::string, ICommMaker* > m_makers;
47  };
48  }
49 }
50 
51 
52 
53 #endif //CORE_PROTOCOL_BASE_COMMFACTORY_HPP
Definition: commFactory.hpp:24
static CommFactory & Instance()
Definition: commFactory.cpp:18
std::shared_ptr< IComm > Create(const std::string &filename, const std::string &name, const std::string &interface) const
Definition: commFactory.cpp:32
void RegisterMaker(const std::string &key, ICommMaker *maker)
Definition: commFactory.cpp:23
Definition: iCommMaker.hpp:23
Definition: commFactory.cpp:15