7 #include "fwActivities/registry/ActivityMsg.hpp" 9 #include <fwData/Composite.hpp> 10 #include <fwData/String.hpp> 12 #include <fwDataCamp/getObject.hpp> 14 #include <fwTools/UUID.hpp> 16 #include <boost/algorithm/string/replace.hpp> 17 #include <boost/regex.hpp> 26 ActivityMsg::ActivityMsg(const ::fwMedData::ActivitySeries::sptr& series,
27 const ::fwActivities::registry::ActivityInfo& info,
28 const ParametersType& parameters)
30 SLM_ASSERT(
"ActivitySeries instantiation failed", series);
32 const std::string asUID =
"AS_UID";
35 m_appConfigID = info.appConfig.id;
39 if(info.tabInfo.empty())
41 m_tabInfo = info.title;
45 std::string newTabInfo = info.tabInfo;
46 ::boost::regex e(
"(!(([[:word:]]+\\.?)+[[:word:]]))");
48 if(boost::regex_search(newTabInfo, what, e))
50 std::string submatch(what[1].first, what[1].second);
52 submatch.replace(0, 1,
"@");
54 ::fwData::Object::sptr obj = ::fwDataCamp::getObject(series->getData(), submatch);
55 OSLM_ASSERT(
"Invalid seshat path : '" << submatch <<
"'", obj);
57 ::fwData::String::sptr stringParameter = ::fwData::String::dynamicCast(obj);
59 std::string tabInfoSeshat;
63 tabInfoSeshat = stringParameter->getValue();
67 OSLM_WARN(
"Seshat path '" << submatch <<
"' doesn't reference an fwData::String");
70 submatch.replace(0, 1,
"!");
71 ::boost::algorithm::replace_all(newTabInfo, submatch, tabInfoSeshat);
74 m_tabInfo = newTabInfo;
76 m_iconPath = info.icon;
77 m_tooltip = m_tabInfo;
80 namespace ActiReg = ::fwActivities::registry;
81 ActiReg::ActivityAppConfig::ActivityAppConfigParamsType params = info.appConfig.parameters;
82 params.reserve(params.size() + parameters.size() + 1);
83 params.insert(params.end(), parameters.begin(), parameters.end());
84 ActiReg::ActivityAppConfigParam asConfigParam;
85 asConfigParam.replace = asUID;
86 asConfigParam.by = series->getID();
87 params.push_back(asConfigParam);
88 for(
const ActiReg::ActivityAppConfigParam& param : params)
92 m_replaceMap[param.replace] = param.by;
96 std::string parameterToReplace = param.by;
97 if (parameterToReplace.substr(0, 1) ==
"!")
99 parameterToReplace.replace(0, 1,
"@");
102 ::fwData::Object::sptr obj = ::fwDataCamp::getObject(series->getData(), parameterToReplace);
103 OSLM_ASSERT(
"Invalid seshat path : '"<<param.by<<
"'", obj);
105 ::fwData::String::sptr stringParameter = ::fwData::String::dynamicCast(obj);
107 std::string parameterValue = obj->getID();
109 if(stringParameter && param.by.substr(0, 1) ==
"!")
111 parameterValue = stringParameter->getValue();
113 m_replaceMap[param.replace] = parameterValue;
Contains fwAtomsFilter::registry details.
#define OSLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
#define OSLM_WARN(message)
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
Namespace containing activities data and builder.