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
cDomainSingle.h
Go to the documentation of this file.
1 /**
2  * @class cDomainSingle
3  * file name: cDomainSingle.h
4  * @author Betti Oesterholz
5  * @date 13.05.2009
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This class represents a scalar 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 basisclass of all scalar Fib -domains.
28  * It's not possible to create instances from this class.
29  *
30  */
31 /*
32 History:
33 13.05.2009 Oesterholz created
34 12.05.2010 Oesterholz scalingfactor moved from cDomainSingle to cDomainIntegerBasis
35 19.09.2010 Oesterholz the createGoodDomain() function added
36 01.12.2011 Oesterholz method isInBoundaries() added
37 */
38 
39 #ifndef ___C_DOMAIN_SINGLE_H__
40 #define ___C_DOMAIN_SINGLE_H__
41 
42 
43 #include "version.h"
44 #include "fibDatatyps.h"
45 #include "cReadBits.h"
46 
47 #include "cDomain.h"
48 
49 #include <list>
50 
51 namespace fib{
52 
53 
54 class cDomainSingle: public cDomain{
55 public:
56 
57  /**
58  * @return true if the object represents a scalar domain, else false
59  */
60  virtual bool isScalar() const{
61  return true;
62  }
63 
64  /**
65  * @return true if the object represents a vector domain, else false
66  */
67  virtual bool isVector() const{
68  return false;
69  }
70 
71 
72  /**
73  * This method checks if the given value is an element of the
74  * domain. If the value dValue is an element of the
75  * domain true is returned, else false.
76  *
77  * @param dValue the value for which to check, if it is an element of
78  * the domain
79  * @return if the value dValue is an element of the domain true
80  * is returned, else false
81  */
82  virtual bool isElement( const doubleFib dValue ) const = 0;
83 
84  /**
85  * This method checks if the given value is inside the domain
86  * boundaries. If the value dValue is inside of the domain boundaries
87  * true is returned, else false.
88  * A value is inside of the vector domain boudaries, if it is greater
89  * than the minimum value minus the scaling factor and lower than the
90  * maximum value plus the scaling factor.
91  *
92  * @param dValue the value for which to check, if it is inside of
93  * the domain boundaries
94  * @return if the vector dValue is inside of the domain boundaries
95  * true is returned, else false
96  */
97  virtual bool isInBoundaries( const doubleFib dValue ) const = 0;
98 
99 
100  /**
101  * This method round the given value dValue to an value in the
102  * domain of this object.
103  * The rounded value will be the value with the minimal distance to the
104  * given value dValue. If more of these exists the smales will be
105  * returned.
106  *
107  * @param dValue the value which should be rounded
108  * @return the rounded value of dValue
109  */
110  virtual doubleFib round( const doubleFib dValue ) const = 0;
111 
112 
113  /**
114  * This method returns the biggest value in the domain.
115  *
116  * @return the biggest value in the domain
117  */
118  virtual doubleFib getMaximum() const = 0;
119 
120 
121  /**
122  * This method returns the smalest value in the domain.
123  *
124  * @return the smalest value in the domain
125  */
126  virtual doubleFib getMinimum() const = 0;
127 
128 
129  /**
130  * This method returns the nullvalue of the domain.
131  * The nullvalue is the value 0 rounded to an value in the
132  * domain.
133  *
134  * @return the nullvalue of the domain
135  */
136  virtual doubleFib getNull() const = 0;
137 
138  /**
139  * This Method clones this object.
140  *
141  * @return a clone of this object
142  */
143  virtual cDomainSingle *clone() const = 0;
144 
145  /**
146  * This method evaluades the size of values in the domain in bits in
147  * the compressed file form.
148  *
149  * @see store()
150  * @return the size of the domain in bits in the compressed form
151  */
152  virtual unsignedIntFib getCompressedSizeForValue() const = 0;
153 
154  /**
155  * This method stores the given value dValue in the compressed
156  * fib -format for the domain into the given stream.
157  * It is needed because the stream can yust store byts but the size of
158  * fib -elements can be any number of bits. Because of that ther have to
159  * be a possibility to exchange the missing bits betwean the fib -elements.
160  *
161  * @see cFibElement::store
162  * @param dValue the value to store
163  * @param stream the stream where this domain should be stored to
164  * @param cRestBits the not yet writen bits which should be stored
165  * @param uiRestBitPosition the number of bits in the cRestBits which
166  * should be writen respectively containing valid information
167  * @return true if the domain is stored, else false
168  */
169  virtual bool storeValue( doubleFib dValue, ostream & stream,
170  char & cRestBits, unsigned char & uiRestBitPosition ) const = 0;
171 
172 
173  /**
174  * This method restores the a value of the domain from the stream
175  * iBitStream wher it is stored in the compressed fib -format.
176  *
177  * @see storeValue
178  * @see cFibElement::restore
179  * @param iBitStream the stream where this value is stored to in,
180  * because this stream is an cReadBits, any number of bits can be
181  * readed from it
182  * @param outStatus An reference to an integervalue where the errorvalue
183  * can be stored to. If the pointer is NULL no errorvalue will be
184  * given back.
185  * possible errorvalues are:
186  * - 0 loading successful
187  * - -1 loading error, invalid stream
188  * - -2 loading error, invalid data in stream
189  * - 1 loading warning, invalid data in stream, error could be corrected
190  * - 2 loading warning, invalid data in stream, maybe the loaded
191  * object is wrong
192  */
193  virtual doubleFib restoreValue( cReadBits & iBitStream, intFib & outStatus ) const = 0;
194 
195  /**
196  * This function creates creates a good domain wich contains all the
197  * numbers of the given list liValues.
198  * A domain is better than an other domain, if it takes less storage bits
199  * to store the numbers and the domain.
200  * Beware: You have to care that the returned domain is deleted. (if
201  * one was returned)
202  *
203  * @param liValues the list with the values, for which a domain is to create
204  * @return a new domain which contains all the given values liValues
205  */
206  static cDomainSingle * createGoodDomain( list< doubleFib > & liValues );
207 
208 
209 };//end class cDomainSingle
210 
211 
212 }//end namespace fib
213 
214 #endif
215