Autowiring  1.0.3
A C++ Inversion of Control Framework
auto_in.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2015 Leap Motion, Inc. All rights reserved.
2 #pragma once
3 #include "auto_arg.h"
4 #include MEMORY_HEADER
5 #include <vector>
6 
7 class AutoPacket;
8 
9 namespace autowiring {
10 
11 template<class T>
12 class auto_arg;
13 
17 template<class T>
18 class auto_in
19 {
20 public:
21  auto_in(const T& value) :
22  m_value(value)
23  {}
24 
25 private:
26  const T& m_value;
27 
28 public:
29  operator const T&() const { return m_value; }
30  const T& operator*(void) const { return m_value; }
31  const T* operator->(void) const { return &m_value; }
32 };
33 
34 template<>
35 class auto_in<AutoPacket>
36 {
37 public:
38  auto_in(AutoPacket& packet) :
39  packet(packet)
40  {}
41 
42 private:
43  AutoPacket& packet;
44 
45 public:
46  operator AutoPacket&() const { return packet; }
47  AutoPacket& operator*(void) const { return packet; }
48  AutoPacket* operator->(void) const { return &packet; }
49 };
50 
51 template<class T>
52 class auto_in<T const **>
53 {
54 public:
55  auto_in(std::vector<const T*>&& values) :
56  m_values(std::move(values))
57  {}
58 
59 private:
60  const AutoPacket& packet;
61  std::vector<const T*> m_values;
62 
63 public:
64  operator const T**() { return &m_values[0]; }
65 };
66 
70 template<class T>
71 class auto_arg<auto_in<T>> :
72  public auto_arg<T>
73 {};
74 
75 }
STL namespace.
A decorator-style processing packet
Definition: AutoPacket.h:49
Reinterpret copied argument as input
Definition: auto_arg.h:30
Fundamental type of required input arguments of AutoFilter methods.
Definition: auto_arg.h:10
Definition: auto_arg.h:8