37 #ifndef INCLUDED_OSCPACK_MESSAGEMAPPINGOSCPACKETLISTENER_H
38 #define INCLUDED_OSCPACK_MESSAGEMAPPINGOSCPACKETLISTENER_H
43 #include "OscPacketListener.h"
50 class MessageMappingOscPacketListener :
public OscPacketListener{
52 typedef void (T::*function_type)(
const osc::ReceivedMessage&,
const IpEndpointName&);
55 void RegisterMessageFunction(
const char *addressPattern, function_type f )
57 functions_.insert( std::make_pair( addressPattern, f ) );
60 virtual void ProcessMessage(
const osc::ReceivedMessage& m,
61 const IpEndpointName& remoteEndpoint )
63 typename function_map_type::iterator i = functions_.find( m.AddressPattern() );
64 if( i != functions_.end() )
65 (dynamic_cast<T*>(
this)->*(i->second))( m, remoteEndpoint );
70 bool operator()(
const char *lhs,
const char *rhs )
const
71 {
return std::strcmp( lhs, rhs ) < 0; }
74 typedef std::map<const char*, function_type, cstr_compare> function_map_type;
75 function_map_type functions_;