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
cTypeDimension.h
Go to the documentation of this file.
1 /**
2  * @class cTypeDimension
3  * file name: cTypeDimension.h
4  * @author Betti Oesterholz
5  * @date 03.06.2009
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This class represents Fib -dimensionselementtyps.
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 file contains the basisclass of all Fib -dimensionselementtyps.
28  * Fib -dimensionselementtyps are typs of the elements in an Fib
29  * -positionsvector.
30  *
31  */
32 /*
33 History:
34 03.06.2009 Oesterholz created
35 12.02.2012 Oesterholz restoreXml*() without restoring domain possible
36 27.02.2012 Oesterholz DIRECTION_ANYWHERE added
37 */
38 
39 #ifndef ___C_TYPE_DIMENSION_H__
40 #define ___C_TYPE_DIMENSION_H__
41 
42 
43 #include "version.h"
44 #include "fibDatatyps.h"
45 #include "cTypeElement.h"
46 
47 #include "vector"
48 
49 using std::vector;
50 
51 
52 namespace fib{
53 
54 
56 private:
57 
58  /**
59  * the vector with the mappings for the dimensions
60  */
61  vector<unsignedIntFib> dimensionMapping;
62 
63 
64 public:
65 
66  /**
67  * constants for the directions/mappings of the dimension
68  */
69  static const unsignedIntFib DIRECTION_NONE = 0;
72  static const unsignedIntFib DIRECTION_DEPTH = 3;
73  static const unsignedIntFib DIRECTION_TIME = 4;
74 
76 
77 
78  /**
79  * The constructor for dimension typs.
80  *
81  * @param iNumberOfDimensions the Number of dimensions the
82  * positionvetordomain has
83  */
84  cTypeDimension( unsignedIntFib iNumberOfDimensions=2 );
85 
86  /**
87  * The constructor for dimension typs.
88  * Duplicte mapping will be set to 0.
89  *
90  * @param dimensionMapping the mappings for the dimensions
91  */
92  cTypeDimension( vector<unsignedIntFib> dimensionMapping );
93 
94  /**
95  * The copyconstructor for dimension typs.
96  *
97  * @param typeDimension the type dimension to copy
98  */
99  cTypeDimension( const cTypeDimension &typeDimension );
100 
101 
102  /**
103  * This Function returns for the type of the element an number.
104  * The values, which are returned, mean:
105  * - 1: cTypeDimension
106  * - 2: cTypeUnderArea
107  * - 3: cTypeUnderFunction
108  * - 5: cTypeInVar
109  * - 6: cTypeProperty
110  * - 10: cTypeVariable
111  * - 11: cTypeComments
112  * - 12: cTypeExtObject
113  * - 13: cTypeExtSubobject
114  * - 14: cTypeFibSet
115  * - 15: cTypeFibMatrix
116  * - 16: cTypeExtObjectInput
117  *
118  * @return for the type of the element an number
119  */
120  virtual unsignedIntFib getType() const;
121 
122  /**
123  * This Method returns a pointer to a new instance of the standart
124  * domain for elements of this dimension type.
125  * The returned standarddomain is adapted to the number of dimensions of this
126  * object. If you want the global standarddomain, please construct a
127  * cTypeDimension object with the constructor without parameters. ( The
128  * standard constructor.)
129  * You have to delete the returned object after usage.
130  *
131  * @return the standart domain for elements of this type
132  */
133  virtual cDomain *getStandardDomain( ) const;
134 
135  /**
136  * This method checks, if this element type is compatible with the
137  * given domain. Just domains which are compadible can be used for the
138  * elements of this type.
139  *
140  * @param domain the domain, which should be compatible
141  * @return true if the given domain is compatible, else false
142  */
143  virtual bool isCompatible( const cDomain &domain ) const;
144 
145 
146  /**
147  * @return the number of dimensions of the Fib -object
148  */
150 
151 
152  /**
153  * This method returns in which direction the iDimensionNumber dimension
154  * is mapped.
155  *
156  * @param iDimensionNumber the number of the dimension for which the
157  * mapping is to be returned
158  * @return the direction in which the iDimensionNumber dimension is
159  * mapped
160  */
161  unsignedIntFib getDimensionMapping( unsignedIntFib iDimensionNumber ) const;
162 
163 
164  /**
165  * This method sets in which direction the iDimensionNumber dimension
166  * is mapped.
167  *
168  * @param iDimensionNumber the number of the dimension for which the
169  * mapping is to be set
170  * @param iMapping the mapping to set for the dimension
171  * @return true if the mapping for the iDimensionNumber dimension is
172  * set to the given value iMapping, else false
173  */
174  bool setDimensionMapping( unsignedIntFib iDimensionNumber,
175  unsignedIntFib iMapping );
176 
177  /**
178  * This method returns a name for the dimensionmapping with the given
179  * number.
180  *
181  * @see getNumberForDimensionMappingName()
182  * @param iMapping the mapping for which a string/name is to be returned
183  * @return a string for the mapping with the number iMapping if known,
184  * else an empty string
185  */
186  string getDimensionMappingName( unsignedIntFib iMapping ) const;
187 
188  /**
189  * This method returns the number for the given name of the dimensionmapping.
190  *
191  * @see getDimensionMappingName()
192  * @param szMappingName the mappingname for which the number is to be returned
193  * @return the number for the szMappingName or 0 if non such exists
194  */
195  unsignedIntFib getNumberForDimensionMappingName( string szMappingName ) const;
196 
197  /**
198  * @return The SI unit for the dimension this type represents;
199  * possible values are:
200  * - "": for direction 0 none
201  * - "m": for direction 1 horizontal, 2 vertical or 3 depth direction
202  * - "s": for direction 4 time
203  */
204  virtual vector<string> getUnit() const;
205 
206  /**
207  * This Method checks if the elementtype of the given type is equal to
208  * the elementtype of this type.
209  * Two elementtype are not equal if ther are for different fib -elements.
210  *
211  * @param typeElement the typeelement to compare with this typeelement
212  * @return true if the elementtype of the given type is equal to the
213  * elementtype of this type, else false
214  */
215  virtual bool equalElementType( const cTypeElement & typeElement ) const;
216 
217  /**
218  * This Method checks if the given type is equal to this type.
219  *
220  * @return true if the given type is equal to this type, else false
221  */
222  virtual bool operator==( const cTypeElement &typeElement ) const;
223 
224  /**
225  * This Method clones this object.
226  *
227  * @return a clone of this object
228  */
229  virtual cTypeDimension *clone() const;
230 
231  /**
232  * This method evaluades the size of the typeelement in bits in the
233  * compressed file form.
234  *
235  * @see store()
236  * @return the size of the typeelement in bits in the compressed form
237  */
238  virtual unsignedLongFib getCompressedSize() const;
239 
240  /**
241  * This method stores this type in the XML -format into the
242  * given stream.
243  *
244  * @param ostream the stream where domains should be stored to
245  * @param domain the domain which should be stored to this type;
246  * if a Nullpointer NULL (the standardvalue) is given, no domain
247  * will be stored to this type
248  * @return true if this type are stored, else false
249  */
250  virtual bool storeXml( ostream & ostream,
251  const cDomain * domain = NULL ) const;
252 
253  /**
254  * This method restores a type with a domain in the XML -format from an
255  * TinyXml element.
256  *
257  * @param pXmlNode a pointer to the TinyXml node wher the type is stored in
258  * @param outStatus an integer value with the errorvalue
259  * possible errorvalues are:
260  * - 0 loading successful
261  * - -1 loading error, invalid pXmlElement
262  * - -2 loading error, invalid data in pXmlElement
263  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
264  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
265  * object is wrong
266  * @param bRestoreDomain if true a domain is to be asumed in the type
267  * element and it will be restored, else no domain will be restores
268  * @return a pointer to the restored domain, or NULL if it couldn't be restored
269  */
270  virtual cDomain * restoreXmlWithDomain( const TiXmlElement * pXmlElement,
271  intFib & outStatus, const bool bRestoreDomain = true );
272 
273  /**
274  * This method stores this typeelement in the compressed fib -format
275  * into the given stream.
276  * It is needed because the stream can yust store byts but the size of
277  * fib -elements can be any number of bits. Because of that ther have to
278  * be a possibility to exchange the missing bits betwean the fib -elements.
279  *
280  * @see cFibElement::store
281  * @param stream the stream where this typeelement should be stored to
282  * @param cRestBits the not yet writen bits which should be stored
283  * @param uiRestBitPosition the number of bits in the cRestBits which
284  * should be writen respectively containing valid information
285  * @return true if the typeelement is stored, else false
286  */
287  virtual bool store( ostream & stream, char & cRestBits,
288  unsigned char & uiRestBitPosition ) const;
289 
290  /**
291  * This method restores a type from a bitstream, wher it is
292  * stored in the compressed fib -format.
293  *
294  * @see store
295  * @param iBitStream the stream where the type is stored in,
296  * because the stream is an cReadBits, any number of bits can be
297  * readed from it
298  * @return an integervalue with the errorvalue
299  * possible errorvalues are:
300  * - 0 loading successful
301  * - -1 loading error, invalid pXmlElement
302  * - -2 loading error, invalid data in pXmlElement
303  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
304  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
305  * object is wrong
306  */
307  virtual intFib restore( cReadBits & iBitStream );
308 
309 
310 };//end class cTypeDimension
311 
312 
313 }//end namespace fib
314 
315 #endif //___C_TYPE_DIMENSION_H__