fw4spl
ServiceConfig.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
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 #pragma once
8 
9 #include "fwServices/config.hpp"
10 
11 #include <fwRuntime/ConfigurationElement.hpp>
12 
13 #include <fwTools/Object.hpp>
14 
15 #include <map>
16 
17 namespace fwServices
18 {
19 
20 namespace registry
21 {
22 
25 class FWSERVICES_CLASS_API ServiceConfigInfo : public ::fwCore::BaseObject
26 {
27 public:
28 
30 
33  {
34  }
35 
38  {
39  }
40 
41  std::string service;
42  std::string desc;
43  ::fwRuntime::ConfigurationElement::csptr config;
44 };
45 
65 class FWSERVICES_CLASS_API ServiceConfig : public ::fwCore::BaseObject
66 {
67 
68 public:
69 
71 
73  FWSERVICES_API static ServiceConfig::sptr getDefault();
74 
76  FWSERVICES_API virtual ~ServiceConfig();
77 
83  FWSERVICES_API void parseBundleInformation();
84 
93  FWSERVICES_API void addServiceConfigInfo( const std::string& configId,
94  const std::string& service,
95  const std::string& desc,
96  ::fwRuntime::ConfigurationElement::csptr config );
97 
102  FWSERVICES_API ::fwRuntime::ConfigurationElement::csptr getServiceConfig( const std::string& configId,
103  const std::string& serviceImpl =
104  "" ) const;
105 
110  FWSERVICES_API const std::string& getConfigDesc( const std::string& configId ) const;
111 
117  FWSERVICES_API std::vector< std::string > getAllConfigForService( std::string serviceImpl,
118  bool matchingOnly = false ) const;
119 
124  FWSERVICES_API void clearRegistry();
125 
126 protected:
127 
128  typedef std::map< std::string, ServiceConfigInfo::sptr > Registry;
129 
131  Registry m_reg;
132 
134  FWSERVICES_API ServiceConfig();
135 
136  const static std::string CONFIG_EXT_POINT;
137 
139  mutable ::fwCore::mt::ReadWriteMutex m_registryMutex;
140 
142  static ServiceConfig::sptr s_currentServiceConfig;
143 };
144 
145 } // namespace registry
146 
147 } // namespace fwServices
Contains fwAtomsFilter::registry details.
Base class for all FW4SPL&#39;s classes.
Definition: BaseObject.hpp:22
This class allows to register all the service configuration which has the point extension "::fwServic...
Namespace fwServices is dedicated to (mimic) the dynamic affectation of methods to (pure data) object...
mutable::fwCore::mt::ReadWriteMutex m_registryMutex
Used to protect the registry access.
Registry m_reg
Container of service information <configId, service config information>
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
static ServiceConfig::sptr s_currentServiceConfig
The global instance of the service config.
virtual ~ServiceConfigInfo()
Destructor, do nothing.
ServiceConfigInfo()
Constructor, do nothing.