fw4spl
IObjectWriter.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/writer/factory/new.hpp"
11 #include "fwDataIO/writer/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 
25 namespace fwDataIO
26 {
27 
28 namespace writer
29 {
30 
41 class FWDATAIO_CLASS_API IObjectWriter : 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::writer::factory::Key Key;
52 
59  template <typename T>
60  class Registrar
61  {
62  public:
63  Registrar()
64  {
65  ::fwDataIO::writer::registry::get()->addFactory(T::classname(), &::fwDataIO::writer::factory::New<T>);
66  }
67  };
68 
74  FWDATAIO_API virtual void write() = 0;
75 
80  FWDATAIO_API virtual void setLocation( const ::fwData::location::ILocation::sptr location );
81 
87  FWDATAIO_API virtual ::fwData::location::ILocation::sptr getLocation();
88 
95  FWDATAIO_API virtual void setObject( ::fwTools::Object::csptr object );
96 
102  FWDATAIO_API virtual ::fwTools::Object::csptr getObject() const;
103 
111  FWDATAIO_API virtual std::string extension() = 0;
112 
116  FWDATAIO_API virtual void cancel();
117 
119  virtual SPTR(::fwJobs::IJob) getJob() const
120  {
121  return nullptr;
122  }
123 
124 protected:
125 
127  FWDATAIO_API IObjectWriter();
128 
130  FWDATAIO_API virtual ~IObjectWriter();
131 
137  ::fwTools::Object::cwptr m_object;
138 
140  ::fwData::location::ILocation::sptr m_location;
141 
143  std::string m_extension;
144 
145 };
146 
147 } // namespace writer
148 
149 } // 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
std::string m_extension
Extension of file format.
This namespace fwDataIO contains reader and writer for several framework&#39;s data.
::fwTools::Object::cwptr m_object
Object write on filesystem by the 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 )
Base class for all object writers.