addon_manager.h
Go to the documentation of this file.
1 
11 
12 #ifndef __COMMON_ADDONS_MANAGER_H__
13 #define __COMMON_ADDONS_MANAGER_H__
14 
17 #include <opc/common/interface.h>
18 #include <opc/common/logger.h>
19 #include <string>
20 #include <vector>
21 
22 namespace Common
23 {
25 
26 class Addon;
27 class AddonFactory;
28 
30 {
31  AddonId Id;
32  std::shared_ptr<AddonFactory> Factory;
33  std::vector<AddonId> Dependencies;
35 };
36 
37 class AddonsManager : private Interface
38 {
39 public:
41 
42 public:
43  AddonsManager(const Logger::SharedPtr & logger): Logger(logger) {}
44 
49  virtual void Register(const AddonInformation & caddonConfiguration) = 0;
50 
55  virtual void Unregister(const AddonId & id) = 0;
56 
61 
62  virtual std::shared_ptr<Addon> GetAddon(const AddonId & id) const = 0;
63 
64  virtual std::shared_ptr<Addon> GetAddon(const char id[]) const
65  {
66  return GetAddon(AddonId(id));
67  }
68 
72  template <class AddonClass>
73  typename std::shared_ptr<AddonClass> GetAddon(const AddonId & id) const;
74 
75 // template <class AddonClass>
76 // typename std::shared_ptr<AddonClass> GetAddon(const char* id) const;
77 
78  template <class AddonClass>
79  typename std::shared_ptr<AddonClass> GetAddon(const char id[]) const;
80 
81 
85  virtual void Start(/*const AddonsConfiguration& config*/) = 0;
86 
87  // @brief Stopping all addons;
88  virtual void Stop() = 0;
89 
90  virtual const Logger::SharedPtr & GetLogger() const { return Logger; }
91 
92 protected:
93  Logger::SharedPtr Logger;
94 };
95 
96 
101 AddonsManager::UniquePtr CreateAddonsManager(const Common::Logger::SharedPtr & logger);
102 
103 template <class AddonClass>
104 typename std::shared_ptr<AddonClass> AddonsManager::GetAddon(const AddonId & id) const
105 {
106  return std::dynamic_pointer_cast<AddonClass>(GetAddon(id));
107 }
108 
109 template <class AddonClass>
110 typename std::shared_ptr<AddonClass> AddonsManager::GetAddon(const char id[]) const
111 {
112  return std::dynamic_pointer_cast<AddonClass>(GetAddon(AddonId(id)));
113 }
114 
115 
116 } // namespace Common
117 
118 #endif // __COMMON_ADDONS_MANAGER_H__
119 
virtual const Logger::SharedPtr & GetLogger() const
Definition: addon_manager.h:90
virtual std::shared_ptr< Addon > GetAddon(const char id[]) const
Definition: addon_manager.h:64
Addon interface definition GNU LGPL.
virtual std::shared_ptr< Addon > GetAddon(const AddonId &id) const =0
getting addon by id
std::shared_ptr< AddonFactory > Factory
Definition: addon_manager.h:32
std::vector< AddonId > Dependencies
Definition: addon_manager.h:33
AddonsManager::UniquePtr CreateAddonsManager(const Common::Logger::SharedPtr &logger)
Get instance of addons core.
Logger::SharedPtr Logger
Definition: addon_manager.h:93
AddonParameters Parameters
Definition: addon_manager.h:34
std::string AddonId
Definition: addon_manager.h:24
#define DEFINE_CLASS_POINTERS(ClassName)
Exception declarations GNU LGPL.
AddonsManager(const Logger::SharedPtr &logger)
Definition: addon_manager.h:43


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:06:03