EventBinding.cti

Go to the documentation of this file.
00001 // $Id: EventBinding.cti 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2007
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program 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
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 //#include "EventBinding.ih"
00027 
00028 // Custom includes
00029 #include <senf/PPI/EventManager.hh>
00030 
00031 #define prefix_ inline
00032 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00033 
00034 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00035 // senf::ppi::detail::EventBindingHelper<EventType,Self>
00036 
00037 template <class EventType, class Self>
00038 prefix_ void
00039 senf::ppi::detail::EventBindingHelper<EventType,Self>::callback(EventArg event,
00040                                                                 ClockService::clock_type time)
00041 {
00042     self().eventTime(time);
00043     self().callback_(event);
00044 }
00045 
00046 template <class EventType, class Self>
00047 prefix_ void senf::ppi::detail::EventBindingHelper<EventType,Self>::callback(EventArg event)
00048 {
00049     callback(event, self().manager().now());
00050 }
00051 
00052 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00053 // private members
00054 
00055 template <class EventType, class Self>
00056 prefix_ Self & senf::ppi::detail::EventBindingHelper<EventType,Self>::self()
00057 {
00058     return * static_cast<Self*>(this);
00059 }
00060 
00061 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00062 // senf::ppi::detail::EventBindingHelper<void,Self>
00063 
00064 template <class Self>
00065 prefix_ void
00066 senf::ppi::detail::EventBindingHelper<void,Self>::callback(ClockService::clock_type time)
00067 {
00068     self().eventTime(time);
00069     self().callback_();
00070 }
00071 
00072 template <class Self>
00073 prefix_ void senf::ppi::detail::EventBindingHelper<void,Self>::callback()
00074 {
00075     callback(self().manager().now());
00076 }
00077 
00078 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00079 // private members
00080 
00081 template <class Self>
00082 prefix_ Self & senf::ppi::detail::EventBindingHelper<void,Self>::self()
00083 {
00084     return * static_cast<Self*>(this);
00085 }
00086 
00087 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00088 // senf::ppi::detail::EventBinding<EvImpl>
00089 
00090 template <class EventType>
00091 prefix_ senf::ppi::detail::EventBinding<EventType>::EventBinding(EventManager & manager,
00092                                                                  module::Module & module,
00093                                                                  Callback callback,
00094                                                                  EventDescriptor & descriptor)
00095     : EventBindingBase(manager, module, descriptor), callback_(callback)
00096 {}
00097 
00098 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00099 #undef prefix_
00100 
00101 
00102 // Local Variables:
00103 // mode: c++
00104 // fill-column: 100
00105 // comment-column: 40
00106 // c-file-style: "senf"
00107 // indent-tabs-mode: nil
00108 // ispell-local-dictionary: "american"
00109 // compile-command: "scons -u ../test"
00110 // End: