Choice.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 Choice.h
22 
23  \brief This class models the XML Schema choice element.
24 */
25 
26 #ifndef __TERRALIB_XSD_INTERNAL_CHOICE_H
27 #define __TERRALIB_XSD_INTERNAL_CHOICE_H
28 
29 // TerraLib
30 #include "Annotated.h"
31 #include "Content.h"
32 #include "Identifiable.h"
33 #include "Occurs.h"
34 
35 // Boost
36 #include <boost/ptr_container/ptr_vector.hpp>
37 
38 namespace te
39 {
40  namespace xsd
41  {
42 // Forward declarations
43  class Any;
44  class Element;
45 
46  /*!
47  \class Choice
48 
49  \brief This class models the XML Schema choice element.
50 
51  The choice element allows only one of the elements contained in the <choice> declaration to be present within the containing element.
52 
53  \note Parent elements: group, choice, sequence, complexType, restriction (both simpleContent and complexContent), extension (both simpleContent and complexContent).
54 
55  \todo This class is not preserving the order: (element|group|choice|sequence|any)*. We must work on this later!
56  */
57  class TEXSDEXPORT Choice : public Content, public Occurs, public Identifiable, public Annotated
58  {
59  public:
60 
61  /*!
62  \brief Constructor.
63 
64  \param id It specifies a unique ID for the element. It can be a NULL value.
65  \param minOccurs The minimum number of times the element can occur.
66  \param maxOccurs The maximum number of times the element can occur.
67  */
68  Choice(unsigned int minOccurs = 1, unsigned int maxOccurs = 1, Annotation* ann = 0, std::string* id = 0);
69 
70  /*!
71  \brief Copy constructor.
72 
73  \param rhs Right-hand-side object.
74 
75  \todo We must implement this method.
76  */
77  Choice(const Choice& rhs);
78 
79  /*! \brief Destructor. */
80  ~Choice();
81 
82  /*!
83  \brief Assignment operator.
84 
85  \param rhs Right-hand-side object.
86 
87  \return A reference to this object.
88 
89  \todo We must implement this method.
90  */
91  Choice& operator=(const Choice& rhs);
92 
93  /*!
94  \brief It returns the list of elements of Choice.
95 
96  \return The list of elements.
97  */
98  const boost::ptr_vector<Element>& getElements() const;
99 
100  /*!
101  \brief It returns the list of Content elements of Choice.
102 
103  \return The list of Content elements: group | choice | sequence.
104  */
105  const boost::ptr_vector<Content>& getContents() const;
106 
107  /*!
108  \brief It returns the list of any elements of Choice.
109 
110  \return The list of any elements.
111  */
112  const boost::ptr_vector<Any>& getAnys() const;
113 
114  /*!
115  \brief It adds an element to this Choice element.
116 
117  \param e The element that will be added.
118 
119  \note The Choice object will take the ownership of the given pointer.
120  */
121  void addElement(Element* e);
122 
123  /*!
124  \brief It adds a Content element to this Choice element.
125 
126  \param c The appropriate Content element. It can be: group | choice | sequence.
127 
128  \note The Choice object will take the ownership of the given pointer.
129  */
130  void addContent(Content* c);
131 
132  /*!
133  \brief It adds an any to this Choice element.
134 
135  \param a The any that will be added.
136 
137  \note The Choice object will take the ownership of the given pointer.
138  */
139  void addAny(Any* a);
140 
141  Content* clone() const;
142 
143  private:
144 
145  boost::ptr_vector<Element> m_elementVec; //!< The list of elements.
146  boost::ptr_vector<Content> m_contentVec; //!< The list of Contents elements (group | choice | sequence).
147  boost::ptr_vector<Any> m_anyVec; //!< The list of any elements.
148  };
149 
150  } // end namespace xsd
151 } // end namespace te
152 
153 #endif // __TERRALIB_XSD_INTERNAL_CHOICE_H
A base class for XSD classes that may allow annotation.
Definition: Annotated.h:49
A base class for XSD classes that have occurs attributes.
Definition: Occurs.h:43
A base class for XSD classes that may allow annotation.
This class models the element of a XML Schema.
Definition: Element.h:56
A base class for elements that are not definitions nor declarations. This class is just for creating ...
Definition: Content.h:43
boost::ptr_vector< Element > m_elementVec
The list of elements.
Definition: Choice.h:145
It models the XML Schema any element.
Definition: Any.h:49
A base class for elements that are not definitions nor declarations. This class is just for creating ...
A base class for XSD classes that must provide a unique ID property.
Definition: Identifiable.h:46
This class models the XML Schema choice element.
Definition: Choice.h:57
URI C++ Library.
boost::ptr_vector< Content > m_contentVec
The list of Contents elements (group | choice | sequence).
Definition: Choice.h:146
A base class for XSD classes that have occurs attributes.
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
A class that models a XSD annotation element.
Definition: Annotation.h:55
boost::ptr_vector< Any > m_anyVec
The list of any elements.
Definition: Choice.h:147