scg3  0.6
Node.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright 2014 Volker Ahlers
11  *
12  * Licensed under the Apache License, Version 2.0 (the "License");
13  * you may not use this file except in compliance with the License.
14  * You may obtain a copy of the License at
15  *
16  * http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS,
20  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  */
24 
25 #ifndef NODE_H_
26 #define NODE_H_
27 
28 #include <string>
29 #include <unordered_map>
30 #include <vector>
31 #include "scg_internals.h"
32 
33 namespace scg {
34 
35 
47 class Node {
48 
49  friend class Composite;
50 
51 public:
52 
56  Node();
57 
61  virtual ~Node() = 0;
62 
66  virtual void clear();
67 
71  virtual void destroy();
72 
76  int getNCores() const;
77 
83  const std::string& getMetaInfo(const std::string& key) const;
84 
90  void setMetaInfo(const std::string& key, const std::string& value);
91 
95  bool isVisible() const;
96 
100  void setVisible(bool isVisible = true);
101 
105  virtual void traverse(Traverser* traverser) = 0;
106 
110  virtual void accept(Traverser* traverser);
111 
115  virtual void render(RenderState* renderState);
116 
117 protected:
118 
123  void addSibling_(NodeSP sibling);
124 
131  void removeSibling_(Node* node, bool& result);
132 
137  void processCores_(RenderState* renderState);
138 
143  void postProcessCores_(RenderState* renderState);
144 
145 protected:
146 
149  std::vector<CoreSP> cores_;
151  mutable std::unordered_map<std::string, std::string> metaInfo_;
152 
153 };
154 
155 
156 } /* namespace scg */
157 
158 #endif /* NODE_H_ */
void addSibling_(NodeSP sibling)
virtual ~Node()=0
void setMetaInfo(const std::string &key, const std::string &value)
Base class for all composite nodes, i.e., nodes with children (composite pattern, abstract).
Definition: Composite.h:37
int getNCores() const
void postProcessCores_(RenderState *renderState)
void setVisible(bool isVisible=true)
virtual void destroy()
virtual void accept(Traverser *traverser)
NodeSP rightSibling_
Definition: Node.h:147
Base class for all traversers (visitor pattern, abstract).
Definition: Traverser.h:36
virtual void traverse(Traverser *traverser)=0
bool isVisible_
Definition: Node.h:150
bool isVisible() const
The central render state that collects information about the current shader, transformations,...
Definition: RenderState.h:107
std::unordered_map< std::string, std::string > metaInfo_
Definition: Node.h:151
std::vector< CoreSP > cores_
Definition: Node.h:149
Definition: Animation.h:28
virtual void render(RenderState *renderState)
const std::string & getMetaInfo(const std::string &key) const
Internal definitions required by most classes.
virtual void clear()
Base class for all nodes (composite pattern, abstract).
Definition: Node.h:47
void removeSibling_(Node *node, bool &result)
void processCores_(RenderState *renderState)
Composite * parent_
Definition: Node.h:148