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
cTypeElement.h
Go to the documentation of this file.
1 /**
2  * @class cTypeElement
3  * file name: cTypeElement.h
4  * @author Betti Oesterholz
5  * @date 02.06.2009
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This class represents an abstract Fib -vectorelementtype.
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 Fib -vectorelementtyps.
28  * Fib -vectorelementtyps are typs of the elements in an Fib -vector (e.g.
29  * for an underarea vector the type of the elements is underarea).
30  *
31  */
32 /*
33 History:
34 02.06.2009 Oesterholz created
35 31.01.2012 Oesterholz isInherited() method added
36 12.02.2012 Oesterholz restoreXml*() without restoring domain possible
37 */
38 
39 #ifndef ___C_TYPE_ELEMENT_H__
40 #define ___C_TYPE_ELEMENT_H__
41 
42 
43 #include "version.h"
44 #include "fibDatatyps.h"
45 #include "cReadBits.h"
46 
47 #include "cDomain.h"
48 
49 #include "tinyxml.h"
50 
51 #include <ostream>
52 #include <istream>
53 
54 
55 namespace fib{
56 
57 
59 
60 public:
61 
62  /**
63  * destructor
64  */
65  virtual ~cTypeElement() = 0;
66 
67  /**
68  * This Function returns for the type of the element an number.
69  * The values, which are returned, mean:
70  * - 1: cTypeDimension
71  * - 2: cTypeUnderArea
72  * - 3: cTypeUnderFunction
73  * - 5: cTypeInVar
74  * - 6: cTypeProperty
75  * - 10: cTypeVariable
76  * - 11: cTypeComments
77  * - 12: cTypeExtObject
78  * - 13: cTypeExtSubobject
79  * - 14: cTypeFibSet
80  * - 15: cTypeFibMatrix
81  * - 16: cTypeExtObjectInput
82  *
83  * @return for the type of the element an number
84  */
85  virtual unsignedIntFib getType() const = 0;
86 
87 
88  /**
89  * This method checks, if this element type is compatible with the
90  * given domain. Just domains which are compadible can be used for the
91  * elements of this type.
92  *
93  * @param domain the domain, which should be compatible
94  * @return true if the given domain is compatible, else false
95  */
96  virtual bool isCompatible( const cDomain &domain ) const;
97 
98 
99  /**
100  * This Method returns a pointer to a new instance of the standart
101  * domain for elements of this type.
102  * You have to delete the returned object after usage.
103  *
104  * @return the standart domain for elements of this type
105  */
106  virtual cDomain *getStandardDomain( ) const;
107 
108 
109  /**
110  * This Method checks if the elementtype of the given type is equal to
111  * the elementtype of this type.
112  * Two elementtype are not equal if ther are for different fib -elements.
113  *
114  * @param typeElement the typeelement to compare with this typeelement
115  * @return true if the elementtype of the given type is equal to the
116  * elementtype of this type, else false
117  */
118  virtual bool equalElementType( const cTypeElement & typeElement ) const;
119 
120  /**
121  * This Method checks if the given type is equal to this type.
122  *
123  * @param typeElement the typeelement to compare with this typeelement
124  * @return true if the given type is equal to this type, else false
125  */
126  virtual bool equal( const cTypeElement &typeElement ) const;
127 
128  /**
129  * This Method checks if the given type is equal to this type.
130  *
131  * @param typeElement the typeelement to compare with this typeelement
132  * @return true if the given type is equal to this type, else false
133  */
134  virtual bool operator==( const cTypeElement &typeElement ) const;
135 
136 
137  /**
138  * This Method clones this object.
139  *
140  * @return a clone of this object
141  */
142  virtual cTypeElement *clone() const = 0;
143 
144  /**
145  * This method evaluades the size of the typeelement in bits in the
146  * compressed file form.
147  *
148  * @see store()
149  * @return the size of the typeelement in bits in the compressed form
150  */
151  virtual unsignedLongFib getCompressedSize() const = 0;
152 
153  /**
154  * This method stores this type in the XML -format into the
155  * given stream.
156  *
157  * @param ostream the stream where domains should be stored to
158  * @param domain the domain which should be stored to this type;
159  * if a Nullpointer NULL (the standardvalue) is given, no domain
160  * will be stored to this type
161  * @return true if this type are stored, else false
162  */
163  virtual bool storeXml( ostream & ostream,
164  const cDomain * domain = NULL ) const = 0;
165 
166  /**
167  * This method restores a type in the XML -format from a TinyXml element.
168  *
169  * @pattern Factory Method
170  * @param pXmlNode a pointer to the TinyXml node wher the type is stored in
171  * @param outStatus an integer value with the errorvalue
172  * possible errorvalues are:
173  * - 0 loading successful
174  * - -1 loading error, invalid pXmlElement
175  * - -2 loading error, invalid data in pXmlElement
176  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
177  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
178  * object is wrong
179  * @return the pointer to the restored type, if it could be restored
180  * else it is a NULL pointer
181  */
182  static cTypeElement * restoreXmlType(
183  const TiXmlElement * pXmlElement, intFib & outStatus );
184 
185  /**
186  * This method restores a type with a domain in the XML -format from an
187  * TinyXml element.
188  *
189  * @pattern Factory Method
190  * @param pXmlNode a pointer to the TinyXml node wher the type is stored in
191  * @param outStatus an integer value with the errorvalue
192  * possible errorvalues are:
193  * - 0 loading successful
194  * - -1 loading error, invalid pXmlElement
195  * - -2 loading error, invalid data in pXmlElement
196  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
197  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
198  * object is wrong
199  * @param bRestoreDomain if true a domain is to be asumed in the type
200  * element and it will be restored, else no domain will be restores
201  * @return a pair with the pointers to the restored type and domain
202  * if one couldn't be restored it's pointer is NULL
203  */
204  static pair< cTypeElement * , cDomain * > restoreXmlTypeWithDomain(
205  const TiXmlElement * pXmlElement, intFib & outStatus,
206  const bool bRestoreDomain = true );
207 
208  /**
209  * This method restores a type with a domain in the XML -format from an
210  * TinyXml element.
211  *
212  * @pattern Factory Method
213  * @param pXmlNode a pointer to the TinyXml node wher the type is stored in
214  * @param outStatus an integer value with the errorvalue
215  * possible errorvalues are:
216  * - 0 loading successful
217  * - -1 loading error, invalid pXmlElement
218  * - -2 loading error, invalid data in pXmlElement
219  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
220  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
221  * object is wrong
222  * @param bRestoreDomain if true a domain is to be asumed in the type
223  * element and it will be restored, else no domain will be restores
224  * @return a pointer to the restored domain, or NULL if it couldn't be restored
225  */
226  virtual cDomain * restoreXmlWithDomain( const TiXmlElement * pXmlElement,
227  intFib & outStatus, const bool bRestoreDomain = true ) = 0;
228 
229  /**
230  * This method stores this typeelement in the compressed fib -format
231  * into the given stream.
232  * It is needed because the stream can yust store byts but the size of
233  * fib -elements can be any number of bits. Because of that ther have to
234  * be a possibility to exchange the missing bits betwean the fib -elements.
235  *
236  * @see restore
237  * @see cFibElement::store
238  * @param stream the stream where this typeelement should be stored to
239  * @param cRestBits the not yet writen bits which should be stored
240  * @param uiRestBitPosition the number of bits in the cRestBits which
241  * should be writen respectively containing valid information
242  * @return true if the typeelement is stored, else false
243  */
244  virtual bool store( ostream & stream, char & cRestBits,
245  unsigned char & uiRestBitPosition ) const = 0;
246 
247  /**
248  * This method restores a type from a bitstream, wher it is
249  * stored in the compressed fib -format.
250  *
251  * @see store
252  * @param iBitStream the stream where the type is stored in,
253  * because the stream is an cReadBits, any number of bits can be
254  * readed from it
255  * @param outStatus an integer value with the errorvalue
256  * possible errorvalues are:
257  * - 0 loading successful
258  * - -1 loading error, invalid pXmlElement
259  * - -2 loading error, invalid data in pXmlElement
260  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
261  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
262  * object is wrong
263  * @return a pointer to the restored type or NULL
264  */
265  static cTypeElement * restore( cReadBits & iBitStream, intFib & outStatus );
266 
267  /**
268  * This method restores a type from a bitstream, wher it is
269  * stored in the compressed fib -format.
270  *
271  * @see store
272  * @param iBitStream the stream where the type is stored in,
273  * because the stream is an cReadBits, any number of bits can be
274  * readed from it
275  * @return an integer value with the errorvalue
276  * possible errorvalues are:
277  * - 0 loading successful
278  * - -1 loading error, invalid pXmlElement
279  * - -2 loading error, invalid data in pXmlElement
280  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
281  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
282  * object is wrong
283  */
284  virtual intFib restore( cReadBits & iBitStream ) = 0;
285 
286  /**
287  * @return true if domains of this type are inerted else false
288  */
289  virtual bool isInherited() const;
290 
291 protected:
292 
293  /**
294  * @return true if the given domain is a domain for counters (it only
295  * contains positiv numbers), else false
296  */
297  static bool isCounterDomain( const cDomain * pDomain );
298 
299 };//end class cTypeElement
300 
301 
302 }//end namespace fib
303 
304 #endif //___C_TYPE_ELEMENT_H__