nhandler1.hpp

Go to the documentation of this file.
00001 // LICENSE: (Please see the file COPYING for details)
00002 //
00003 // NUS - Nemesis Utilities System: A C++ application development framework 
00004 // Copyright (C) 2006, 2008 Otavio Rodolfo Piske
00005 //
00006 //  This file is part of NUS
00007 //
00008 //  This library is free software; you can redistribute it and/or
00009 //  modify it under the terms of the GNU Lesser General Public
00010 //  License as published by the Free Software Foundation version 2.1
00011 //  of the License.
00012 //
00013 //  This library is distributed in the hope that it will be useful,
00014 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 //  Lesser General Public License for more details.
00017 //
00018 //  You should have received a copy of the GNU Lesser General Public
00019 //  License along with this library; if not, write to the Free Software
00020 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00021 //
00022 #ifndef NHANDLER1_HPP
00023 #define NHANDLER1_HPP
00024 
00035 template <typename ParamT>
00036 class NEventHandlerBase1 {
00037       public:
00041             virtual ~NEventHandlerBase1(void) { };
00042             
00046             virtual void notify(ParamT param) = 0;
00047 
00048 };
00049 
00050 
00057 template <typename ListenerT, typename ParamT>
00058 class NEventHandler1: public NEventHandlerBase1<ParamT> {
00059       public:
00060             typedef void (ListenerT::*PtrMember)(ParamT);
00061       
00068             NEventHandler1(ListenerT* object, PtrMember member);
00069             
00073             ~NEventHandler1(void);
00074             
00080             void notify(ParamT param);
00081       
00082       private:
00083             ListenerT* m_object;
00084             PtrMember m_member;
00085             
00086             NEventHandler1(const NEventHandler1<ListenerT, ParamT> &other);
00087             NEventHandler1<ListenerT, ParamT> 
00088                         &operator=(const NEventHandler1<ListenerT, ParamT> &rhs);
00089 
00090 };
00091 
00092 
00093 template <typename ListenerT, typename ParamT>
00094 NEventHandler1<ListenerT, ParamT>::NEventHandler1(ListenerT* object, PtrMember member)
00095             : m_object(object),
00096             m_member(member)
00097 { 
00098       assert(member && member);
00099 }
00100 
00101 
00102 template <typename ListenerT, typename ParamT>
00103 void NEventHandler1<ListenerT, ParamT>::notify(ParamT param) {
00104       (m_object->*m_member)(param);
00105 }
00106 
00107 
00108 template <typename ListenerT, typename ParamT>
00109 NEventHandler1<ListenerT, ParamT>::~NEventHandler1(void) { }
00110 
00111 #endif // NHANDLER1_HPP

Generated on Wed Mar 5 23:10:35 2008 for NemesisUtilitiesSystem by  doxygen 1.5.4