fw4spl
src/fwData/Port.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/Port.hpp"
10 
11 fwDataRegisterMacro( ::fwData::Port );
12 
13 namespace fwData
14 {
15 //------------------------------------------------------------------------------
16 
17 Port::Port(::fwData::Object::Key key) : m_identifier("IDNOTdefined"),
18  m_type("TypeNotDefined")
19 {
20 }
21 
22 //------------------------------------------------------------------------------
23 
25 {
26 }
27 
28 //------------------------------------------------------------------------------
29 
30 void Port::shallowCopy(const Object::csptr &_source )
31 {
32  Port::csptr other = Port::dynamicConstCast(_source);
33  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
34  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
35  + " to " + this->getClassname()), !bool(other) );
36  this->fieldShallowCopy( _source );
37 
38  m_identifier = other->m_identifier;
39  m_type = other->m_type;
40 }
41 
42 //------------------------------------------------------------------------------
43 
44 void Port::cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache)
45 {
46  Port::csptr other = Port::dynamicConstCast(_source);
47  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
48  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
49  + " to " + this->getClassname()), !bool(other) );
50  this->fieldDeepCopy( _source, cache );
51 
52  m_identifier = other->m_identifier;
53  m_type = other->m_type;
54 }
55 
56 //------------------------------------------------------------------------------
57 
58 } // namespace fwData
FWDATA_API Port(::fwData::Object::Key key)
Constructor.
FWDATA_API void cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache) override
Defines deep copy.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Implements data exception class.
FWDATA_API void shallowCopy(const Object::csptr &_source) override
Retrieve the input data.
FWDATA_API void fieldDeepCopy(const ::fwData::Object::csptr &source)
A deep copy of fields (objects in m_children)
std::string m_type
port type
Definition: Port.hpp:71
A port is defined by an identifier and a type.
Definition: Port.hpp:20
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)
std::string m_identifier
port identifier
Definition: Port.hpp:69
virtual FWDATA_API ~Port()
Destructor.
virtual const std::string & getClassname() const override
return full object&#39;s classname with its namespace, i.e. fwCore::BaseObject
Definition: Port.hpp:23