Libmacro  0.2
Libmacro is an extensible macro and hotkey library.
reference.h
Go to the documentation of this file.
1 /* Libmacro - A multi-platform, extendable macro and hotkey C library
2  Copyright (C) 2013 Jonathan Pelletier, New Paradigm Software
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
23 #ifndef MCR_EXTRAS_REFERENCES_REFERENCE_H_
24 #define MCR_EXTRAS_REFERENCES_REFERENCE_H_
25 
26 #include "mcr/extras/wrappers.h"
27 
28 namespace mcr
29 {
32 template<typename T>
33 class MCR_API Reference
34 {
35 public:
36  Reference(Libmacro &context, T *reference = nullptr) :
37  _context(&context), _reference(reference)
38  {
39  }
40  Reference(const Reference &) = default;
41  virtual ~Reference() {}
42  Reference &operator =(const Reference &) = delete;
43 
44  inline T &operator *() const
45  {
46  return *_reference;
47  }
48  inline T *operator ->() const
49  {
50  return _reference;
51  }
52  inline T *operator &() const
53  {
54  return _reference;
55  }
56  inline T *operator ()() const
57  {
58  return _reference;
59  }
60 
61  Libmacro &context() const
62  {
63  return _context;
64  }
65 private:
66  Libmacro *_context;
67  T *_reference;
68 };
69 
70 //typedef Reference<mcr_ISignal> ISignalBuilder;
71 //typedef Reference<mcr_Signal> SignalBuilder;
72 //typedef Reference<mcr_ITrigger> ITriggerBuilder;
73 //typedef Reference<mcr_Trigger> TriggerBuilder;
74 }
75 
76 #endif
C++ wrappers and extensions of C types.
Libmacro, by Jonathan Pelletier, New Paradigm Software. Alpha version.
Definition: classes.h:31