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
cConditionNot.h
Go to the documentation of this file.
1 /**
2  * @class cConditionNot
3  * file name: cConditionNot.h
4  * @author Betti Oesterholz
5  * @date 09.05.2011
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This class represents a not condition.
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 a not condition.
28  * This condition is allways the opposite of the contained condition.
29  *
30  */
31 /*
32 History:
33 09.05.2011 Oesterholz created
34 19.10.2011 Oesterholz FEATURE_EQUAL_FIB_OBJECT implemented
35 */
36 
37 #ifndef ___C_CONDITION_NOT_H__
38 #define ___C_CONDITION_NOT_H__
39 
40 
41 #include "version.h"
42 #include "fibDatatyps.h"
43 #include "cReadBits.h"
44 
45 #include "cCondition.h"
46 
47 
48 using std::set;
49 
50 namespace fib{
51 
52 
53 class cConditionNot: public cCondition{
54 protected:
55  /**
56  * The condition this condition contains.
57  */
59 
60 public:
61 
62 
63  /**
64  * The constructor of the true condition.
65  *
66  * @param pInSubCondition a pointer to the condition, this condition
67  * contains; Beware: It (pSubCondition) won't be copied.
68  * @see pSubCondition
69  * @param pInSuperiorCondition the condition which contains the
70  * new condition
71  * @param pInDefiningFibElement the Fib-element which defines/ uses
72  * the new condition
73  */
74  cConditionNot( cCondition * pInSubCondition,
75  cCondition * pInSuperiorCondition = NULL,
76  cFibElement * pInDefiningFibElement = NULL );
77 
78  /**
79  * The constructor of the true condition.
80  *
81  * @param inSubCondition the condition, this condition contains
82  * @see pSubCondition
83  * @param pInSuperiorCondition the condition which contains the
84  * new condition
85  * @param pInDefiningFibElement the Fib-element which defines/ uses
86  * the new condition
87  */
88  cConditionNot( const cCondition & pInSubCondition,
89  cCondition * pInSuperiorCondition = NULL,
90  cFibElement * pInDefiningFibElement = NULL );
91 
92  /**
93  * The copy constructor of the condition.
94  * This constructor will also copy the subconditions of the given
95  * condition.
96  *
97  * @param condition the condition which to copy
98  * @param pInSuperiorCondition the condition which contains the
99  * new condition
100  * @param pInDefiningFibElement the Fib-element which defines/ uses
101  * the new condition
102  */
103  cConditionNot( const cConditionNot & condition,
104  cCondition * pInSuperiorCondition = NULL,
105  cFibElement *pInDefiningFibElement = NULL );
106 
107 
108  /**
109  * The destructor of the condition.
110  */
111  virtual ~cConditionNot();
112 
113  /**
114  * This method returns if this condition is valid, else false.
115  * All subcondition and underfunctions must be valid.
116  * No condition should contain itself or should be contained in one
117  * of its condition (no cycles allowed).
118  *
119  * @return true if this condition is valid, else false
120  */
121  virtual bool isValid() const;
122 
123  /**
124  * This method checks if the given variable is used in this condition.
125  *
126  * @see cFibVariable
127  * @param variable the variable to check if it is used
128  * @return true if the variable is used, else false
129  */
130  virtual bool isUsedVariable( const cFibVariable * variable ) const;
131 
132  /**
133  * This method returns all variables used in this condition.
134  *
135  * @see cFibVariable
136  * @return all variables used in this condition
137  */
138  virtual set<cFibVariable*> getUsedVariables();
139 
140  /**
141  * This method replace the variable variableOld with the variable
142  * variableNew in the condition.
143  *
144  * @see cFibVariable
145  * @see isVariable()
146  * @see isUsedVariable()
147  * @param variableOld the variable to replace
148  * @param variableNew the variable with which the variable variableOld
149  * is to replace
150  * @return true if the variable variableOld is replaced with variableNew,
151  * else false
152  */
153  virtual bool replaceVariable( cFibVariable * variableOld,
154  cFibVariable * variableNew );
155 
156  /**
157  * Returns the value true of the condition.
158  *
159  * @return true
160  */
161  virtual bool getValue() const;
162 
163  /**
164  * @return the number of conditions, a condition of this type has
165  */
166  virtual unsignedIntFib getNumberOfConditions() const;
167 
168  /**
169  * @return the number of underfunctions, a condition of this type has
170  */
172 
173  /**
174  * Sets the Fib-element which defines/ uses this condition.
175  * If the given pointer is the nullpointer (standardvalue), no
176  * Fib-element defines this condition.
177  *
178  * @param pDefiningFibElement a pointer to the Fib-element which
179  * defines/ uses this condition
180  * @param bCheckDomains get the domains of the defining element and
181  * check the underfunctionelements with it
182  */
184  bool bCheckDomains=true );
185 
186  /**
187  * This method evaluades a value for the time needed to evalue the
188  * condition.
189  * This value should not exceed lMaxTime, if the value for the time
190  * is greater than lMaxTime the evaluation will be stopt and lMaxTime
191  * returned. If lMaxTime is 0 (for infinity) the evaluation won't be
192  * stoped, this is the standard case.
193  *
194  * @see cFibElement::evalueObject()
195  * @param lMaxTime the maximum time for the evaluation, the returned
196  * exceed this value; the value 0 stands for infinity, so the
197  * evaluation won't be stoped
198  * @return a value for the time needed to evalue this condition
199  */
200  virtual unsignedLongFib getTimeNeed( unsignedLongFib lMaxTime=0 ) const;
201 
202  /**
203  * This method evaluades the size of the Fib-object in bits in the
204  * compressed file form.
205  * The optionalpart field of point -elements will be ignored.
206  *
207  * @see store()
208  * @return the size of the Fib-object in bits in the compressed form
209  */
210  virtual unsignedLongFib getCompressedSize() const;
211 
212  /**
213  * This method stores this Fib-object in the compressed Fib-format
214  * into the given stream.
215  * It is needed becouse the stream can yust store byts but the size of
216  * Fib-elements can be any number of bits. Because of that ther have to
217  * be a possibility to exchange the missing bits betwean the Fib-elements.
218  *
219  * @see store
220  * @param stream the stream where this Fib-object should be stored to
221  * @param cRestBits the not yet writen bits which should be stored
222  * @param uiRestBitPosition the number of bits in the cRestBits which
223  * should be writen respectively containing valid information
224  * @return true if this Fib-object is stored, else false
225  */
226  virtual bool store( ostream & stream, char & cRestBits,
227  unsigned char & uiRestBitPosition ) const;
228 
229  /**
230  * This method stores this condition in the XML-format into the
231  * given stream.
232  * Variables should have ther number as ther value.
233  *
234  * @param stream the stream where this conditionshould be
235  * stored to
236  * @return true if this condition is stored, else false
237  */
238  virtual bool storeXml( ostream & stream ) const;
239 
240  /**
241  * @return the type for the condition
242  */
243  virtual unsignedIntFib getType() const;
244 
245  /**
246  * @return the name for the condition
247  */
248  virtual string getConditionName() const;
249 
250 #ifndef FEATURE_EQUAL_FIB_OBJECT
251 
252  /**
253  * This Method checks if the given condition is equal to this condition.
254  *
255  * @param condition the condition to compare with this condition
256  * @return true if the given condition is equal to this condition, else false
257  */
258  virtual bool equal( const cCondition & condition ) const;
259 
260 #endif //FEATURE_EQUAL_FIB_OBJECT
261 
262  /**
263  * This method duplicates this whole condition.
264  * subcondition of this condition are also cloned.
265  *
266  * @param pSuperiorCondition the condition which contains the cloned
267  * condition
268  * @param pInDefiningFibElement the Fib-element which defines/ uses
269  * the cloned condition
270  * @return the cloned/ duplicated condition
271  */
272  virtual cConditionNot * clone(
273  cCondition * pInSuperiorCondition = NULL,
274  cFibElement *pInDefiningFibElement = NULL) const;
275 
276  /**
277  * @see pSubCondition
278  * @see setSubCondition()
279  * @return a pointer to the condition this condition contains (@see pSubCondition)
280  */
282 
283  /**
284  * @see pSubCondition
285  * @see setSubCondition()
286  * @return a pointer to the condition this condition contains (@see pSubCondition)
287  */
288  const cCondition * getSubCondition() const;
289 
290  /**
291  * This method sets the contained condition (@see pSubCondition) to the
292  * given condition pInSubCondition.
293  * Beware: It (pInSubCondition) won't be copied.
294  *
295  * @see pSubCondition
296  * @see getSubCondition()
297  * @param pInSubCondition a pointer to the subcondition to set
298  * @param bDeleteOld if true, delete the old subcondition from the memory
299  * @return true if pInSubCondition condition was set, else false
300  */
301  bool setSubCondition( cCondition * pInSubCondition, bool bDeleteOld=true );
302 
303  /**
304  * This method sets the contained condition (@see pSubCondition) to the
305  * given condition pInSubCondition.
306  *
307  * @see pSubCondition
308  * @see getSubCondition()
309  * @param pInSubCondition the subcondition to set
310  * @param bDeleteOld if true, delete the old subcondition from the memory
311  * @return true if pInSubCondition condition was set, else false
312  */
313  bool setSubCondition( const cCondition & pInSubCondition, bool bDeleteOld=true );
314 
315 protected:
316 
317 #ifdef FEATURE_EQUAL_FIB_OBJECT
318 
319  /**
320  * This method checks if the given Fib-object is equal to this fib
321  * -object.
322  * Variables can be others, but must be defined and used in equivalent
323  * Fib-elements.
324  *
325  * @param condition the condition to which this condition should be
326  * equal
327  * @param mapEqualRootObjects the root objects of this object that wher
328  * already checked as equal
329  * map entries:
330  * key: the root-element of this Fib object that was checked
331  * value: the to the key correspondending root-element of the
332  * fibObject that was checked and which is equal to the key
333  * root-element
334  * (it is empty if bCheckExternalObjects == false)
335  * @param mapEqualDefinedVariables the Fib elements that defines
336  * variables and are equal;
337  * map entries:
338  * key: the Fib element of this Fib object that was checked
339  * value: the to the key correspondending Fib element of the
340  * fibObject that was checked and which sets its defined
341  * variables to the same values as the key Fib element
342  * @param bCheckExternalObjects if true the external objects of
343  * cExtObject will be compared
344  * @return true if this Fib-object is equal to the given Fib-object,
345  * else false
346  */
347  virtual bool equalInternal( const cCondition & condition,
348  map< const cRoot *, const cRoot * > & mapEqualRootObjects,
349  map< const cFibElement *, const cFibElement * > & mapEqualDefinedVariables,
350  const bool bCheckExternalObjects ) const;
351 
352 #endif //FEATURE_EQUAL_FIB_OBJECT
353 
354 };//end class cConditionNot
355 
356 
357 }//end namespace Fib
358 
359 #endif //___C_CONDITION_NOT_H__