fw4spl
GenericObjectWriter.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/IObjectWriter.hpp"
11 
12 namespace fwDataIO
13 {
14 
15 namespace writer
16 {
17 
26 template<class DATATYPE>
28 {
29 
30 public:
31 
33  typedef DATATYPE DataType;
34 
36 
39  {
40  }
41 
44  {
45  }
46 
53  virtual void setObject( ::fwTools::Object::csptr obj) override
54  {
55  OSLM_ASSERT("Object type: '" << std::string(typeid(obj).name())
56  << "' is not a '" << typeid(DataType()).name()<<"'",
57  std::dynamic_pointer_cast< const DataType >(obj));
59  }
60 
67  virtual std::shared_ptr< const DataType > getConcreteObject() const
68  {
69  return std::dynamic_pointer_cast< const DataType >( getObject() );
70  }
71 
72 };
73 
74 } // namespace writer
75 
76 } // namespace fwDataIO
#define fwCoreNonInstanciableClassDefinitionsMacro(_classinfo_)
Generate common code for Non Instanciable classes (Interfaces, Abstract classes, ...)
#define OSLM_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:310
This namespace fwDataIO contains reader and writer for several framework&#39;s data.
virtual std::shared_ptr< const DataType > getConcreteObject() const
m_object getter.
virtual FWDATAIO_API::fwTools::Object::csptr getObject() const
m_object getter.
virtual void setObject(::fwTools::Object::csptr obj) override
m_object setter.
GenericObjectWriter()
Constructor. Do nothing.
Base class for all object writers.
virtual FWDATAIO_API void setObject(::fwTools::Object::csptr object)
m_object setter.
virtual ~GenericObjectWriter()
Destructor. Do nothing.
DATATYPE DataType
the object type related
generic class for all object writers.