Last change
on this file since 1706 was
1536,
checked in by rgrieder, 16 years ago
|
added virtual destructors for NetworkCallback
|
-
Property svn:eol-style set to
native
|
File size:
578 bytes
|
Rev | Line | |
---|
[1529] | 1 | #ifndef _NETWORK_CALLBACK__ |
---|
| 2 | #define _NETWORK_CALLBACK__ |
---|
| 3 | |
---|
| 4 | namespace network{ |
---|
| 5 | class NetworkCallbackBase |
---|
| 6 | { |
---|
| 7 | public: |
---|
| 8 | virtual void call() = 0; |
---|
[1536] | 9 | virtual ~NetworkCallbackBase() {} |
---|
[1529] | 10 | }; |
---|
| 11 | |
---|
| 12 | template <class T> |
---|
| 13 | class NetworkCallback: public NetworkCallbackBase |
---|
| 14 | { |
---|
| 15 | public: |
---|
| 16 | NetworkCallback(T* object, void (T::*function) (void)) : object_(object), function_(function) {} |
---|
[1536] | 17 | virtual ~NetworkCallback() {} |
---|
[1529] | 18 | virtual void call() |
---|
| 19 | { (this->object_->*function_)(); } |
---|
| 20 | |
---|
| 21 | private: |
---|
| 22 | T* object_; |
---|
| 23 | void (T::*function_) (void); |
---|
| 24 | }; |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.