Gbox 4.20
Grow box automation and monitoring - <a href='https://sites.google.com/site/growboxguy/'>https://sites.google.com/site/growboxguy/</a>
 
Loading...
Searching...
No Matches
FP.h
Go to the documentation of this file.
1
23#ifndef FP_H
24#define FP_H
25
134template<class retT, class argT>
135class FP
136{
137public:
140 FP();
141
146 template<class T>
147 void attach(T *item, retT (T::*method)(argT))
148 {
149 obj_callback = (FPtrDummy *)(item);
150 method_callback = (retT (FPtrDummy::*)(argT))(method);
151 return;
152 }
153
157 void attach(retT (*function)(argT));
158
163 retT operator()(argT arg) const;
164
165 bool attached();
166
167 void detach();
168
169private:
170
171 // empty type used for casting
172 class FPtrDummy;
173
174 FPtrDummy *obj_callback;
175
180 union
181 {
182 retT (*c_callback)(argT);
183 retT (FPtrDummy::*method_callback)(argT);
184 };
185};
186
187#endif
188
API abstraction for a Function Pointers.
Definition FP.h:136
void detach()
Definition FP.cpp:41
retT(* c_callback)(argT)
Definition FP.h:182
bool attached()
Definition FP.cpp:34
retT(FPtrDummy::* method_callback)(argT)
Definition FP.h:183
FP()
Definition FP.cpp:27
retT operator()(argT arg) const
Definition FP.cpp:55
void attach(T *item, retT(T::*method)(argT))
Definition FP.h:147