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. */
60  ObjectIdSet();
61 
62  /*! \brief Copy Constructor. */
63  ObjectIdSet(const ObjectIdSet& rhs, bool copyOids = true);
64 
65  /*! \brief Destructor. */
66  ~ObjectIdSet();
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(std::string geomAttrName, 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  */
107  Expression* getExpression() const;
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::Expression * m_expression
The expression that can be used to retrieve the data set that contains the all indentified elements...
Definition: ObjectIdSet.h:220
std::vector< std::string > m_pnames
The list of property names used to generate the unique ids.
Definition: ObjectIdSet.h:216
This is an abstract class that models a query expression.
Definition: Expression.h:47
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:55
This class represents an unique id for a data set element.
Definition: ObjectId.h:47
URI C++ Library.
std::set< ObjectId *, te::common::LessCmp< ObjectId * > > m_oids
The set of unique ids.
Definition: ObjectIdSet.h:219
std::vector< std::size_t > m_ppos
The list of property positions used to generate the unique ids.
Definition: ObjectIdSet.h:217
std::vector< int > m_ptypes
The list of property types used to generate the unique ids.
Definition: ObjectIdSet.h:218
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:97