The Fib multimedia system
Fib is a system for storing multimedia data (like images or films).
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cDomainInteger.h
Go to the documentation of this file.
1 /**
2  * @class cDomainInteger
3  * file name: cDomainInteger.h
4  * @author Betti Oesterholz
5  * @date 16.05.2010
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This class represents a domain for integer numbers.
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 integer number Fib -domains.
28  * The representet domain is defined by the minimal and maximal number
29  * in the domain.
30  * If X is the minimal and Y is the maximal number, the domain {Y, ..., X}
31  * is the unscaled domain and if dScalingFactor is the scaling factor
32  * { Y*dScalingFactor, ..., X * dScalingFactor} is the scaled
33  * domain.
34  *
35  */
36 /*
37 History:
38 16.05.2010 Oesterholz created
39 14.09.2011 Oesterholz lNumberOfValues added
40 01.12.2011 Oesterholz method isInBoundaries() added
41 */
42 
43 #ifndef ___C_DOMAIN_INTEGER_H__
44 #define ___C_DOMAIN_INTEGER_H__
45 
46 
47 #include "version.h"
48 
49 #include "cDomainIntegerBasis.h"
51 
52 
53 namespace fib{
54 
55 
57 protected:
58 
59  /**
60  * The minimal number of the integer numbers in this domain.
61  */
63 
64  /**
65  * The maximal number of the integer numbers in this domain.
66  */
68 
69  /**
70  * The number of the integer numbers in this domain.
71  */
73 
74  /**
75  * The cDomainInteger uses a cDomainNaturalNumberBit domain for
76  * storing values.
77  */
79 
80 public:
81 
82  /**
83  * The constructor for unscaled integer numer domains.
84  * If lInMinNumber is the minimal number and ulMaxNumber the
85  * maximal number of the domain
86  * {lInMinNumber, ..., ulMaxNumber} is the domain.
87  *
88  * @param lInMinNumber the minimal number of the domain
89  * @param lInMaxNumber the maximal number of the domain
90  */
91  cDomainInteger( longFib lInMinNumber, longFib lInMaxNumber );
92 
93 
94  /**
95  * The constructor for scaled integer numer domains.
96  * If lInMinNumber is the minimal number and ulMaxNumber the
97  * maximal number of the domain
98  * {lInMinNumber*dScalingFactor, ..., ulMaxNumber*dScalingFactor} is
99  * the scaled domain.
100  * ({lInMinNumber, ..., ulMaxNumber} is the unscaled domain)
101  *
102  * @param lInMinNumber the minimal number of the domain
103  * @param lInMaxNumber the maximal number of the domain
104  * @param dScalingFactor the scaling factor of the domain
105  * the scaling factor has to be greater 0.0
106  */
107  cDomainInteger( longFib lInMinNumber, longFib lInMaxNumber,
109 
110  /**
111  * The copyconstructor for integer numer domains.
112  *
113  * @param domain the integer number domain to copy
114  */
115  cDomainInteger( const cDomainInteger &domain );
116 
117  /**
118  * @return the type of the domain as an string
119  */
120  virtual string getType() const;
121 
122  /**
123  * This method checks if the given value is an element of the
124  * domain. If the value dValue is an element of the
125  * domain true is returned, else false.
126  *
127  * @param dValue the value for which to check, if it is an element of
128  * the domain
129  * @return if the value dValue is an element of the domain true
130  * true is returned, else false
131  */
132  virtual bool isElement( const doubleFib dValue ) const;
133 
134  /**
135  * This method checks if the given value is inside the domain
136  * boundaries. If the value dValue is inside of the domain boundaries
137  * true is returned, else false.
138  * A value is inside of the vector domain boudaries, if it is greater
139  * than the minimum value minus the scaling factor and lower than the
140  * maximum value plus the scaling factor.
141  *
142  * @param dValue the value for which to check, if it is inside of
143  * the domain boundaries
144  * @return if the vector dValue is inside of the domain boundaries
145  * true is returned, else false
146  */
147  virtual bool isInBoundaries( const doubleFib dValue ) const;
148 
149  /**
150  * This method round the given value dValue to an value in the
151  * domain of this object.
152  * The rounded vale will be the value with the minimal distance to the
153  * given value dValue. If more of these exists the smales will be
154  * returned.
155  *
156  * @param dValue the value which should be rounded
157  * @return the rounded value of dValue
158  */
159  virtual doubleFib round( const doubleFib dValue ) const;
160 
161 
162  /**
163  * This method returns the biggest value in the domain.
164  *
165  * @return the biggest value in the domain
166  */
167  doubleFib getMaximum() const ;
168 
169 
170  /**
171  * This method returns the smalest value in the domain.
172  *
173  * @return the smalest value in the domain
174  */
175  virtual doubleFib getMinimum() const;
176 
177 
178  /**
179  * This method returns the nullvalue of the domain.
180  * The nullvalue is the value 0 rounded to an value in the
181  * domain.
182  *
183  * @return the nullvalue of the domain
184  */
185  virtual doubleFib getNull() const;
186 
187 
188  /**
189  * This method checks if the given value is an element of the
190  * unscaled domain. If the value lValue is an element of the
191  * unscaled domain true is returned, else false.
192  *
193  * @param lValue the value for which to check, if it is an element of
194  * the unscaled domain
195  * @return if the value dValue is an element of the unscaled
196  * domain true true is returned, else false
197  */
198  virtual bool isUnscaledElement( const longFib lValue ) const;
199 
200 
201  /**
202  * This method round the given value dValue to an value in the
203  * unscaled domain of this object.
204  * The rounded vale will be the unscaled value with the minimal
205  * distance to the given value lValue. If more of these exists the
206  * smales will be returned.
207  *
208  * @param lValue the value which should be rounded
209  * @return the rounded unscaled value of lValue
210  */
211  virtual longFib roundUnscaled( const longFib lValue ) const;
212 
213 
214  /**
215  * This method returns the biggest value in the unscaled domain.
216  *
217  * @return the biggest value in the unscaled domain
218  */
219  virtual longFib getMaximumUnscaled() const;
220 
221 
222  /**
223  * This method returns the smalest value in the unscaled domain.
224  *
225  * @return the smalest value in the unscaled domain
226  */
227  virtual longFib getMinimumUnscaled() const;
228 
229 
230  /**
231  * This method returns the nullvalue of the unscaled domain.
232  * The nullvalue is the value 0 rounded to an value in the unscaled
233  * domain.
234  *
235  * @return the nullvalue of the domain
236  */
237  virtual longFib getNullUnscaled() const;
238 
239  /**
240  * This Method clones this object.
241  *
242  * @return a clone of this object
243  */
244  virtual cDomainInteger *clone() const;
245 
246 
247  /**
248  * This Method checks if the given domain is equal to this domain.
249  *
250  * @param domain the domain which should be equal to this domain
251  * @return true if the given domain is equal to this domain, else false
252  */
253  virtual bool operator==( const cDomain &domain ) const;
254 
255 
256  /**
257  * This method evaluades the size of the domain in bits in the
258  * compressed file form.
259  *
260  * @see store()
261  * @return the size of the domain in bits in the compressed form
262  */
263  virtual unsignedIntFib getCompressedSize() const;
264 
265  /**
266  * This method evaluades the size of values in the domain in bits in
267  * the compressed file form.
268  *
269  * @see store()
270  * @return the size of the domain in bits in the compressed form
271  */
273 
274  /**
275  * This method stores this domain in the XML -format into the
276  * given stream.
277  *
278  * @param ostream the stream where domains should be stored to
279  * @return true if this domain are stored, else false
280  */
281  virtual bool storeXml( ostream & ostream ) const;
282 
283  /**
284  * This method restores a domain in the XML -format from an TinyXml element.
285  *
286  * @param pXmlNode a pointer to the TinyXml node wher the domain is stored in
287  * @return an integervalue with the errorvalue
288  * possible errorvalues are:
289  * - 0 loading successful
290  * - -1 loading error, invalid pXmlElement
291  * - -2 loading error, invalid data in pXmlElement
292  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
293  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
294  * object is wrong
295  */
296  virtual intFib restoreXml( const TiXmlElement * pXmlElement ) ;
297 
298  /**
299  * This method stores this domain in the compressed fib -format
300  * into the given stream.
301  * It is needed because the stream can yust store byts but the size of
302  * fib -elements can be any number of bits. Because of that ther have to
303  * be a possibility to exchange the missing bits betwean the fib -elements.
304  *
305  * @see cFibElement::store
306  * @param stream the stream where this domain should be stored to
307  * @param cRestBits the not yet writen bits which should be stored
308  * @param uiRestBitPosition the number of bits in the cRestBits which
309  * should be writen respectively containing valid information
310  * @return true if the domain is stored, else false
311  */
312  virtual bool store( ostream & stream, char & cRestBits,
313  unsigned char & uiRestBitPosition ) const;
314 
315  /**
316  * This method restores a domain from a bitstream, wher it is
317  * stored in the compressed fib -format.
318  *
319  * @see store
320  * @param iBitStream the stream where the domain is stored in,
321  * because the stream is an cReadBits, any number of bits can be
322  * readed from it
323  * @return an integervalue with the errorvalue
324  * possible errorvalues are:
325  * - 0 loading successful
326  * - -1 loading error, invalid pXmlElement
327  * - -2 loading error, invalid data in pXmlElement
328  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
329  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
330  * object is wrong
331  */
332  virtual intFib restore( cReadBits & iBitStream );
333 
334  /**
335  * This method stores the given value dValue in the compressed
336  * fib -format for the domain into the given stream.
337  * It is needed because the stream can yust store byts but the size of
338  * fib -elements can be any number of bits. Because of that ther have to
339  * be a possibility to exchange the missing bits betwean the fib -elements.
340  *
341  * @see cFibElement::store
342  * @param dValue the value to store
343  * @param stream the stream where this domain should be stored to
344  * @param cRestBits the not yet writen bits which should be stored
345  * @param uiRestBitPosition the number of bits in the cRestBits which
346  * should be writen respectively containing valid information
347  * @return true if the domain is stored, else false
348  */
349  virtual bool storeValue( doubleFib dValue, ostream & stream,
350  char & cRestBits, unsigned char & uiRestBitPosition ) const;
351 
352  /**
353  * This method stores the given unscaled value lValue in the compressed
354  * fib -format for the domain into the given stream.
355  * It is needed because the stream can yust store byts but the size of
356  * fib -elements can be any number of bits. Because of that ther have to
357  * be a possibility to exchange the missing bits betwean the fib -elements.
358  *
359  * @see cFibElement::store
360  * @param lValue the value to store
361  * @param stream the stream where this domain should be stored to
362  * @param cRestBits the not yet writen bits which should be stored
363  * @param uiRestBitPosition the number of bits in the cRestBits which
364  * should be writen respectively containing valid information
365  * @return true if the domain is stored, else false
366  */
367  virtual bool storeUnscaledValue( longFib lValue, ostream & stream,
368  char & cRestBits, unsigned char & uiRestBitPosition ) const;
369 
370  /**
371  * This method restores the a unscaled integer value of the domain from
372  * the stream iBitStream, wher it is stored in the compressed fib -format.
373  *
374  * @see storeValue
375  * @see restoreValue
376  * @see storeUnscaledValue
377  * @see cFibElement::restore
378  * @param iBitStream the stream where this value is stored to in,
379  * because this stream is an cReadBits, any number of bits can be
380  * readed from it
381  * @param outStatus An reference to an integervalue where the errorvalue
382  * can be stored to. If the pointer is NULL no errorvalue will be
383  * given back.
384  * possible errorvalues are:
385  * - 0 loading successful
386  * - -1 loading error, invalid stream
387  * - -2 loading error, invalid data in stream
388  * - 1 loading warning, invalid data in stream, error could be corrected
389  * - 2 loading warning, invalid data in stream, maybe the loaded
390  * object is wrong
391  * @return the unscaled restored value
392  */
393  virtual longFib restoreIntegerValue( cReadBits & iBitStream, intFib & outStatus ) const;
394 
395 };//end class cDomainInteger
396 
397 
398 }//end namespace fib
399 
400 #endif