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