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
cDomainVectorOpenEnd.h
Go to the documentation of this file.
1 /**
2  * @class cDomainVectorOpenEndOpenEnd
3  * file name: cDomainVectorOpenEnd.h
4  * @author Betti Oesterholz
5  * @date 03.12.2011
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This class represents a vector domain.
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 vector Fib-domains for variable domains.
28  * A vector domain is defined with the domains of it's elements.
29  * see vectorOpenEnd( E , D_1, ... , D_E)
30  * This is the domain for vectors with E or more elements, in wich the i'th
31  * element has the domain D_i, for i lower E, and else the domain D_E.
32  * This domain is for elements, which can contain vectors of diffent sizes.
33  * The number of elements in the vector should be determined by the
34  * containing fib-element.
35  *
36  */
37 /*
38 History:
39 03.12.2011 Oesterholz created
40 */
41 
42 #ifndef ___C_DOMAIN_VECTOR_OPEN_END_H__
43 #define ___C_DOMAIN_VECTOR_OPEN_END_H__
44 
45 
46 #include "version.h"
47 #include "fibDatatyps.h"
48 
49 #include "cDomainVectorBasis.h"
50 #include "cDomainSingle.h"
51 
52 #include <vector>
53 
54 using std::vector;
55 
56 namespace fib{
57 
58 
60 
61 protected:
62 
63  /**
64  * This vector contains the domains for the elements of the
65  * vectordomain.
66  */
67  vector<cDomain*> vecElementDomains;
68 
69 public:
70 
71  /**
72  * This constructor of the cDomainVectorOpenEnd element.
73  *
74  * @param vecInElementDomains the vector with the domains for the vector
75  * elements
76  */
77  cDomainVectorOpenEnd( const vector<cDomain*> & vecInElementDomains );
78 
79  /**
80  * This constructor of the cDomainVectorOpenEnd element.
81  *
82  * @param vecInElementDomains the vector with the domains for the vector
83  * elements
84  */
85  cDomainVectorOpenEnd( const vector<cDomainSingle*> & vecInElementDomains );
86 
87  /**
88  * This destructor of the cDomainVectorOpenEnd element.
89  */
90  virtual ~cDomainVectorOpenEnd( );
91 
92  /**
93  * @return the type of the domain as an string
94  */
95  virtual string getType() const;
96 
97 
98  /**
99  * This method checks if the given vector is an element of the
100  * domain. If the value dValue is an element of the
101  * domain true is returned, else false.
102  *
103  * @param fibVector the vector for which to check, if it is an element
104  * of the domain
105  * @return if the vector fibVector is an element of the domain true
106  * is returned, else false
107  */
108  virtual bool isElement( const cFibVector &fibVector ) const;
109 
110  /**
111  * This method checks if the given vector is inside the domain
112  * boundaries. If the value dValue is inside of the domain boundaries
113  * true is returned, else false.
114  * A vector is inside of the vector domain boudaries, if all its
115  * elements are inside ther correspondending element domain boundaries.
116  *
117  * @param fibVector the vector for which to check, if it is inside of
118  * the domain boundaries
119  * @return if the vector fibVector is inside of the domain boundaries
120  * true is returned, else false
121  */
122  virtual bool isInBoundaries( const cFibVector &fibVector ) const;
123 
124  /**
125  * This method round the given value vector to an vector in the
126  * domain of this object.
127  * The rounded vector will be the vector, wich elements have the minimal
128  * summed distance to the elements of the given vector fibVector. If more
129  * than one such vector exists, the vector wich first n elements have
130  * the minimal summed distance to the first n elements of the given
131  * vector fibVector. Wher n is first the number of elements in the
132  * vector, and than is decrased to 1 in steps of 1. If again more such
133  * vectors exists, the one with the smalest k elements is choosen, wher
134  * k begins with 1 and is incrased to the number of vectorelements in
135  * the input vector.
136  * ATTENTION: The returned vector will not be deleted automaticly, you
137  * have to delete it.
138  *
139  * @param fibVector the vector which should be rounded
140  * @return the rounded vector of fibVector
141  */
142  virtual cFibVector * round( cFibVector &fibVector ) const;
143 
144 
145  /**
146  * This method returns the number of elements in the vectors of the
147  * domain.
148  *
149  * @return the number of elements in the vectors of the domain
150  */
151  virtual unsignedIntFib getNumberOfElements() const;
152 
153 
154  /**
155  * This method returns the domain of the iNumberOfElement'th element in
156  * the vectors of the domain.
157  *
158  * @param iNumberOfElement the elementnumber for which the domain is to
159  * return
160  * @return domain of the iNumberOfElement'th element in the vectors of
161  * the domain
162  */
163  virtual cDomain * getElementDomain(
164  const unsignedIntFib iNumberOfElement );
165 
166  /**
167  * This method returns the domain of the iNumberOfElement'th element in
168  * the vectors of the domain.
169  *
170  * @param iNumberOfElement the elementnumber for which the domain is to
171  * return
172  * @return domain of the iNumberOfElement'th element in the vectors of
173  * the domain
174  */
175  virtual const cDomain * getElementDomain(
176  const unsignedIntFib iNumberOfElement ) const;
177 
178  /**
179  * This Method clones this object.
180  *
181  * @return a clone of this object
182  */
183  virtual cDomainVectorOpenEnd *clone() const;
184 
185 
186  /**
187  * This Method checks if the given domain is equal to this domain.
188  *
189  * @param domain the domain which should be equal to this domain
190  * @return true if the given domain is equal to this domain, else false
191  */
192  virtual bool operator==( const cDomain &domain ) const;
193 
194 
195  /**
196  * This method evaluades the size of the domain in bits in the
197  * compressed file form.
198  *
199  * @see store()
200  * @return the size of the domain in bits in the compressed form
201  */
202  virtual unsignedIntFib getCompressedSize() const;
203 
204  /**
205  * This method stores this domain in the XML -format into the
206  * given stream.
207  *
208  * @param ostream the stream where domains should be stored to
209  * @return true if this domain are stored, else false
210  */
211  virtual bool storeXml( ostream & ostream ) const;
212 
213  /**
214  * This method restores a domain in the XML -format from an TinyXml element.
215  *
216  * @param pXmlNode a pointer to the TinyXml node wher the domain is stored in
217  * @return an integervalue with the errorvalue
218  * possible errorvalues are:
219  * - 0 loading successful
220  * - -1 loading error, invalid pXmlElement
221  * - -2 loading error, invalid data in pXmlElement
222  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
223  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
224  * object is wrong
225  */
226  virtual intFib restoreXml( const TiXmlElement * pXmlElement );
227 
228  /**
229  * This method stores this domain in the compressed fib -format
230  * into the given stream.
231  * It is needed because the stream can yust store byts but the size of
232  * fib -elements can be any number of bits. Because of that ther have to
233  * be a possibility to exchange the missing bits betwean the fib -elements.
234  *
235  * @see cFibElement::store
236  * @param stream the stream where this domain should be stored to
237  * @param cRestBits the not yet writen bits which should be stored
238  * @param uiRestBitPosition the number of bits in the cRestBits which
239  * should be writen respectively containing valid information
240  * @return true if the domain is stored, else false
241  */
242  virtual bool store( ostream & stream, char & cRestBits,
243  unsigned char & uiRestBitPosition ) const;
244 
245  /**
246  * This method restores a domain from a bitstream, wher it is
247  * stored in the compressed fib -format.
248  *
249  * @see store
250  * @param iBitStream the stream where the domain is stored in,
251  * because the stream is an cReadBits, any number of bits can be
252  * readed from it
253  * @return an integervalue with the errorvalue
254  * possible errorvalues are:
255  * - 0 loading successful
256  * - -1 loading error, invalid pXmlElement
257  * - -2 loading error, invalid data in pXmlElement
258  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
259  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
260  * object is wrong
261  */
262  virtual intFib restore( cReadBits & iBitStream );
263 
264 
265 };//end class cDomainVectorOpenEnd
266 
267 
268 }//end namespace fib
269 
270 #endif
271