fw4spl
ProcessObject.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
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 #ifndef __FWDATA_PROCESSOBJECT_HPP__
8 #define __FWDATA_PROCESSOBJECT_HPP__
9 
10 #include "fwData/factory/new.hpp"
11 #include "fwData/Object.hpp"
12 
13 #include <map>
14 #include <vector>
15 
16 namespace fwData
17 {
18 class Field;
19 }
20 
21 fwCampAutoDeclareDataMacro((fwData)(ProcessObject), FWDATA_API);
22 
23 namespace fwData
24 {
25 
29 class FWDATA_CLASS_API ProcessObject : public Object
30 {
31 public:
33  ::fwData::factory::New< ProcessObject >);
34 
35  fwCampMakeFriendDataMacro((fwData)(ProcessObject));
36 
37  typedef std::string ParamNameType;
38  typedef std::vector<std::string> ParamNameVectorType;
39  typedef std::map< ParamNameType, ::fwData::Object::sptr > ProcessObjectMapType;
40 
45  FWDATA_API ProcessObject(::fwData::Object::Key key);
46 
50  FWDATA_API virtual ~ProcessObject();
51 
57  FWDATA_API ::fwData::Object::sptr getInput(const ParamNameType& name);
58 
64  template< class OBJECTTYPE >
65  typename OBJECTTYPE::sptr getInput(const ParamNameType& name);
66 
72  FWDATA_API ::fwData::Object::sptr getOutput(const ParamNameType& name);
73 
79  template< class OBJECTTYPE >
80  typename OBJECTTYPE::sptr getOutput(const ParamNameType& name);
81 
86  const ProcessObjectMapType& getInputs () const;
87 
88  void setInputs (const ProcessObjectMapType& val);
90 
95  const ProcessObjectMapType& getOutputs () const;
96 
97  void setOutputs (const ProcessObjectMapType& val);
99 
106  FWDATA_API void setInputValue(const ParamNameType& name, ::fwData::Object::sptr object);
107 
114  FWDATA_API void setOutputValue(const ParamNameType& name, ::fwData::Object::sptr object);
115 
119  FWDATA_API ParamNameVectorType getInputsParamNames() const;
120 
124  FWDATA_API ParamNameVectorType getOutputsParamNames() const;
125 
129  FWDATA_API void clearInputs();
130 
134  FWDATA_API void clearOutputs();
135 
137  FWDATA_API void shallowCopy( const Object::csptr& source ) override;
138 
140  FWDATA_API void cachedDeepCopy(const Object::csptr& source, DeepCopyCacheType& cache) override;
141 
142 protected:
143 
147  FWDATA_API ParamNameVectorType getParamNames(const ProcessObjectMapType& params) const;
148 
156  FWDATA_API void setValue(const ParamNameType& name, ::fwData::Object::sptr object, ProcessObjectMapType& params);
157 
164  FWDATA_API ::fwData::Object::sptr getValue(const ParamNameType& name, const ProcessObjectMapType& params);
165 
169  FWDATA_API void clearParams(ProcessObjectMapType& params);
170 
172  ProcessObjectMapType m_inputs;
173 
175  ProcessObjectMapType m_outputs;
176 };
177 
178 //-----------------------------------------------------------------------------
179 
180 template< class OBJECTTYPE >
181 inline typename OBJECTTYPE::sptr ProcessObject::getInput(const ProcessObject::ParamNameType& name)
182 {
183  return OBJECTTYPE::dynamicCast( this->getInput( name ) );
184 }
185 
186 //-----------------------------------------------------------------------------
187 
188 template< class OBJECTTYPE >
189 inline typename OBJECTTYPE::sptr ProcessObject::getOutput(const ProcessObject::ParamNameType& name)
190 {
191  return OBJECTTYPE::dynamicCast( this->getOutput( name ) );
192 }
193 
194 //-----------------------------------------------------------------------------
195 
196 inline const ProcessObject::ProcessObjectMapType& ProcessObject::getInputs () const
197 {
198  return m_inputs;
199 }
200 
201 //-----------------------------------------------------------------------------
202 
203 inline void ProcessObject::setInputs (const ProcessObject::ProcessObjectMapType& val)
204 {
205  m_inputs = val;
206 }
207 
208 //-----------------------------------------------------------------------------
209 
210 inline const ProcessObject::ProcessObjectMapType& ProcessObject::getOutputs () const
211 {
212  return m_outputs;
213 }
214 
215 //-----------------------------------------------------------------------------
216 
217 inline void ProcessObject::setOutputs (const ProcessObject::ProcessObjectMapType& val)
218 {
219  m_outputs = val;
220 }
221 
222 //-----------------------------------------------------------------------------
223 
224 } // namespace fwData
225 
226 #endif // __FWDATA_PROCESSOBJECT_HPP__
227 
Provides the notion of Process Object: object having inputs and outputs.
ProcessObjectMapType m_outputs
Outputs values map.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
ProcessObjectMapType m_inputs
Inputs values map.
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
FWDATA_API::fwData::Object::sptr getOutput(const ParamNameType &name)
Retrieves the output data associated with specified name (null if non exist).
Base class for each data object.
FWDATA_API::fwData::Object::sptr getInput(const ParamNameType &name)
Retrieves the input data associated with specified name (null if non exist).
const ProcessObjectMapType & getInputs() const
Retrieve the input data.
void setOutputs(const ProcessObjectMapType &val)
Contains the representation of the data objects used in the framework.
const ProcessObjectMapType & getOutputs() const
void setInputs(const ProcessObjectMapType &val)
Retrieve the input data.