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