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
cEvaluePositionList.h
Go to the documentation of this file.
1 /**
2  * @class cEvaluePositionList
3  * file name: cEvaluePositionList.h
4  * @author Betti Oesterholz
5  * @date 18.04.2010
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This file contains the class for evaluing fib -objects and storing
11  * the evalued data into a list.
12  * Copyright (C) @c LGPL3 2010 Betti Oesterholz
13  *
14  * This program is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU Lesser General Public License (LGPL) as
16  * published by the Free Software Foundation, either version 3 of the
17  * License, or any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public License
25  * along with this program. If not, see <http://www.gnu.org/licenses/>.
26  *
27  *
28  * This file contains the class for evaluing fib -objects and storing
29  * the evalued data into a list (@see liEvaluedPositionData).
30  * When the fib -object is evalued this method is called every time a
31  * pointelement is reached. The parameter for the method are the
32  * positionsvector of the point and properties of the point.
33  */
34 /*
35 History:
36 18.04.2010 Oesterholz created
37 05.07.2010 Oesterholz distanceOfProperties() moved from
38  cFibObjectFitnessBasicAlgorithm to hear
39 19.10.2010 Oesterholz toFibObject() added
40 */
41 
42 #ifndef ___C_EVALUE_POSITION_LIST__
43 #define ___C_EVALUE_POSITION_LIST__
44 
45 #include "version.h"
46 
47 #include "iEvaluePosition.h"
48 
49 #include "cVectorPosition.h"
50 #include "cVectorProperty.h"
51 
52 
53 #include <list>
54 
55 
56 using std::list;
57 
58 namespace fib{
59 
61 public:
62 
63  /**
64  * The list for the evalued fib -object data.
65  *
66  * The first pairelement is the position and the second are the
67  * properties for the position.
68  */
69  list< pair< cVectorPosition, list< cVectorProperty > > >
71 
72 #ifdef TEST
73  /**
74  * The number of times the evalueElement() is called.
75  * This is for test purposes only.
76  */
77  unsigned long ulCountOfEvalueMethodCalled;
78 
79  /**
80  * The number of times the evalueElement() gives back true.
81  * This is for test purposes only.
82  */
83  long long lNumberOfTrueEvalueCalls;
84 #endif
85 
86  /**
87  * standardconstructor
88  */
90 
91  /**
92  * The method with wich the evalued points with ther properties are
93  * inserted. Everytime a point (to evalue) is reached in the
94  * evaluation, this method is called with the position and the
95  * properties of the point and stores the copies of this data
96  * to the end of the list @see liEvaluedPositionData .
97  *
98  * @see liEvaluedPositionData
99  * @param vPosition the position of the point, which is evalued
100  * @param vProperties a list of the properties of the point
101  */
102  virtual bool evaluePosition( const cVectorPosition & vPosition,
103  const list<cVectorProperty> & vProperties );
104 
105  /**
106  * This method clears the data from the list with the evalued position data
107  * liEvaluedPositionData.
108  * After the function call the liEvaluedPositionData list will be empty.
109  *
110  * @see liEvaluedPositionData
111  */
112  void clear();
113 
114  /**
115  * This function sorts the list liEvaluedPositionData of
116  * positions with ther values.
117  * It also sorts the property sublists.
118  * A vector is lower if it has less elements than the other vector or
119  * it's i'th element is lower und all j'th elements with i > j are
120  * equal.
121  * The positions with ther properties are sorted in the order as the
122  * positionsvectors.
123  * Propertyvectors with lower propertypvalues are sorted befor
124  * propertyvectors with higer propertypvalues, independent of ther
125  * elements.
126  * Also equal/duplicate positions will be removed, ther properties will be
127  * merged. Properties of a later positions in the given list will
128  * overwrite properties earlier in the list, if neccessary.
129  * Positions without porperties will be removed.
130  *
131  * @see liEvaluedPositionData
132  * @param bDeleteEmptyPoints if true points without properties will be
133  * deleted, else (if false) points without properties won't be deleted
134  */
135  void sortPositionsData( bool bDeleteEmptyPoints=true );
136 
137  /**
138  * This function sorts the given list of positions with ther values.
139  * It also sorts the property sublists.
140  * A vector is lower if it has less elements than the other vector or
141  * it's i'th element is lower und all j'th elements with i > j are
142  * equal.
143  * The positions with ther properties are sorted in the order as the
144  * positionsvectors.
145  * Propertyvectors with lower propertypvalues are sorted befor
146  * propertyvectors with higer propertypvalues, independent of ther
147  * elements.
148  * Also equal/duplicate positions will be removed, ther properties will be
149  * merged. Properties of a later positions in the given list will
150  * overwrite properties earlier in the list, if neccessary.
151  * Positions without porperties will be removed.
152  *
153  * @param liEvaluedPositionData a pointer to the positionsdata to sort
154  * @param bDeleteEmptyPoints if true points without properties will be
155  * deleted, else (if false) points without properties won't be deleted
156  */
157  static void sortPositionsData( list< pair< cVectorPosition,
158  list< cVectorProperty > > > * liEvaluedPositionData,
159  bool bDeleteEmptyPoints=true );
160 
161  /**
162  * This function compares two positions with ther properties.
163  * For that just the positionsvectors are compared.
164  * A (position)vector is lower if it has less elements than the other
165  * vector or it's i'th element is lower and all j'th elements with i > j
166  * are equal.
167  *
168  * @param paPosition1 the first pair of position with it's properties to compare
169  * @param paPosition2 the second pair of position with it's properties to compare
170  * @return true if the positionsvector of paPosition1 is lower than that
171  * of paPosition2, else false
172  */
173  static bool lowerPositionPair(
174  const pair< cVectorPosition, list< cVectorProperty > > & paPosition1,
175  const pair< cVectorPosition, list< cVectorProperty > > & paPosition2 );
176 
177  /**
178  * This function mergs the two given propertylists.
179  * All Properties of the second list liProperties2 that,
180  * aren't overwritten by properties in the first propertylist,
181  * liProperties1 are added to it.
182  *
183  * @param liProperties1 the propertielist to add to
184  * @param liProperties2 the list with the properties to be added
185  * @return a lis with the properties from the list liProperties1 and
186  * the properties from the list liProperties2 which arn't overwirtten
187  * by properties from list liProperties1
188  */
189  static list< cVectorProperty > mergeProperties(
190  const list< cVectorProperty > & liProperties1,
191  const list< cVectorProperty > & liProperties2 );
192 
193  /**
194  * This function evalues the difference betwean the two propertielists.
195  * Both propertylist have to be sorted in the order of lowerPropertyVector().
196  *
197  * @see cVectorProperty::lowerPropertyVector()
198  * @see cVectorProperty::distanceOfProperty()
199  * @see cVectorProperty::distanceOfPropertyToNull()
200  * @param liPropertiesOriginal the positions with ther properties of the
201  * original fib -object
202  * @param liPropertiesGiven the positions with ther properties of the
203  * given fib -object, for which the distance to the original fib -object
204  * (liPropertiesOriginal) should be evalued
205  * @return the sum of the distance of the properties of the points
206  * (for missing properties, ther value to the nullvector will be added)
207  */
208  static doubleFib distanceOfProperties( const list< cVectorProperty > & liPropertiesOriginal,
209  const list< cVectorProperty > & liPropertiesGiven );
210 
211  /**
212  * This function creats a fib -object, which represents the given data.
213  * Beware: You have to care, that the created fib -object is deleted.
214  *
215  * @param vecPosition the position for the to create point
216  * @param liProperties the properties of the create point
217  * @return a fib -object with a point on the given position, wich is
218  * an underobject of propertyelements, with the given properties
219  */
220  static cFibElement * toFibObject( const cVectorPosition & vecPosition,
221  const list< cVectorProperty > & liProperties );
222 
223 
224  /**
225  * This function prints the given list of positions with ther values.
226  * It also prints the property sublists.
227  *
228  * @param liEvaluedPositionData a reference to the positionsdata to print
229  * @param strOutput the stream wher to print the data to
230  */
231  static void printPositionsData( const list< pair< cVectorPosition,
232  list< cVectorProperty > > > & liEvaluedPositionData,
233  ostream & strOutput );
234 
235 };//class cEvaluePositionList
236 
237 };
238 
239 #endif
240 
241