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
cVectorProperty.h
Go to the documentation of this file.
1 /**
2  * @class cVectorProperty
3  * file name: cVectorProperty.h
4  * @author Betti Oesterholz
5  * @date 05.07.2009
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This class represents a property vector.
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 a property vector of the Fib -multimedialanguage.
28  * It is a vector for properties.
29  *
30  */
31 /*
32 History:
33 21.06.2009 Oesterholz created
34 05.07.2010 Oesterholz lowerPropertyVector() moved her from cEvaluePositionList
35  and operator<() added;
36  distanceOfProperty() and distanceOfPropertyToNull() moved from
37  cFibObjectFitnessBasicAlgorithm to hear and distanceToProperty() and
38  distanceOfPropertyToNull() added
39 17.12.2010 Oesterholz isOverwritenVector() method added
40 18.12.2010 Oesterholz isOverwriting() and isEvalued() methods added
41 */
42 
43 #ifndef ___C_VECTOR_PROPERTY_H__
44 #define ___C_VECTOR_PROPERTY_H__
45 
46 
47 #include "version.h"
48 #include "fibDatatyps.h"
49 
50 #include "cDomainVectorBasis.h"
51 #include "cTypeProperty.h"
52 
53 namespace fib{
54 
55 
57 
58 protected:
60 
61 public:
62 
63 //TODO ? change cFibElement to cProperty
64  /**
65  * The constructor of the propertyvector.
66  *
67  * @param uiPropertyType a number for the type of the property,
68  * this should be a type with a correct standard domain
69  * @param pDefiningPropertyElement the Fib -propertyelement which
70  * defines/ uses the propertyvector
71  */
73  cFibElement *pDefiningPropertyElement=NULL );
74 
75  /**
76  * The copy constructor of the vector.
77  *
78  * @param vector the vector from which to copy the data
79  * @param definingFibElement the Fib -element which defines/ uses
80  * the new vector
81  */
82  cVectorProperty( const cVectorProperty & vector,
84 
85  /**
86  * The constructor of the propertyvector.
87  *
88  * @param uiPropertyType a number for the type of the property
89  * @param iNumberOfElements number of elements in the vector
90  * @param pDefiningPropertyElement the Fib -propertyelement which
91  * defines/ uses the propertyvector
92  */
94  unsignedIntFib iNumberOfElements,
95  cFibElement *pDefiningPropertyElement=NULL );
96 
97  /**
98  * The constructor for restoring a vector from an TinyXml element.
99  *
100  * @param pXmlNode a pointer to the TinyXml node the vector is stored in
101  * @param outStatus An reference to an integervalue where the errorvalue
102  * can be stored to.
103  * possible errorvalues are:
104  * - 0 loading successful
105  * - -1 loading error, invalid pXmlElement
106  * - -2 loading error, invalid data in pXmlElement
107  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
108  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
109  * object is wrong
110  * @param liDefinedVariables a list with the defined variables for the
111  * to restore vector, every variable should have it's number
112  * (the number under which it is stored) as it's value
113  */
114  cVectorProperty( const TiXmlElement * pXmlElement, intFib &outStatus,
115  list<cFibVariable*> & liDefinedVariables );
116 
117  /**
118  * This constructor restores a propertyvector from the stream where it is
119  * stored in the compressed fib -format.
120  *
121  * @param iBitStream the stream where this vector is stored to in,
122  * because this stream is an cReadBits, any number of bits can be
123  * readed from it
124  * @param outStatus An reference to an integervalue where the errorvalue
125  * can be stored to. If the pointer is NULL no errorvalue will be
126  * given back.
127  * possible errorvalues are:
128  * - 0 loading successful
129  * - -1 loading error, invalid stream
130  * - -2 loading error, invalid data in stream
131  * - 1 loading warning, invalid data in stream, error could be corrected
132  * - 2 loading warning, invalid data in stream, maybe the loaded
133  * object is wrong
134  * @param liDefinedVariables a list with the defined variables for the
135  * to restore vector, every variable should have it's number
136  * (the number under which it is stored) as it's value
137  * @param pInVectorDomain the domain for this vector
138  * @param pInDomainVariable the domain for variables
139  * @param uiInPropertyType a number for the type of the property
140  */
141  cVectorProperty( cReadBits & iBitStream, intFib & outStatus,
142  list<cFibVariable*> & liDefinedVariables,
143  const cDomain * pInVectorDomain, const cDomain * pInDomainVariable,
144  unsignedIntFib uiInPropertyType );
145 
146 
147 
148  /**
149  * The constructor of the propertyvector.
150  *
151  * @param typeProperty the type this propertyvector should have
152  */
153  cVectorProperty( const cTypeProperty & typeProperty );
154 
155 
156 //TODO change cFibElement to cProperty
157  /**
158  * This method creates an instance of this vector type.
159  *
160  * @param iNumberOfElements number of elements in the vector
161  * @param definingPropertyElement the Fib -propertyelement which
162  * defines/ uses the propertyvector
163  */
165  unsignedIntFib iNumberOfElements=2,
166  cFibElement *definingPropertyElement=NULL ) const;
167 
168  /**
169  * Returns the type of the vector.
170  * You have to delete the returned object after usage.
171  *
172  * @return the type of the vector
173  */
174  virtual cTypeElement * getElementType() const;
175 
176  /**
177  * This method returns a number for the type of the property.
178  * @see cTypeProperty
179  *
180  * @return a number for the type of the property
181  */
182  virtual unsignedIntFib getPropertyType() const;
183 
184  /**
185  * This method checks if the given vector is overwritten by this vector.
186  *
187  * @param vectorToCheck the vector to check, if it is overwritten
188  * @return true if vectorToCheck is overwritten by this vector, else false
189  */
190  bool isOverwritenVector( const cVectorProperty & vectorToCheck ) const;
191 
192  /**
193  * This function checks if the this property vector overwrites property vectors.
194  *
195  * @return if the given vector overwrites vector true, else false
196  */
197  bool isOverwriting() const;
198 
199  /**
200  * @return this method returnes true, if the property of this vector is
201  * for evaluating a fib -object, else false is returned
202  */
203  bool isEvalued() const;
204 
205  /**
206  * @return the name for the type of the vector
207  */
208  virtual string getVectorType() const;
209 
210  /**
211  * This Method makes this vectorelements equal to the correspondending
212  * vectorelements of the given vector.
213  * The type of the vector won't be changed.
214  * The type of the propertie will be adapted.
215  *
216  * @param vector the vector to copy
217  */
218  virtual cVectorProperty & operator=( const cFibVector &vector );
219 
220  /**
221  * This function compares this propertyvector with the given propertyvector.
222  * Propertyvectors is lower if it's propertypvalues is lower than the
223  * propertyvectors of the other vector or its propertypvalues is equal, but
224  * if it has less elements than the other vector or it's i'th element is
225  * lower and all j'th elements with i > j are equal.
226  *
227  * @see cFibVector::lowerVector()
228  * @see lowerPropertyVector()
229  * @param vector the property to compare this with
230  * @return true if this propertyvectors is lower than the
231  * propertyvectors vector, else false
232  */
233  bool operator<( const cVectorProperty & vector ) const;
234 
235  /**
236  * This function compares two propertyvectors.
237  * Propertyvectors is lower if it's propertypvalues is lower than the
238  * propertyvectors of the other vector or its propertypvalues is equal, but
239  * if it has less elements than the other vector or it's i'th element is
240  * lower and all j'th elements with i > j are equal.
241  *
242  * @see cFibVector::lowerVector()
243  * @param vector1 the first property to compare
244  * @param vector2 the second property to compare
245  * @return true if the propertyvectors vector1 is lower than that
246  * of vector2, else false
247  */
248  static bool lowerPropertyVector( const cVectorProperty & vector1,
249  const cVectorProperty & vector2 );
250 
251  /**
252  * This function evalues the distance of this property to the given
253  * property of the same type.
254  * This distance is the sum of the differnece of the property
255  * vectorelements
256  *
257  * @param property the first propertyvector
258  * @return the sum of differneces betwean the vectorelements in this
259  * property and the given property
260  */
261  doubleFib distanceToProperty( const cVectorProperty & property ) const;
262 
263  /**
264  * This function evalues the distance of two properties of the same type.
265  * This distance is the sum of the differnece of the property
266  * vectorelements
267  *
268  * @param property1 the first propertyvector
269  * @param property2 the second propertyvector
270  * @return the sum of differneces betwean the vectorelements in property1
271  * and property2
272  */
273  static doubleFib distanceOfProperty( const cVectorProperty & property1,
274  const cVectorProperty & property2 );
275 
276  /**
277  * This function evalues the distance of the this property to a
278  * property of the same type, wher all vectorelements are 0.
279  * This distance is the sum of the differnece of the property
280  * vectorelements
281  *
282  * @param property the propertyvector
283  * @return the sum of differneces betwean the vectorelements in property
284  * and the nullvector of the same type with all vectorelements 0
285  */
287 
288  /**
289  * This function evalues the distance of the given property to a
290  * property of the same type, wher all vectorelements are 0.
291  * This distance is the sum of the differnece of the property
292  * vectorelements
293  *
294  * @param property the propertyvector
295  * @return the sum of differneces betwean the vectorelements in property
296  * and the nullvector of the same type with all vectorelements 0
297  */
298  static doubleFib distanceOfPropertyToNull( const cVectorProperty & property );
299 
300 
301 };//cVectorProperty
302 }//namespace fib
303 
304 #endif //___C_VECTOR_PROPERTY_H__
305 
306 
307 
308 
309 
310