ComplexType.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file ComplexType.h
22 
23  \brief It models a XML Schema Complex Type definition.
24 */
25 
26 #ifndef __TERRALIB_XSD_INTERNAL_COMPLEXTYPE_H
27 #define __TERRALIB_XSD_INTERNAL_COMPLEXTYPE_H
28 
29 // TerraLib
30 #include "Annotated.h"
31 #include "Enums.h"
32 #include "Identifiable.h"
33 #include "Type.h"
34 
35 // Boost
36 #include <boost/ptr_container/ptr_vector.hpp>
37 
38 namespace te
39 {
40  namespace xsd
41  {
42 // Forward declaration
43  class AbstractAttribute;
44  class AnyAttribute;
45  class ComplexContent;
46  class Content;
47  class SimpleContent;
48 
49  /*!
50  \class ComplexType
51 
52  \brief It models a XML Schema Complex Type definition.
53 
54  \note Parent elements: element, redefine, schema
55  */
56  class TEXSDEXPORT ComplexType : public Type, public Identifiable, public Annotated
57  {
58  public:
59 
60  /*!
61  \brief Constructor.
62 
63  \param id It specifies a unique ID for the element. It can be a NULL value.
64  */
65  ComplexType(Annotation* ann = 0, std::string* id = 0);
66 
67  /*!
68  \brief Copy constructor.
69 
70  \param rhs Right-hand-side object.
71 
72  \todo Implement!
73  */
74  ComplexType(const ComplexType& rhs);
75 
76  /*! \brief Destructor. */
77  ~ComplexType();
78 
79  /*!
80  \brief Assignment operator.
81 
82  \param rhs Right-hand-side object.
83 
84  \return A reference to this object.
85 
86  \todo Implement!
87  */
88  ComplexType& operator=(const ComplexType& rhs);
89 
90  /*!
91  \brief It returns the element name or NULL if it doesn't have one.
92 
93  \return The element name or NULL if it doesn't have one.
94  */
95  std::string* getName() const;
96 
97  /*!
98  \brief If the CompleType is "abstract" or not.
99 
100  \return True if the CompleType is "abstract" and false if not.
101  */
102  bool isAbstract();
103 
104  /*!
105  \brief If the CompleType is "mixed" or not.
106 
107  \return True if the CompleType is "mixed" and false if not.
108  */
109  bool isMixed();
110 
111  /*!
112  \brief It returns the block value for the CompleType.
113 
114  \return The block value. It can be: #all | list of (extension|restriction).
115  */
116  int getBlock();
117 
118  /*!
119  \brief It returns the final value for the CompleType.
120 
121  \return The final value. It can be: #all | list of (extension|restriction).
122  */
123  int getFinal();
124 
125  /*!
126  \brief It returns the SimpleContent of this ComplexType.
127 
128  \return The SimpleContent of this ComplexType.
129  */
130  SimpleContent* getSimpleContent() const;
131 
132  /*!
133  \brief It returns the ComplexContent of this ComplexType.
134 
135  \return The ComplexContent of this ComplexType.
136  */
137  ComplexContent* getComplexContent() const;
138 
139  /*!
140  \brief It returns the content element of this ComplexType.
141 
142  \return The content element of this ComplexType. It can be: group | all | choice | sequence.
143  */
144  Content* getContent();
145 
146  /*!
147  \brief It returns the list of attributes of this ComplexType.
148 
149  \return The list of attributes of this ComplexType.
150  */
151  const boost::ptr_vector<AbstractAttribute>& getAttributes() const;
152 
153  /*!
154  \brief It returns the anyAttribute defined on this ComplexType.
155 
156  \return The anyAttribute defined on this ComplexType.
157  */
158  AnyAttribute* getAnyAttribute() const;
159 
160  /*!
161  \brief It sets the element name.
162 
163  \param name The element name.
164 
165  \note The ComplexType object will take the ownership of the given name.
166  */
167  void setName(std::string* name);
168 
169  /*!
170  \brief It specifies whether the element can be used in an instance of the document.
171 
172  \param v True indicates that the element cannot appear in the instance document. Instead, another element whose substitutionGroup attribute contains the qualified name (QName) of this element must appear in this element's place.
173  */
174  void setAsAbstract(bool v);
175 
176  /*!
177  \brief It specifies whether character data is allowed to appear between the child elements of this complexType element.
178 
179  \param v True indicates that character data is allowed to appear between the child elements of this complexType element.
180  */
181  void setAsMixed(bool v);
182 
183  /*!
184  \brief It prevents an element with a specified type of derivation from being used in place of this element.
185 
186  \param v It can be: #all|list of (extension|restriction).
187  */
188  void setBlock(int v);
189 
190  /*!
191  \brief It sets the default value of the final attribute on the element element.
192 
193  \param v It can be: #all|list of (extension|restriction).
194  */
195  void setFinal(int v);
196 
197  /*!
198  \brief It sets the SimpleContent to this ComplexType.
199 
200  \param sc The SimpleContent to this ComplexType.
201 
202  \note Setting the SimpleContent element will turn to NULL the ComplexContent, Content, Attributes and AnyAttribute.
203  \note The ComplexType object will take the ownership of the given pointer.
204  */
205  void setSimpleContent(SimpleContent* sc);
206 
207  /*!
208  \brief It sets the ComplexContent to this ComplexType.
209 
210  \param cc The ComplexContent to this ComplexType.
211 
212  \note Setting the ComplexContent element will turn to NULL the SimpleContent, Content, Attributes and AnyAttribute.
213  \note The ComplexType object will take the ownership of the given pointer.
214  */
215  void setComplexContent(ComplexContent* cc);
216 
217  /*!
218  \brief It sets the ComplexType content. It can be one of: group | all | choice | sequence.
219 
220  \param c The content to this ComplexType.
221 
222  \note Setting the content element will turn to NULL the SimpleContent and the ComplexContent.
223  \note The ComplexType object will take the ownership of the given pointer.
224  */
225  void setContent(Content* c);
226 
227  /*!
228  \brief It adds an attribute to this ComplexType.
229 
230  \param a The attribute that will be added. It can be: attribute | attributeGroup.
231 
232  \note Adding a attribute will turn to NULL the SimpleContent and the ComplexContent.
233  \note The ComplexType object will take the ownership of the given pointer.
234  */
235  void addAttribute(AbstractAttribute* a);
236 
237  /*!
238  \brief It sets the anyAttribute to this ComplexType.
239 
240  \param a It specifies the anyAttribute.
241 
242  \note Setting the anyAttribute will turn to NULL the SimpleContent and the ComplexContent.
243  \note The ComplexType object will take the ownership of the given pointer.
244  */
245  void setAnyAttribute(AnyAttribute* a);
246 
247  Type* clone() const;
248 
249  private:
250 
251  std::string* m_name; //!< The type name if it is not an unonoymous type (declared inside a element definition).
252  bool m_abstract; //!< It specifies whether the complex type can be used in an instance document (optional). True indicates that an element cannot use this complex type directly but must use a complex type derived from this complex type. Default is false.
253  bool m_mixed; //!< It specifies whether character data is allowed to appear between the child elements of this complexType element (optional). Default is false. If a simpleContent element is a child element, the mixed attribute is not allowed.
254  int m_block; //!< It prevents an element with a specified type of derivation from being used in place of this element. (Optional)
255  int m_final; //!< It sets the default value of the final attribute on the element element. This attribute cannot be used if the parent element is not the schema element. (Optional)
256  SimpleContent* m_sContent; //!< SimpleContent. If m_cContent is present this must be NULL. Likewise if m_content or m_attributes or m_anyAttr is present this must be also NULL.
257  ComplexContent* m_cContent; //!< ComplexContent. If m_sContent is present this must be NULL. Likewise if m_content or m_attributes or m_anyAttr is present this must be also NULL.
258  Content* m_content; //!< It can be: group|all|choice|sequence. If m_sContent or m_cContent is present, this must be NULL.
259  boost::ptr_vector<AbstractAttribute> m_attributeVec; //!< It can be: (attribute|attributeGroup)*. If m_sContent or m_cContent is present, this must be NULL.
260  AnyAttribute* m_anyAttr; //!< A pointer to a anyAttribute. If m_sContent or m_cContent is present, this must be NULL.
261  };
262 
263  } // end namespace xsd
264 } // end namespace te
265 
266 #endif // __TERRALIB_XSD_INTERNAL_COMPLEXTYPE_H
267 
Content * m_content
It can be: group|all|choice|sequence. If m_sContent or m_cContent is present, this must be NULL...
Definition: ComplexType.h:258
An abstract class for modeling the definition of a new XML Schema Type.
It models an XML Schema complexContent element.
AnyAttribute * m_anyAttr
A pointer to a anyAttribute. If m_sContent or m_cContent is present, this must be NULL...
Definition: ComplexType.h:260
A base class for XSD classes that may allow annotation.
Definition: Annotated.h:49
A base class for XSD classes that may allow annotation.
bool m_mixed
It specifies whether character data is allowed to appear between the child elements of this complexTy...
Definition: ComplexType.h:253
bool m_abstract
It specifies whether the complex type can be used in an instance document (optional). True indicates that an element cannot use this complex type directly but must use a complex type derived from this complex type. Default is false.
Definition: ComplexType.h:252
A base class for elements that are not definitions nor declarations. This class is just for creating ...
Definition: Content.h:43
int m_final
It sets the default value of the final attribute on the element element. This attribute cannot be use...
Definition: ComplexType.h:255
It models an XML anyAttribute element.
Definition: AnyAttribute.h:49
This is the base class for XML Schema Attribute classes.
int m_block
It prevents an element with a specified type of derivation from being used in place of this element...
Definition: ComplexType.h:254
It models a XML Schema Complex Type definition.
Definition: ComplexType.h:56
std::string * m_name
The type name if it is not an unonoymous type (declared inside a element definition).
Definition: ComplexType.h:251
A base class for XSD classes that must provide a unique ID property.
Definition: Identifiable.h:46
URI C++ Library.
SimpleContent * m_sContent
SimpleContent. If m_cContent is present this must be NULL. Likewise if m_content or m_attributes or m...
Definition: ComplexType.h:256
A base class for XSD classes that must provide a unique ID property.
#define TEXSDEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:57
ComplexContent * m_cContent
ComplexContent. If m_sContent is present this must be NULL. Likewise if m_content or m_attributes or ...
Definition: ComplexType.h:257
A class that models an XML Schema simpleContent element.
Definition: SimpleContent.h:50
boost::ptr_vector< AbstractAttribute > m_attributeVec
It can be: (attribute|attributeGroup)*. If m_sContent or m_cContent is present, this must be NULL...
Definition: ComplexType.h:259
A class that models a XSD annotation element.
Definition: Annotation.h:55
An abstract class for modeling the definition of a new XML Schema Type.
Definition: Type.h:65