All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Filter.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 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 Filter.cpp
22 
23  \brief A Filter is any valid predicate expression.
24  */
25 
26 // TerraLib
27 #include "../common/STLUtils.h"
28 #include "Filter.h"
29 
30 // STL
31 #include <cassert>
32 
34  : m_op(0),
35  m_ids(0)
36 {
37 }
38 
40 {
41  delete m_op;
42 
43  if(m_ids)
44  {
46  delete m_ids;
47  }
48 }
49 
51 {
52  delete m_op;
53  m_op = o;
54 }
55 
57 {
58  return m_op;
59 }
60 
62 {
63  if(m_ids == 0)
64  m_ids = new std::vector<ObjectId*>;
65 
66  m_ids->push_back(id);
67 }
68 
70 {
71  assert(m_ids && (i < m_ids->size()));
72  return (*m_ids)[i];
73 }
74 
76 {
77  assert(m_ids && (i < m_ids->size()));
78  return (*m_ids)[i];
79 }
80 
82 {
83  return (m_ids ? m_ids->size() : 0);
84 }
85 
87 {
88  delete m_op;
89  m_op = 0;
90 
91  if(m_ids)
92  {
94  delete m_ids;
95  m_ids = 0;
96  }
97 }
98 
ObjectId * operator[](size_t i) const
It returns a specified object identifier.
Definition: Filter.cpp:69
ObjectId * getOid(size_t i) const
It returns a specified object identifier.
Definition: Filter.cpp:75
Filter()
It initializes a new Filter.
Definition: Filter.cpp:33
AbstractOp * getOp() const
It returns main filter operation.
Definition: Filter.cpp:56
A Filter is any valid predicate expression.
void setOp(AbstractOp *o)
It sets the filter main operation (expression).
Definition: Filter.cpp:50
size_t getNumberOfOids() const
It returns the size of the list of object identifiers.
Definition: Filter.cpp:81
An object identifier is meant to represent a unique identifier for an object instance within the cont...
Definition: ObjectId.h:58
void clear()
It clears the object identifier list and drop it off.
Definition: Filter.cpp:86
An abstract interface for operators.
Definition: AbstractOp.h:47
void add(ObjectId *id)
It adds the object identifier to the list of identifiers.
Definition: Filter.cpp:61
~Filter()
Destructor.
Definition: Filter.cpp:39
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
Definition: BoostUtils.h:55