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
cDomainElement.h
Go to the documentation of this file.
1 /**
2  * @class cDomainElement
3  * file name: cDomainElement.h
4  * @author Betti Oesterholz
5  * @date 06.06.2009
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This class represents an domain element of an domain list.
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 class represents an domain element of an domain list in an
28  * root -element. The domain element consist of an domain and an type for
29  * the doamin.
30  *
31  */
32 /*
33 History:
34 06.06.2009 Oesterholz created
35 22.02.2012 Oesterholz method isCompatible() added
36 */
37 
38 #ifndef ___C_DOMAIN_ELEMENT_H__
39 #define ___C_DOMAIN_ELEMENT_H__
40 
41 #include "version.h"
42 
43 #include "cTypeElement.h"
44 #include "cDomain.h"
45 
46 
47 namespace fib{
48 
49 
51 protected:
52 
53  /**
54  * the type of the element this domain element represents
55  */
57 
58  /**
59  * the domain of this domain element
60  */
62 
63  /**
64  * if the domain is a copy of the original domain and will be deleted
65  * on distruction of this object
66  */
68 
69 
70 public:
71 
72  /**
73  * The constructor for domain elements.
74  *
75  * @param typeElement the type of the element this domain element
76  * represents
77  * @param domain the domain for this domain element;
78  * if it is Nullpointer NULL (the standard value) as the domain
79  * or the given domain is not compatible to the geven type typeElement
80  * the standard domain of the TypeElement will be set
81  */
83 
84  /**
85  * The constructor for domain elements.
86  * The given domain is inclueded direct, without copying it.
87  *
88  * @param typeElement the type of the element this domain element
89  * represents
90  * @param domain a pointer to the domain for this domain element;
91  * if it is Nullpointer NULL (the standard value) as the domain
92  * or the given domain is not compatible to the given type typeElement
93  * the standard domain of the TypeElement will be set
94  */
96 
97  /**
98  * The copyconstructor for domain elements.
99  *
100  * @param domainElement the domain element to copy
101  */
102  cDomainElement( const cDomainElement &domainElement );
103 
104  /**
105  * The destructor for domain elements.
106  */
107  ~cDomainElement();
108 
109 
110  /**
111  * @return the type of the element this domain element represents
112  */
113  cTypeElement * getElementType() const;
114 
115  /**
116  * @return a reference to the domain of this domain element;
117  * so you can adopt the domain
118  */
119  cDomain * getDomain() const;
120 
121  /**
122  * This method sets the domain of this domain element to the given
123  * domain.
124  *
125  * @param domain the domain for this domain element
126  * @return true if the given domain is set, else false
127  */
128  bool setDomain( const cDomain &domain );
129 
130  /**
131  * This method sets the domain of this domain element to the given
132  * domain.
133  * The giving domain won't be copied befor inserted.
134  *
135  * @param domain a pointer to the domain for this domain element
136  * @return true if the given domain is set, else false
137  */
138  bool setDomain( cDomain * domain );
139 
140  /**
141  * This method evaluades the size of the domain element in bits in the
142  * compressed file form.
143  *
144  * @see store()
145  * @return the size of the domain element in bits in the compressed form
146  */
147  virtual unsignedLongFib getCompressedSize() const;
148 
149  /**
150  * This method stores this domain element in the XML -format into the
151  * given stream.
152  *
153  * @param ostream the stream where domains should be stored to
154  * @return true if this domain element are stored, else false
155  */
156  virtual bool storeXml( ostream & ostream ) const;
157 
158  /**
159  * This method stores this domain element in the compressed Fib -format
160  * into the given stream.
161  * It is needed because the stream can yust store byts but the size of
162  * fib -elements can be any number of bits. Because of that ther have to
163  * be a possibility to exchange the missing bits betwean the fib -elements.
164  *
165  * @see cFibElement::store
166  * @param stream the stream where this domains should be stored to
167  * @param cRestBits the not yet writen bits which should be stored
168  * @param uiRestBitPosition the number of bits in the cRestBits which
169  * should be writen respectively containing valid information
170  * @return true if the domain element is stored, else false
171  */
172  virtual bool store( ostream & stream, char & cRestBits,
173  unsigned char & uiRestBitPosition ) const;
174 
175 
176  /**
177  * This method checks if the given domain is compatible with the given
178  * type.
179  * Reference domains (cDomainReference) are compatible with all typs.
180  * @see cDomainReference
181  *
182  * @param typeElement the type for which to check if the domain is compatible
183  * @param domain the domain which should be compatible with the given
184  * type typeElement
185  * @return true if the given domain is compatible with the type typeElement
186  */
187  static bool isCompatible( const cTypeElement &typeElement,
188  const cDomain & domain );
189 
190 };//end class cDomainElement
191 
192 
193 }//end namespace fib
194 
195 #endif //___C_DOMAIN_ELEMENT_H__