fw4spl
core/fwDataIO/include/fwDataIO/reader/IObjectReader.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 "fwDataIO/config.hpp"
10 #include "fwDataIO/reader/factory/new.hpp"
11 #include "fwDataIO/reader/registry/detail.hpp"
12 
13 #include <fwCore/base.hpp>
14 
15 #include <fwData/location/ILocation.hpp>
16 
17 #include <fwJobs/IJob.hpp>
18 
19 #include <fwTools/Object.hpp>
20 
21 #include <boost/filesystem/path.hpp>
22 
23 #include <cstdint>
24 #include <functional>
25 
26 namespace fwDataIO
27 {
28 
29 namespace reader
30 {
31 
41 class FWDATAIO_CLASS_API IObjectReader : public ::fwCore::BaseObject
42 {
43 
44 public:
45 
47 
48  typedef std::function< void ( std::uint64_t /*progress*/) > ProgressCallback;
49  typedef std::function< void ( ) > CancelCallback;
50 
51  typedef ::fwDataIO::reader::factory::Key Key;
52 
59  template <typename T>
60  class Registrar
61  {
62  public:
63  Registrar()
64  {
65  ::fwDataIO::reader::registry::get()->addFactory(T::classname(), &::fwDataIO::reader::factory::New<T>);
66  }
67  };
68 
74  FWDATAIO_API virtual void read() = 0;
75 
82  FWDATAIO_API virtual void setObject( ::fwTools::Object::sptr _pObject );
83 
90  FWDATAIO_API virtual ::fwTools::Object::sptr getObject();
91 
96  FWDATAIO_API virtual void setLocation( const ::fwData::location::ILocation::sptr _location );
97 
103  FWDATAIO_API virtual ::fwData::location::ILocation::sptr getLocation();
104 
105  FWDATAIO_API virtual std::string extension() = 0;
106 
110  FWDATAIO_API void cancel();
111 
113  FWDATAIO_API virtual SPTR(::fwJobs::IJob) getJob() const
114  {
115  return nullptr;
116  }
117 
118 protected:
119 
121  FWDATAIO_API IObjectReader();
122 
124  FWDATAIO_API virtual ~IObjectReader();
125 
131  ::fwTools::Object::wptr m_object;
132 
134  ::fwData::location::ILocation::sptr m_location;
135 
136 };
137 
138 } // namespace reader
139 
140 } // namespace fwDataIO
#define SPTR(_cls_)
#define fwCoreNonInstanciableClassDefinitionsMacro(_classinfo_)
Generate common code for Non Instanciable classes (Interfaces, Abstract classes, ...)
Base class for all FW4SPL&#39;s classes.
Definition: BaseObject.hpp:22
This class is an interface for class managing job.
Definition: IJob.hpp:28
This namespace fwDataIO contains reader and writer for several framework&#39;s data.
::fwTools::Object::wptr m_object
Object result of reading process.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Class used to register a class factory in factory registry. This class defines also the object factor...
::fwData::location::ILocation::sptr m_location
Object location ( file path, directory path, url, etc )