andrew@0
|
1 /*
|
andrew@0
|
2
|
andrew@0
|
3 Copyright (c) 2007-2009, Damian Stewart
|
andrew@0
|
4 All rights reserved.
|
andrew@0
|
5
|
andrew@0
|
6 Redistribution and use in source and binary forms, with or without
|
andrew@0
|
7 modification, are permitted provided that the following conditions are met:
|
andrew@0
|
8 * Redistributions of source code must retain the above copyright
|
andrew@0
|
9 notice, this list of conditions and the following disclaimer.
|
andrew@0
|
10 * Redistributions in binary form must reproduce the above copyright
|
andrew@0
|
11 notice, this list of conditions and the following disclaimer in the
|
andrew@0
|
12 documentation and/or other materials provided with the distribution.
|
andrew@0
|
13 * Neither the name of the developer nor the
|
andrew@0
|
14 names of its contributors may be used to endorse or promote products
|
andrew@0
|
15 derived from this software without specific prior written permission.
|
andrew@0
|
16
|
andrew@0
|
17 THIS SOFTWARE IS PROVIDED BY DAMIAN STEWART ''AS IS'' AND ANY
|
andrew@0
|
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
andrew@0
|
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
andrew@0
|
20 DISCLAIMED. IN NO EVENT SHALL DAMIAN STEWART BE LIABLE FOR ANY
|
andrew@0
|
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
andrew@0
|
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
andrew@0
|
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
andrew@0
|
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
andrew@0
|
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
andrew@0
|
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
andrew@0
|
27 */
|
andrew@0
|
28
|
andrew@0
|
29
|
andrew@0
|
30 #ifndef _ofxOscMESSAGE_H
|
andrew@0
|
31 #define _ofxOscMESSAGE_H
|
andrew@0
|
32
|
andrew@0
|
33 #include "ofxOscArg.h"
|
andrew@0
|
34 #include <vector>
|
andrew@0
|
35 #include <string>
|
andrew@0
|
36
|
andrew@0
|
37 using namespace std;
|
andrew@0
|
38
|
andrew@0
|
39 class ofxOscMessage
|
andrew@0
|
40 {
|
andrew@0
|
41 public:
|
andrew@0
|
42 ofxOscMessage();
|
andrew@0
|
43 ~ofxOscMessage();
|
andrew@0
|
44 ofxOscMessage( const ofxOscMessage& other ){ copy ( other ); }
|
andrew@0
|
45 ofxOscMessage& operator= ( const ofxOscMessage& other ) { return copy( other ); }
|
andrew@0
|
46 /// for operator= and copy constructor
|
andrew@0
|
47 ofxOscMessage& copy( const ofxOscMessage& other );
|
andrew@0
|
48
|
andrew@0
|
49 /// clear this message, erase all contents
|
andrew@0
|
50 void clear();
|
andrew@0
|
51
|
andrew@0
|
52 /// return the address
|
andrew@0
|
53 string getAddress() const { return address; }
|
andrew@0
|
54
|
andrew@0
|
55 /// return the remote ip
|
andrew@0
|
56 string getRemoteIp() { return remote_host; }
|
andrew@0
|
57 /// return the remote port
|
andrew@0
|
58 int getRemotePort() { return remote_port; }
|
andrew@0
|
59
|
andrew@0
|
60 /// return number of argumentsļ
|
andrew@0
|
61 int getNumArgs() const;
|
andrew@0
|
62 /// return argument type code for argument # index
|
andrew@0
|
63 ofxOscArgType getArgType( int index ) const;
|
andrew@0
|
64 /// return argument type name as string
|
andrew@0
|
65 /// - either "int", "float", or "string"
|
andrew@0
|
66 string getArgTypeName( int index ) const;
|
andrew@0
|
67
|
andrew@0
|
68 /// get the argument with the given index as an int, float, or string
|
andrew@0
|
69 /// ensure that the type matches what you're requesting
|
andrew@0
|
70 /// (eg for an int argument, getArgType(index)==OF_TYPE_INT32
|
andrew@0
|
71 /// or getArgTypeName(index)=="int32")
|
andrew@0
|
72 int32_t getArgAsInt32( int index ) const;
|
andrew@0
|
73 float getArgAsFloat( int index ) const;
|
andrew@0
|
74 string getArgAsString( int index ) const;
|
andrew@0
|
75
|
andrew@0
|
76 /// message construction
|
andrew@0
|
77 void setAddress( string _address ) { address = _address; };
|
andrew@0
|
78 /// host and port of the remote endpoint
|
andrew@0
|
79 void setRemoteEndpoint( string host, int port ) { remote_host = host; remote_port = port; }
|
andrew@0
|
80 void addIntArg( int32_t argument );
|
andrew@0
|
81 void addFloatArg( float argument );
|
andrew@0
|
82 void addStringArg( string argument );
|
andrew@0
|
83
|
andrew@0
|
84
|
andrew@0
|
85 private:
|
andrew@0
|
86
|
andrew@0
|
87 string address;
|
andrew@0
|
88 vector<ofxOscArg*> args;
|
andrew@0
|
89
|
andrew@0
|
90 string remote_host;
|
andrew@0
|
91 int remote_port;
|
andrew@0
|
92
|
andrew@0
|
93
|
andrew@0
|
94 };
|
andrew@0
|
95
|
andrew@0
|
96 #endif
|