aimsdata 6.0.0
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
40#include <cartobase/object/object.h>
41
42
43namespace 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 }
70
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
85
93 template<class T> class Writer : public GenericWriter
94 {
95 public:
96 inline Writer() {};
97 inline Writer( const std::string& filename,
99 GenericWriter( filename, options ) {}
100 virtual ~Writer() {}
101
108 virtual bool write( const T & obj, bool ascii = false,
109 const std::string* format = 0 );
110
111 virtual std::string writtenObjectType() const;
112 virtual std::string writtenObjectDataType() const;
113 virtual std::string writtenObjectFullType() const;
114 };
115
116 template <class T>
118 operator << ( aims::GenericWriter & writer, const T & thing )
119 {
120 writer.write( thing );
121 return writer;
122 }
123
124
125 template <class T>
126 inline aims::Writer<T> &
127 operator << ( aims::Writer<T> & writer, const T & thing )
128 {
129 writer.write( thing );
130 return writer;
131 }
132
133
140 template <typename T>
141 inline bool write( const T & obj, const std::string & filename,
142 carto::Object options = carto::none(),
143 const std::string* format = 0 )
144 {
145 Writer<T> w( filename );
146 w.setOptions( options );
147 return w.write( obj, false, format );
148 }
149
150}
151
152
153#endif
154
155
virtual std::string writtenObjectDataType() const =0
void setOptions(carto::Object opt)
Definition writer.h:73
void setFileName(const std::string &fileName)
set output file name
Definition writer.h:66
const carto::Object options() const
Definition writer.h:72
carto::Object _options
Definition writer.h:81
GenericWriter(const std::string &filename, carto::Object options=carto::none())
Definition writer.h:50
const std::string & fileName() const
get output file name
Definition writer.h:71
virtual std::string writtenObjectFullType() const =0
std::string _filename
Definition writer.h:80
virtual std::string writtenObjectType() const =0
virtual ~GenericWriter()
Definition writer.h:53
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
Generic writer for every format of Aims object.
Definition writer.h:94
virtual std::string writtenObjectType() const
Definition writer_d.h:87
virtual std::string writtenObjectDataType() const
Definition writer_d.h:94
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
virtual std::string writtenObjectFullType() const
Definition writer_d.h:101
Writer(const std::string &filename, carto::Object options=carto::none())
Definition writer.h:97
virtual ~Writer()
Definition writer.h:100
The class for EcatSino data write operation.
bool write(const T &obj, const std::string &filename, carto::Object options=carto::none(), const std::string *format=0)
Finds the correct format and writes the object, global version.
Definition writer.h:141
AIMSDATA_API PovWriter< D, T > & operator<<(PovWriter< D, T > &writer, const AimsTimeSurface< D, T > &thing)
Definition povW.h:72
Object none()