A.I.M.S


reader.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 #ifndef AIMS_IO_READER_H
35 #define AIMS_IO_READER_H
36 
38 #include <aims/def/general.h>
40 #include <string>
41 
42 namespace aims
43 {
44 
69  template<class T> class Reader
70  {
71  public:
72  Reader();
73  Reader( const std::string& filename );
74  virtual ~Reader() {}
75 
83  virtual bool read( T & obj, int border=0, const std::string* format = 0,
84  int frame = -1 );
92  virtual T* read( int border = 0, const std::string* format = 0,
93  int frame = -1 );
95  void setMode( carto::AllocatorStrategy::MappingMode mode );
97  void setAllocatorContext( const carto::AllocatorContext & ac );
98  const carto::AllocatorContext & allocatorContext() const;
100  void setFileName( const std::string &fileName );
102  inline const std::string &fileName() const { return _filename; }
104  carto::Object options() const;
106 
107  static std::string extension( const std::string & filename );
108 
109  protected:
110  std::string _filename;
111  carto::AllocatorStrategy::MappingMode _mode;
112  carto::AllocatorContext _alloccontext;
114  };
115 
116 }
117 
118 
119 template <class T>
120 inline aims::Reader<T> &
121 operator >> ( aims::Reader<T> & reader, T & thing )
122 {
123  reader.read( thing );
124  return reader;
125 }
126 
127 
128 #endif
virtual ~Reader()
Definition: reader.h:74
aims::Reader< T > & operator>>(aims::Reader< T > &reader, T &thing)
Definition: reader.h:121
void setMode(carto::AllocatorStrategy::MappingMode mode)
set input file mode - soon obsolete
Definition: reader_d.h:74
std::string _filename
Definition: reader.h:110
void setFileName(const std::string &fileName)
set input file name
Definition: reader_d.h:113
carto::AllocatorContext _alloccontext
Definition: reader.h:112
void setAllocatorContext(const carto::AllocatorContext &ac)
allocator control (not used by every format yet)
Definition: reader_d.h:101
static std::string extension(const std::string &filename)
carto::Object options() const
Definition: reader_d.h:125
Generic reader for every format of Aims object.
Definition: reader.h:69
carto::AllocatorStrategy::MappingMode _mode
Definition: reader.h:111
const carto::AllocatorContext & allocatorContext() const
Definition: reader_d.h:107
carto::Object _options
Definition: reader.h:113
const std::string & fileName() const
get input file name
Definition: reader.h:102
virtual bool read(T &obj, int border=0, const std::string *format=0, int frame=-1)
Finds the correct format and reads the object. if format is specified, this format is tried first...
Definition: reader_d.h:137
void setOptions(carto::Object options)
Definition: reader_d.h:119