aimsdata 6.0.0
Neuroimaging data handling
bckItemR.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_BCKITEMR_H
38#define AIMS_IO_BCKITEMR_H
39
40
43#include <aims/bucket/item.h>
44
45
46namespace aims
47{
48
49#ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
50
51 template<class T>
53 : public ItemReader<AimsBucketItem<T> >
54 {
55 public:
57 virtual ~DefaultItemReader() { }
58
59 virtual void read( std::istream & is, AimsBucketItem<T> * pitem,
60 size_t n ) const;
62 reader( const std::string & openmode = "binar", bool bswap = false ) const;
63 };
64
65
66 template <class T>
68 : public DefaultItemReader<AimsBucketItem<T> >
69 {
70 public:
73
74 virtual void read( std::istream & is, AimsBucketItem<T> * pitem,
75 size_t n ) const;
76 };
77
78
79 template <class T>
81 : public DefaultItemReader<AimsBucketItem<T> >
82 {
83 public:
86
87 virtual void read( std::istream & is, AimsBucketItem<T> * pitem,
88 size_t n ) const;
89 };
90
91#endif // DOXYGEN_HIDE_INTERNAL_CLASSES
92
93 // definitions
94
95 template <class T> ItemReader<AimsBucketItem<T> >*
96 DefaultItemReader<AimsBucketItem<T> >::reader( const std::string & openmode,
97 bool bswap ) const
98 {
99 if( openmode == "ascii" )
101 if( bswap )
103 return( new DefaultItemReader<AimsBucketItem<T> > );
104 }
105
106 template <class T> inline
108 AimsBucketItem<T>* pitem,
109 size_t n ) const
110 {
113 unsigned p;
114 AimsBucketItem<T> *ptr = pitem;
115
116 for( p=0; p<n; ++p, ++ptr )
117 {
118 pr.read( is, ptr->location() );
119 ir.read( is, ptr->value() );
120 }
121 }
122
123
124 template <class T> inline void
126 AimsBucketItem<T>* pitem,
127 size_t n ) const
128 {
131 unsigned p;
132 AimsBucketItem<T> *ptr = pitem;
133
134 for( p=0; p<n; ++p, ++ptr )
135 {
136 pr.read( is, ptr->location() );
137 ir.read( is, ptr->value() );
138 }
139 }
140
141
142 template <class T> inline void
144 AimsBucketItem<T>* pitem,
145 size_t n ) const
146 {
149 unsigned p;
150 AimsBucketItem<T> *ptr = pitem;
151
152 for( p=0; p<n; ++p, ++ptr )
153 {
154 pr.read( is, ptr->location() );
155 ir.read( is, ptr->value() );
156 }
157 }
158
159
160}
161
162
163#endif
164
#define AIMSDATA_API
The template base class for all types of bucket items.
Definition item.h:63
const T & value() const
Get a const reference to the value of the bucket item.
Definition item.h:87
const AimsVector< short, 3 > & location() const
Get a const reference to the location of the bucket item.
Definition item.h:92
virtual void read(std::istream &is, AimsBucketItem< T > *pitem, size_t n) const
Definition bckItemR.h:125
virtual void read(std::istream &is, T &item) const
virtual void read(std::istream &is, AimsBucketItem< T > *pitem, size_t n) const
Definition bckItemR.h:143
virtual void read(std::istream &is, T &item) const
virtual void read(std::istream &is, AimsBucketItem< T > *pitem, size_t n) const
Definition bckItemR.h:107
virtual ItemReader< AimsBucketItem< T > > * reader(const std::string &openmode="binar", bool bswap=false) const
Definition bckItemR.h:96
virtual void read(std::istream &is, T &item) const
Low-level "small item" reader, used by higher-level file readers.
Definition itemR.h:99
The class for EcatSino data write operation.