aimsdata  5.0.5
Neuroimaging data handling
writer.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 /*
35  * Data reader class
36  */
37 #ifndef AIMS_IO_WRITER_H
38 #define AIMS_IO_WRITER_H
39 
41 
42 
43 namespace aims
44 {
45 
47  {
48  public:
49  inline GenericWriter() {};
50  inline GenericWriter( const std::string& filename,
52  _filename( filename ), _options( options ) {}
53  virtual ~GenericWriter() {}
54 
61  template <typename T>
62  bool write( const T & obj, bool ascii = false,
63  const std::string* format = 0 );
64 
66  inline void setFileName( const std::string &fileName )
67  {
69  }
71  inline const std::string &fileName() const { return _filename; }
72  const carto::Object options() const { return _options; }
73  void setOptions( carto::Object opt ) { _options = opt; }
74 
75  virtual std::string writtenObjectType() const = 0;
76  virtual std::string writtenObjectDataType() const = 0;
77  virtual std::string writtenObjectFullType() const = 0;
78 
79  protected:
80  std::string _filename;
82 
83  };
84 
92  template<class T> class Writer : public GenericWriter
93  {
94  public:
95  inline Writer() {};
96  inline Writer( const std::string& filename,
98  GenericWriter( filename, options ) {}
99  virtual ~Writer() {}
100 
107  virtual bool write( const T & obj, bool ascii = false,
108  const std::string* format = 0 );
109 
110  virtual std::string writtenObjectType() const;
111  virtual std::string writtenObjectDataType() const;
112  virtual std::string writtenObjectFullType() const;
113  };
114 
115  template <class T>
116  inline aims::GenericWriter &
117  operator << ( aims::GenericWriter & writer, const T & thing )
118  {
119  writer.write( thing );
120  return writer;
121  }
122 
123 
124  template <class T>
125  inline aims::Writer<T> &
126  operator << ( aims::Writer<T> & writer, const T & thing )
127  {
128  writer.write( thing );
129  return writer;
130  }
131 
132 }
133 
134 
135 #endif
136 
137 
bool write(const T &obj, bool ascii=false, const std::string *format=0)
Finds the correct format and writes the object.
Definition: writer_d.h:74
virtual ~Writer()
Definition: writer.h:99
const std::string & fileName() const
get output file name
Definition: writer.h:71
virtual ~GenericWriter()
Definition: writer.h:53
The class for EcatSino data write operation.
Definition: border.h:44
const carto::Object options() const
Definition: writer.h:72
void setOptions(carto::Object opt)
Definition: writer.h:73
virtual bool write(const T &obj, bool ascii=false, const std::string *format=0)
Finds the correct format and writes the object.
Definition: writer_d.h:108
std::string _filename
Definition: writer.h:80
virtual std::string writtenObjectType() const =0
GenericWriter(const std::string &filename, carto::Object options=carto::none())
Definition: writer.h:50
Generic writer for every format of Aims object.
Definition: writer.h:92
virtual std::string writtenObjectDataType() const =0
MotionWriter & operator<<(MotionWriter &writer, const AffineTransformation3d &thing) __attribute__((__deprecated__("OBSOLETE")))
— OBSOLETE —
Definition: motionW.h:87
virtual std::string writtenObjectFullType() const =0
Object none()
Pointer to an empty aims::StructuringElement.
void setFileName(const std::string &fileName)
set output file name
Definition: writer.h:66
Writer(const std::string &filename, carto::Object options=carto::none())
Definition: writer.h:96
carto::Object _options
Definition: writer.h:81