7 #include "ioPacs/SPacsConfigurationInitializer.hpp" 9 #include <fwData/Composite.hpp> 10 #include <fwData/String.hpp> 12 #include <fwPreferences/helper.hpp> 14 #include <fwServices/macros.hpp> 15 #include <fwServices/registry/ObjectService.hpp> 17 #include <boost/foreach.hpp> 27 static const ::fwServices::IService::KeyType s_CONFIG_INOUT =
"config";
44 _sstream <<
"SPacsConfigurationInitializer::info";
65 template<
typename T,
typename CAST_T = T>
70 void operator()(::fwData::Composite::sptr config, std::string
const& confName, T& attribute)
75 if(it != config->end())
77 ::fwData::String::sptr obj = ::fwData::String::dynamicCast(it->second);
78 attribute = T(::boost::lexical_cast<CAST_T>(obj->value()));
90 ::fwRuntime::ConfigurationElement::sptr config =
m_configuration->findConfigurationElement(
"config");
91 SLM_ASSERT(
"The service ::ioPacs::SPacsConfigurationInitializer must have a \"config\" element.",
98 SLM_ASSERT(
"It should be a \"localApplicationTitle\" tag in the " 99 "::ioPacs::SPacsConfigurationInitializer config element.", success);
102 ::boost::tie(success,
m_pacsHostName) = config->getSafeAttributeValue(
"pacsHostName");
103 SLM_ASSERT(
"It should be a \"pacsHostName\" tag in the " 104 "::ioPacs::SPacsConfigurationInitializer config element.", success);
108 SLM_ASSERT(
"It should be a \"pacsApplicationTitle\" tag in the " 109 "::ioPacs::SPacsConfigurationInitializer config element.", success);
112 std::string pacsApplicationPort;
113 ::boost::tie(success, pacsApplicationPort) = config->getSafeAttributeValue(
"pacsApplicationPort");
114 SLM_ASSERT(
"It should be a \"pacsApplicationPort\" tag in the " 115 "::ioPacs::SPacsConfigurationInitializer config element.", success);
120 SLM_ASSERT(
"It should be a \"moveApplicationTitle\" tag in the " 121 "::ioPacs::SPacsConfigurationInitializer config element.", success);
124 std::string moveApplicationPort;
125 ::boost::tie(success, moveApplicationPort) = config->getSafeAttributeValue(
"moveApplicationPort");
126 SLM_ASSERT(
"It should be a \"moveApplicationPort\" tag in the " 127 "::ioPacs::SPacsConfigurationInitializer config element.", success);
131 std::string retrieveMethod;
132 ::boost::tie(success, retrieveMethod) = config->getSafeAttributeValue(
"retrieveMethod");
133 SLM_ASSERT(
"It should be a \"retrieveMethod\" tag in the " 134 "::ioPacs::SPacsConfigurationInitializer config element.", success);
136 (::fwPacsIO::data::PacsConfiguration::GET_RETRIEVE_METHOD):
137 (::fwPacsIO::data::PacsConfiguration::MOVE_RETRIEVE_METHOD);
142 ::fwPacsIO::data::PacsConfiguration::sptr pacsConfiguration = this->getInOut< ::fwPacsIO::data::PacsConfiguration >(
144 if (!pacsConfiguration)
147 pacsConfiguration = this->getObject< ::fwPacsIO::data::PacsConfiguration >();
153 ::fwData::Composite::sptr prefs = ::fwPreferences::getPreferences();
156 ::fwData::Composite::sptr config = ::fwData::Composite::dynamicCast((*prefs)[
m_preferenceKey]);
185 ::fwPacsIO::data::PacsConfiguration::sptr pacsConfiguration = this->getInOut< ::fwPacsIO::data::PacsConfiguration >(
187 if (!pacsConfiguration)
190 pacsConfiguration = this->getObject< ::fwPacsIO::data::PacsConfiguration >();
215 ::fwData::Composite::sptr prefs = ::fwPreferences::getPreferences();
222 ::fwData::Composite::sptr config = ::fwData::Composite::dynamicCast((*prefs)[
m_preferenceKey]);
224 (*config)[
"PacsHostName" ] = ::fwData::String::New(
m_pacsHostName);
226 (*config)[
"PacsApplicationPort" ] =
229 (*config)[
"MoveApplicationPort" ] =
231 (*config)[
"RetrieveMethod" ] =
232 ::fwData::String::New(::boost::lexical_cast<std::string>(
m_retrieveMethod));
234 ::fwPreferences::savePreferences();
#define FW_DEPRECATED_KEY(newKey, access, version)
Use this macro when deprecating a service key to warn the developer.
std::string m_preferenceKey
The key to save/load the preferences.
ioPacs contains services use to deal with PACS using DCMTK library.
#define SLM_TRACE_FUNC()
Trace contextual function signature.
IOPACS_API SPacsConfigurationInitializer() noexcept
Constructor.
This class defines a Pacs configuration.
unsigned short m_pacsApplicationPort
Pacs port.
unsigned short m_moveApplicationPort
Move application port.
::fwPacsIO::data::PacsConfiguration::RETRIEVE_METHOD m_retrieveMethod
Request mode.
virtual IOPACS_API void configuring() override
Configuring method. This method is used to configure the service.
This service is used to initialize a Pacs Configuration data.
std::string m_moveApplicationTitle
Move application title.
std::string m_pacsHostName
Pacs host name.
This interface defines control service API. Does nothing particularly, can be considered as a default...
std::string m_pacsApplicationTitle
Pacs application title.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
::fwRuntime::ConfigurationElement::sptr m_configuration
Configuration element used to configure service internal state using a generic XML like structure TOD...
IOPACS_API void info(std::ostream &_sstream) override
Override.
virtual IOPACS_API ~SPacsConfigurationInitializer() noexcept
Destructor.
std::string m_localApplicationTitle
Local application title.
virtual IOPACS_API void starting() override
Override.
virtual IOPACS_API void stopping() override
Override.
ContainerType::iterator iterator
IOPACS_API void updating() override
Override.