00001 /* 00002 Copyright 2007, 2008, 2009, 2010, 2011 Instituto de Sistemas e Robotica, Instituto Superior Tecnico 00003 00004 This file is part of MeRMaID. 00005 00006 MeRMaID is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU Lesser General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 MeRMaID is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public License 00017 along with MeRMaID. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 00021 00022 /** 00023 * @Filename DataFeedInputHandlerMethod.hpp 00024 * @Description DataFeedInputHandlerMethod 00025 * @Status Work in Progress 00026 * @Version $Id: DataFeedInputHandlerMethod.hpp 1 2011-03-04 18:13:18Z jreis $ 00027 * @Maintainer Marco Barbosa 00028 */ 00029 00030 #ifndef __SERVICE_DATAFEEDINPUTHANDLERMETHOD_H 00031 #define __SERVICE_DATAFEEDINPUTHANDLERMETHOD_H 00032 00033 00034 #include <DataBox.hpp> 00035 00036 namespace mermaid 00037 { 00038 namespace support 00039 { 00040 namespace service 00041 { 00042 00043 using mermaid::support::data::DataBox; 00044 using boost::shared_ptr; 00045 00046 /** 00047 * @Class DataFeedInputHandlerMethodBase DataFeedInputHandlerMethod.hpp "DataFeedInputHandlerMethod.hpp" 00048 * @Description Base class for all DataFeedInputHandlerMethod objects. 00049 * 00050 * This class is needed in order to call DataFeedInputHandlerMethod without having to know the specific class used by the template. 00051 * @Author Marco Barbosa 00052 */ 00053 class DataFeedInputHandlerMethodBase 00054 { 00055 public: 00056 /** 00057 * @Description Handler call method. 00058 * 00059 * This method calls the handler to which the instance of this class points to. 00060 * @Author Marco Barbosa 00061 */ 00062 virtual void callHandler (shared_ptr<DataBox> dataBox) = 0; 00063 }; 00064 00065 00066 /** 00067 * @Class DataFeedInputHandlerMethod DataFeedInputHandlerMethod.hpp "DataFeedInputHandlerMethod.hpp" 00068 * @Description Class that stores a pointer to a method of an object. It holds a pointer to a method suitable for handling input of data feeds. 00069 * @Author Marco Barbosa 00070 */ 00071 template <class o> 00072 class DataFeedInputHandlerMethod : public DataFeedInputHandlerMethodBase 00073 { 00074 typedef void (o::*DATA_FEED_HANDLER_METHOD) (shared_ptr<DataBox> dataBox); 00075 public: 00076 /** 00077 * @Description Contstructor. 00078 * @Argument object Object instance on which the method shall be called 00079 * @Argument method Method of the object's class 00080 */ 00081 DataFeedInputHandlerMethod (o * object, DATA_FEED_HANDLER_METHOD method) { 00082 object_ = object; 00083 method_ = method; 00084 } 00085 00086 /** 00087 * @Description Method call 00088 * @Argument dataBox DataBox containing the input data. 00089 */ 00090 virtual void callHandler (shared_ptr<DataBox> dataBox) { 00091 (object_->*method_) (dataBox); 00092 } 00093 00094 private: 00095 o * object_; 00096 DATA_FEED_HANDLER_METHOD method_; 00097 }; // class DataFeedInputHandlerMethod 00098 } // namespace service 00099 } // namespace support 00100 } // namespace mermaid 00101 00102 #endif // __SERVICE_DATAFEEDINPUTHANDLERMETHOD_H