fw4spl
src/fwData/Edge.cpp
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 #include "fwData/registry/macros.hpp"
8 #include "fwData/Exception.hpp"
9 #include "fwData/Edge.hpp"
10 
11 fwDataRegisterMacro( ::fwData::Edge );
12 
13 namespace fwData
14 {
15 
16 std::string Edge::NATURE_FLOW = "flow";
17 std::string Edge::NATURE_DATA = "data";
18 
19 //------------------------------------------------------------------------------
20 
22  m_fromPortIdentifier("not defined"),
23  m_toPortIdentifier("not defined"),
24  m_nature("not defined")
25 {
27 }
28 
29 //------------------------------------------------------------------------------
30 
32 {
34 }
35 
36 //------------------------------------------------------------------------------
37 
38 void Edge::setIdentifiers(const std::string & fromPortIndentifier, const std::string & toPortIndentifier)
39 {
40  m_fromPortIdentifier = fromPortIndentifier;
41  m_toPortIdentifier = toPortIndentifier;
42 }
43 
44 //------------------------------------------------------------------------------
45 
46 std::pair<std::string,std::string> Edge::getIdentifiers() const
47 {
48  return make_pair(m_fromPortIdentifier, m_toPortIdentifier);
49 }
50 
51 //------------------------------------------------------------------------------
52 
53 std::string Edge::getFromPortID() const
54 {
55  return m_fromPortIdentifier;
56 }
57 
58 //------------------------------------------------------------------------------
59 
60 std::string Edge::getToPortID() const
61 {
62  return m_toPortIdentifier;
63 }
64 
65 //------------------------------------------------------------------------------
66 
67 
68 std::string Edge::getPortID(bool upStream) const
69 {
70  return upStream ? m_fromPortIdentifier : m_toPortIdentifier;
71 }
72 
73 //------------------------------------------------------------------------------
74 
75 void Edge::setNature(std::string nature)
76 {
77  m_nature = nature;
78 }
79 
80 //------------------------------------------------------------------------------
81 
82 const std::string &Edge::getNature() const
83 {
84  return m_nature;
85 }
86 
87 //------------------------------------------------------------------------------
88 void Edge::shallowCopy(const Object::csptr &_source )
89 {
90  Edge::csptr other = Edge::dynamicConstCast(_source);
91  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
92  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
93  + " to " + this->getClassname()), !bool(other) );
94 
95  this->fieldShallowCopy( _source );
96  m_fromPortIdentifier = other->m_fromPortIdentifier;
97  m_toPortIdentifier = other->m_toPortIdentifier;
98  m_nature = other->m_nature;
99 }
100 
101 //------------------------------------------------------------------------------
102 
103 void Edge::cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache)
104 {
105  Edge::csptr other = Edge::dynamicConstCast(_source);
106  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
107  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
108  + " to " + this->getClassname()), !bool(other) );
109  this->fieldDeepCopy( _source, cache );
110  m_fromPortIdentifier = other->m_fromPortIdentifier;
111  m_toPortIdentifier = other->m_toPortIdentifier;
112  m_nature = other->m_nature;
113 
114 }
115 
116 //------------------------------------------------------------------------------
117 
118 } // namespace fwData
#define SLM_TRACE_FUNC()
Trace contextual function signature.
Definition: spyLog.hpp:329
FWDATA_API Edge(::fwData::Object::Key key)
Constructor.
FWDATA_API std::string getFromPortID() const
return "from" identifier
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Implements data exception class.
FWDATA_API const std::string & getNature() const
Get edge nature ("FLOW" , "FWDATA")
FWDATA_API void setNature(std::string nature)
Set edge nature ("FLOW" , "FWDATA")
virtual FWDATA_API ~Edge()
Destructor.
FWDATA_API void cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache) override
do a deep copy of edge
FWDATA_API void fieldDeepCopy(const ::fwData::Object::csptr &source)
A deep copy of fields (objects in m_children)
FWDATA_API std::string getToPortID() const
return "to" identifier
FWDATA_API std::pair< std::string, std::string > getIdentifiers() const
Get the edge identifier.
FWDATA_API std::string getPortID(bool upStream) const
return "to or from" identifier according to upStream
FWDATA_API void shallowCopy(const Object::csptr &_source) override
do a shallow copy of edge
virtual const std::string & getClassname() const override
return full object&#39;s classname with its namespace, i.e. fwCore::BaseObject
Definition: Edge.hpp:28
Contains the representation of the data objects used in the framework.
FWDATA_API void fieldShallowCopy(const ::fwData::Object::csptr &source)
A shallow copy of fields (objects in m_children)
FWDATA_API void setIdentifiers(const std::string &_fromPortIndentifier, const std::string &_toPortIndentifier)
Set the edge identifier ("ID_SIZEX" , ...)
This class defines an edge object.
Definition: Edge.hpp:25