7 #ifndef __FWDATA_COMPOSITE_HPP__ 8 #define __FWDATA_COMPOSITE_HPP__ 10 #include "fwData/config.hpp" 11 #include "fwData/factory/new.hpp" 12 #include "fwData/Object.hpp" 14 #include <fwCom/Signal.hpp> 15 #include <fwCom/Signals.hpp> 24 fwCampAutoDeclareDataMacro((
fwData)(Composite), FWDATA_API);
41 typedef std::map< std::string, ::fwData::Object::sptr > ContainerType;
43 typedef ContainerType::key_type KeyType;
44 typedef ContainerType::mapped_type MappedType;
45 typedef ContainerType::value_type ValueType;
46 typedef ContainerType::iterator IteratorType;
47 typedef ContainerType::const_iterator ConstIteratorType;
48 typedef ContainerType::reverse_iterator ReverseIteratorType;
49 typedef ContainerType::const_reverse_iterator ConstReverseIteratorType;
50 typedef ContainerType::size_type SizeType;
74 ConstIteratorType begin()
const;
75 ConstIteratorType end()
const;
77 ReverseIteratorType rbegin();
78 ReverseIteratorType rend();
79 ConstReverseIteratorType rbegin()
const;
80 ConstReverseIteratorType rend()
const;
83 SizeType size()
const;
85 mapped_type& operator[] ( KeyType n );
87 IteratorType find (
const KeyType&
x );
88 ConstIteratorType find (
const KeyType&
x )
const;
90 SizeType count (
const KeyType&
x )
const;
95 ContainerType& getContainer();
96 const ContainerType& getContainer ()
const;
97 void setContainer (
const ContainerType& val);
101 FWDATA_API
void shallowCopy(
const Object::csptr& _source )
override;
104 FWDATA_API
void cachedDeepCopy(
const Object::csptr& _source, DeepCopyCacheType& cache)
override;
107 template<
class DATATYPE >
108 void setDataContainer(
const std::map< std::string,
SPTR(DATATYPE) >& map );
111 template<
class DATATYPE >
112 std::map< std::string, SPTR(DATATYPE) > getDataContainer()
const;
122 template<
class DATATYPE >
123 SPTR(DATATYPE) at(const
std::
string& key);
133 template< class DATATYPE >
134 CSPTR(DATATYPE) at(const
std::
string& key) const;
142 FWDATA_API static const ::
fwCom::Signals::SignalKeyType s_ADDED_OBJECTS_SIG;
146 FWDATA_API static const ::
fwCom::Signals::SignalKeyType s_CHANGED_OBJECTS_SIG;
150 FWDATA_API static const ::
fwCom::Signals::SignalKeyType s_REMOVED_OBJECTS_SIG;
156 ContainerType m_container;
163 return m_container.
begin();
170 return m_container.end();
177 return m_container.begin();
184 return m_container.end();
191 return m_container.rbegin();
198 return m_container.rend();
205 return m_container.rbegin();
212 return m_container.rend();
219 return m_container.empty();
226 return m_container.size();
233 return this->m_container[n];
240 return m_container.find(x);
247 return m_container.find(x);
254 return m_container.count(x);
280 template<
class DATATYPE >
283 this->getContainer().clear();
284 this->getContainer().insert( map.begin(), map.end() );
289 template<
class DATATYPE >
292 std::map< std::string, SPTR(DATATYPE) > map;
293 SPTR(DATATYPE) castData;
296 castData = std::dynamic_pointer_cast<DATATYPE>( elem.second );
298 map[elem.first] = castData;
306 template<
class DATATYPE >
309 SPTR(DATATYPE) castData;
311 if(iter != this->end())
313 castData = std::dynamic_pointer_cast<DATATYPE>(iter->second);
318 SLM_TRACE(
"Object '" + key +
"' not found.");
325 template<
class DATATYPE >
328 CSPTR(DATATYPE) castData;
330 if(iter != this->end())
332 castData = std::dynamic_pointer_cast<DATATYPE>(iter->second);
337 SLM_TRACE(
"Object '" + key +
"' not found.");
#define SLM_TRACE_IF(message, cond)
void setDataContainer(const std::map< std::string, std::shared_ptr< DATATYPE > > &map)
Method to initialize a fwData::Composite from a std::map< string, X >
ContainerType::const_reverse_iterator const_reverse_iterator
#define OSLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
mapped_type & operator[](KeyType n)
Namespace containing fw4spl communication tools.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
ReverseIteratorType rend()
SizeType count(const KeyType &x) const
ContainerType::value_type value_type
std::map< std::string, std::shared_ptr< DATATYPE > > getDataContainer() const
Method to get a std::map< string, X > from fwData::Composite.
ContainerType::mapped_type mapped_type
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
Type demangler. Use Demangler class to get a demangled string for the type T.
void setContainer(const ContainerType &val)
get/set the map of std::string/fwData::Object
ContainerType::const_iterator const_iterator
Base class for each data object.
IteratorType find(const KeyType &x)
ContainerType::size_type size_type
ContainerType::key_type key_type
#define SLM_TRACE(message)
ReverseIteratorType rbegin()
Contains the representation of the data objects used in the framework.
This class defines a composite object.
ContainerType::reverse_iterator reverse_iterator
ContainerType & getContainer()
get/set the map of std::string/fwData::Object
ContainerType::iterator iterator