BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
INodeVisitor.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Param/Node/INodeVisitor.cpp
6 //! @brief Implements class INodeVisitor.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************** //
14 
17 
18 void VisitNodesPreorder(const INode& node, INodeVisitor& visitor)
19 {
21  it.first();
22  while (!it.isDone()) {
23  visitor.setDepth(it.depth());
24  const INode* child = it.getCurrent();
25  child->accept(&visitor);
26  it.next();
27  }
28 }
29 
30 void VisitNodesPostorder(const INode& node, INodeVisitor& visitor)
31 {
33  it.first();
34  while (!it.isDone()) {
35  visitor.setDepth(it.depth());
36  const INode* child = it.getCurrent();
37  child->accept(&visitor);
38  it.next();
39  }
40 }
void VisitNodesPostorder(const INode &node, INodeVisitor &visitor)
void VisitNodesPreorder(const INode &node, INodeVisitor &visitor)
Defines class IterationStrategy and children.
Defines classes IteratorState, IteratorMemento and NodeIterator.
Visitor interface to visit ISample objects.
Definition: INodeVisitor.h:149
void setDepth(int depth)
Sets depth of the visitor in the composite hierarchy.
Definition: INodeVisitor.h:283
Base class for tree-like structures containing parameterized objects.
Definition: INode.h:49
virtual void accept(INodeVisitor *visitor) const =0
Calls the INodeVisitor's visit method.
Iterator through INode tree of objects.
Definition: NodeIterator.h:90
int depth() const
Definition: NodeIterator.h:132
const INode * getCurrent()
Definition: NodeIterator.h:122
bool isDone() const
Definition: NodeIterator.h:127