All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Union.cpp
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 Union.cpp
22 
23  \brief It defines a simple type as a collection (union) of values from specified simple data types.
24 */
25 
26 // TerraLib
27 #include "../common/STLUtils.h"
28 #include "QName.h"
29 #include "SimpleType.h"
30 #include "Union.h"
31 
32 // STL
33 #include <cassert>
34 
35 te::xsd::Union::Union(Annotation* ann, std::string* id)
36  : SimpleTypeConstructor(ann, id)
37 {
38 }
39 
42 {
43  for(std::size_t i = 0; i < rhs.m_memberTypeVec.size(); ++i)
44  m_memberTypeVec.push_back(new QName(rhs.m_memberTypeVec[i]));
45 
46  for(std::size_t i = 0; i < rhs.m_internalSimpleTypeVec.size(); ++i)
47  m_internalSimpleTypeVec.push_back(static_cast<SimpleType*>(rhs.m_internalSimpleTypeVec[i].clone()));
48 }
49 
51 {
52 }
53 
55 {
56  if(this != &rhs)
57  {
59 
60  for(std::size_t i = 0; i < rhs.m_memberTypeVec.size(); ++i)
61  m_memberTypeVec.push_back(new QName(rhs.m_memberTypeVec[i]));
62 
63  for(std::size_t i = 0; i < rhs.m_internalSimpleTypeVec.size(); ++i)
64  m_internalSimpleTypeVec.push_back(static_cast<SimpleType*>(rhs.m_internalSimpleTypeVec[i].clone()));
65  }
66 
67  return *this;
68 }
69 
70 const boost::ptr_vector<te::xsd::QName>& te::xsd::Union::getMemberTypes() const
71 {
72  return m_memberTypeVec;
73 }
74 
75 const boost::ptr_vector<te::xsd::SimpleType>& te::xsd::Union::getSimpleTypes() const
76 {
77  return m_internalSimpleTypeVec;
78 }
79 
81 {
82  m_memberTypeVec.push_back(name);
83 }
84 
86 {
87  m_internalSimpleTypeVec.push_back(a);
88 }
89 
91 {
92  return new Union(*this);
93 }
void addSimpleType(SimpleType *a)
It adds an internal simple type element to this Union element.
Definition: Union.cpp:85
void addMemberType(QName *name)
It adds a member type to this Union element.
Definition: Union.cpp:80
SimpleTypeConstructor * clone() const
It creates a clone of the object.
Definition: Union.cpp:90
Union(Annotation *ann=0, std::string *id=0)
Constructor.
Definition: Union.cpp:35
boost::ptr_vector< SimpleType > m_internalSimpleTypeVec
Used when the union has internal simple types.
Definition: Union.h:120
It models a XML Schema SimpleType element.
~Union()
Destructor.
Definition: Union.cpp:50
A class to deal with XML qualified names.
A base class for SympleType elements. List, Union and Restriction4SimpleType is derived from this bas...
boost::ptr_vector< QName > m_memberTypeVec
It specifies a list of built-in data types or simpleType elements defined in a schema. (Optional)
Definition: Union.h:119
SimpleTypeConstructor & operator=(const SimpleTypeConstructor &rhs)
Assignment operator not allowed.
const boost::ptr_vector< QName > & getMemberTypes() const
It returns the list of member types.
Definition: Union.cpp:70
A class to be used to represent XML qualified names.
Definition: QName.h:49
It defines a simple type as a collection (union) of values from specified simple data types...
Definition: Union.h:50
A class that models a XSD annotation element.
Definition: Annotation.h:55
It models a XML Schema SimpleType element.
Definition: SimpleType.h:54
Union & operator=(const Union &rhs)
Assignment operator.
Definition: Union.cpp:54
It defines a simple type as a collection (union) of values from specified simple data types...
const boost::ptr_vector< SimpleType > & getSimpleTypes() const
It returns the list of simple types defined on this union element.
Definition: Union.cpp:75