All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ObjectIdSet.h
Go to the documentation of this file.
1 /* Copyright (C) 2008-2013 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 da
41  {
42 // Forward declaration
43  class ObjectId;
44  class Expression;
45 
46  /*!
47  \class ObjectIdSet
48 
49  \brief This class represents a set of unique ids created in the same context. i.e. from the same data set.
50 
51  \sa DataSet, DataSetType, ObjectId
52  */
54  {
55  public:
56 
57  /*! \brief Constructor. */
58  ObjectIdSet();
59 
60  /*! \brief Copy Constructor. */
61  ObjectIdSet(const ObjectIdSet& rhs, bool copyOids = true);
62 
63  /*! \brief Destructor. */
64  ~ObjectIdSet();
65 
66  /*!
67  \brief It adds a property that will be used to generate the unique ids.
68 
69  \param name A property name that will be used to generate the unique ids.
70  \param name The property position.
71  \param type The property data type.
72  */
73  void addProperty(const std::string& name, std::size_t pos, int type);
74 
75  /*!
76  \brief It adds an object id to this object id set.
77 
78  \param The object id that will be added.
79 
80  \note This class will take the ownership of the given pointer.
81  */
82  void add(ObjectId* oid);
83 
84  /*!
85  \brief It returns the expression that can be used to retrieve the data set that contains the all indentified elements.
86 
87  \return The expression that can be used to retrieve the data set that contains the all indentified elements.
88 
89  \note The caller will take the ownership of the given pointer.
90  */
91  Expression* getExpression(const std::string source = "") const;
92 
93  /*!
94  \brief It clears this object id set.
95  */
96  void clear();
97 
98  /*!
99  \brief It returns the object id set size.
100 
101  \return The object id set size.
102  */
103  std::size_t size() const;
104 
105  /*!
106  \brief It returns the property names used to generated the oids.
107 
108  \return The property names used to generated the oids.
109  */
110  const std::vector<std::string>& getPropertyNames() const;
111 
112  /*!
113  \brief It returns the property positions used to generated the oids.
114 
115  \return The property positions used to generated the oids.
116  */
117  const std::vector<std::size_t>& getPropertyPos() const;
118 
119  /*!
120  \brief It returns the property types used to generated the oids.
121 
122  \return The property types used to generated the oids.
123  */
124  const std::vector<int>& getPropertyTypes() const;
125 
126  /*!
127  \brief It returns if the object id set contains the given oid.
128 
129  \param oid The object id that will be searched.
130 
131  \return True if the object id set contains the given oid. False, otherwise.
132 
133  \note The ObjectIdSet will NOT take the ownership of the given pointer.
134  */
135  bool contains(ObjectId* oid) const;
136 
137  /*!
138  \brief Removes the object id from set.
139 
140  \param oid Object id to be removed.
141 
142  \note This WILL NOT take the ownership of \a oid.
143  */
144  void remove(ObjectId* oid);
145 
146  /*!
147  \brief It performs the union operation between this ObjectIdSet and the given ObjectIdSet.
148 
149  \param rhs A valid ObjectIdSet that will be used on union operation. Do not pass NULL!
150 
151  \note The ObjectIdSet will take the ownership of the given pointer.
152 
153  \note The given pointer will be invalidated at end of union operation.
154  */
155  void Union(ObjectIdSet* rhs);
156 
157  /*!
158  \brief It performs the difference operation between this ObjectIdSet and the given ObjectIdSet.
159 
160  \param rhs A valid ObjectIdSet that will be used on difference operation. Do not pass NULL!
161 
162  \note The ObjectIdSet will NOT take the ownership of the given pointer.
163  */
164  void difference(const ObjectIdSet* rhs);
165 
166  /*!
167  \brief It performs the symmetric difference operation between this ObjectIdSet and the given ObjectIdSet.
168 
169  \param rhs A valid ObjectIdSet that will be used on difference operation. Do not pass NULL!
170 
171  \note The ObjectIdSet will NOT take the ownership of the given pointer.
172  */
173  void symDifference(const ObjectIdSet* rhs);
174 
175  /*!
176  \brief Returns an iterator for the object ids in container
177 
178  \return Iterator for the begin element of the container.
179 
180  \note When using the iterators it WILL NOT give the ownership of the pointers.
181  This means that the caller MUST NOT delete the pointers or it will lead to an inconsistent state.
182  */
183  std::set<ObjectId*, te::common::LessCmp<ObjectId*> >::const_iterator begin() const;
184 
185  /*!
186  \brief Returns an iterator for the object ids in container
187 
188  \return Iterator for the ending element of the container.
189  */
190  std::set<ObjectId*, te::common::LessCmp<ObjectId*> >::const_iterator end() const;
191 
192  ObjectIdSet* clone() const;
193 
194  private:
195 
196  std::vector<std::string> m_pnames; //!< The list of property names used to generate the unique ids.
197  std::vector<std::size_t> m_ppos; //!< The list of property positions used to generate the unique ids.
198  std::vector<int> m_ptypes; //!< The list of property types used to generate the unique ids.
199  std::set<ObjectId*, te::common::LessCmp<ObjectId*> > m_oids; //!< The set of unique ids.
200  };
201 
202  } // end namespace da
203 } // end namespace te
204 
205 #endif // __TERRALIB_DATAACCESS_INTERNAL_OBJECTIDSET_H
std::vector< std::string > m_pnames
The list of property names used to generate the unique ids.
Definition: ObjectIdSet.h:196
This is an abstract class that models a query expression.
Definition: Expression.h:47
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:53
This class represents an unique id for a data set element.
Definition: ObjectId.h:47
std::set< ObjectId *, te::common::LessCmp< ObjectId * > > m_oids
The set of unique ids.
Definition: ObjectIdSet.h:199
std::vector< std::size_t > m_ppos
The list of property positions used to generate the unique ids.
Definition: ObjectIdSet.h:197
std::vector< int > m_ptypes
The list of property types used to generate the unique ids.
Definition: ObjectIdSet.h:198
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:100