fw4spl
src/fwData/location/SingleFile.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/location/Folder.hpp"
8 #include "fwData/Exception.hpp"
9 
10 #include "fwData/location/SingleFile.hpp"
11 
12 #include "fwData/registry/macros.hpp"
13 
14 
15 fwDataRegisterMacro( ::fwData::location::SingleFile );
16 
17 
18 
19 namespace fwData
20 {
21 namespace location
22 {
23 
24 //------------------------------------------------------------------------------
25 
27 {
28 }
29 
30 //------------------------------------------------------------------------------
31 
33 {
34 }
35 
36 //------------------------------------------------------------------------------
37 
38 void SingleFile::shallowCopy(const Object::csptr &_source )
39 {
40  SingleFile::csptr other = SingleFile::dynamicConstCast(_source);
41  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
42  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
43  + " to " + this->getClassname()), !bool(other) );
44  this->fieldShallowCopy( _source );
45  this->m_path = other->m_path;
46 }
47 
48 //------------------------------------------------------------------------------
49 
50 void SingleFile::cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache)
51 {
52  SingleFile::csptr other = SingleFile::dynamicConstCast(_source);
53  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
54  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
55  + " to " + this->getClassname()), !bool(other) );
56  this->fieldDeepCopy( _source, cache );
57  this->m_path = other->m_path;
58 }
59 
60 //------------------------------------------------------------------------------
61 
62 SingleFile::sptr SingleFile::SingleFileFactory(PathType path)
63 {
64  SingleFile::sptr singlefile = SingleFile::New();
65  singlefile->setPath(path);
66  return singlefile;
67 }
68 
69 //------------------------------------------------------------------------------
70 
71 void SingleFile::setPath( PathType path)
72 {
73  m_path = path;
74 }
75 
76 //------------------------------------------------------------------------------
77 
78 ILocation::PathType SingleFile::getPath() const
79 {
80  return m_path;
81 }
82 
83 //------------------------------------------------------------------------------
84 
85 }
86 }
This class defines a single file location.
Definition: SingleFile.hpp:25
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Implements data exception class.
FWDATA_API void cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache) override
Defines deep copy.
FWDATA_API void shallowCopy(const Object::csptr &_source) override
Defines shallow copy.
FWDATA_API void fieldDeepCopy(const ::fwData::Object::csptr &source)
A deep copy of fields (objects in m_children)
virtual const std::string & getClassname() const override
return full object&#39;s classname with its namespace, i.e. fwCore::BaseObject
Definition: SingleFile.hpp:32
virtual FWDATA_API ~SingleFile()
Destructor.
FWDATA_API SingleFile(::fwData::Object::Key key)
Constructor.
PathType m_path
file system path
Definition: SingleFile.hpp:59
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 setPath(PathType path)
Set file system path.
FWDATA_API PathType getPath() const
Get file system path.