Attribute.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 Lesser 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 Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser 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 Attribute.h
22 
23  \brief It models a XML Schema attribute.
24 */
25 
26 #ifndef __TERRALIB_XSD_INTERNAL_ATTRIBUTE_H
27 #define __TERRALIB_XSD_INTERNAL_ATTRIBUTE_H
28 
29 // TerraLib
30 #include "AbstractAttribute.h"
31 #include "Annotated.h"
32 #include "Enums.h"
33 #include "Identifiable.h"
34 
35 // STL
36 #include <map>
37 
38 namespace te
39 {
40  namespace xsd
41  {
42 // Forward declarations
43  class QName;
44  class SimpleType;
45 
46  /*!
47  \class Attribute
48 
49  \brief It models a XML Schema attribute.
50 
51  Some notes:
52  <ul>
53  <li>Attributes can not contain other elements or other attributes.</li>
54  <li>The default and fixed attributes can not both be present.</li>
55  <li>Name and ref attributes cannot both be present. If ref is present the named type, form, and SimpleType cannot be present.</li>
56  <li>If a named type is used, ref and SimpleType cannot be present.</li>
57  </ul>
58 
59  \note Parent elements: attributeGroup, schema, complexType, restriction (both simpleContent and complexContent), extension (both simpleContent and complexContent).
60  */
62  {
63  public:
64 
65  /*!
66  \brief Constructor.
67 
68  \param ann An annotation.
69  \param id It specifies a unique ID for the element.
70 
71  \note The Attribute object will take the ownership of the annotation and id.
72  */
73  Attribute(Annotation* ann = 0, std::string* id = 0);
74 
75  /*!
76  \brief Copy constructor.
77 
78  \param rhs Right-hand-side object.
79  */
80  Attribute(const Attribute& rhs);
81 
82  /*! \brief Destructor. */
83  ~Attribute();
84 
85  /*!
86  \brief Assignment operator.
87 
88  \param rhs Right-hand-side object.
89 
90  \return A reference to this object.
91  */
92  Attribute& operator=(const Attribute& rhs);
93 
94  /*!
95  \brief It returns the default value for the attribute.
96 
97  \return The default value.
98  */
99  std::string* getDefault() const;
100 
101  /*!
102  \brief It returns the fixed value for the attribute.
103 
104  \return The fixed value.
105  */
106  std::string* getFixed() const;
107 
108  /*!
109  \brief It returns the form property value of attribute.
110 
111  \return Form property value of attribute: Qualified or Unqualified.
112  */
113  Form getForm() const;
114 
115  /*!
116  \brief It returns the name of the attribute.
117 
118  \return The name of the object.
119  */
120  std::string* getName() const;
121 
122  /*!
123  \brief It returns the reference to a named attribute element.
124 
125  \return The reference to a named attribute element.
126  */
127  QName* getRef() const;
128 
129  /*!
130  \brief It returns a built-in data type or simple type for the attribute element.
131 
132  \return A built-in data type or simple type for the attribute element.
133  */
134  QName* getType() const;
135 
136  /*!
137  \brief It returns a AttributeUse object that specifies how how the attribute is used.
138 
139  \return An AttributeUse object that specifies how the attribute is used.
140  */
141  AttributeUse getUse() const;
142 
143  /*!
144  \brief It returns the simpleType element of the attribute.
145 
146  \return A simpleType element.
147  */
148  SimpleType* getInnerType() const;
149 
150  /*!
151  \brief It returns a map with other properties of the attribute element.
152 
153  \return Other properties of the attribute element as a key-value map.
154  */
155  //std::map<std::string, std::string>* getOtherAttributes() const;
156 
157  /*!
158  \brief It sets a default value for the attribute.
159 
160  \param def A default value.
161 
162  \note Setting the default property will turn to NULL the fixed property.
163  \note The Attribute object will take the ownership of the given pointer.
164  */
165  void setDefault(std::string* def);
166 
167  /*!
168  \brief It sets a fixed value for the attribute.
169 
170  \param fix A fixed value.
171 
172  \note Setting the fixed property will turn to NULL the default property.
173  \note The Attribute object will take the ownership of the given pointer.
174  */
175  void setFixed(std::string* fix);
176 
177  /*!
178  \brief It sets the form property of the attribute.
179 
180  \param f The value for form property of the attribute: Qualified or Unqualified.
181  */
182  void setForm(Form f);
183 
184  /*!
185  \brief It sets a name for the attribute.
186 
187  \param name A name for this attribute.
188 
189  \note Setting a name will turn to NULL the reference property.
190  \note The Attribute object will take the ownership of the given pointer.
191  */
192  void setName(std::string* name);
193 
194  /*!
195  \brief It sets a reference to a named attribute.
196 
197  \param ref A reference to a named attribute as a QName object.
198 
199  \note Setting a reference will turn to NULL the name and type properties and the SimpleType element.
200  \note The Attribute object will take the ownership of the given pointer.
201  */
202  void setRef(QName* ref);
203 
204  /*!
205  \brief It sets a built-in data type or simple type for the attribute.
206 
207  \param type A built-in data type or simple type as a QName object.
208 
209  \note Setting a reference will turn to NULL the reference property and the inner SimpleType element.
210  \note The Attribute object will take the ownership of the given pointer.
211  */
212  void setType(QName* type);
213 
214  /*!
215  \brief It sets how the attribute is used.
216 
217  \param use A AttributeUse object that specifies how the attribute is used.
218  */
219  void setUse(AttributeUse use);
220 
221  /*!
222  \brief It sets a inner simpleType element for the attribute.
223 
224  \param iType A SimpleType object that represents a inner simpleType element for the attribute.
225 
226  \note Setting a simpleType element for the attribute will turn to NULL the reference and type properties.
227  \note The Attribute object will take the ownership of the given pointer.
228  */
229  void setInnerType(SimpleType* iType);
230 
231  /*!
232  \brief Add a property with non-schema namespace to the attribute.
233 
234  \param key The name of the property.
235  \param value The value of the property.
236  */
237  //void addOtherAttribute(std::string key, std::string value);
238 
239  AbstractAttribute* clone() const;
240 
241  private:
242 
243  std::string* m_default; //!< It specifies a default value for the attribute (Optional).
244  std::string* m_fixed; //!< It specifies a fixed value for the attribute (Optional).
245  Form m_form; //!< It specifies if the attribute must be qualified or not. Default = unqualified. (Optional)
246  std::string* m_name; //!< It specifies a name for the attribute. It will be NULL if m_ref is present. (Optional)
247  QName* m_ref; //!< It specifies a reference to a named attribute. NULL if m_name is present. (Optional)
248  QName* m_type; //!< It specifies a built-in data type or simple type for the attribute. It is NULL if m_ref is present or m_innerType. (Optional)
249  AttributeUse m_use; //!< It specifies how the attribute is used. (Optional)
250  SimpleType* m_innerType; //!< It specifies the attribute type as a simple type. It will be NULL if m_ref is present or if m_type is present. (Optional)
251  //std::map<std::string, std::string>* m_otherAttributes; //!< It specifies a list of other attributes with non-schema namespace (Optional).
252  };
253 
254  } // end namespace xsd
255 } // end namespace te
256 
257 #endif // __TERRALIB_XSD_INTERNAL_ATTRIBUTE_H
258 
QName * m_type
It specifies a built-in data type or simple type for the attribute. It is NULL if m_ref is present or...
Definition: Attribute.h:248
AttributeUse
It specifies how the attribute is used.
Definition: Enums.h:69
A base class for XSD classes that may allow annotation.
Definition: Annotated.h:49
AttributeUse m_use
It specifies how the attribute is used. (Optional)
Definition: Attribute.h:249
Form m_form
It specifies if the attribute must be qualified or not. Default = unqualified. (Optional) ...
Definition: Attribute.h:245
A base class for XSD classes that may allow annotation.
std::string * m_default
It specifies a default value for the attribute (Optional).
Definition: Attribute.h:243
This is the base class for XML Schema Attribute classes.
This is the base class for XML Schema Attribute classes.
A base class for XSD classes that must provide a unique ID property.
Definition: Identifiable.h:46
It models a XML Schema attribute.
Definition: Attribute.h:61
Form
It specifies the form for the attribute.
Definition: Enums.h:112
URI C++ Library.
SimpleType * m_innerType
It specifies the attribute type as a simple type. It will be NULL if m_ref is present or if m_type is...
Definition: Attribute.h:250
A base class for XSD classes that must provide a unique ID property.
QName * m_ref
It specifies a reference to a named attribute. NULL if m_name is present. (Optional) ...
Definition: Attribute.h:247
#define TEXSDEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:57
A class to be used to represent XML qualified names.
Definition: QName.h:49
std::string * m_name
It specifies a name for the attribute. It will be NULL if m_ref is present. (Optional) ...
Definition: Attribute.h:246
std::string * m_fixed
It specifies a fixed value for the attribute (Optional).
Definition: Attribute.h:244
A class that models a XSD annotation element.
Definition: Annotation.h:55
It models a XML Schema SimpleType element.
Definition: SimpleType.h:54