state_machine_cpp
attribute_tree.h
Go to the documentation of this file.
1 //
2 // Created by henri on 10/11/21.
3 //
4 
5 #ifndef STATE_MACHINE_CPP_ATTRIBUTE_TREE_H
6 #define STATE_MACHINE_CPP_ATTRIBUTE_TREE_H
7 
8 #include <array>
9 #include <memory>
10 
12 #include "layer.h"
13 
14 namespace state_machine_cpp {
15  template<class ...T> class AttributeTree;
16 }
17 
18 template<class HT, class ...QT>
20 
21  std::array<std::shared_ptr<AbstractLayer>, sizeof...(QT) + 1> m_layers;
22 
23  template<unsigned int N, class ...HX, class ...QX>
24  void initialize(Layer<HX...>* t_head, QX* ...t_queue) {
25  m_layers[N] = std::shared_ptr<Layer<HX...>>(t_head);
26  if constexpr (sizeof...(QX) > 0) {
27  initialize<N + 1>(t_queue...);
28  }
29  }
30 
31 protected:
32 
33  AbstractLayer& layer(unsigned int t_i) override {
34  return *m_layers[t_i].get();
35  }
36 
37 public:
38  AttributeTree() : m_layers({std::make_shared<HT>(), std::make_shared<QT>()... }) { }
39 
40  AttributeTree(HT* t_head, QT* ...t_queue) {
41  initialize<0>(t_head, t_queue...);
42  }
43 
44 };
45 
46 
47 #endif //STATE_MACHINE_CPP_ATTRIBUTE_TREE_H
layer.h
state_machine_cpp::AbstractAttributeTree
Definition: abstract_attribute_tree.h:17
state_machine_cpp
Definition: algorithm.h:14
state_machine_cpp::AbstractLayer
Definition: abstract_layer.h:12
state_machine_cpp::AttributeTree
Definition: attribute_tree.h:15
state_machine_cpp::AttributeTree< HT, QT... >::AttributeTree
AttributeTree(HT *t_head, QT *...t_queue)
Definition: attribute_tree.h:40
state_machine_cpp::Layer
Definition: layer.h:12
state_machine_cpp::AttributeTree< HT, QT... >::AttributeTree
AttributeTree()
Definition: attribute_tree.h:38
state_machine_cpp::AttributeTree< HT, QT... >::layer
AbstractLayer & layer(unsigned int t_i) override
Definition: attribute_tree.h:33
abstract_attribute_tree.h