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
cDomain.h
Go to the documentation of this file.
1 /**
2  * @class cDomain
3  * file name: cDomain.h
4  * @author Betti Oesterholz
5  * @date 13.05.2009
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This class represents an abstract domain.
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 -domains. It's not
28  * possible to create instances from this class.
29  *
30  */
31 /*
32 History:
33 13.05.2009 Oesterholz created
34 09.02.2012 Oesterholz isReference() added
35 */
36 
37 #ifndef ___C_DOMAIN_H__
38 #define ___C_DOMAIN_H__
39 
40 
41 #include "version.h"
42 
43 #include "nBitStream.h"
44 #include "fibDatatyps.h"
45 #include "cReadBits.h"
46 
47 #include "tinyxml.h"
48 
49 #include <string>
50 #include <ostream>
51 #include <istream>
52 
53 
54 using std::string;
55 
56 namespace fib{
57 
58 
59 class cDomain{
60 
61 public:
62 
63  /**
64  * destructor
65  */
66  virtual ~cDomain() = 0;
67 
68  /**
69  * @return the type of the domain as an string
70  */
71  virtual string getType() const = 0;
72 
73  /**
74  * @return true if the object represents a scalar domain, else false
75  */
76  virtual bool isScalar() const;
77 
78  /**
79  * @return true if the object represents a vector domain, else false
80  */
81  virtual bool isVector() const;
82 
83  /**
84  * @return true if the object represents a reference domain, else false
85  * @see cDomainReference
86  */
87  virtual bool isReference() const;
88 
89  /**
90  * This Method clones this object.
91  *
92  * @return a clone of this object
93  */
94  virtual cDomain *clone() const = 0;
95 
96  /**
97  * This Method checks if the given domain is equal to this domain.
98  *
99  * @param domain the domain which should be equal to this domain
100  * @return true if the given domain is equal to this domain, else false
101  */
102  virtual bool equal( const cDomain &domain ) const;
103 
104  /**
105  * This Method checks if the given domain is equal to this domain.
106  *
107  * @param domain the domain which should be equal to this domain
108  * @return true if the given domain is equal to this domain, else false
109  */
110  virtual bool operator==( const cDomain &domain ) const;
111 
112  /**
113  * This method evaluades the size of the domain in bits in the
114  * compressed file form.
115  *
116  * @see store()
117  * @return the size of the domain in bits in the compressed form
118  */
119  virtual unsignedIntFib getCompressedSize() const = 0;
120 
121  /**
122  * This method stores this domain in the XML -format into the
123  * given stream.
124  *
125  * @param ostream the stream where domains should be stored to
126  * @return true if this domain are stored, else false
127  */
128  virtual bool storeXml( ostream & ostream ) const = 0;
129 
130 
131  /**
132  * This method restores a domain in the XML -format from an TinyXml element.
133  *
134  * @pattern Factory Method
135  * @param pXmlNode a pointer to the TinyXml node wher the domain is stored in
136  * @param outStatus an integervalue with the errorvalue
137  * possible errorvalues are:
138  * - 0 loading successful
139  * - -1 loading error, invalid pXmlElement
140  * - -2 loading error, invalid data in pXmlElement
141  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
142  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
143  * object is wrong
144  * @return the pointers to the restored domain, if non could be restored
145  * the returned pointer is NULL
146  */
147  static cDomain * restoreXml( const TiXmlElement * pXmlElement,
148  intFib & outStatus );
149 
150  /**
151  * This method restores a domain in the XML -format from an TinyXml element.
152  *
153  * @pattern Factory Method
154  * @param pXmlNode a pointer to the TinyXml node wher the domain is stored in
155  * @return an integervalue with the errorvalue
156  * possible errorvalues are:
157  * - 0 loading successful
158  * - -1 loading error, invalid pXmlElement
159  * - -2 loading error, invalid data in pXmlElement
160  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
161  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
162  * object is wrong
163  */
164  virtual intFib restoreXml( const TiXmlElement * pXmlElement ) = 0;
165 
166  /**
167  * This method stores this domain in the compressed fib -format
168  * into the given stream.
169  * It is needed because the stream can yust store byts but the size of
170  * fib -elements can be any number of bits. Because of that ther have to
171  * be a possibility to exchange the missing bits betwean the fib -elements.
172  *
173  * @see cFibElement::store
174  * @param stream the stream where this domain should be stored to
175  * @param cRestBits the not yet writen bits which should be stored
176  * @param uiRestBitPosition the number of bits in the cRestBits which
177  * should be writen respectively containing valid information
178  * @return true if the domain is stored, else false
179  */
180  virtual bool store( ostream & stream, char & cRestBits,
181  unsigned char & uiRestBitPosition ) const = 0;
182 
183 
184  /**
185  * This method restores a domain from a bitstream, wher it is
186  * stored in the compressed fib -format.
187  *
188  * @pattern Factory Method
189  * @see store
190  * @param iBitStream the stream where the domain is stored in,
191  * because the stream is an cReadBits, any number of bits can be
192  * readed from it
193  * @param outStatus an integervalue with the errorvalue
194  * possible errorvalues are:
195  * - 0 loading successful
196  * - -1 loading error, invalid pXmlElement
197  * - -2 loading error, invalid data in pXmlElement
198  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
199  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
200  * object is wrong
201  * @return a pointer to the restored domain or NULL
202  */
203  static cDomain * restore( cReadBits & iBitStream, intFib & outStatus );
204 
205  /**
206  * This method restores a domain from a bitstream, wher it is
207  * stored in the compressed fib -format.
208  *
209  * @pattern Factory Method
210  * @see store
211  * @param iBitStream the stream where the domain is stored in,
212  * because the stream is an cReadBits, any number of bits can be
213  * readed from it
214  * @return an integervalue with the errorvalue
215  * possible errorvalues are:
216  * - 0 loading successful
217  * - -1 loading error, invalid pXmlElement
218  * - -2 loading error, invalid data in pXmlElement
219  * - 1 loading warning, invalid data in pXmlElement, error could be corrected
220  * - 2 loading warning, invalid data in pXmlElement, maybe the loaded
221  * object is wrong
222  */
223  virtual intFib restore( cReadBits & iBitStream ) = 0;
224 
225 
226 };//end class cDomain
227 
228 
229 }//end namespace fib
230 
231 #endif