aimsdata  4.7.0
Neuroimaging data handling
bckItemW.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  * Bucket item reader class
36  */
37 #ifndef AIMS_IO_BCKITEMW_H
38 #define AIMS_IO_BCKITEMW_H
39 
40 
41 #include <aims/io/defaultItemW.h>
42 #include <aims/bucket/item.h>
43 
44 
45 namespace aims
46 {
47 
48 #ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
49 
50  template<class T> class DefaultItemWriter<AimsBucketItem<T> >
51  : public ItemWriter<AimsBucketItem<T> >
52  {
53  public:
55  virtual ~DefaultItemWriter() { }
56 
57  virtual void write( std::ostream & is,
58  const AimsBucketItem<T> & item ) const;
59  virtual void write( std::ostream & is, const AimsBucketItem<T> * pitem,
60  size_t n ) const;
62  writer( const std::string & openmode = "binar",
63  bool bswap = false ) const;
64  };
65 
66 
67  template<class T> class DefaultAsciiItemWriter<AimsBucketItem<T> >
68  : public DefaultItemWriter<AimsBucketItem<T> >
69  {
70  public:
73 
74  virtual void write( std::ostream & is,
75  const AimsBucketItem<T> & item ) const;
76  };
77 
78 
79  template<class T> class DefaultBSwapItemWriter<AimsBucketItem<T> >
80  : public DefaultItemWriter<AimsBucketItem<T> >
81  {
82  public:
85 
86  virtual void write( std::ostream & is,
87  const AimsBucketItem<T> & item ) const;
88  };
89 
90 #endif // DOXYGEN_HIDE_INTERNAL_CLASSES
91 
92 
93  // definitions
94 
95  template<class T> ItemWriter<AimsBucketItem<T> >*
96  DefaultItemWriter<AimsBucketItem<T> >::writer( const std::string & openmode,
97  bool bswap ) const
98  {
99  if( openmode == "ascii" )
101  if( bswap )
103  return( new DefaultItemWriter<AimsBucketItem<T> > );
104  }
105 
106 
107  template<class T>
109  ( std::ostream & is, const AimsBucketItem<T>* pitem, size_t n ) const
110  {
111  const AimsBucketItem<T> *ptr = pitem;
112  for( size_t i=0; i<n; ++i )
113  write( is, *ptr++ );
114  }
115 
116 
117  template<class T> void
119  (
120  std::ostream & os, const AimsBucketItem<T> & item ) const
121  {
123  DefaultItemWriter<T> itemW2;
124 
125  itemW1.write( os, item.location() );
126  itemW2.write( os, item.value() );
127  }
128 
129 
130  template<class T> void DefaultAsciiItemWriter<AimsBucketItem<T> >::write
131  ( std::ostream & os, const AimsBucketItem<T> & item ) const
132  {
135 
136  itemW1.write( os, item.location() );
137  itemW2.write( os, item.value() );
138  }
139 
140 
141  template<class T> void DefaultBSwapItemWriter<AimsBucketItem<T> >::write
142  ( std::ostream & os, const AimsBucketItem<T> & item ) const
143  {
146 
147  itemW1.write( os, item.location() );
148  itemW2.write( os, item.value() );
149  }
150 
151 }
152 
153 
154 #endif
155 
156 
Default low-levels writers.
Definition: defaultItemW.h:58
virtual ItemWriter< T > * writer(const std::string &openmode="binar", bool bswap=false) const
Definition: defaultItemW.h:139
virtual void write(std::ostream &os, const T &item) const
Definition: defaultItemW.h:159
The class for EcatSino data write operation.
Definition: border.h:42
const AimsVector< short, 3 > & location() const
Get a const reference to the location of the bucket item.
Definition: item.h:92
Low-level "small item" writer, used by higher-level file readers.
Definition: itemW.h:50
virtual void write(std::ostream &os, const T &item) const
Definition: defaultItemW.h:91
const T & value() const
Get a const reference to the value of the bucket item.
Definition: item.h:87
The template base class for all types of bucket items.
Definition: item.h:47
virtual void write(std::ostream &os, const T &item) const
Definition: defaultItemW.h:64