The Fib multimedia system
Fib is a system for storing multimedia data (like images or films).
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
cDomainRational.h
Go to the documentation of this file.
1
/**
2
* @class cDomainRational
3
* file name: cDomainRational.h
4
* @author Betti Oesterholz
5
* @date 13.05.2009
6
* @mail webmaster@BioKom.info
7
*
8
* System: C++
9
*
10
* This file contains the class for rational Fib -domains.
11
* Copyright (C) @c LGPL3 2009 Betti Oesterholz
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU Lesser General Public License (LGPL) as
15
* published by the Free Software Foundation, either version 3 of the
16
* License, or any later version.
17
*
18
* This program is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
* GNU Lesser General Public License for more details.
22
*
23
* You should have received a copy of the GNU Lesser General Public License
24
* along with this program. If not, see <http://www.gnu.org/licenses/>.
25
*
26
*
27
* This file contains the class for rational Fib -domains.
28
* Rational numbers are composed of two numbers the mantissa and the exponent.
29
* The number is: mantissa * 2^exponent
30
* This domain stores the numbers for the mantisa and exponent as two
31
* cDomainIntegerBasis numbers.
32
*
33
*/
34
/*
35
History:
36
13.05.2009 Oesterholz created
37
01.12.2011 Oesterholz method isInBoundaries() added
38
*/
39
40
#ifndef ___C_DOMAIN_REAL_H__
41
#define ___C_DOMAIN_REAL_H__
42
43
44
#include "version.h"
45
46
#include "
cDomainRationalBasis.h
"
47
48
49
namespace
fib{
50
51
52
class
cDomainRational
:
public
cDomainRationalBasis
{
53
public
:
54
55
/**
56
* The constructor for rational number domains.
57
*
58
* @param dfMantissa the domain for the mantisse of the rational domain
59
* @param dfExponent the domain for the exponent of the rational domain
60
*/
61
cDomainRational
(
const
cDomainIntegerBasis
&dfMantissa,
62
const
cDomainIntegerBasis
&dfExponent );
63
64
/**
65
* This constructor restores a domain in the XML -format from an TinyXml element.
66
*
67
* @param pXmlNode a pointer to the TinyXml node wher the domain is stored in
68
* @param outStatus an integervalue with the errorvalue
69
* possible errorvalues are:
70
* - 0 loading successful
71
* - -1 loading error, invalid pXmlElement
72
* - -2 loading error, invalid data in pXmlElement
73
* - 1 loading warning, invalid data in pXmlElement, error could be corrected
74
* - 2 loading warning, invalid data in pXmlElement, maybe the loaded
75
* object is wrong
76
*/
77
cDomainRational
(
const
TiXmlElement * pXmlElement,
intFib
& outStatus );
78
79
/**
80
* The copyconstructor for natural numer domains.
81
*
82
* @param domain the rational number domain to copy
83
*/
84
cDomainRational
(
const
cDomainRational
&domain );
85
86
/**
87
* @return the type of the domain as an string
88
*/
89
virtual
string
getType
()
const
;
90
91
/**
92
* This method checks if the given value is an element of the
93
* domain. If the value dValue is an element of the
94
* domain true is returned, else false.
95
*
96
* @param dValue the value for which to check, if it is an element of
97
* the domain
98
* @return if the value dValue is an element of the domain true
99
* true is returned, else false
100
*/
101
virtual
bool
isElement
(
const
doubleFib
dValue )
const
;
102
103
/**
104
* This method checks if the given value is inside the domain
105
* boundaries. If the value dValue is inside of the domain boundaries
106
* true is returned, else false.
107
* A value is inside of the vector domain boudaries, if it is greater
108
* than the minimum value and lower than the maximum value.
109
*
110
* @param dValue the value for which to check, if it is inside of
111
* the domain boundaries
112
* @return if the vector dValue is inside of the domain boundaries
113
* true is returned, else false
114
*/
115
virtual
bool
isInBoundaries
(
const
doubleFib
dValue )
const
;
116
117
118
/**
119
* This method round the given value dValue to an value in the
120
* domain of this object.
121
* The rounded vale will be the value with the minimal distance to the
122
* given value dValue. If more of these exists the smales will be
123
* returned.
124
*
125
* @param dValue the value which should be rounded
126
* @return the rounded value of dValue
127
*/
128
virtual
doubleFib
round
(
const
doubleFib
dValue )
const
;
129
130
131
/**
132
* This method returns the biggest value in the domain.
133
*
134
* @return the biggest value in the domain
135
*/
136
doubleFib
getMaximum
( )
const
;
137
138
139
/**
140
* This method returns the smalest value in the domain.
141
*
142
* @return the smalest value in the domain
143
*/
144
virtual
doubleFib
getMinimum
( )
const
;
145
146
147
/**
148
* This method returns the nullvalue of the domain.
149
* The nullvalue is the value 0 rounded to an value in the
150
* domain.
151
*
152
* @return the nullvalue of the domain
153
*/
154
virtual
doubleFib
getNull
( )
const
;
155
156
157
/**
158
* This Method clones this object.
159
*
160
* @return a clone of this object
161
*/
162
virtual
cDomainRational
*
clone
()
const
;
163
164
/**
165
* This method evaluades the size of the domain in bits in the
166
* compressed file form.
167
*
168
* @see store()
169
* @return the size of the domain in bits in the compressed form
170
*/
171
virtual
unsignedIntFib
getCompressedSize
()
const
;
172
173
/**
174
* This method evaluades the size of values in the domain in bits in
175
* the compressed file form.
176
*
177
* @see store()
178
* @return the size of the domain in bits in the compressed form
179
*/
180
virtual
unsignedIntFib
getCompressedSizeForValue
()
const
;
181
182
/**
183
* This method stores this domain in the XML -format into the
184
* given stream.
185
*
186
* @param ostream the stream where domains should be stored to
187
* @return true if this domain are stored, else false
188
*/
189
virtual
bool
storeXml
( ostream & ostream )
const
;
190
191
/**
192
* This method restores a domain in the XML -format from an TinyXml element.
193
*
194
* @param pXmlNode a pointer to the TinyXml node wher the domain is stored in
195
* @return an integervalue with the errorvalue
196
* possible errorvalues are:
197
* - 0 loading successful
198
* - -1 loading error, invalid pXmlElement
199
* - -2 loading error, invalid data in pXmlElement
200
* - 1 loading warning, invalid data in pXmlElement, error could be corrected
201
* - 2 loading warning, invalid data in pXmlElement, maybe the loaded
202
* object is wrong
203
*/
204
virtual
intFib
restoreXml
(
const
TiXmlElement * pXmlElement ) ;
205
206
/**
207
* This method stores this domain in the compressed fib -format
208
* into the given stream.
209
* It is needed because the stream can yust store byts but the size of
210
* fib -elements can be any number of bits. Because of that ther have to
211
* be a possibility to exchange the missing bits betwean the fib -elements.
212
*
213
* @see cFibElement::store
214
* @param stream the stream where this domain should be stored to
215
* @param cRestBits the not yet writen bits which should be stored
216
* @param uiRestBitPosition the number of bits in the cRestBits which
217
* should be writen respectively containing valid information
218
* @return true if the domain is stored, else false
219
*/
220
virtual
bool
store
( ostream & stream,
char
& cRestBits,
221
unsigned
char
& uiRestBitPosition )
const
;
222
223
/**
224
* This method restores a domain from a bitstream, wher it is
225
* stored in the compressed fib -format.
226
*
227
* @see store
228
* @param iBitStream the stream where the domain is stored in,
229
* because the stream is an cReadBits, any number of bits can be
230
* readed from it
231
* @return an integervalue with the errorvalue
232
* possible errorvalues are:
233
* - 0 loading successful
234
* - -1 loading error, invalid pXmlElement
235
* - -2 loading error, invalid data in pXmlElement
236
* - 1 loading warning, invalid data in pXmlElement, error could be corrected
237
* - 2 loading warning, invalid data in pXmlElement, maybe the loaded
238
* object is wrong
239
*/
240
virtual
intFib
restore
(
cReadBits
& iBitStream );
241
242
/**
243
* This method stores the given value dValue in the compressed
244
* fib -format for the domain into the given stream.
245
* It is needed because the stream can yust store byts but the size of
246
* fib -elements can be any number of bits. Because of that ther have to
247
* be a possibility to exchange the missing bits betwean the fib -elements.
248
*
249
* @see cFibElement::store
250
* @param dValue the value to store
251
* @param stream the stream where this domain should be stored to
252
* @param cRestBits the not yet writen bits which should be stored
253
* @param uiRestBitPosition the number of bits in the cRestBits which
254
* should be writen respectively containing valid information
255
* @return true if the domain is stored, else false
256
*/
257
virtual
bool
storeValue
(
doubleFib
dValue, ostream & stream,
258
char
& cRestBits,
unsigned
char
& uiRestBitPosition )
const
;
259
260
/**
261
* This method restores the a unscaled integer value of the domain from
262
* the stream iBitStream, wher it is stored in the compressed fib -format.
263
*
264
* @see storeValue
265
* @see restoreValue
266
* @see storeUnscaledValue
267
* @see cFibElement::restore
268
* @param iBitStream the stream where this value is stored to in,
269
* because this stream is an cReadBits, any number of bits can be
270
* readed from it
271
* @param outStatus An reference to an integervalue where the errorvalue
272
* can be stored to. If the pointer is NULL no errorvalue will be
273
* given back.
274
* possible errorvalues are:
275
* - 0 loading successful
276
* - -1 loading error, invalid stream
277
* - -2 loading error, invalid data in stream
278
* - 1 loading warning, invalid data in stream, error could be corrected
279
* - 2 loading warning, invalid data in stream, maybe the loaded
280
* object is wrong
281
* @return the restored value
282
*/
283
virtual
doubleFib
restoreValue
(
cReadBits
& iBitStream,
intFib
& outStatus )
const
;
284
285
286
protected
:
287
288
/**
289
* Decompses a doubleFib number into it's mantissa and exponent part.
290
*
291
* @param dNumber the number to decompose
292
* @param lInOutMantissa a pointer to the longFib field wher the mantissa
293
* should be stored
294
* @param lInOutExponent a pointer to the longFib field wher the exponent
295
* should be stored
296
*/
297
void
decomposeDoubleFib
(
const
doubleFib
dNumber,
298
longFib
& lInOutMantissa,
longFib
& lInOutExponent )
const
;
299
300
301
302
};
//end class cDomainRational
303
304
305
}
//end namespace fib
306
307
#endif
fib
incl
cDomainRational.h
Generated on Thu Feb 14 2013 14:06:56 for The Fib multimedia system by
1.8.1