fw4spl
FileHolder.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
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 #pragma once
8 
9 #include "fwMemory/config.hpp"
10 
11 #include <fwCore/macros.hpp>
12 
13 #include <boost/filesystem/path.hpp>
14 
15 namespace fwMemory
16 {
17 
18 struct FileAutoDelete;
19 
20 class FWMEMORY_CLASS_API FileHolder
21 {
22 public:
23  FileHolder()
24  {
25  }
26  FWMEMORY_API FileHolder(const ::boost::filesystem::path& file, bool autodelete = false);
27 
28  operator :: boost::filesystem::path() const
29  {
30  return m_path;
31  }
32 
33  //------------------------------------------------------------------------------
34 
35  bool empty() const
36  {
37  return m_path.empty();
38  }
39 
40  //------------------------------------------------------------------------------
41 
42  void clear()
43  {
44  m_path.clear();
45  m_autoDelete.reset();
46  }
47 
48  //------------------------------------------------------------------------------
49 
50  std::string string() const
51  {
52  return m_path.string();
53  }
54 
55 protected:
56  ::boost::filesystem::path m_path;
57  SPTR(FileAutoDelete) m_autoDelete;
58 };
59 
60 } // namespace fwMemory
#define SPTR(_cls_)
The namespace fwMemory contains tools to manage memory. Use for dump.
Definition: SReader.hpp:20
This file defines fwCore base macros.