fw4spl
AppConfig.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-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_REGISTRY_APPCONFIG_HPP__
8 #define __FWSERVICES_REGISTRY_APPCONFIG_HPP__
9 
10 #include "fwServices/config.hpp"
11 #include "fwServices/registry/AppInfo.hpp"
12 
13 #include <fwCore/mt/types.hpp>
14 
15 #include <fwData/Composite.hpp>
16 
17 #include <fwRuntime/ConfigurationElement.hpp>
18 #include <fwRuntime/EConfigurationElement.hpp>
19 #include <fwRuntime/Extension.hpp>
20 
21 #include <fwTools/Object.hpp>
22 
23 #include <map>
24 #include <unordered_set>
25 
26 namespace fwServices
27 {
28 
29 namespace registry
30 {
31 
36 class FWSERVICES_CLASS_API AppConfig : public ::fwCore::BaseObject
37 {
38 
39 public:
40 
42  typedef std::map< std::string, std::string > FieldAdaptorType;
43 
45 
47  FWSERVICES_API virtual ~AppConfig();
48 
54  FWSERVICES_API void parseBundleInformation();
55 
61  FWSERVICES_API void parseBundleInformation(
62  const std::vector< std::shared_ptr< ::fwRuntime::Extension > >& extensions);
63 
74  FWSERVICES_API void addAppInfo( const std::string& configId,
75  const std::string& group,
76  const std::string& desc,
77  const AppInfo::ParametersType& parameters,
78  const ::fwRuntime::ConfigurationElement::csptr& config,
79  const std::string& bundleId,
80  const std::string& bundleVersion);
81 
88  FWSERVICES_API ::fwRuntime::ConfigurationElement::csptr getAdaptedTemplateConfig( const std::string& configId,
89  const FieldAdaptorType replaceFields,
90  bool autoPrefixId ) const;
91 
98  FWSERVICES_API ::fwRuntime::ConfigurationElement::csptr getAdaptedTemplateConfig( const std::string& configId,
99  ::fwData::Composite::csptr replaceFields,
100  bool autoPrefixId )
101  const;
102 
107  FWSERVICES_API std::shared_ptr< ::fwRuntime::Bundle > getBundle(const std::string& _configId);
108 
113  FWSERVICES_API std::vector< std::string > getAllConfigs() const;
114 
119  FWSERVICES_API std::vector< std::string > getConfigsFromGroup(const std::string& group) const;
120 
125  FWSERVICES_API void clearRegistry();
126 
131  FWSERVICES_API static std::string getUniqueIdentifier(const std::string& serviceUid = "" );
132 
134  FWSERVICES_API static AppConfig::sptr getDefault();
135 
136 protected:
137 
138  typedef std::map< std::string, AppInfo::sptr > Registry;
139 
141  Registry m_reg;
142 
144  FWSERVICES_API AppConfig();
145 
146 private:
147 
148  typedef std::unordered_set< std::string > UidParameterReplaceType;
149 
151  FieldAdaptorType compositeToFieldAdaptor( ::fwData::Composite::csptr fieldAdaptors ) const;
152 
153  static void collectUIDForParameterReplace(::fwRuntime::ConfigurationElement::csptr _cfgElem,
154  UidParameterReplaceType& replaceMap);
155 
157  static ::fwRuntime::EConfigurationElement::sptr adaptConfig(::fwRuntime::ConfigurationElement::csptr _cfgElem,
158  const FieldAdaptorType& _fieldAdaptors,
159  const UidParameterReplaceType& _uidParameterReplace,
160  const std::string& _autoPrefixId );
161 
163  static std::string adaptField(const std::string& _str, const FieldAdaptorType& _variablesMap );
164 
166  mutable ::fwCore::mt::ReadWriteMutex m_registryMutex;
167 
169  static ::fwCore::mt::Mutex s_idMutex;
170 
172  static AppConfig::sptr s_currentAppConfig;
173 
175  static std::string s_mandatoryParameterIdentifier;
176 
178  typedef std::multimap< std::string, std::string > UidDefinitionType;
179  static UidDefinitionType s_uidDefinitionDictionary;
180 };
181 
182 } // namespace registry
183 
184 } // namespace fwServices
185 
186 #endif // __FWSERVICES_REGISTRY_APPCONFIG_HPP__
187 
Contains fwAtomsFilter::registry details.
Base class for all FW4SPL&#39;s classes.
Definition: BaseObject.hpp:22
Namespace fwServices is dedicated to (mimic) the dynamic affectation of methods to (pure data) object...
Registry m_reg
Container of <configId, AppConfig information>
Definition: AppConfig.hpp:141
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
std::map< std::string, std::string > FieldAdaptorType
Associations of <pattern, value>.
Definition: AppConfig.hpp:42
This class allows to register all the configuration which has the point extension "::fwServices::regi...
Definition: AppConfig.hpp:36