Visualization Library 2.1.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Visitor.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef VLXVisitor_INCLUDE_ONCE
33 #define VLXVisitor_INCLUDE_ONCE
34 
35 #include <vlCore/Object.hpp>
36 #include <set>
37 
38 namespace vlX
39 {
40  class VLXStructure;
41  class VLXList;
42  class VLXRawtextBlock;
43  class VLXArray;
44  class VLXArrayInteger;
45  class VLXArrayReal;
46  /*
47  class VLXArrayString;
48  class VLXArrayIdentifier;
49  class VLXArrayID;
50  */
51  //-----------------------------------------------------------------------------
53  class Visitor: public vl::Object
54  {
56 
57  public:
58  virtual void visitStructure(VLXStructure*) {}
59  virtual void visitList(VLXList*) {}
61  virtual void visitArray(VLXArrayInteger*) {}
62  virtual void visitArray(VLXArrayReal*) {}
63  /*
64  virtual void visitArray(VLXArrayString*) {}
65  virtual void visitArray(VLXArrayIdentifier*) {}
66  virtual void visitArray(VLXArrayID*) {}
67  */
68 
69  bool isVisited(void* node)
70  {
71  std::set< void* >::iterator it = mVisited.find(node);
72  if (it == mVisited.end())
73  {
74  mVisited.insert(node);
75  return false;
76  }
77  else
78  return true;
79  }
80 
81  void resetVisitedNodes() { mVisited.clear(); };
82 
83  private:
84  std::set< void* > mVisited;
85  };
86 }
87 
88 #endif
void resetVisitedNodes()
Definition: Visitor.hpp:81
An array of 64 bits floating point numbers, can also have a tag.
Definition: Value.hpp:144
virtual void visitArray(VLXArrayReal *)
Definition: Visitor.hpp:62
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
A list of key/VLXValue pairs, can also have a tag.
Definition: Value.hpp:541
A simple sequence of VLXValue objects, can also have a tag.
Definition: Value.hpp:634
The base class for all the reference counted objects.
Definition: Object.hpp:158
virtual void visitList(VLXList *)
Definition: Visitor.hpp:59
An array of 64 bits integers, can also have a tag.
Definition: Value.hpp:133
A block of raw text.
Definition: Value.hpp:71
Base class for all visitors visiting a VLX hierarchy.
Definition: Visitor.hpp:53
bool isVisited(void *node)
Definition: Visitor.hpp:69
virtual void visitArray(VLXArrayInteger *)
Definition: Visitor.hpp:61
virtual void visitRawtextBlock(VLXRawtextBlock *)
Definition: Visitor.hpp:60
virtual void visitStructure(VLXStructure *)
Definition: Visitor.hpp:58