fw4spl
IAppConfigManager.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2015-2017.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWSERVICES_IAPPCONFIGMANAGER_HPP__
8 #define __FWSERVICES_IAPPCONFIGMANAGER_HPP__
9 
10 #include "fwServices/config.hpp"
11 #include "fwServices/registry/AppInfo.hpp"
12 
13 #include <fwData/Composite.hpp>
14 
15 #include <fwTools/Object.hpp>
16 
17 namespace fwServices
18 {
22 class FWSERVICES_CLASS_API IAppConfigManager : public ::fwTools::Object
23 {
24 public:
25  typedef registry::FieldAdaptorType FieldAdaptorType;
26 
28 
30  FWSERVICES_API IAppConfigManager();
31 
33  FWSERVICES_API virtual ~IAppConfigManager();
34 
37  FWSERVICES_API static SPTR(IAppConfigManager) New();
38 
40  bool isCreated() const;
41  bool isStarted() const;
42  bool isStopped() const;
43  bool isDestroyed() const;
44 
46  void setConfig(::fwRuntime::ConfigurationElement::csptr cfgElem);
47 
53  FWSERVICES_API virtual void setConfig(const std::string& configId,
54  const FieldAdaptorType& replaceFields = FieldAdaptorType()) = 0;
55 
61  FWSERVICES_API virtual void setConfig(const std::string& configId,
62  const ::fwData::Composite::csptr& replaceFields) = 0;
63 
65  FWSERVICES_API virtual ::fwData::Object::sptr getConfigRoot() const = 0;
66 
68  FWSERVICES_API virtual void launch() = 0;
69 
71  FWSERVICES_API virtual void stopAndDestroy() = 0;
72 
74  FWSERVICES_API virtual void create() = 0;
75 
77  FWSERVICES_API virtual void start() = 0;
78 
80  FWSERVICES_API virtual void update() = 0;
81 
83  FWSERVICES_API virtual void stop() = 0;
84 
86  FWSERVICES_API virtual void destroy() = 0;
87 
88 protected:
89  enum ConfigState
90  {
91  STATE_CREATED,
92  STATE_STARTED,
93  STATE_STOPPED,
94  STATE_DESTROYED,
95  };
96 
98  ::fwRuntime::ConfigurationElement::csptr m_cfgElem;
99 
101  ConfigState m_state;
102 };
103 
104 //------------------------------------------------------------------------------
105 
107  m_state(STATE_DESTROYED)
108 {
109 }
110 
111 //------------------------------------------------------------------------------
112 
114 {
115 
116 }
117 
118 //------------------------------------------------------------------------------
119 
120 inline bool IAppConfigManager::isCreated() const
121 {
122  return m_state == STATE_CREATED;
123 }
124 
125 //------------------------------------------------------------------------------
126 
127 inline bool IAppConfigManager::isStarted() const
128 {
129  return m_state == STATE_STARTED;
130 }
131 
132 //------------------------------------------------------------------------------
133 
134 inline bool IAppConfigManager::isStopped() const
135 {
136  return m_state == STATE_STOPPED;
137 }
138 
139 //------------------------------------------------------------------------------
140 
141 inline bool IAppConfigManager::isDestroyed() const
142 {
143  return m_state == STATE_DESTROYED;
144 }
145 
146 //------------------------------------------------------------------------------
147 
148 inline void IAppConfigManager::setConfig(fwRuntime::ConfigurationElement::csptr cfgElem)
149 {
150  m_cfgElem = cfgElem;
151 }
152 
153 //------------------------------------------------------------------------------
154 
155 } // namespace fwServices
156 
157 #endif // __FWSERVICES_IAPPCONFIGMANAGER_HPP__
#define SPTR(_cls_)
#define fwCoreNonInstanciableClassDefinitionsMacro(_classinfo_)
Generate common code for Non Instanciable classes (Interfaces, Abstract classes, ...)
bool isCreated() const
Return state.
Define Base class for FW4SPL objects and services.
::fwRuntime::ConfigurationElement::csptr m_cfgElem
XML Configuration tree.
STL namespace.
Namespace fwServices is dedicated to (mimic) the dynamic affectation of methods to (pure data) object...
void setConfig(::fwRuntime::ConfigurationElement::csptr cfgElem)
Set config param.
The namespace fwRuntime contains classes to manage bundle, configuration element, extension point in ...
std::map< std::string, std::string > FieldAdaptorType
Associations of <pattern, value>.
Definition: AppInfo.hpp:24
virtual FWSERVICES_API ~IAppConfigManager()
Destructor. Do nothing.
Contains the representation of the data objects used in the framework.
FWSERVICES_API IAppConfigManager()
Constructor. Do nothing.
This class provides an interface to manage configurations template.
ConfigState m_state
Running state of the app config manager.