fw4spl
ILocation.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_ILOCATION_HPP__
8 #define __FWDATA_LOCATION_ILOCATION_HPP__
9 
10 #include "fwData/Object.hpp"
11 #include "fwData/config.hpp"
12 
13 #include <boost/filesystem/path.hpp>
14 
15 namespace fwData
16 {
20 namespace location
21 {
22 
28 class FWDATA_CLASS_API ILocation : public ::fwData::Object
29 {
30 public:
32 
33  typedef ::boost::filesystem::path PathType;
34  typedef std::vector<PathType> VectPathType;
35 
36 protected:
37 
39  FWDATA_API ILocation();
40 
42  FWDATA_API virtual ~ILocation();
43 };
44 
49 template<class LOCATION, class RW >
50 inline typename LOCATION::sptr getLocation(RW* rw)
51 {
52  SLM_ASSERT("rw not instanced", rw);
53  typename LOCATION::sptr location;
54  location = LOCATION::dynamicCast( rw->getLocation() );
55  if ( !location )
56  {
57  location = LOCATION::New();
58  rw->setLocation(location);
59  }
60  return location;
61 }
62 
64 template<class LOCATION, class RW >
65 inline bool have(RW* rw)
66 {
67  return (LOCATION::dynamicCast( rw->getLocation() )) ? true : false;
68 }
69 
70 }
71 }
72 
73 #endif /* __FWDATA_LOCATION_ILOCATION_HPP__ */
#define fwCoreNonInstanciableClassDefinitionsMacro(_classinfo_)
Generate common code for Non Instanciable classes (Interfaces, Abstract classes, ...)
LOCATION::sptr getLocation(RW *rw)
Get reader or writer location.
Definition: ILocation.hpp:50
bool have(RW *rw)
test if a Reader/writer (ie a class implementing get/setLocation) have an specialized LOCATION ...
Definition: ILocation.hpp:65
#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
Abstract class to define a location ( fileSystem, directory(IES) etc.... )
Definition: ILocation.hpp:28
Base class for each data object.
Contains the representation of the data objects used in the framework.