7 #include "fwActivities/builder/ActivitySeries.hpp" 9 #include "fwActivities/builder/registry/macros.hpp" 11 #include <fwData/Composite.hpp> 12 #include <fwData/Vector.hpp> 14 #include <fwDataCamp/getObject.hpp> 16 #include <fwMedData/Equipment.hpp> 17 #include <fwMedData/Patient.hpp> 18 #include <fwMedData/Study.hpp> 20 #include <fwTools/dateAndTime.hpp> 21 #include <fwTools/UUID.hpp> 23 #include <boost/date_time/posix_time/posix_time.hpp> 46 ::fwData::Composite::sptr vectorToComposite(const ::fwData::Vector::csptr& vector,
47 const ::fwActivities::registry::ActivityRequirement& req)
49 namespace ActReg = ::fwActivities::registry;
50 ::fwData::Composite::sptr composite = ::fwData::Composite::New();
52 OSLM_ASSERT(
"Each possible items in requirement need to have a matching key", req.keys.size() >= req.maxOccurs );
54 ActReg::ActivityRequirement::KeyType::const_iterator iter = req.keys.begin();
56 for(const ::fwData::Object::sptr& obj : *vector)
58 const ActReg::ActivityRequirementKey& keyTag = (*iter++);
59 if(keyTag.path.empty())
61 (*composite)[keyTag.key] = obj;
65 (*composite)[keyTag.key] = ::fwDataCamp::getObject( obj, keyTag.path );
75 const ::fwActivities::registry::ActivityInfo& activityInfo,
76 const ::fwData::Vector::csptr& currentSelection )
const 78 ::fwMedData::ActivitySeries::sptr actSeries = ::fwMedData::ActivitySeries::New();
80 ::fwMedData::Series::sptr series;
81 for(const ::fwData::Object::sptr& obj : *currentSelection)
83 series = ::fwMedData::Series::dynamicCast(obj);
97 actSeries->setModality(
"OT");
100 ::boost::posix_time::ptime now = ::boost::posix_time::second_clock::local_time();
104 actSeries->setActivityConfigId(activityInfo.id);
105 ::fwData::Composite::sptr data = actSeries->getData();
107 namespace ActReg = ::fwActivities::registry;
109 ActReg::ActivityInfo::RequirementsType reqVect = activityInfo.requirements;
110 for(
const ActReg::ActivityRequirement& req : reqVect)
112 ::fwData::Vector::sptr vectorType = this->getType(currentSelection, req.type);
114 if(req.maxOccurs == 1 && req.minOccurs == 1)
116 OSLM_ASSERT(
"No param name "<<req.name<<
" with type "<<req.type, !vectorType->empty());
117 (*data)[req.name] = (*vectorType)[0];
121 SLM_ASSERT(
"Unknown specified container: '"+req.container+
"'.",
122 req.container.empty() ||
123 req.container ==
"vector" ||
124 req.container ==
"composite");
125 if(req.container ==
"vector")
127 (*data)[req.name] = vectorType;
129 else if(req.container ==
"composite" || req.container.empty())
131 (*data)[req.name] = vectorToComposite(vectorType, req);
Defines the default builder for the data ActivitySeries.
virtual FWACTIVITIES_API::fwMedData::ActivitySeries::sptr buildData(const ::fwActivities::registry::ActivityInfo &activityInfo, const std::shared_ptr< const ::fwData::Vector > ¤tSelection) const override
Build an ActivitySeries with required data present in currentSelection and defined in configuration...
#define OSLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
virtual FWACTIVITIES_API ~ActivitySeries()
Destructor. Do nothing.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
FWACTIVITIES_API ActivitySeries(::fwActivities::IBuilder::Key key)
Constructor. Do nothing.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
static FWDATA_API::fwData::Object::sptr copy(const ::fwData::Object::csptr &source)
return a copy of the source. if source is a null pointer, return a null pointer.
Namespace containing activities data and builder.