~ubuntu-branches/ubuntu/trusty/openscenegraph/trusty

« back to all changes in this revision

Viewing changes to OpenSceneGraph/src/osgPlugins/osc/osc/MessageMappingOscPacketListener.h

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2013-11-12 02:21:14 UTC
  • mfrom: (31.1.3 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20131112022114-qaxfhdnhn88vnh10
Tags: 3.2.0~rc1-1ubuntu1
Fix deprecated url_feof.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
        oscpack -- Open Sound Control packet manipulation library
 
3
        http://www.audiomulch.com/~rossb/oscpack
 
4
 
 
5
        Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
 
6
 
 
7
        Permission is hereby granted, free of charge, to any person obtaining
 
8
        a copy of this software and associated documentation files
 
9
        (the "Software"), to deal in the Software without restriction,
 
10
        including without limitation the rights to use, copy, modify, merge,
 
11
        publish, distribute, sublicense, and/or sell copies of the Software,
 
12
        and to permit persons to whom the Software is furnished to do so,
 
13
        subject to the following conditions:
 
14
 
 
15
        The above copyright notice and this permission notice shall be
 
16
        included in all copies or substantial portions of the Software.
 
17
 
 
18
        Any person wishing to distribute modifications to the Software is
 
19
        requested to send the modifications to the original developer so that
 
20
        they can be incorporated into the canonical version.
 
21
 
 
22
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
23
        EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
24
        MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
25
        IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
 
26
        ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 
27
        CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 
28
        WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
29
*/
 
30
#ifndef INCLUDED_MESSAGEMAPPINGOSCPACKETLISTENER_H
 
31
#define INCLUDED_MESSAGEMAPPINGOSCPACKETLISTENER_H
 
32
 
 
33
#include <string.h>
 
34
#include <map>
 
35
 
 
36
#include "OscPacketListener.h"
 
37
 
 
38
 
 
39
 
 
40
namespace osc{
 
41
 
 
42
template< class T >
 
43
class MessageMappingOscPacketListener : public OscPacketListener{
 
44
public:
 
45
    typedef void (T::*function_type)(const osc::ReceivedMessage&, const IpEndpointName&);
 
46
 
 
47
protected:
 
48
    void RegisterMessageFunction( const char *addressPattern, function_type f )
 
49
    {
 
50
        functions_.insert( std::make_pair( addressPattern, f ) );
 
51
    }
 
52
 
 
53
    virtual void ProcessMessage( const osc::ReceivedMessage& m,
 
54
                const IpEndpointName& remoteEndpoint )
 
55
    {
 
56
        typename function_map_type::iterator i = functions_.find( m.AddressPattern() );
 
57
        if( i != functions_.end() )
 
58
            (dynamic_cast<T*>(this)->*(i->second))( m, remoteEndpoint );
 
59
    }
 
60
    
 
61
private:
 
62
    struct cstr_compare{
 
63
        bool operator()( const char *lhs, const char *rhs ) const
 
64
            { return strcmp( lhs, rhs ) < 0; }
 
65
    };
 
66
 
 
67
    typedef std::map<const char*, function_type, cstr_compare> function_map_type;
 
68
    function_map_type functions_;
 
69
};
 
70
 
 
71
} // namespace osc
 
72
 
 
73
#endif /* INCLUDED_MESSAGEMAPPINGOSCPACKETLISTENER_H */
 
 
b'\\ No newline at end of file'