aimsdata 6.0.0
Neuroimaging data handling
item.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 class
36 */
37#ifndef AIMS_BUCKET_ITEM_H
38#define AIMS_BUCKET_ITEM_H
39
40
42#include <iostream>
43#include <aims/vector/vector.h>
44
45
46
47template <class T> class AimsBucketItem;
48
49
50template <class T> AIMSDATA_API
51std::ostream& operator << (std::ostream& out, const AimsBucketItem<T>& thing);
52
53template <class T>
54int operator == (const AimsBucketItem<T>& thing1,
55 const AimsBucketItem<T>& thing2);
56
61template <class T>
63{ protected:
66
71
72 public:
75
76 AimsBucketItem() : _location((short)0) { }
79 _location(other._location), _value(other._value) { }
80
83
86
87 const T& value() const { return _value; }
89 T& value() { return _value; }
90
92 const AimsVector<short,3>& location() const { return _location; }
96
98 friend
99 int operator == <> (const AimsBucketItem<T>& thing1,
100 const AimsBucketItem<T>& thing2);
101
103 friend
104 std::ostream& operator << <> (std::ostream& out,
105 const AimsBucketItem<T>& thing);
106};
107
108
109template <class T> inline
111 const AimsBucketItem<T>& thing2)
112{ return thing1.location() == thing2.location() &&
113 thing1.value() == thing2.value();
114}
115
116
117template <class T> inline
118std::ostream& operator << (std::ostream& out, const AimsBucketItem<T>& thing)
119{ return out << "{" << thing.location() << "," << thing.value() << "}";
120}
121
122
123#endif
124
125
126
127
128
129
130
131
132
133
#define AIMSDATA_API
The template base class for all types of bucket items.
Definition item.h:63
AimsVector< short, 3 > & location()
Get a non-const reference to the location of the bucket item.
Definition item.h:94
AimsBucketItem(const AimsBucketItem< T > &other)
Copy constructor.
Definition item.h:78
AimsVector< short, 3 > _location
Location of the item in the 3D image.
Definition item.h:67
T & value()
Get a non-const reference to the value of the bucket item.
Definition item.h:89
AimsBucketItem()
Constructor sets location to origin (0,0,0)
Definition item.h:76
~AimsBucketItem()
Destructor does nothing.
Definition item.h:81
T _value
Value associated to the location.
Definition item.h:69
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
int operator==(const AimsBucketItem< T > &thing1, const AimsBucketItem< T > &thing2)
Definition item.h:110
AIMSDATA_API std::ostream & operator<<(std::ostream &out, const AimsBucketItem< T > &thing)
Definition item.h:118