fw4spl
ActivitySeriesInitData.cpp
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 #include "fwActivities/builder/ActivitySeriesInitData.hpp"
8 
9 #include "fwActivities/builder/registry/macros.hpp"
10 
11 #include <fwData/Composite.hpp>
12 #include <fwData/Vector.hpp>
13 
14 namespace fwActivities
15 {
16 namespace builder
17 {
18 
19 fwActivitiesBuilderRegisterMacro(
20  ::fwActivities::builder::ActivitySeriesInitData, "::fwActivities::builder::ActivitySeriesInitData");
21 
22 //-----------------------------------------------------------------------------
23 
25  fwActivities::builder::ActivitySeries(key)
26 {
27 }
28 
29 //-----------------------------------------------------------------------------
30 
31 ActivitySeriesInitData::~ActivitySeriesInitData()
32 {
33 }
34 
35 //-----------------------------------------------------------------------------
36 
37 ::fwMedData::ActivitySeries::sptr ActivitySeriesInitData::buildData(
38  const ::fwActivities::registry::ActivityInfo& activityInfo,
39  const ::fwData::Vector::csptr& currentSelection ) const
40 {
41  ::fwMedData::ActivitySeries::sptr actSeries = this->ActivitySeries::buildData(activityInfo, currentSelection);
42  ::fwData::Composite::sptr data = actSeries->getData();
43 
44  namespace ActReg = ::fwActivities::registry;
45 
46  ActReg::ActivityInfo::RequirementsType reqVect = activityInfo.requirements;
47  for(const ActReg::ActivityRequirement& req : reqVect)
48  {
49  if(req.maxOccurs == 0 && req.minOccurs == 0)
50  {
51  (*data)[req.name] = ::fwData::factory::New(req.type);
52  }
53  }
54 
55  return actSeries;
56 }
57 
58 //-----------------------------------------------------------------------------
59 
60 } // namespace builder
61 } // namespace fwActivities
Defines an activity builder which instanciates a new requirement if minOccurs and maxOccurs are set t...
FWACTIVITIES_API ActivitySeriesInitData(::fwActivities::IBuilder::Key key)
Constructor. Do nothing.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Namespace containing activities data and builder.