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
cProperty.h
Go to the documentation of this file.
1 /**
2  * @class cProperty
3  * file name: cProperty.h
4  * @author Betti Oesterholz
5  * @date 26.11.2009
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This class represents the property -Fib -element.
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 class represents the propertyelement of the Fib -multimedialanguage.
28  * It represents a property for a fib -object.
29  *
30  */
31 /*
32 History:
33 08.12.2009 Oesterholz created
34 18.04.2010 Oesterholz evalueObject() methods changed: not a function but
35  an object is given to evalue the data
36 08.03.2011 Oesterholz method for const getProperty() added
37 19.10.2011 Oesterholz FEATURE_EQUAL_FIB_OBJECT implemented
38 */
39 
40 #ifndef ___C_PROPERTY_H__
41 #define ___C_PROPERTY_H__
42 
43 
44 #include "version.h"
45 
46 #include "fibDatatyps.h"
47 
48 #include "cFibLimb.h"
49 #include "cRoot.h"
50 #include "cVectorProperty.h"
51 
52 
53 namespace fib{
54 
55 
56 class cProperty: public cFibLimb{
57 
58 friend class cFibElement;
59 
60 private:
61 
62  /**
63  * The propertyvector of this property.
64  */
66 
67 
68 public:
69 
70 #ifdef FEATURE_SIMPLE_CONSTRUCTOR
71 
72  /**
73  * parameterconstructor
74  *
75  * @param inVectorProperty the propertyvector this property should have
76  * @param pInUnderobject the fib -Element which is the underobject of
77  * this fib -element (it also stands next in the order of fib -elements)
78  * @param pInSuperiorElement the fib -Element in which this
79  * property -element is an underobject
80  */
81  cProperty( const cVectorProperty & inVectorProperty,
82  cFibElement * pInUnderobject = NULL,
83  cFibElement * pInSuperiorElement = NULL );
84 
85 #else //FEATURE_SIMPLE_CONSTRUCTOR
86 
87  /**
88  * parameterconstructor
89  *
90  * @param inVectorProperty the propertyvector this property should have
91  * @param pInSuperiorElement the fib -Element in which this
92  * property -element is an underobject
93  * @param pInPreviousFibElement the fib -Element which stands in th order
94  * of Fib -elements befor this Fib -element
95  * @param pInUnderobject the fib -Element which is the underobject of
96  * this fib -element (it also stands next in the order of fib -elements)
97  */
98  cProperty( const cVectorProperty & inVectorProperty,
99  cFibElement * pInSuperiorElement = NULL,
100  cFibElement * pInPreviousFibElement = NULL,
101  cFibElement * pInUnderobject = NULL );
102 
103 #endif //FEATURE_SIMPLE_CONSTRUCTOR
104 
105 
106  /**
107  * copyconstructor
108  * This copyconstructor constructs a copy of the given property -Element.
109  * It dosn't copy other property -elements than the given, even if ther are
110  * in the property -element.
111  *
112  * @param propertyElement the property -element to copy
113  */
114  cProperty( const cProperty &propertyElement );
115 
116 protected:
117 
118  /**
119  * The constructor for restoring a propertyobject from an TinyXml element.
120  *
121  * @param pXmlNode a pointer to the TinyXml node wher the fib -object is stored in
122  * @param outStatus An reference to an integervalue where the errorvalue
123  * can be stored to.
124  * possible errorvalues are:
125  * - 0 loading successful
126  * - -1 loading error, invalid pXmlElement
127  * - -2 loading error, invalid data in pXmlElement
128  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
129  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
130  * object is wrong
131  * @param liDefinedVariables a list with the defined variables for the
132  * to restore fib -element, every variable should have it's number
133  * (the number under which it is stored) as it's value
134  */
135  cProperty( const TiXmlElement * pXmlElement, intFib &outStatus,
136  list<cFibVariable*> & liDefinedVariables );
137 
138  /**
139  * This constructor restores a propertyobject from the stream where it is
140  * stored in the compressed fib -format.
141  * This method is for internal use only.
142  *
143  * @param iBitStream the stream wher the propertyobject is stored to in,
144  * because this stream is an cReadBits, any number of bits can be
145  * readed from it
146  * @param outStatus An reference to an integervalue where the errorvalue
147  * can be stored to. If the pointer is NULL no errorvalue will be
148  * given back.
149  * possible errorvalues are:
150  * - 0 loading successful
151  * - -1 loading error, invalid stream
152  * - -2 loading error, invalid data in stream
153  * - 1 loading warning, invalid data in stream, error could be corrected
154  * - 2 loading warning, invalid data in stream, maybe the loaded
155  * object is wrong
156  * @param liDefinedVariables a list with the defined variables for the
157  * to restore fib -element, every variable should have it's number
158  * (the number under which it is stored) as it's value
159  * @param validDomains the domains valid for restoring the fib -elements
160  * @param pNextRoot the next higher root -element for the to restore
161  * fib -elements, or the last restored root -element
162  */
163  cProperty( cReadBits & iBitStream, intFib & outStatus,
164  list<cFibVariable*> & liDefinedVariables, const cDomains & validDomains,
165  cRoot * pNextRoot );
166 
167 
168 public:
169 
170  /**
171  * @see getTypeName
172  * @return a character for the typ of the Fib -element
173  * Types are:
174  * - u: element of unknown typ
175  * - p: point
176  * - l: list-element
177  * - y: property
178  * - c: comment
179  * - a: area
180  * - f: function
181  * - i: if-condition
182  * - o: extern object element
183  * - s: extern subobject element
184  * - v: set-element
185  * - m: matrix element
186  * - r: root-element
187  */
188  virtual char getType() const;
189 
190  /**
191  * This method evaluades the fib -object.
192  *
193  * @param evaluePosition a reference to the object with the
194  * evaluePosition() method to evalue /store the positions and ther
195  * properties; everytime a point (to evalue) is reached in the
196  * evaluation, this method is called with the position and the
197  * properties of the point; @see iEvaluePosition
198  * @param objectPoint the object point in the order of true partobjects
199  * to evalue
200  * @param liVecProperties a list with the property vectors which should
201  * be global for the evalued object
202  * @return if the evalueation was successfull true, else false
203  */
204  virtual bool evalueObject( iEvaluePosition & evaluePosition,
205  const unsignedIntFib objectPoint,
206  list<cVectorProperty> & liVecProperties ) const;
207 
208  /**
209  * This method evaluades the fib -object.
210  * Evertime a fib -elements, with a type of the given type chars in
211  * liCFibElementTyps, is reached while evaluation, it is given
212  * back with the properties which it has.
213  * Ever pointelement is given back. The type chars for pointelements
214  * don't need to be in the list liCFibElementTyps.
215  *
216  * @param evalueFibElement a reference to the object with the
217  * evalueElement() method to evalue /store the fib -elements and ther
218  * properties; everytime a fib -element (with one of the type given
219  * in liCFibElementTyps) is reached in the evaluation, the method
220  * evalueElement() of this objects is called with the fib -element
221  * and the properties of the fib -element; @see iEvalueFibElement
222  * @param objectPoint the object point in the order of true partobjects
223  * to evalue
224  * @param liVecProperties a list with the property vectors which should
225  * be global for the evalued object
226  * @param liCFibElementTyps a list with the type chars (@see getType)
227  * of the fib -elements to return
228  * @return if the evalueation was successfull true, else false
229  */
230  virtual bool evalueObject( iEvalueFibElement & evalueFibElement,
231  const unsignedIntFib objectPoint,
232  list<cVectorProperty> & liVecProperties,
233  const list<char> & liCFibElementTyps );
234 
235  /**
236  * This method evaluades a value for the time needed to evalue the
237  * object.
238  * This value should not exceed lMaxTime, if the value for the time
239  * is greater than lMaxTime the evaluation will be stopt and lMaxTime
240  * returned. If lMaxTime is 0 (for infinity) the evaluation won't be
241  * stoped, this is the standard case.
242  *
243  * @see evalueObject()
244  * @param lMaxTime the maximum time for the evaluation, the returned
245  * exceed this value; the value 0 stands for infinity, so the
246  * evaluation won't be stoped
247  * @return a value for the time needed to evalue the object
248  */
249  virtual unsignedLongFib getTimeNeed( unsignedLongFib lMaxTime=0 ) const;
250 
251  /**
252  * This method evaluades the size of the Fib -object in bits in the
253  * compressed file form.
254  * The optionalpart field of property -elements will be ignored.
255  *
256  * @see store()
257  * @return the size of the Fib -object in bits in the compressed form
258  */
259  virtual unsignedLongFib getCompressedSize() const;
260 
261  /**
262  * This method checks if the given variable is used in the given
263  * direction from this Fib -element.
264  *
265  * @see cFibVariable
266  * @see isDefinedVariable()
267  * @param variable the variable to check if it is used
268  * @param direction the direction from this Fib -element, in which the
269  * variable should be used; standardvalue is ED_POSITION so yust
270  * this Fib -element will be checked
271  * @return true if the variable is used, else false
272  */
273  virtual bool isUsedVariable( const cFibVariable *variable ,
274  edDirection direction=ED_POSITION ) const;
275 
276  /**
277  * This method returns all variables used in the given direction from
278  * this Fib -element.
279  *
280  * @see cFibVariable
281  * @see isUsedVariable()
282  * @see isDefinedVariable()
283  * @param direction the direction from this Fib -element, in which the
284  * variable should be used; standardvalue is ED_POSITION so yust
285  * this Fib -element will be checked
286  * @return the set with all variables used in the given direction from
287  * this Fib -element
288  */
289  virtual set<cFibVariable*> getUsedVariables( edDirection direction=ED_POSITION );
290 
291  /**
292  * This method replace the variable variableOld with the variable
293  * variableNew in the object.
294  *
295  * @see cFibVariable
296  * @see isUsedVariable()
297  * @see isDefinedVariable()
298  * @param variableOld the variable to replace
299  * @param variableNew the variable with which the variable variableOld
300  * is to replace
301  * @return true if the variable variableOld is replaced with variableNew,
302  * else false
303  */
304  virtual bool replaceVariable( cFibVariable *variableOld,
305  cFibVariable *variableNew );
306 
307 
308  /**
309  * This method copies the Fib -element on the specified position.
310  * Variables which are not defined in the Fib -element but used
311  * don't change ther reference.
312  *
313  * @see getType()
314  * @param cType the type of the Fib -element to copy
315  * @param elementPoint the number of the Fib -element, in the order of
316  * Fib -elements of the given type cType, to copy
317  * @param bAbsolute if the lNumber is an absolute value for the wool
318  * fib -object
319  * @return the copy of the fib -element
320  */
321  virtual cFibElement *copyElement( const char cType='u', const unsignedIntFib
322  elementPoint=0, bool bAbsolute=false ) const;
323 
324 #ifndef FEATURE_EQUAL_FIB_OBJECT
325 
326  /**
327  * This method checks if the given Fib -object is equal to this Fib
328  * -object.
329  * Variables can be others, but must be defined and used in equivalent
330  * Fib -elements.
331  *
332  * @param fibObject the Fib -object to which this Fib -object should be
333  * equal
334  * @return true if this Fib -object is equal to the given Fib -object,
335  * else false
336  */
337  virtual bool equal( const cFibElement & fibObject ) const;
338 
339  /**
340  * This method checks if the given fib -element is equal to this fib
341  * -element.
342  * The underobjects arn't compared, not even ther count is compared.
343  * Used variables can be others.
344  *
345  * @param fibElement the fib -element to which this fib -element should be
346  * equal
347  * @return true if this fib -element is equal to the given fib -object,
348  * else false
349  */
350  virtual bool equalElement( const cFibElement & fibElement ) const;
351 
352 #endif //FEATURE_EQUAL_FIB_OBJECT
353 
354  /**
355  * This method stores this Fib -object in the XML -format into the
356  * given stream.
357  *
358  * @param stream the stream where this Fib -object should be stored to
359  * @return true if this Fib -object is stored, else false
360  */
361  virtual bool storeXml( ostream &stream ) const;
362 
363 
364 
365 /*
366  * Property -element methods
367  */
368 
369 
370  /**
371  * @return a pointer to the propertyvector of this propertyelement
372  */
373  virtual cVectorProperty * getProperty();
374 
375  /**
376  * @return a pointer to the propertyvector of this propertyelement
377  */
378  virtual const cVectorProperty * getProperty() const;
379 
380 
381 protected:
382 
383  /**
384  * This method stores this Fib -object in the compressed Fib -format
385  * into the given stream.
386  * It is needed becouse the stream can yust store byts but the size of
387  * fib -elements can be any number of bits. Because of that ther have to
388  * be a possibility to exchange the missing bits betwean the fib -elements.
389  * Beware: You need to call storeBit() of the root -elements with the
390  * domain for the property or the property will not be readebel.
391  *
392  * @see store
393  * @param stream the stream where this Fib -object should be stored to
394  * @param cRestBits the not yet writen bits which should be stored
395  * @param uiRestBitPosition the number of bits in the cRestBits which
396  * should be writen respectively containing valid information
397  * @return true if this Fib -object is stored, else false
398  */
399  virtual bool storeBit( ostream & stream, char & cRestBits,
400  unsigned char & uiRestBitPosition ) const;
401 
402  /**
403  * This method copies the connected object with the given number in the
404  * order of connected objects.
405  * For this every Fib -element, beginning from this Fib -element, that
406  * is part of the connected object will be copied.
407  * Variables which are not defined in the connected object but used
408  * don't change ther reference.
409  * It is an helpmethod for the copy method. It dosn't update the
410  * structural information of the created fib -object.
411  *
412  * @param iObjectPoint the number of the connected object to copy;
413  * the standartvalue is 0 for coping the complet actual object
414  * @return the copy of the connected object or NULL if non such exists
415  */
416  virtual cFibElement *copyInternal( const unsignedIntFib iObjectPoint=0 ) const;
417 
418 #ifdef FEATURE_EQUAL_FIB_OBJECT
419 
420  /**
421  * This method checks if the given Fib-object is equal to this fib
422  * -object.
423  * Variables can be others, but must be defined and used in equivalent
424  * Fib-elements.
425  *
426  * @param fibObject the Fib-object to which this Fib-object should be
427  * equal
428  * @param mapEqualRootObjects the root objects of this object that wher
429  * already checked as equal
430  * map entries:
431  * key: the root-element of this Fib object that was checked
432  * value: the to the key correspondending root-element of the
433  * fibObject that was checked and which is equal to the key
434  * root-element
435  * (it is empty if bCheckExternalObjects == false)
436  * @param mapEqualDefinedVariables the Fib elements that defines
437  * variables and are equal;
438  * map entries:
439  * key: the Fib element of this Fib object that was checked
440  * value: the to the key correspondending Fib element of the
441  * fibObject that was checked and which sets its defined
442  * variables to the same values as the key Fib element
443  * @param bCheckExternalObjects if true the external objects of
444  * cExtObject will be compared
445  * @return true if this Fib-object is equal to the given Fib-object,
446  * else false
447  */
448  virtual bool equalInternal( const cFibElement & fibObject,
449  map< const cRoot *, const cRoot * > & mapEqualRootObjects,
450  map< const cFibElement *, const cFibElement * > & mapEqualDefinedVariables,
451  const bool bCheckExternalObjects ) const;
452 
453  /**
454  * This method checks if the given Fib-element is equal to this fib
455  * -element.
456  * The subobjects arn't compared, not even ther count is compared.
457  * Used variables can be others.
458  *
459  * @param fibElement the Fib-element to which this Fib-element should be
460  * equal
461  * @param mapEqualRootObjects the root objects of this object that wher
462  * already checked as equal
463  * map entries:
464  * key: the root-element of this Fib object that was checked
465  * value: the to the key correspondending root-element of the
466  * fibObject that was checked and which is equal to the key
467  * root-element
468  * (it is empty if bCheckExternalObjects == false)
469  * @param mapEqualDefinedVariables the Fib elements that defines
470  * variables and are equal;
471  * map entries:
472  * key: the Fib element of this Fib object that was checked
473  * value: the to the key correspondending Fib element of the
474  * fibObject that was checked and which sets its defined
475  * variables to the same values as the key Fib element
476  * @param bCheckExternalObjects if true the external objects of
477  * cExtObject will be compared
478  * @return true if this Fib-element is equal to the given Fib-object,
479  * else false
480  */
481  virtual bool equalElementInternal( const cFibElement & fibElement,
482  map< const cRoot *, const cRoot * > & mapEqualRootObjects,
483  map< const cFibElement *, const cFibElement * > & mapEqualDefinedVariables,
484  const bool bCheckExternalObjects ) const;
485 
486 #endif //FEATURE_EQUAL_FIB_OBJECT
487 
488 };
489 }//namespace fib
490 
491 #endif //___C_PROPERTY_H__
492 
493 
494 
495 
496 
497