GEOS  3.13.0dev
planargraph/GraphComponent.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2001-2002 Vivid Solutions Inc.
7  * Copyright (C) 2005-2006 Refractions Research Inc.
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU Lesser General Public Licence as published
11  * by the Free Software Foundation.
12  * See the COPYING file for more information.
13  *
14  **********************************************************************
15  *
16  * Last port: planargraph/GraphComponent.java rev. 1.7 (JTS-1.7)
17  *
18  **********************************************************************/
19 
20 #pragma once
21 
22 #include <geos/export.h>
23 
24 namespace geos {
25 namespace planargraph { // geos.planargraph
26 
45 class GEOS_DLL GraphComponent {
46 
47 protected:
48 
51 
54 
55 public:
56 
58  :
59  isMarkedVar(false),
60  isVisitedVar(false)
61  {}
62 
63  virtual
64  ~GraphComponent() {}
65 
72  virtual bool
73  isVisited() const
74  {
75  return isVisitedVar;
76  }
77 
82  virtual void
83  setVisited(bool p_isVisited)
84  {
85  isVisitedVar = p_isVisited;
86  }
87 
96  template <typename T>
97  static void
98  setVisited(T start, T end, bool visited)
99  {
100  for(T i = start; i != end; ++i) {
101  (*i)->setVisited(visited);
102  }
103  }
104 
113  template <typename T>
114  static void
115  setVisitedMap(T start, T end, bool visited)
116  {
117  for(T i = start; i != end; ++i) {
118  i->second->setVisited(visited);
119  }
120  }
121 
130  template <typename T>
131  static void
132  setMarked(T start, T end, bool marked)
133  {
134  for(T i = start; i != end; ++i) {
135  (*i)->setMarked(marked);
136  }
137  }
138 
139 
148  template <typename T>
149  static void
150  setMarkedMap(T start, T end, bool marked)
151  {
152  for(T i = start; i != end; ++i) {
153  i->second->setMarked(marked);
154  }
155  }
156 
162  virtual bool
163  isMarked() const
164  {
165  return isMarkedVar;
166  }
167 
172  virtual void
173  setMarked(bool p_isMarked)
174  {
175  isMarkedVar = p_isMarked;
176  }
177 
178 };
179 
180 } // namespace geos::planargraph
181 } // namespace geos
182 
The base class for all graph component classes.
Definition: planargraph/GraphComponent.h:45
static void setVisited(T start, T end, bool visited)
Sets the Visited state for the elements of a container, from start to end iterator.
Definition: planargraph/GraphComponent.h:98
virtual void setVisited(bool p_isVisited)
Sets the visited flag for this component.
Definition: planargraph/GraphComponent.h:83
static void setMarkedMap(T start, T end, bool marked)
Sets the Marked state for the values of each map container element, from start to end iterator.
Definition: planargraph/GraphComponent.h:150
virtual void setMarked(bool p_isMarked)
Sets the marked flag for this component.
Definition: planargraph/GraphComponent.h:173
static void setMarked(T start, T end, bool marked)
Sets the Marked state for the elements of a container, from start to end iterator.
Definition: planargraph/GraphComponent.h:132
static void setVisitedMap(T start, T end, bool visited)
Sets the Visited state for the values of each map container element, from start to end iterator.
Definition: planargraph/GraphComponent.h:115
bool isMarkedVar
Variable holding ''marked'' status.
Definition: planargraph/GraphComponent.h:50
bool isVisitedVar
Variable holding ''visited'' status.
Definition: planargraph/GraphComponent.h:53
virtual bool isVisited() const
Tests if a component has been visited during the course of a graph algorithm.
Definition: planargraph/GraphComponent.h:73
virtual bool isMarked() const
Tests if a component has been marked at some point during the processing involving this graph.
Definition: planargraph/GraphComponent.h:163
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25