fw4spl
SrcLib/core/fwAtoms/include/fwAtoms/Object.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 __FWATOMS_OBJECT_HPP__
8 #define __FWATOMS_OBJECT_HPP__
9 
10 #include "fwAtoms/Base.hpp"
11 #include "fwAtoms/config.hpp"
12 #include "fwAtoms/factory/new.hpp"
13 
14 namespace fwAtoms
15 {
16 
21 class FWATOMS_CLASS_API Object : public Base
22 {
23 public:
24  fwCoreClassDefinitionsWithFactoryMacro( (Object)(::fwAtoms::Base), (()), ::fwAtoms::factory::New< Object >);
25 
26  typedef std::map<std::string, Base::sptr> AttributesType;
27  typedef std::map<std::string, std::string> MetaInfosType;
28 
29  //--------------------------------------------------------------------------
30 
36  {
37  }
38 
42  virtual ~Object()
43  {
44  }
45 
47  FWATOMS_API void setAttributes(const AttributesType& attrs);
48 
50  const AttributesType& getAttributes() const
51  {
52  return m_attributes;
53  }
54 
56  FWATOMS_API Base::sptr getAttribute(const std::string& key) const;
57 
59  template < typename OBJECT_TYPE >
60  SPTR(OBJECT_TYPE) getAttribute(const std::string& key) const;
61 
63  FWATOMS_API void setAttribute(const std::string& key, const Base::sptr&);
64 
72  FWATOMS_API AttributesType::size_type eraseAttribute(const std::string& key);
73 
75  FWATOMS_API void clearAttribute();
76 
77  //--------------------------------------------------------------------------
78 
83  FWATOMS_API void setMetaInfo(const std::string& key, const std::string& value);
84 
86  FWATOMS_API void setMetaInfos(const MetaInfosType& metaInfos);
87 
89  FWATOMS_API std::string getMetaInfo(const std::string& key) const;
90 
92  const MetaInfosType& getMetaInfos() const
93  {
94  return m_metaInfos;
95  }
96 
104  FWATOMS_API MetaInfosType::size_type eraseMetaInfo(const std::string& key);
105 
107  FWATOMS_API void clearMetaInfo();
108 
112  FWATOMS_API virtual Base::sptr clone() const override;
113 
117  ::fwAtoms::Base::AtomType type() const override
118  {
119  return ::fwAtoms::Base::OBJECT;
120  }
121 
122 private:
123 
124  MetaInfosType m_metaInfos;
125  AttributesType m_attributes;
126 
127 };
128 
129 }
130 
131 #endif /* __FWATOMS_OBJECT_HPP__ */
132 
#define SPTR(_cls_)
fwAtoms contains basic objects to represent any other kind of object
const MetaInfosType & getMetaInfos() const
Get internal metaInfo mapping.
::fwAtoms::Base::AtomType type() const override
returns Atom type
const AttributesType & getAttributes() const
Returns the internal map.
Class represented a fwData::Object.
Object(::fwAtoms::Base::Key key)
Constructor.
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Base class for all Atom classes.