object_list.h
Go to the documentation of this file.
1 
8 #pragma once
11 
12 namespace illumina {
13 namespace interop {
14 
15 
24  template<class T, class Base>
25  class object_list_node : public Base
26  {
28  protected:
30  typedef typename Base::base_t node_t;
31  protected:
37  {
38  return m_object;
39  }
44  const T& get_ref()const
45  {
46  return m_object;
47  }
53  template<typename UnaryOp>
54  static void visit(this_t& node, UnaryOp& op)
55  {
56  op(node.m_object);
57  node_t::visit(node, op);
58  }
64  template<typename UnaryOp>
65  static void visit(this_t& node, const UnaryOp& op)
66  {
67  op(node.m_object);
68  node_t::visit(node, op);
69  }
75  template<typename UnaryOp>
76  static void visit(const this_t& node, UnaryOp& op)
77  {
78  op(node.m_object);
79  node_t::visit(node, op);
80  }
86  template<typename UnaryOp>
87  static void visit(const this_t& node, const UnaryOp& op)
88  {
89  op(node.m_object);
90  node_t::visit(node, op);
91  }
92 
93  private:
94  T m_object;
95  };
96 
99  struct last_node
100  {
102  typedef last_node base_t;
105  template<typename UnaryOp>
106  static void visit(const last_node&, const UnaryOp&){}
107  };
108 
111  template<class TypeList>
112  class object_list : protected hierarchy::linear_hierarchy<TypeList, interop::object_list_node, last_node>
113  {
114  typedef last_node root_type;
116  public:
121  template<class T>
122  T& get()
123  {
125  return current_t::get_ref();
126  }
131  template<class T>
132  const T& get()const
133  {
135  return current_t::get_ref();
136  }
141  template<typename UnaryOp>
142  void apply(UnaryOp& op)
143  {
144  parent_t::visit(*this, op);
145  }
150  template<typename UnaryOp>
151  void apply(UnaryOp& op)const
152  {
153  parent_t::visit(*this, op);
154  }
159  template<typename UnaryOp>
160  void apply(const UnaryOp& op)
161  {
162  parent_t::visit(*this, op);
163  }
168  template<typename UnaryOp>
169  void apply(const UnaryOp& op)const
170  {
171  parent_t::visit(*this, op);
172  }
173  };
174 
175 }
176 }
177 
T & get_ref()
Definition: object_list.h:36
Definition: enum_description.h:15
void apply(UnaryOp &op)
Definition: object_list.h:142
const T & get_ref() const
Definition: object_list.h:44
Definition: linear_hierarchy.h:21
void apply(UnaryOp &op) const
Definition: object_list.h:151
static void visit(const this_t &node, UnaryOp &op)
Definition: object_list.h:76
static void visit(const this_t &node, const UnaryOp &op)
Definition: object_list.h:87
void apply(const UnaryOp &op) const
Definition: object_list.h:169
Definition: object_list.h:25
static void visit(const last_node &, const UnaryOp &)
Definition: object_list.h:106
Base::base_t node_t
Definition: object_list.h:30
static void visit(this_t &node, const UnaryOp &op)
Definition: object_list.h:65
last_node base_t
Definition: object_list.h:102
Definition: enums.h:301
Definition: object_list.h:99
Definition: object_list.h:112
void apply(const UnaryOp &op)
Definition: object_list.h:160
static void visit(this_t &node, UnaryOp &op)
Definition: object_list.h:54
Definition: linear_hierarchy.h:79