ObjectIdSet.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 terralib/dataaccess/dataset/ObjectIdSet.h
22 
23  \brief This class represents a set of unique ids created in the same context. i.e. from the same data set.
24 */
25 
26 #ifndef __TERRALIB_DATAACCESS_INTERNAL_OBJECTIDSET_H
27 #define __TERRALIB_DATAACCESS_INTERNAL_OBJECTIDSET_H
28 
29 // TerraLib
30 #include "../../common/Comparators.h"
31 #include "../Config.h"
32 
33 // STL
34 #include <set>
35 #include <vector>
36 #include <string>
37 
38 namespace te
39 {
40  namespace gm { class Envelope; }
41 
42  namespace da
43  {
44 // Forward declaration
45  class ObjectId;
46  class Expression;
47 
48  /*!
49  \class ObjectIdSet
50 
51  \brief This class represents a set of unique ids created in the same context. i.e. from the same data set.
52 
53  \sa DataSet, DataSetType, ObjectId
54  */
56  {
57  public:
58 
59  /*! \brief Constructor. */
61 
62  /*! \brief Copy Constructor. */
63  ObjectIdSet(const ObjectIdSet& rhs, bool copyOids = true);
64 
65  /*! \brief Destructor. */
67 
68  /*!
69  \brief It adds a property that will be used to generate the unique ids.
70 
71  \param name A property name that will be used to generate the unique ids.
72  \param name The property position.
73  \param type The property data type.
74  */
75  void addProperty(const std::string& name, std::size_t pos, int type);
76 
77  /*!
78  \brief It adds an object id to this object id set.
79 
80  \param The object id that will be added.
81 
82  \note This class will take the ownership of the given pointer.
83  */
84  void add(ObjectId* oid);
85 
86 
87  /*!
88  \brief It set the expression that can be used to retrieve the data set that contains the all indentified elements.
89 
90  \param expression The expression that can be used to retrieve the data set that contains the all indentified elements.
91 
92  \note This method will take the ownership of the given pointer.
93  */
94  void setExpression(te::da::Expression* expression, bool isClauseIn);
95 
96  void setExpressionByIntersection(const std::string& geomAttrName, const te::gm::Envelope& env, int srid);
97 
98  void setExpressionByInClause(const std::string& source = "");
99 
100  /*!
101  \brief It returns the expression that can be used to retrieve the data set that contains the all indentified elements.
102 
103  \return The expression that can be used to retrieve the data set that contains the all indentified elements.
104 
105  \note The caller will take the ownership of the given pointer.
106  */
108 
109  Expression* getExpressionByInClause(const std::string& source = "") const;
110 
111  /*!
112  \brief It clears this object id set.
113  */
114  void clear();
115 
116  /*!
117  \brief It returns the object id set size.
118 
119  \return The object id set size.
120  */
121  std::size_t size() const;
122 
123  /*!
124  \brief It returns the property names used to generated the oids.
125 
126  \return The property names used to generated the oids.
127  */
128  const std::vector<std::string>& getPropertyNames() const;
129 
130  /*!
131  \brief It returns the property positions used to generated the oids.
132 
133  \return The property positions used to generated the oids.
134  */
135  const std::vector<std::size_t>& getPropertyPos() const;
136 
137  /*!
138  \brief It returns the property types used to generated the oids.
139 
140  \return The property types used to generated the oids.
141  */
142  const std::vector<int>& getPropertyTypes() const;
143 
144  /*!
145  \brief It returns if the object id set contains the given oid.
146 
147  \param oid The object id that will be searched.
148 
149  \return True if the object id set contains the given oid. False, otherwise.
150 
151  \note The ObjectIdSet will NOT take the ownership of the given pointer.
152  */
153  bool contains(ObjectId* oid) const;
154 
155  /*!
156  \brief Removes the object id from set.
157 
158  \param oid Object id to be removed.
159 
160  \note This WILL NOT take the ownership of \a oid.
161  */
162  void remove(ObjectId* oid);
163 
164  /*!
165  \brief It performs the union operation between this ObjectIdSet and the given ObjectIdSet.
166 
167  \param rhs A valid ObjectIdSet that will be used on union operation. Do not pass NULL!
168 
169  \note The ObjectIdSet will take the ownership of the given pointer.
170 
171  \note The given pointer will be invalidated at end of union operation.
172  */
173  void Union(ObjectIdSet* rhs);
174 
175  /*!
176  \brief It performs the difference operation between this ObjectIdSet and the given ObjectIdSet.
177 
178  \param rhs A valid ObjectIdSet that will be used on difference operation. Do not pass NULL!
179 
180  \note The ObjectIdSet will NOT take the ownership of the given pointer.
181  */
182  void difference(const ObjectIdSet* rhs);
183 
184  /*!
185  \brief It performs the symmetric difference operation between this ObjectIdSet and the given ObjectIdSet.
186 
187  \param rhs A valid ObjectIdSet that will be used on difference operation. Do not pass NULL!
188 
189  \note The ObjectIdSet will NOT take the ownership of the given pointer.
190  */
191  void symDifference(const ObjectIdSet* rhs);
192 
193  /*!
194  \brief Returns an iterator for the object ids in container
195 
196  \return Iterator for the begin element of the container.
197 
198  \note When using the iterators it WILL NOT give the ownership of the pointers.
199  This means that the caller MUST NOT delete the pointers or it will lead to an inconsistent state.
200  */
201  std::set<ObjectId*, te::common::LessCmp<ObjectId*> >::const_iterator begin() const;
202 
203  /*!
204  \brief Returns an iterator for the object ids in container
205 
206  \return Iterator for the ending element of the container.
207  */
208  std::set<ObjectId*, te::common::LessCmp<ObjectId*> >::const_iterator end() const;
209 
210  ObjectIdSet* clone() const;
211 
212  bool isExpressionClauseIn() const;
213 
214  private:
215 
216  std::vector<std::string> m_pnames; //!< The list of property names used to generate the unique ids.
217  std::vector<std::size_t> m_ppos; //!< The list of property positions used to generate the unique ids.
218  std::vector<int> m_ptypes; //!< The list of property types used to generate the unique ids.
219  std::set<ObjectId*, te::common::LessCmp<ObjectId*> > m_oids; //!< The set of unique ids.
220  te::da::Expression* m_expression; //!< The expression that can be used to retrieve the data set that contains the all indentified elements.
221 
223  };
224 
225  } // end namespace da
226 } // end namespace te
227 
228 #endif // __TERRALIB_DATAACCESS_INTERNAL_OBJECTIDSET_H
te::da::ObjectIdSet::~ObjectIdSet
~ObjectIdSet()
Destructor.
te::gm::Envelope
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
te::da::ObjectIdSet::getPropertyPos
const std::vector< std::size_t > & getPropertyPos() const
It returns the property positions used to generated the oids.
te::da::ObjectId
This class represents an unique id for a data set element.
Definition: ObjectId.h:48
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::da::ObjectIdSet::end
std::set< ObjectId *, te::common::LessCmp< ObjectId * > >::const_iterator end() const
Returns an iterator for the object ids in container.
te::da::ObjectIdSet::getExpression
Expression * getExpression() const
It returns the expression that can be used to retrieve the data set that contains the all indentified...
te::da::ObjectIdSet::clone
ObjectIdSet * clone() const
te::da::ObjectIdSet::setExpressionByInClause
void setExpressionByInClause(const std::string &source="")
te::da::ObjectIdSet::m_pnames
std::vector< std::string > m_pnames
The list of property names used to generate the unique ids.
Definition: ObjectIdSet.h:216
te::da::ObjectIdSet::begin
std::set< ObjectId *, te::common::LessCmp< ObjectId * > >::const_iterator begin() const
Returns an iterator for the object ids in container.
te::da::ObjectIdSet::setExpression
void setExpression(te::da::Expression *expression, bool isClauseIn)
It set the expression that can be used to retrieve the data set that contains the all indentified ele...
TEDATAACCESSEXPORT
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:97
te::da::ObjectIdSet::addProperty
void addProperty(const std::string &name, std::size_t pos, int type)
It adds a property that will be used to generate the unique ids.
te::da::ObjectIdSet::ObjectIdSet
ObjectIdSet()
Constructor.
te::da::ObjectIdSet::symDifference
void symDifference(const ObjectIdSet *rhs)
It performs the symmetric difference operation between this ObjectIdSet and the given ObjectIdSet.
te::da::Expression
This is an abstract class that models a query expression.
Definition: Expression.h:48
te::da::ObjectIdSet::remove
void remove(ObjectId *oid)
Removes the object id from set.
te::da::ObjectIdSet::m_ppos
std::vector< std::size_t > m_ppos
The list of property positions used to generate the unique ids.
Definition: ObjectIdSet.h:217
te::da::ObjectIdSet::m_ptypes
std::vector< int > m_ptypes
The list of property types used to generate the unique ids.
Definition: ObjectIdSet.h:218
te::da::ObjectIdSet::m_oids
std::set< ObjectId *, te::common::LessCmp< ObjectId * > > m_oids
The set of unique ids.
Definition: ObjectIdSet.h:219
te::da::ObjectIdSet::setExpressionByIntersection
void setExpressionByIntersection(const std::string &geomAttrName, const te::gm::Envelope &env, int srid)
te::da::ObjectIdSet::m_expByClauseIn
bool m_expByClauseIn
Definition: ObjectIdSet.h:222
te::da::ObjectIdSet::getExpressionByInClause
Expression * getExpressionByInClause(const std::string &source="") const
te::da::ObjectIdSet::getPropertyTypes
const std::vector< int > & getPropertyTypes() const
It returns the property types used to generated the oids.
te::da::ObjectIdSet::getPropertyNames
const std::vector< std::string > & getPropertyNames() const
It returns the property names used to generated the oids.
te::da::ObjectIdSet::Union
void Union(ObjectIdSet *rhs)
It performs the union operation between this ObjectIdSet and the given ObjectIdSet.
te::da::ObjectIdSet::contains
bool contains(ObjectId *oid) const
It returns if the object id set contains the given oid.
te::da::ObjectIdSet::clear
void clear()
It clears this object id set.
te::da::ObjectIdSet::size
std::size_t size() const
It returns the object id set size.
te::da::ObjectIdSet::isExpressionClauseIn
bool isExpressionClauseIn() const
te::da::ObjectIdSet::m_expression
te::da::Expression * m_expression
The expression that can be used to retrieve the data set that contains the all indentified elements.
Definition: ObjectIdSet.h:220
te::da::ObjectIdSet::ObjectIdSet
ObjectIdSet(const ObjectIdSet &rhs, bool copyOids=true)
Copy Constructor.
te::da::ObjectIdSet::add
void add(ObjectId *oid)
It adds an object id to this object id set.
te::da::ObjectIdSet
This class represents a set of unique ids created in the same context. i.e. from the same data set.
Definition: ObjectIdSet.h:56
te::da::ObjectIdSet::difference
void difference(const ObjectIdSet *rhs)
It performs the difference operation between this ObjectIdSet and the given ObjectIdSet.