creaImageIO_lib
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
creaImageIOTreeComparators.h
Go to the documentation of this file.
1
/*
2
# ---------------------------------------------------------------------
3
#
4
# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5
# pour la Santé)
6
# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7
# Previous Authors : Laurent Guigues, Jean-Pierre Roux
8
# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9
#
10
# This software is governed by the CeCILL-B license under French law and
11
# abiding by the rules of distribution of free software. You can use,
12
# modify and/ or redistribute the software under the terms of the CeCILL-B
13
# license as circulated by CEA, CNRS and INRIA at the following URL
14
# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15
# or in the file LICENSE.txt.
16
#
17
# As a counterpart to the access to the source code and rights to copy,
18
# modify and redistribute granted by the license, users are provided only
19
# with a limited warranty and the software's author, the holder of the
20
# economic rights, and the successive licensors have only limited
21
# liability.
22
#
23
# The fact that you are presently reading this means that you have had
24
# knowledge of the CeCILL-B license and that you accept its terms.
25
# ------------------------------------------------------------------------
26
*/
27
28
29
#ifndef __creaImageIOTreeNodeComparators_h_INCLUDED__
30
#define __creaImageIOTreeNodeComparators_h_INCLUDED__
31
32
#include <vector>
33
#include <iostream>
34
35
namespace
creaImageIO
36
{
37
38
namespace
tree
39
{
40
41
42
class
Node;
43
44
48
//=====================================================================
50
struct
Comparator
51
{
52
virtual
~Comparator
() {}
53
virtual
bool
operator()
(
Node
*
const
& x,
Node
*
const
& y) = 0;
54
};
55
//=====================================================================
56
57
58
59
//=====================================================================
61
struct
ComparatorWithOrder
:
public
Comparator
62
{
63
ComparatorWithOrder
(
bool
reverse_order =
false
)
64
:
mReverseOrder
(reverse_order) {}
65
virtual
~ComparatorWithOrder
() {}
66
67
68
virtual
bool
compare
(
Node
*
const
&,
Node
*
const
&) = 0;
69
70
virtual
bool
operator()
(
Node
*
const
& x,
Node
*
const
& y)
71
{
72
if
(
mReverseOrder
)
return
this->
compare
(y,x);
73
return
this->
compare
(x,y);
74
};
75
76
bool
mReverseOrder
;
77
};
78
//=====================================================================
79
80
81
82
//=====================================================================
85
class
LexicographicalComparator
:
public
Comparator
86
{
87
public
:
88
LexicographicalComparator
(
const
std::string& name)
89
:
mName
(name) {}
90
~LexicographicalComparator
() {}
91
92
const
std::string&
GetName
()
const
{
return
mName
; }
93
void
SetName
(
const
std::string& s) {
mName
= s; }
94
void
Clear
() {
mComparator
.clear(); }
95
void
DeleteComparators
()
96
{
97
std::vector<Comparator*>::iterator i;
98
for
(i =
mComparator
.begin();
99
i!=
mComparator
.end();
100
++i)
101
{
102
delete
*i;
103
}
104
mComparator
.clear();
105
}
106
void
Add
(
Comparator
* c) {
mComparator
.push_back(c); }
107
108
bool
operator()
(
Node
*
const
& x,
Node
*
const
& y);
109
110
private
:
111
std::string
mName
;
112
std::vector<Comparator*>
mComparator
;
113
};
114
//=====================================================================
115
116
117
118
119
//===================================================================
121
struct
IntComparator
:
122
public
ComparatorWithOrder
123
{
124
IntComparator
(
const
std::string& key,
125
bool
reverse_order)
126
:
127
ComparatorWithOrder
(reverse_order),
128
mKey
(key)
129
{}
130
virtual
bool
compare
(
Node
*
const
& x,
Node
*
const
& y);
131
132
private
:
133
std::string
mKey
;
134
};
135
//===================================================================
136
137
//===================================================================
139
struct
FloatComparator
:
140
public
ComparatorWithOrder
141
{
142
FloatComparator
(
const
std::string& key,
143
bool
reverse_order )
144
:
145
ComparatorWithOrder
(reverse_order),
146
mKey
(key)
147
{}
148
149
virtual
bool
compare
(
Node
*
const
& x,
Node
*
const
& y);
150
151
private
:
152
std::string
mKey
;
153
};
154
//===================================================================
155
156
//===================================================================
158
struct
StringComparator
:
159
public
ComparatorWithOrder
160
{
161
StringComparator
(
const
std::string& key,
162
bool
reverse_order )
163
:
164
ComparatorWithOrder
(reverse_order),
165
mKey
(key)
166
{}
167
168
virtual
bool
compare
(
Node
*
const
& x,
Node
*
const
& y);
169
170
private
:
171
std::string
mKey
;
172
};
173
//===================================================================
174
175
//===================================================================
176
#define INT_FIELD_COMP(NAME,FIELD) \
177
struct Node##NAME##Comparator : \
178
public IntComparator \
179
{ \
180
Node##NAME##Comparator(bool o = false) : \
181
IntComparator(FIELD,o) \
182
{} \
183
}
184
//==================================================================
185
186
//===================================================================
187
#define FLOAT_FIELD_COMP(NAME,FIELD) \
188
struct Node##NAME##Comparator : \
189
public FloatComparator \
190
{ \
191
Node##NAME##Comparator(bool o = false) : \
192
FloatComparator(FIELD,o) \
193
{} \
194
}
195
//===================================================================
196
197
//===================================================================
198
#define STRING_FIELD_COMP(NAME,FIELD) \
199
struct Node##NAME##Comparator : \
200
public StringComparator \
201
{ \
202
Node##NAME##Comparator(bool o = false) : \
203
StringComparator(FIELD,o) \
204
{} \
205
}
206
//===================================================================
207
208
209
210
//===================================================================
211
// Patient comparators
213
STRING_FIELD_COMP
(PatientName,
"A0010_0010"
);
215
STRING_FIELD_COMP
(PatientSex,
"A0010_0040"
);
217
STRING_FIELD_COMP
(PatientBirthday,
"A0010_0030"
);
218
//===================================================================
219
220
//===================================================================
221
// Study comparators
223
STRING_FIELD_COMP
(StudyDate,
"A0008_0020"
);
225
STRING_FIELD_COMP
(StudyDescription,
"A0008_1030"
);
226
//===================================================================
227
228
//===================================================================
229
// Series comparators
231
STRING_FIELD_COMP
(Modality,
"A0008_0060"
);
233
STRING_FIELD_COMP
(SeriesDescription,
"A0008_103E"
);
235
STRING_FIELD_COMP
(SeriesDate,
"A0008_0021"
);
236
//===================================================================
237
238
//===================================================================
239
// Image comparators
241
INT_FIELD_COMP
(ImageNumber,
"A0020_0013"
);
243
FLOAT_FIELD_COMP
(SliceLocation,
"A0020_1041"
);
245
STRING_FIELD_COMP
(FullFileName,
"FullFileName"
);
246
//===================================================================
247
}
// namespace tree
248
249
}
// namespace creaImageIO
250
251
252
253
#endif // #ifndef __creaImageIOComparators_h_INCLUDED__
creatools_source
creaImageIO
src
creaImageIOTreeComparators.h
Generated by
1.8.3.1