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
cExtSubobject.h
Go to the documentation of this file.
1 /**
2  * @class cExtSubobject
3  * file name: cExtSubobject.h
4  * @author Betti Oesterholz
5  * @date 06.11.2011
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This class represents the external subobject element.
11  * Copyright (C) @c LGPL3 2011 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 external subobject element.
28  * External subobject elements are for calling subobjects that are given a
29  * external object element (@see cExtObject).
30  *
31  */
32 /*
33 History:
34 06.11.2011 Oesterholz created
35 29.01.2011 Oesterholz FEATURE_EXT_SUBOBJECT_INPUT_VECTOR implemented:
36  the input values are now a vector of values
37 */
38 
39 #ifndef ___C_EXT_SUBOBJECT_H__
40 #define ___C_EXT_SUBOBJECT_H__
41 
42 
43 #include "version.h"
44 
45 #include "fibDatatyps.h"
46 
47 #include "cFibLeaf.h"
48 #include "cRoot.h"
49 #include "cFibVariable.h"
50 
51 
52 #ifdef FEATURE_EXT_SUBOBJECT_INPUT_VECTOR
53  #include "cVectorExtSubobject.h"
54 #endif //FEATURE_EXT_SUBOBJECT_INPUT_VECTOR
55 
56 
57 namespace fib{
58 
59 
60 #ifdef FEATURE_EXT_SUBOBJECT_INPUT_VECTOR
61 
62 class cExtSubobject: public cFibLeaf{
63 
64 #else //FEATURE_EXT_SUBOBJECT_INPUT_VECTOR
65 
66 class cExtSubobject: public cFibLeaf, public iVariableUser{
67 
68 #endif //FEATURE_EXT_SUBOBJECT_INPUT_VECTOR
69 
70 friend class cFibElement;
71 
72 private:
73 
74  /**
75  * The number of the subobject to call.
76  * @see cRoot
77  * @see cExtObject
78  */
80 
81 #ifdef FEATURE_EXT_SUBOBJECT_INPUT_VECTOR
82  /**
83  * The vector with the output variables for the subobject to call.
84  */
86 #else //FEATURE_EXT_SUBOBJECT_INPUT_VECTOR
87  /**
88  * The vector with the output variables for the subobject to call.
89  */
90  vector< cFibVariable * > vecOutputValues;
91 #endif //FEATURE_EXT_SUBOBJECT_INPUT_VECTOR
92 
93 public:
94 
95 #ifdef FEATURE_EXT_SUBOBJECT_INPUT_VECTOR
96 
97  /**
98  * parameterconstructor
99  *
100  * @param uiInNumberOfSubobject the number of the subobject to call
101  * @param vecInOutputValues the vector with the output values
102  * of the subobject to call
103  * @param pInSuperiorElement the Fib element in which this
104  * external object element is an subobject
105  */
106  cExtSubobject( unsignedIntFib uiInNumberOfSubobject,
107  cVectorExtSubobject vecInOutputValues,
108  cFibElement * pInSuperiorElement = NULL );
109 
110  /**
111  * parameterconstructor
112  *
113  * @param uiInNumberOfSubobject the number of the subobject to call
114  * @param uiNumberOfOutputVariables the number of output variables
115  * of the subobject to call
116  * @param pInSuperiorElement the Fib element in which this
117  * external object element is an subobject
118  */
119  cExtSubobject( unsignedIntFib uiInNumberOfSubobject,
120  unsignedIntFib uiNumberOfOutputVariables=0,
121  cFibElement * pInSuperiorElement = NULL );
122 
123 #else //FEATURE_EXT_SUBOBJECT_INPUT_VECTOR
124 
125  /**
126  * parameterconstructor
127  *
128  * @param uiInNumberOfSubobject the number of the subobject to call
129  * @param vecInOutputVariables the vector with the output variables
130  * or the subobject to call
131  * @param pInSuperiorElement the Fib element in which this
132  * external object element is an subobject
133  */
134  cExtSubobject( unsignedIntFib uiInNumberOfSubobject,
135  vector< cFibVariable* > vecInOutputVariables=vector< cFibVariable* >(),
136  cFibElement * pInSuperiorElement = NULL );
137 
138 #endif //FEATURE_EXT_SUBOBJECT_INPUT_VECTOR
139 
140  /**
141  * copyconstructor
142  * This copyconstructor constructs a copy of the given external object element.
143  * It dosn't copy other Fib elements than the given.
144  *
145  * @param extObjectElement the external object element to copy
146  */
147  cExtSubobject( const cExtSubobject & extObjectElement );
148 
149 protected:
150 
151  /**
152  * The constructor for restoring a pointelement from an TinyXml element.
153  *
154  * @param pXmlNode a pointer to the TinyXml node the Fib object is stored in
155  * @param outStatus An reference to an integervalue where the errorvalue
156  * can be stored to.
157  * possible error values are:
158  * - 0 loading successful
159  * - -1 loading error, invalid pXmlElement
160  * - -2 loading error, invalid data in pXmlElement
161  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
162  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
163  * object is wrong
164  * @param liDefinedVariables a list with the defined variables for the
165  * to restore Fib element, every variable should have it's number
166  * (the number under which it is stored) as it's value
167  */
168  cExtSubobject( const TiXmlElement * pXmlElement, intFib &outStatus,
169  list<cFibVariable*> & liDefinedVariables );
170 
171  /**
172  * This constructor restores a pointelement from the stream where it is
173  * stored in the compressed Fib format.
174  * This method is for internal use only.
175  *
176  * @param iBitStream the stream where this pointelement is stored in,
177  * because this stream is an cReadBits, any number of bits can be
178  * readed from it
179  * @param outStatus An reference to an integervalue, where the errorvalue
180  * can be stored to. If the pointer is NULL no errorvalue will be
181  * given back.
182  * possible error values are:
183  * - 0 loading successful
184  * - -1 loading error, invalid stream
185  * - -2 loading error, invalid data in stream
186  * - 1 loading warning, invalid data in stream, error could be corrected
187  * - 2 loading warning, invalid data in stream, maybe the loaded
188  * object is wrong
189  * @param liDefinedVariables a list with the defined variables for the
190  * to restore Fib element, every variable should have it's number
191  * (the number under which it is stored) as it's value
192  * @param validDomains the domains valid for restoring the Fib elements
193  * @param pNextRoot the next higher root-element for the to restore
194  * Fib elements, or the last restored root-element
195  */
196  cExtSubobject( cReadBits & iBitStream, intFib & outStatus,
197  list<cFibVariable*> & liDefinedVariables, const cDomains & validDomains,
198  cRoot * pNextRoot );
199 
200 public:
201 
202  /**
203  * destructor
204  */
205  virtual ~cExtSubobject();
206 
207  /**
208  * This method checks, if this Fib element is an valid Fib element.
209  *
210  * @return true if this Fib element is an valid Fib element, else false
211  */
212  virtual bool isValidFibElement() const;
213 
214  /**
215  * @see getTypeName
216  * @return a character for the typ of the Fib element
217  * Types are:
218  * - u: element of unknown typ
219  * - p: point
220  * - l: list-element
221  * - y: property
222  * - c: comment
223  * - a: area
224  * - f: function
225  * - i: if-condition
226  * - o: extern object element
227  * - s: extern subobject element
228  * - v: set-element
229  * - m: matrix element
230  * - r: root-element
231  */
232  virtual char getType() const;
233 
234  /**
235  * This method evaluades the Fib object.
236  *
237  * @param evaluePosition a reference to the object with the
238  * evaluePosition() method to evalue /store the positions and ther
239  * properties; everytime a point (to evalue) is reached in the
240  * evaluation, this method is called with the position and the
241  * properties of the point; @see iEvaluePosition
242  * @param objectPoint the object point in the order of true partobjects
243  * to evalue
244  * @param liVecProperties a list with the property vectors which should
245  * be global for the evalued object
246  * @return if the evalueation was successfull true, else false
247  */
248  virtual bool evalueObject( iEvaluePosition & evaluePosition,
249  const unsignedIntFib objectPoint,
250  list<cVectorProperty> & liVecProperties ) const;
251 
252  /**
253  * This method evaluades the Fib object.
254  * Evertime a Fib elements, with a type of the given type chars in
255  * liCFibElementTyps, is reached while evaluation, it is given
256  * back with the properties which it has.
257  * Ever point element is given back. The type chars for point elements
258  * don't need to be in the list liCFibElementTyps.
259  *
260  * @param evalueFibElement a reference to the object with the
261  * evalueElement() method to evalue /store the Fib elements and ther
262  * properties; everytime a Fib element (with one of the type given
263  * in liCFibElementTyps) is reached in the evaluation, the method
264  * evalueElement() of this objects is called with the Fib element
265  * and the properties of the Fib element; @see iEvalueFibElement
266  * @param objectPoint the object point in the order of true partobjects
267  * to evalue
268  * @param liVecProperties a list with the property vectors which should
269  * be global for the evalued object
270  * @param liCFibElementTyps a list with the type chars (@see getType)
271  * of the Fib elements to return
272  * @return if the evalueation was successfull true, else false
273  */
274  virtual bool evalueObject( iEvalueFibElement & evalueFibElement,
275  const unsignedIntFib objectPoint,
276  list<cVectorProperty> & liVecProperties,
277  const list<char> & liCFibElementTyps );
278 
279  /**
280  * This method evaluades a value for the time needed to evalue the
281  * object.
282  * This value should not exceed lMaxTime, if the value for the time
283  * is greater than lMaxTime the evaluation will be stopt and lMaxTime
284  * returned. If lMaxTime is 0 (for infinity) the evaluation won't be
285  * stoped, this is the standard case.
286  *
287  * @see evalueObject()
288  * @param lMaxTime the maximum time for the evaluation, the returned
289  * exceed this value; the value 0 stands for infinity, so the
290  * evaluation won't be stoped
291  * @return a value for the time needed to evalue the object
292  */
293  virtual unsignedLongFib getTimeNeed( unsignedLongFib lMaxTime=0 ) const;
294 
295  /**
296  * This method evaluades the size of the Fib object in bits in the
297  * compressed file form.
298  *
299  * @see store()
300  * @return the size of the Fib object in bits in the compressed form
301  */
302  virtual unsignedLongFib getCompressedSize() const;
303 
304  /**
305  * This method checks if the given variable is used in the given
306  * direction from this Fib element.
307  *
308  * @see cFibVariable
309  * @see isDefinedVariable()
310  * @param pVariable the variable to check if it is used
311  * @param direction the direction from this Fib element, in which the
312  * variable should be used; standardvalue is ED_POSITION so yust
313  * this Fib element will be checked
314  * @return true if the variable is used, else false
315  */
316  virtual bool isUsedVariable( const cFibVariable * pVariable ,
317  edDirection direction=ED_POSITION ) const;
318 
319  /**
320  * This method returns all variables used in the given direction from
321  * this Fib element.
322  *
323  * @see cFibVariable
324  * @see isUsedVariable()
325  * @see isDefinedVariable()
326  * @param direction the direction from this Fib element, in which the
327  * variable should be used; standardvalue is ED_POSITION so yust
328  * this Fib element will be checked
329  * @return the set with all variables used in the given direction from
330  * this Fib element
331  */
332  virtual set<cFibVariable*> getUsedVariables( edDirection direction=ED_POSITION );
333 
334  /**
335  * This method replace the variable variableOld with the variable
336  * variableNew in the object.
337  *
338  * @see cFibVariable
339  * @see isUsedVariable()
340  * @see isDefinedVariable()
341  * @param pVariableOld the variable to replace
342  * @param pVariableNew the variable with which the variable variableOld
343  * is to replace
344  * @return true if the variable variableOld is replaced with variableNew,
345  * else false
346  */
347  virtual bool replaceVariable( cFibVariable * pVariableOld,
348  cFibVariable * pVariableNew );
349 
350  /**
351  * This method copies the Fib element on the specified position.
352  * Variables which are not defined in the Fib element but used
353  * don't change ther reference.
354  *
355  * @see getType()
356  * @param cType the type of the Fib element to copy
357  * @param elementPoint the number of the Fib element, in the order of
358  * Fib elements of the given type cType, to copy
359  * @param bAbsolute if the lNumber is an absolute value for the wool
360  * Fib object
361  * @return the copy of the Fib element
362  */
363  virtual cFibElement * copyElement( const char cType='u', const unsignedIntFib
364  elementPoint=0, bool bAbsolute=false ) const;
365 
366  /**
367  * This method stores this Fib object in the XML -format into the
368  * given stream.
369  *
370  * @param stream the stream where this Fib object should be stored to
371  * @return true if this Fib object is stored, else false
372  */
373  virtual bool storeXml( ostream &stream ) const;
374 
375 
376 
377 /*
378  * external subobject element methods
379  */
380 
381  /**
382  * @return the number of the subobject to call @see uiNumberOfSubobject
383  */
385 
386  /**
387  * This method sets the number of the subobject to call
388  * (@see uiNumberOfSubobject).
389  *
390  * @param iInSubobjectNumber the number of the subobject to set
391  * @return if the subobject number was set true, else false
392  */
393  bool setNumberSubobject( const unsignedIntFib iInSubobjectNumber );
394 
395 #ifdef FEATURE_EXT_SUBOBJECT_INPUT_VECTOR
396 
397  /**
398  * @return the vector with the output values of this external subobject
399  * element
400  * @see vecOutputValues
401  */
402  cVectorExtSubobject * getOutputVector();
403 
404  /**
405  * @return the vector with the output values of this external subobject
406  * element
407  * @see vecOutputValues
408  */
409  const cVectorExtSubobject * getOutputVector() const;
410 
411 #else //FEATURE_EXT_SUBOBJECT_INPUT_VECTOR
412  /**
413  * @return the number of output variables of this object respectively
414  * the input variables for the external subobject to call
415  * @see vecOutputValues
416  */
418 
419  /**
420  * @return the vector with the output variables of this object
421  * respectively the input variables for the external subobject to
422  * call @see vecOutputValues
423  */
424  vector< cFibVariable * > getOutputVariables();
425 
426  /**
427  * This method sets the vector with the output variables of this object
428  * respectively the input variables for the external subobject to
429  * call (@see vecOutputValues).
430  *
431  * @param vecOutputValues the vector with the output variables of
432  * this object respectively the input variables for the external
433  * subobject to call (@see vecOutputValues)
434  * @return if the vector with the output variables was set true, else false
435  */
436  bool setOutputVariables( vector< cFibVariable * > vecOutputValues );
437 
438  /**
439  * This method returns the uiVariableNumber'th output variable of the
440  * vector with the output variables of this object respectively the
441  * input variables for the external subobject to call
442  * @see vecOutputValues or NULL if non exists.
443  *
444  * @param uiVariableNumber the number of the output variable to set
445  * @return the uiVariableNumber'th output variable of the vector with
446  * the output variables of this object respectively the input
447  * variables for the external subobject to call
448  * @see vecOutputValues or NULL if non exists
449  */
450  cFibVariable * getOutputVariable( const unsignedIntFib uiVariableNumber );
451 
452  /**
453  * This method sets the uiVariableNumber'th output variable of the
454  * vector with the output variables of this object respectively the
455  * input variables for the external subobject to call
456  * @see vecOutputValues.
457  * It will create a new variable if ther are one less than
458  * uiVariableNumber output variables.
459  *
460  * @param uiVariableNumber the number of the output variable to set
461  * @param pOutputVariable the uiVariableNumber'th output variable of
462  * the vector with the output variables @see vecOutputValues to set
463  * @return true if the uiVariableNumber'th output variables was set
464  * else false
465  */
466  bool setOutputVariable( const unsignedIntFib uiVariableNumber,
467  cFibVariable * pOutputVariable );
468 
469 #endif //FEATURE_EXT_SUBOBJECT_INPUT_VECTOR
470 
471 
472 protected:
473 
474  /**
475  * This method stores this Fib object in the compressed Fib format
476  * into the given stream.
477  * It is needed because the stream can yust store byts but the size of
478  * Fib elements can be any number of bits. Because of that ther have to
479  * be a possibility to exchange the missing bits betwean the Fib elements.
480  *
481  * @see store
482  * @param stream the stream where this Fib object should be stored to
483  * @param cRestBits the not yet writen bits which should be stored
484  * @param uiRestBitPosition the number of bits in the cRestBits which
485  * should be writen respectively containing valid information
486  * @return true if this Fib object is stored, else false
487  */
488  virtual bool storeBit( ostream & stream, char & cRestBits,
489  unsigned char & uiRestBitPosition ) const;
490 
491  /**
492  * This method copies the connected object with the given number in the
493  * order of connected objects.
494  * For this every Fib element, beginning from this Fib element, that
495  * is part of the connected object, will be copied.
496  * Variables which are not defined in the connected object but used
497  * don't change ther reference.
498  * It is an help method for the copy method. It dosn't update the
499  * structural information of the created Fib object.
500  *
501  * @see copy()
502  * @param iObjectPoint the number of the connected object to copy;
503  * the standart value is 0 for coping the complet actual object
504  * @return the copy of the connected object or NULL if non such exists
505  */
506  virtual cFibElement *copyInternal( const unsignedIntFib iObjectPoint=0 ) const;
507 
508  /**
509  * This method checks if the given Fib object is equal to this Fib
510  * object.
511  * Variables can be others, but must be defined and used in equivalent
512  * Fib elements.
513  *
514  * @param fibObject the Fib object to which this Fib object should be
515  * equal
516  * @param mapEqualRootObjects the root objects of this object that wher
517  * already checked as equal
518  * map entries:
519  * key: the root-element of this Fib object that was checked
520  * value: the to the key correspondending root-element of the
521  * fibObject that was checked and which is equal to the key
522  * root-element
523  * (it is empty if bCheckExternalObjects == false)
524  * @param mapEqualDefinedVariables the Fib elements that defines
525  * variables and are equal;
526  * map entries:
527  * key: the Fib element of this Fib object that was checked
528  * value: the to the key correspondending Fib element of the
529  * fibObject that was checked and which sets its defined
530  * variables to the same values as the key Fib element
531  * @param bCheckExternalObjects if true the external objects of
532  * @see cExtObject will be compared
533  * @return true if this Fib object is equal to the given Fib object,
534  * else false
535  */
536  virtual bool equalInternal( const cFibElement & fibObject,
537  map< const cRoot *, const cRoot * > & mapEqualRootObjects,
538  map< const cFibElement *, const cFibElement * > & mapEqualDefinedVariables,
539  const bool bCheckExternalObjects ) const;
540 
541  /**
542  * This method checks if the given Fib element is equal to this fib
543  * -element.
544  * The subobjects arn't compared, not even ther count is compared.
545  * Used variables can be others.
546  *
547  * @param fibElement the Fib element to which this Fib element should be
548  * equal
549  * @param mapEqualRootObjects the root objects of this object that wher
550  * already checked as equal
551  * map entries:
552  * key: the root-element of this Fib object that was checked
553  * value: the to the key correspondending root-element of the
554  * fibObject that was checked and which is equal to the key
555  * root-element
556  * (it is empty if bCheckExternalObjects == false)
557  * @param mapEqualDefinedVariables the Fib elements that defines
558  * variables and are equal;
559  * map entries:
560  * key: the Fib element of this Fib object that was checked
561  * value: the to the key correspondending Fib element of the
562  * fibObject that was checked and which sets its defined
563  * variables to the same values as the key Fib element
564  * @param bCheckExternalObjects if true the external objects of
565  * cExtObject will be compared
566  * @return true if this Fib element is equal to the given Fib object,
567  * else false
568  */
569  virtual bool equalElementInternal( const cFibElement & fibElement,
570  map< const cRoot *, const cRoot * > & mapEqualRootObjects,
571  map< const cFibElement *, const cFibElement * > & mapEqualDefinedVariables,
572  const bool bCheckExternalObjects ) const;
573 
574 #ifndef FEATURE_EXT_SUBOBJECT_INPUT_VECTOR
575 
576  /**
577  * @return the Fib element which uses the variables of this element
578  */
579  virtual cFibElement * getVariableUsingFibElement() const;
580 
581  /**
582  * This method deletes all occurencies of the given variable from this
583  * element. So the variable is not used anymore by this element.
584  * Beware: This element has to be unregistered (call
585  * unregisterUsingElement() ) at the pVariable seperatly. Do this directly
586  * befor or after calling this method.
587  *
588  * @param pVariable the variable which is to delete from this element
589  * @return true if the variable dosn't occure anymore in this element,
590  * else false
591  */
592  virtual bool deleteVariable( cFibVariable * pVariable );
593 
594 #endif //FEATURE_EXT_SUBOBJECT_INPUT_VECTOR
595 
596 };
597 }//namespace fib
598 
599 #endif //___C_EXT_SUBOBJECT_H__
600 
601 
602 
603 
604 
605