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
cTypeProperty.h
Go to the documentation of this file.
1 /**
2  * @class cTypeProperty
3  * file name: cTypeProperty.h
4  * @author Betti Oesterholz
5  * @date 18.07.2009
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This class represents Fib -propertytyps.
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 -propertytyps.
28  * Fib -propertytyps are typs of the elements in an Fib
29  * -propertyvector.
30  *
31  */
32 /*
33 History:
34 18.07.2009 Oesterholz created
35 10.12.2009 Oesterholz getOverwritenTyps() and isEvalued() added
36 05.07.2010 Oesterholz lowerTypeProperty() moved her from cEvaluePositionList
37  and operator<() added
38 17.12.2010 Oesterholz isOverwritenTyp() method added
39 18.12.2010 Oesterholz isOverwriting() and static isEvalued() methods added
40 12.02.2012 Oesterholz restoreXml*() without restoring domain possible
41 28.01.2013 Oesterholz colorSW changed to colorGrascale
42 */
43 
44 #ifndef ___C_TYPE_PROPERTY_H__
45 #define ___C_TYPE_PROPERTY_H__
46 
47 
48 #include "version.h"
49 #include "fibDatatyps.h"
50 #include "cTypeElement.h"
51 #include "cDomain.h"
52 
53 #include <vector>
54 #include <list>
55 
56 using std::vector;
57 
58 namespace fib{
59 
60 
62 private:
63 
64  /**
65  * the number of the dimension this type represents;
66  * possible values are:
67  * TODO
68  */
70 
71  /**
72  * The number of dimension this property type is for.
73  * Some properties like soundPolarized change ther domains for different
74  * number of dimensions. So they need to be known, when the information
75  * about the domain of thes properties are given.
76  */
78 
79 public:
80 
81  /**
82  * constants for the property type
83  */
84  static const unsignedIntFib NONE = 0;
85 
86  static const unsignedIntFib COLOR_RGB = 1;
87  static const unsignedIntFib COLOR_GRAYSCALE = 2;
88  static const unsignedIntFib LAYER = 100;
89  static const unsignedIntFib TRANSPARENCY = 200;
90  static const unsignedIntFib SOUND = 300;
91  static const unsignedIntFib SOUND_POLARIZED = 301;
92  static const unsignedIntFib SOUND_AMPLITUDE = 305;
93  static const unsignedIntFib SOUND_BARRIER = 310;
94  static const unsignedIntFib SOUND_REFLECTED = 311;
95  static const unsignedIntFib SOUND_DAMPING = 312;
96  static const unsignedIntFib KELVIN = 400;
97  static const unsignedIntFib ELECTRO_MAGNETIC= 410;
98 
99  static const unsignedIntFib CHECKSUM = 600;
100 
101  /**
102  * The constructor for dimension typs.
103  *
104  * @param iPropertyType the number of the property this type
105  * represents;
106  * possible values are:
107  * TODO
108  * @param iPropertyType the number of dimension this property type is for;
109  * you don't have to give them if the number of dimensions is
110  * irrelevant for the property type
111  */
114 
115  /**
116  * The copyconstructor for property typs.
117  *
118  * @param typeProperty the type property to copy
119  */
120  cTypeProperty( const cTypeProperty &typeProperty );
121 
122  /**
123  * The constructor for property typs.
124  * This constructor constructs a propertytype, which is of the same type
125  * as the given propertytype typeProperty, but which is adapted to the
126  * given domain if possible. For that the number of dimension is
127  * set to a value that is compatible to the vectordomain if possible.
128  * (If not possible number of dimension is set to the value as in
129  * typeProperty.)
130  *
131  * @param typeProperty the type property to copy
132  * @param domain the domain to which the propertytype is to be adapted
133  */
134  cTypeProperty( const cTypeProperty &typeProperty,
135  const cDomain & domain );
136 
137 
138  /**
139  * This method checks, if this element type is compatible with the
140  * given domain. Just domains which are compadible can be used for the
141  * elements of this type.
142  *
143  * @param domain the domain, which should be compatible
144  * @return true if the given domain is compatible, else false
145  */
146  virtual bool isCompatible( const cDomain &domain ) const;
147 
148 
149  /**
150  * This Method returns a pointer to a new instance of the standart
151  * domain for elements of this type.
152  * You have to delete the returned object after usage.
153  *
154  * @return the standart domain for elements of this type
155  */
156  virtual cDomain *getStandardDomain() const;
157 
158  /**
159  * This Function returns for the type of the element an number.
160  * The values, which are returned, mean:
161  * - 1: cTypeDimension
162  * - 2: cTypeUnderArea
163  * - 3: cTypeUnderFunction
164  * - 5: cTypeInVar
165  * - 6: cTypeProperty
166  * - 10: cTypeVariable
167  * - 11: cTypeComments
168  * - 12: cTypeExtObject
169  * - 13: cTypeExtSubobject
170  * - 14: cTypeFibSet
171  * - 15: cTypeFibMatrix
172  * - 16: cTypeExtObjectInput
173  *
174  * @return for the type of the element an number
175  */
176  virtual unsignedIntFib getType() const;
177 
178  /**
179  * @return the type of property this type represents
180  */
181  virtual unsignedIntFib getNumberOfProperty() const;
182 
183  /**
184  * @see getNumberForPropertyName()
185  * @return the name of property this type represents
186  */
187  virtual string getNameOfProperty() const;
188 
189  /**
190  * @see getNameOfProperty()
191  * @param szPropertyName a name for a property
192  * @return the number the name szPropertyName represents
193  */
194  static unsignedIntFib getNumberForPropertyName( const string szPropertyName );
195 
196  /**
197  * @return The SI unit for the dimension this type represents;
198  * possible values are:
199  * - "": for none
200  * - "m": for meter
201  * - "s": for secound
202  * TODO
203  */
204  virtual vector<string> getUnit() const;
205 
206  /**
207  * @return The typs of the properties the properties of this type overwrites
208  */
209  virtual list<cTypeProperty> getOverwritenTyps() const;
210 
211  /**
212  * This method checks if the given type is overwritten by this type.
213  *
214  * @param typeToCheck the type to check, if it is overwritten
215  * @return true if typeToCheck is overwritten by this type, else false
216  */
217  bool isOverwritenTyp( const cTypeProperty & typeToCheck ) const;
218 
219  /**
220  * This method checks if the given type is overwritten by this type.
221  *
222  * @see uiPropertyType
223  * @param uiTypeToCheck the number of the type to check, if it is overwritten
224  * @return true if uiTypeToCheck is overwritten by this type, else false
225  */
226  bool isOverwritenTyp( const unsignedIntFib & uiTypeToCheck ) const;
227 
228  /**
229  * @return if this type overwrites typs true, else false
230  */
231  bool isOverwriting() const;
232 
233  /**
234  * This function checks if the given type overwrites some typs.
235  *
236  * @param uiTypeToCheck the number of the type to check, if it overwrittes
237  * other typs
238  * @return if the given type overwrites typs true, else false
239  */
240  static bool isOverwriting( const unsignedIntFib & uiTypeToCheck );
241 
242  /**
243  * @return this method returnes true, if the property of this type is
244  * for evaluating a fib -object, else false is returned
245  */
246  virtual bool isEvalued() const;
247 
248  /**
249  * This function checks if the given type is evalued.
250  *
251  * @param uiTypeToCheck the number of the type to check, if it is evalued
252  * @return this method returnes true, if the property of the given type is
253  * for evaluating a fib -object, else false is returned
254  */
255  static bool isEvalued( const unsignedIntFib & uiTypeToCheck );
256  /**
257  * This Method checks if the given type is equal to this type.
258  *
259  * @return true if the given type is equal to this type, else false
260  */
261  virtual bool operator==( const cTypeElement &typeElement ) const;
262 
263  /**
264  * This Method clones this object.
265  *
266  * @return a clone of this object
267  */
268  virtual cTypeProperty *clone() const;
269 
270  /**
271  * This method evaluades the size of the typeelement in bits in the
272  * compressed file form.
273  *
274  * @see store()
275  * @return the size of the typeelement in bits in the compressed form
276  */
277  virtual unsignedLongFib getCompressedSize() const;
278 
279  /**
280  * This method stores this type in the XML -format into the
281  * given stream.
282  *
283  * @param ostream the stream where domains should be stored to
284  * @param domain the domain which should be stored to this type;
285  * if a Nullpointer NULL (the standardvalue) is given, no domain
286  * will be stored to this type
287  * @return true if this type are stored, else false
288  */
289  virtual bool storeXml( ostream & ostream,
290  const cDomain * domain = NULL ) const;
291 
292  /**
293  * This method restores a type with a domain in the XML -format from an
294  * TinyXml element.
295  *
296  * @param pXmlNode a pointer to the TinyXml node wher the type is stored in
297  * @param outStatus an integer value with the errorvalue
298  * possible errorvalues are:
299  * - 0 loading successful
300  * - -1 loading error, invalid pXmlElement
301  * - -2 loading error, invalid data in pXmlElement
302  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
303  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
304  * object is wrong
305  * @param bRestoreDomain if true a domain is to be asumed in the type
306  * element and it will be restored, else no domain will be restores
307  * @return a pointer to the restored domain, or NULL if it couldn't be restored
308  */
309  virtual cDomain * restoreXmlWithDomain( const TiXmlElement * pXmlElement,
310  intFib & outStatus, const bool bRestoreDomain = true );
311 
312  /**
313  * This method stores this typeelement in the compressed fib -format
314  * into the given stream.
315  * It is needed because the stream can yust store byts but the size of
316  * fib -elements can be any number of bits. Because of that ther have to
317  * be a possibility to exchange the missing bits betwean the fib -elements.
318  *
319  * @see cFibElement::store
320  * @param stream the stream where this typeelement should be stored to
321  * @param cRestBits the not yet writen bits which should be stored
322  * @param uiRestBitPosition the number of bits in the cRestBits which
323  * should be writen respectively containing valid information
324  * @return true if the typeelement is stored, else false
325  */
326  virtual bool store( ostream & stream, char & cRestBits,
327  unsigned char & uiRestBitPosition ) const;
328 
329  /**
330  * This method restores a type from a bitstream, wher it is
331  * stored in the compressed fib -format.
332  *
333  * @see store
334  * @param iBitStream the stream where the type is stored in,
335  * because the stream is an cReadBits, any number of bits can be
336  * readed from it
337  * @return an integervalue with the errorvalue
338  * possible errorvalues are:
339  * - 0 loading successful
340  * - -1 loading error, invalid pXmlElement
341  * - -2 loading error, invalid data in pXmlElement
342  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
343  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
344  * object is wrong
345  */
346  virtual intFib restore( cReadBits & iBitStream );
347 
348  /**
349  * This function compares this property type with the given property type.
350  * Propertytype is lower, if it's number is lower than the number of the
351  * other Propertytype.
352  *
353  * @param typeProperty a pointer to the second propertytype to compare
354  * @return true if this propertytype is lower than that the given
355  * of typeProperty, else false
356  */
357  virtual bool operator<( const cTypeProperty & typeProperty ) const;
358 
359  /**
360  * This function compares two cTypeProperty.
361  * Propertytype is lower, if it's number is lower than the number of the
362  * other Propertytype.
363  *
364  * @param pTypeProperty1 a pointer to the first propertytype to compare
365  * @param pTypeProperty2 a pointer to the second propertytype to compare
366  * @return true if the propertytype pTypeProperty1 is lower than that
367  * of pTypeProperty2, else false
368  */
369  static bool lowerTypeProperty( const cTypeProperty & pTypeProperty1,
370  const cTypeProperty & pTypeProperty2 );
371 
372  /**
373  * This function compares two cTypeProperty.
374  * Propertytype is lower, if it's number is lower than the number of the
375  * other Propertytype.
376  *
377  * @param pTypeProperty1 a pointer to the first propertytype to compare
378  * @param pTypeProperty2 a pointer to the second propertytype to compare
379  * @return true if the propertytype pTypeProperty1 is lower than that
380  * of pTypeProperty2, else false
381  */
382  static bool lowerTypeProperty( const cTypeProperty * pTypeProperty1,
383  const cTypeProperty * pTypeProperty2 );
384 
385 
386 };//end class cTypeProperty
387 
388 
389 }//end namespace fib
390 
391 #endif //___C_TYPE_PROPERTY_H__