4S Device Communication Module Collection  Version 0.6-SNAPSHOT
Full documentation of the modules in the 4SDC collection (aimed at 4SDC module developers)
msgcallback.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014-2015 The 4S Foundation (www.4s-online.dk)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
32 #ifndef MSGCALLBACK_H
33 #define MSGCALLBACK_H
34 
35 #include "basemsg.h"
36 #include "handle.h"
37 
38 #include <memory>
39 
40 
41 namespace FSYS
42 {
54  class MsgCallBack : virtual public Handle
55  {
56  public:
60  MsgCallBack( void ) {}
61 
70  virtual void callBack(std::shared_ptr<BaseMsg> &baseMsg) = 0;
71  };
72 
79  template<class T> class MsgCallBackT : public MsgCallBack
80  {
81  public:
89  virtual void callBack(T &arg) = 0;
90 
99  void callBack(std::shared_ptr<BaseMsg> &baseMsg)
100  {
101  T &msg = static_cast<T&>(*baseMsg);
102  callBack(msg);
103  }
104  };
105 
106 }
107 
108 #endif // MSGCALLBACK_H
MsgCallBack(void)
Default constructor.
Definition: msgcallback.h:60
virtual void callBack(std::shared_ptr< BaseMsg > &baseMsg)=0
Call back function that evantually maps to receive(T)
Class that holds and assigns handles.
Definition: handle.h:55
Contains interface declaration for the FSYS::Handle class.
Contains interface declaration for the FSYS::BaseMsg class.
Definition: basemsg.h:38
void callBack(std::shared_ptr< BaseMsg > &baseMsg)
callBack function that casts the message to the correct typedef
Definition: msgcallback.h:99
The MsgCallBack class is an internal class to the message system.
Definition: msgcallback.h:54
Template class that inherits from MsgCallBack.
Definition: msgcallback.h:79