fw4spl
AtomVisitor.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
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 __FWATOMCONVERSION_ATOMVISITOR_HPP__
8 #define __FWATOMCONVERSION_ATOMVISITOR_HPP__
9 
10 #include <map>
11 
12 #include <fwTools/UUID.hpp>
13 
14 #include <fwAtoms/Object.hpp>
15 
16 #include "fwAtomConversion/config.hpp"
17 
18 namespace fwData
19 {
20 class Object;
21 }
22 
23 namespace fwAtomConversion
24 {
25 
31 class FWATOMCONVERSION_CLASS_API AtomVisitor
32 {
33 
34 public:
35 
40  struct IReadPolicy
41  {
42  virtual SPTR(::fwData::Object) operator() (const std::string &uuid, const std::string &classname) const = 0;
43  };
44 
49  { FWATOMCONVERSION_API virtual SPTR(::fwData::Object) operator() (const std::string &uuid,
50  const std::string &classname) const; };
51 
56  { FWATOMCONVERSION_API virtual SPTR(::fwData::Object) operator() (const std::string &uuid,
57  const std::string &classname) const; };
58 
63  { FWATOMCONVERSION_API virtual SPTR(::fwData::Object) operator() (const std::string &uuid,
64  const std::string &classname) const; };
68  typedef std::map< ::fwTools::UUID::UUIDType, SPTR(::fwData::Object) > DataCacheType;
69 
71  FWATOMCONVERSION_API AtomVisitor( const ::fwAtoms::Object::sptr &atomObj, DataCacheType & cache,
72  const IReadPolicy &uuidPolicy );
73 
75  FWATOMCONVERSION_API virtual ~AtomVisitor();
76 
86  FWATOMCONVERSION_API void visit();
87 
89  FWATOMCONVERSION_API SPTR(::fwData::Object) getDataObject() const;
90 
91 private:
92 
94  void processMetaInfos( const ::fwAtoms::Object::MetaInfosType & metaInfos );
95 
97  void processAttributes( const ::fwAtoms::Object::AttributesType & attributes );
98 
100  ::fwAtoms::Object::sptr m_atomObj;
101 
103  SPTR(::fwData::Object) m_dataObj;
104 
106  DataCacheType & m_cache;
107 
109  const IReadPolicy &m_uuidPolicy;
110 };
111 
112 } // end namespace fwAtomConversion
113 
114 #endif // __FWATOMCONVERSION_ATOMVISITOR_HPP__
#define SPTR(_cls_)
This policy throws an exception if the loaded uuid is not available.
Definition: AtomVisitor.hpp:62
This namespace contains the necessary class for fwData <-> fwAtoms conversion.
Visitor UUID Management policies.
Definition: AtomVisitor.hpp:40
This policy changes data&#39;s uuid if it already exists.
Definition: AtomVisitor.hpp:55
This policy reuses the data associated with an existing uuid.
Definition: AtomVisitor.hpp:48
Base class for each data object.
Contains the representation of the data objects used in the framework.
This class is used to convert a fwAtoms to a fwData.
Definition: AtomVisitor.hpp:31