AutoPas  3.0.0
Loading...
Searching...
No Matches
OctreeStaticNodeSelector.h
Go to the documentation of this file.
1
7#pragma once
8
9#include <memory>
10
14
15namespace autopas {
16template <typename Particle_T>
17class OctreeInnerNode;
18
28template <typename Particle_T, typename FunctionType>
29decltype(auto) withStaticNodeType(const std::unique_ptr<OctreeNodeInterface<Particle_T>> &root,
30 FunctionType &&function) {
31 OctreeNodeInterface<Particle_T> *nodePtr = root.get();
32 // TODO: These should be static casts because we already do the runtime check via hasChildren()
33 if (nodePtr->hasChildren()) {
34 return function(dynamic_cast<OctreeInnerNode<Particle_T> *>(nodePtr));
35 } else {
36 return function(dynamic_cast<OctreeLeafNode<Particle_T> *>(nodePtr));
37 }
38}
39} // namespace autopas
Inner nodes of the octree data structure.
Definition: OctreeInnerNode.h:23
An octree leaf node.
Definition: OctreeLeafNode.h:27
The base class that provides the necessary function definitions that can be applied to an octree.
Definition: OctreeNodeInterface.h:32
virtual bool hasChildren()=0
Check if the node is a leaf or an inner node.
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32
decltype(auto) withStaticNodeType(const std::unique_ptr< OctreeNodeInterface< Particle_T > > &root, FunctionType &&function)
Will execute the passed function on the given root node.
Definition: OctreeStaticNodeSelector.h:29