fw4spl
src/fwData/location/Folder.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 
10 #include "fwData/location/Folder.hpp"
11 
12 fwDataRegisterMacro( ::fwData::location::Folder );
13 
14 namespace fwData
15 {
16 namespace location
17 {
18 
19 //------------------------------------------------------------------------------
20 
22 {
23 }
24 
25 //------------------------------------------------------------------------------
26 
28 {
29 }
30 
31 //------------------------------------------------------------------------------
32 
33 Folder::sptr Folder::FolderFactory(PathType path, bool recursive )
34 {
35  FwCoreNotUsedMacro(recursive);
36  Folder::sptr folder = Folder::New();
37  folder->setFolder(path);
38  return folder;
39 }
40 
41 //------------------------------------------------------------------------------
42 
43 void Folder::shallowCopy(const Object::csptr &_source )
44 {
45  Folder::csptr other = Folder::dynamicConstCast(_source);
46  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
47  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
48  + " to " + this->getClassname()), !bool(other) );
49  this->fieldShallowCopy( _source );
50  this->m_folder = other->m_folder;
51 }
52 
53 //------------------------------------------------------------------------------
54 
55 void Folder::cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache)
56 {
57  Folder::csptr other = Folder::dynamicConstCast(_source);
58  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
59  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
60  + " to " + this->getClassname()), !bool(other) );
61  this->fieldDeepCopy( _source, cache );
62  this->m_folder = other->m_folder;
63 }
64 
65 //------------------------------------------------------------------------------
66 
67 void Folder::setFolder( PathType folder)
68 {
69  m_folder = folder;
70 }
71 
72 //------------------------------------------------------------------------------
73 
74 ILocation::PathType Folder::getFolder() const
75 {
76  return m_folder;
77 }
78 
79 //------------------------------------------------------------------------------
80 
81 void Folder::setRecursive( bool recursive)
82 {
83  m_isRecursive = recursive;
84 }
85 
86 //------------------------------------------------------------------------------
87 
89 {
90  return m_isRecursive;
91 }
92 
93 //------------------------------------------------------------------------------
94 
95 }
96 }
This class defines a folder location.
Definition: Folder.hpp:25
PathType m_folder
Folder path
Definition: Folder.hpp:66
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
Defines shallow copy.
virtual const std::string & getClassname() const override
return full object&#39;s classname with its namespace, i.e. fwCore::BaseObject
Definition: Folder.hpp:33
FWDATA_API Folder(::fwData::Object::Key key)
Constructor.
FWDATA_API void fieldDeepCopy(const ::fwData::Object::csptr &source)
A deep copy of fields (objects in m_children)
FWDATA_API void setFolder(PathType folder)
Set folder filesystem path.
bool m_isRecursive
Flag if folder is recursive.
Definition: Folder.hpp:69
FWDATA_API void setRecursive(bool recursive)
Set the flag if folder location is recursive.
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)
virtual FWDATA_API ~Folder()
Destructor.
FWDATA_API bool getRecursive()
Get the flag if folder location is recursive.
FWDATA_API PathType getFolder() const
Get folder filesystem path.