OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
gfx_node_visitor.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_GFX_NODE_VISITOR_HH
20 #define OST_GFX_NODE_VISITOR_HH
21 
22 /*
23  Author: Ansgar Philippsen
24 */
25 
26 #include <stack>
27 
28 #include <ost/gfx/module_config.hh>
29 #include "gfx_node_fw.hh"
30 #include "gfx_object_fw.hh"
31 
32 namespace ost { namespace gfx {
33 
35 {
36 public:
37  // in the below methods, contains the 'path' to the current
38  // node or obj, where top() returns the direct parent
39  typedef std::stack<GfxNode*> Stack;
40 
41  virtual void OnStart() {}
42  virtual void OnEnd() {}
43 
44  // is called for each base node in the hierarchy
45  // expected to return true if descent into child nodes is wanted
46  virtual bool VisitNode(GfxNode* node, const Stack& st) {return true;}
47 
48  // is called for each leaf
49  virtual void VisitObject(GfxObj* obj, const Stack& st) {}
50 
51  // is called just before returning to parent hierarchy
52  virtual void LeaveNode(GfxNode* node, const Stack& st) {}
53 
54  virtual ~GfxNodeVisitor() {}
55 };
56 
57 }} // ns
58 
59 #endif
main class for all graphic objects
Definition: gfx_object.hh:51
virtual void LeaveNode(GfxNode *node, const Stack &st)
#define DLLEXPORT_OST_GFX
std::stack< GfxNode * > Stack
virtual bool VisitNode(GfxNode *node, const Stack &st)
virtual void VisitObject(GfxObj *obj, const Stack &st)