fw4spl
SingleFile.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
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 __FWDATA_LOCATION_SINGLEFILE_HPP__
8 #define __FWDATA_LOCATION_SINGLEFILE_HPP__
9 
10 #include "fwData/config.hpp"
11 #include "fwData/factory/new.hpp"
12 #include "fwData/location/ILocation.hpp"
13 
14 #include <boost/filesystem.hpp>
15 
16 fwCampAutoDeclareDataMacro((fwData)(location)(SingleFile), FWDATA_API);
17 
18 namespace fwData
19 {
20 namespace location
21 {
25 class FWDATA_CLASS_API SingleFile : public ILocation
26 {
27 public:
30  ((::fwData::factory::New< SingleFile >, () ))
31  ((SingleFileFactory, ((::boost::filesystem::path)) ))
32  );
33 
35  FWDATA_API SingleFile( ::fwData::Object::Key key );
36 
38  FWDATA_API virtual ~SingleFile();
39 
40  fwCampMakeFriendDataMacro((fwData)(location)(SingleFile));
41 
43  FWDATA_API void shallowCopy( const Object::csptr& _source ) override;
44 
46  FWDATA_API void cachedDeepCopy(const Object::csptr& _source, DeepCopyCacheType& cache) override;
47 
49  FWDATA_API void setPath( PathType path);
50 
52  FWDATA_API PathType getPath() const;
53 
54 protected:
55 
56  FWDATA_API static sptr SingleFileFactory(PathType path);
57 
59  PathType m_path;
60 
61 };
62 
69 template<typename RW> // reader or writer class should only need to implement get/setLocation
71 {
76  enableSingleFile(RW* rw) :
77  m_rw(rw)
78  {
79  SLM_ASSERT("m_rw not instanced", m_rw);
80  }
81 
83  void setFile(ILocation::PathType path)
84  {
85  getLocation<SingleFile>(m_rw)->setPath(path);
86  }
87 
89  ILocation::PathType getFile()
90  {
91  return (getLocation<SingleFile>(m_rw))->getPath();
92  }
93 
94  private:
97  RW* m_rw;
98 
99 };
100 
101 }
102 }
103 
104 #endif /* __FWDATA_LOCATION_SINGLEFILE_HPP__ */
#define fwCoreClassDefinitionsWithNFactoriesMacro(_classinfo_, _factories_args_)
Generate common construction methods for classes with several factories.
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.
void setFile(ILocation::PathType path)
Set file system path.
Definition: SingleFile.hpp:83
#define SLM_ASSERT(message, cond)
work like &#39;assert&#39; from &#39;cassert&#39;, with in addition a message logged by spylog (with FATAL loglevel) ...
Definition: spyLog.hpp:308
This class is derived by reader/writer.
Definition: SingleFile.hpp:70
enableSingleFile(RW *rw)
constructor
Definition: SingleFile.hpp:76
Abstract class to define a location ( fileSystem, directory(IES) etc.... )
Definition: ILocation.hpp:28
PathType m_path
file system path
Definition: SingleFile.hpp:59
ILocation::PathType getFile()
Get file system path.
Definition: SingleFile.hpp:89
Contains the representation of the data objects used in the framework.