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
cFunctionMod.h
Go to the documentation of this file.
1 /**
2  * @class cFunctionMod
3  * file name: cFunctionMod.h
4  * @author Betti Oesterholz
5  * @date 09.11.2012
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This class represents a Fib function for the symmetric modulo operator.
11  * Copyright (C) @c LGPL3 2010 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 Fib function for the symmetric modulo operator.
28  * This function works on two subfunctions. The symmetric modulo operator
29  * returns the remainder of the integer division.
30  * ( mod(x, y) = x - y * int (x / y), where int refers to the truncation of
31  * the decimal digits)
32  *
33  */
34 /*
35 History:
36 09.11.2012 Oesterholz created
37 */
38 
39 #ifndef ___C_FUNCTION_MOD_H__
40 #define ___C_FUNCTION_MOD_H__
41 
42 
43 #include "cFunctionTwoValue.h"
44 
45 
46 namespace fib{
47 
48 
50 
51 public:
52 
53  /**
54  * The constructor of the underfunction.
55  *
56  * @param firstUnderfunction the first underfunction for the function
57  * @see pFirstUnderfunction
58  * @param secondUnderfunction the second underfunction for the function
59  * @see pSecondUnderfunction
60  * @param pInSuperiorFunction the underfunction which contains the
61  * new underfunction
62  * @param pInDefiningFibElement the fib -element which defines/ uses
63  * the new underfunction
64  */
65  cFunctionMod( const cUnderFunction & firstUnderfunction,
66  const cUnderFunction & secondUnderfunction,
67  cUnderFunction * pInSuperiorFunction = NULL,
68  cFibElement * pInDefiningFibElement = NULL );
69 
70  /**
71  * The copy constructor of the underfunction.
72  * This constructor will also copy the underfunctions of the given
73  * function.
74  *
75  * @param underfunction the underfunction which to copy
76  * @param pInSuperiorFunction the underfunction which contains the
77  * new underfunction
78  * @param pInDefiningFibElement the fib -element which defines/ uses
79  * the new underfunction
80  */
81  cFunctionMod( const cFunctionMod & underfunction,
82  cUnderFunction * pInSuperiorFunction = NULL,
83  cFibElement *pInDefiningFibElement = NULL );
84 
85  /**
86  * The constructor for restoring a value underfunction from an TinyXml element.
87  *
88  * @param pXmlNode a pointer to the TinyXml node the underfunction is stored in
89  * @param outStatus An reference to an integervalue where the errorvalue
90  * can be stored to.
91  * possible errorvalues are:
92  * - 0 loading successful
93  * - -1 loading error, invalid pXmlElement
94  * - -2 loading error, invalid data in pXmlElement
95  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
96  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
97  * object is wrong
98  * @param liDefinedVariables a list with the defined variables for the
99  * to restore fib -element, every variable should have it's number
100  * (the number under which it is stored) as it's value
101  * @param pInSuperiorFunction the underfunction which contains the
102  * new underfunction
103  * @param pInDefiningFibElement the fib -element which defines/ uses
104  * the new underfunction
105  */
106  cFunctionMod( const TiXmlElement * pXmlElement, intFib & outStatus,
107  list<cFibVariable*> & liDefinedVariables,
108  cUnderFunction * pInSuperiorFunction = NULL,
109  cFibElement * pInDefiningFibElement = NULL );
110 
111  /**
112  * This constructor restores a value underfunction from the stream
113  * where it is stored in the compressed fib -format.
114  * Beware: The bits for the functiontype should be allready readed, this
115  * constructor reads yust the two underfunctions.
116  *
117  * @param iBitStream the stream where this underfunction is stored to in,
118  * because this stream is an cReadBits, any number of bits can be
119  * readed from it
120  * @param outStatus An reference to an integervalue where the errorvalue
121  * can be stored to. If the pointer is NULL no errorvalue will be
122  * given back.
123  * possible errorvalues are:
124  * - 0 loading successful
125  * - -1 loading error, invalid stream
126  * - -2 loading error, invalid data in stream
127  * - 1 loading warning, invalid data in stream, error could be corrected
128  * - 2 loading warning, invalid data in stream, maybe the loaded
129  * object is wrong
130  * @param liDefinedVariables a list with the defined variables for the
131  * to restore fib -element, every variable should have it's number
132  * (the number under which it is stored) as it's value
133  * @param pInDomainValue the domain for value underfunction
134  * @param pInDomainVariable the domain for variables
135  * @param pInSuperiorFunction the underfunction which contains the
136  * new underfunction
137  * @param pInDefiningFibElement the fib -element which defines/ uses
138  * the new underfunction
139  */
140  cFunctionMod( cReadBits & iBitStream, intFib & outStatus,
141  list<cFibVariable*> & liDefinedVariables,
142  const cDomainSingle * pInDomainValue, const cDomainSingle * pInDomainVariable,
143  cUnderFunction * pInSuperiorFunction = NULL,
144  cFibElement * pInDefiningFibElement = NULL );
145 
146 
147  /**
148  * Returns the value of the underfunction or 0 if non such exists.
149  *
150  * @return the value of the underfunction or 0 if non
151  * such exists
152  */
153  virtual doubleFib getValue() const;
154 
155  /**
156  * This method evaluades the size of the Fib object in bits in the
157  * compressed file form.
158  * The optional part field of point elements will be ignored.
159  *
160  * @see store()
161  * @return the size of the Fib object in bits in the compressed form
162  */
163  virtual unsignedLongFib getCompressedSize() const;
164 
165  /**
166  * This method stores this Fib object in the compressed Fib -format
167  * into the given stream.
168  * It is needed becouse the stream can yust store byts but the size of
169  * fib -elements can be any number of bits. Because of that ther have to
170  * be a possibility to exchange the missing bits betwean the fib -elements.
171  *
172  * @see store
173  * @param stream the stream where this Fib object should be stored to
174  * @param cRestBits the not yet writen bits which should be stored
175  * @param uiRestBitPosition the number of bits in the cRestBits which
176  * should be writen respectively containing valid information
177  * @return true if this Fib object is stored, else false
178  */
179  virtual bool store( ostream & stream, char & cRestBits,
180  unsigned char & uiRestBitPosition ) const;
181 
182  /**
183  * @return the type for the underfunction
184  */
185  virtual unsignedIntFib getType() const;
186 
187  /**
188  * @return the name for the underfunction
189  */
190  virtual string getUnderFunctionName() const;
191 
192  /**
193  * This method duplicates this whole underfunction.
194  * Underfunctions of this underfunction are also cloned.
195  *
196  * @param pSuperiorUnderFunction the underfunction which contains
197  * @param pInDefiningFibElement the Fib -element which defines/ uses
198  * @return the cloned/ duplicated underfunction
199  */
200  virtual cFunctionMod * clone(
201  cUnderFunction * pInSuperiorUnderFunction = NULL,
202  cFibElement *pInDefiningFibElement = NULL) const;
203 
204 
205 
206 };//end class cFunctionMod
207 
208 
209 }//end namespace fib
210 
211 #endif