BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
node_progeny Namespace Reference

Functions

template<typename T >
std::vector< const T * > AllDescendantsOfType (const INode &node)
 
template<typename T >
std::vector< const T * > ChildNodesOfType (const INode &node)
 
template<typename T >
const T * OnlyChildOfType (const INode &node)
 

Function Documentation

◆ AllDescendantsOfType()

template<typename T >
std::vector<const T*> node_progeny::AllDescendantsOfType ( const INode node)

Definition at line 45 of file NodeProgeny.h.

46 {
47  std::vector<const T*> result;
48  for (const auto* p_child : node.getChildren()) {
49  if (const auto* t = dynamic_cast<const T*>(p_child))
50  result.push_back(t);
51  for (const auto* t : AllDescendantsOfType<T>(*p_child))
52  result.push_back(t);
53  }
54  return result;
55 }
virtual std::vector< const INode * > getChildren() const
Returns a vector of children.
Definition: INode.cpp:63

References INode::getChildren().

Here is the call graph for this function:

◆ ChildNodesOfType()

template<typename T >
std::vector<const T*> node_progeny::ChildNodesOfType ( const INode node)

Definition at line 27 of file NodeProgeny.h.

28 {
29  std::vector<const T*> result;
30  for (const auto& p_child : node.getChildren()) {
31  if (const auto* t = dynamic_cast<const T*>(p_child))
32  result.push_back(t);
33  }
34  return result;
35 }

References INode::getChildren().

Here is the call graph for this function:

◆ OnlyChildOfType()

template<typename T >
const T* node_progeny::OnlyChildOfType ( const INode node)

Definition at line 37 of file NodeProgeny.h.

38 {
39  const auto list = ChildNodesOfType<T>(node);
40  if (list.size() != 1)
41  return nullptr;
42  return list.front();
43 }