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