All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Node.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 Node.h
22 
23  \brief A class that represents an R-tree node.
24 */
25 
26 #ifndef __TERRALIB_SAM_RTREE_INTERNAL_NODE_H
27 #define __TERRALIB_SAM_RTREE_INTERNAL_NODE_H
28 
29 // TerraLib
30 #include "Branch.h"
31 
32 namespace te
33 {
34  namespace sam
35  {
36  namespace rtree
37  {
38  /*!
39  \class Node
40 
41  \brief A class that represents an R-tree node.
42 
43  Level 0 indicates that this is a leaf node, other values indicate that it is an internal node.
44  */
45  template<class DATATYPE, int MAXNODES = 8, int MINNODES = MAXNODES / 2> class Node
46  {
47  public:
48 
50 
51  /*! \brief Constructor. */
52  Node()
53  : m_count(0), m_level(-1)
54  {
55  }
56 
57  /*!
58  \brief It returns true if this is a internal node.
59 
60  \return True if this is a internal node and false if it is a leaf.
61  */
62  bool isInternalNode() const
63  {
64  return (m_level > 0);
65  }
66 
67  /*!
68  \brief It returns true if this is a leaf node.
69 
70  \return True if this is a leaf node and false if it is internal.
71  */
72  bool isLeaf() const
73  {
74  return (m_level == 0);
75  }
76 
77  /*! \brief This method is used during split when a node retained and used again (beeing re-filled). */
78  void init()
79  {
80  m_count = 0;
81  m_level = -1;
82  }
83 
84  private:
85 
86  /*!
87  \brief No copy constructor allowed.
88 
89  \param rhs The other geometry.
90  */
91  Node(const Node& rhs);
92 
93  /*!
94  \brief No assignment operator allowed.
95 
96  \param rhs The other geometry.
97 
98  \return A reference for this.
99  */
100  Node& operator=(const Node& rhs);
101 
102 
103  public:
104 
105  int m_count; //!< The number of elements in the node (count).
106  int m_level; //!< Leaf is zero, others positive.
107  BranchType m_branch[MAXNODES]; //!< Branches.
108  };
109 
110  } // end namespace rtree
111  } // end namespace sam
112 } // end namespace te
113 
114 
115 #endif // __TERRALIB_SAM_RTREE_INTERNAL_NODE_H
116 
A struct that represents a node-branch in an R-tree.
A class that represents an R-tree node.
Definition: Node.h:45
void init()
This method is used during split when a node retained and used again (beeing re-filled).
Definition: Node.h:78
bool isInternalNode() const
It returns true if this is a internal node.
Definition: Node.h:62
int m_level
Leaf is zero, others positive.
Definition: Node.h:106
int m_count
The number of elements in the node (count).
Definition: Node.h:105
Node & operator=(const Node &rhs)
No assignment operator allowed.
Node()
Constructor.
Definition: Node.h:52
BranchType m_branch[MAXNODES]
Branches.
Definition: Node.h:107
bool isLeaf() const
It returns true if this is a leaf node.
Definition: Node.h:72
te::sam::rtree::Branch< Node, DATATYPE > BranchType
Definition: Node.h:49