]> git.sesse.net Git - casparcg/blob - protocol/osc/oscpack/OscTypes.h
- Implemented real-time state notification using OSC-UDP.
[casparcg] / protocol / osc / oscpack / OscTypes.h
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_OSCTYPES_H
31 #define INCLUDED_OSCTYPES_H
32
33
34 namespace osc{
35
36 // basic types
37
38 #if defined(__BORLANDC__) || defined(_MSC_VER)
39
40 typedef __int64 int64;
41 typedef unsigned __int64 uint64;
42
43 #elif defined(__x86_64__) || defined(_M_X64)
44
45 typedef long int64;
46 typedef unsigned long uint64;
47
48 #else
49
50 typedef long long int64;
51 typedef unsigned long long uint64;
52
53 #endif
54
55
56
57 #if defined(__x86_64__) || defined(_M_X64)
58
59 typedef signed int int32;
60 typedef unsigned int uint32;
61
62 #else
63
64 typedef signed long int32;
65 typedef unsigned long uint32;
66
67 #endif
68
69
70
71 enum TypeTagValues {
72     TRUE_TYPE_TAG = 'T',
73     FALSE_TYPE_TAG = 'F',
74     NIL_TYPE_TAG = 'N',
75     INFINITUM_TYPE_TAG = 'I',
76     INT32_TYPE_TAG = 'i',
77     FLOAT_TYPE_TAG = 'f',
78     CHAR_TYPE_TAG = 'c',
79     RGBA_COLOR_TYPE_TAG = 'r',
80     MIDI_MESSAGE_TYPE_TAG = 'm',
81     INT64_TYPE_TAG = 'h',
82     TIME_TAG_TYPE_TAG = 't',
83     DOUBLE_TYPE_TAG = 'd',
84     STRING_TYPE_TAG = 's',
85     SYMBOL_TYPE_TAG = 'S',
86     BLOB_TYPE_TAG = 'b'
87 };
88
89
90
91 // i/o manipulators used for streaming interfaces
92
93 struct BundleInitiator{
94     explicit BundleInitiator( uint64 timeTag_ ) : timeTag( timeTag_ ) {}
95     uint64 timeTag;
96 };
97
98 extern BundleInitiator BeginBundleImmediate;
99
100 inline BundleInitiator BeginBundle( uint64 timeTag=1 )
101 {
102     return BundleInitiator(timeTag);
103 }
104
105
106 struct BundleTerminator{
107 };
108
109 extern BundleTerminator EndBundle;
110
111 struct BeginMessage{
112     explicit BeginMessage( const char *addressPattern_ ) : addressPattern( addressPattern_ ) {}
113     const char *addressPattern;
114 };
115
116 struct MessageTerminator{
117 };
118
119 extern MessageTerminator EndMessage;
120
121
122 // osc specific types. they are defined as structs so they can be used
123 // as separately identifiable types with the streaming operators.
124
125 struct NilType{
126 };
127
128 extern NilType Nil;
129
130
131 struct InfinitumType{
132 };
133
134 extern InfinitumType Infinitum;
135
136 struct RgbaColor{
137     RgbaColor() {}
138     explicit RgbaColor( uint32 value_ ) : value( value_ ) {}
139     uint32 value;
140
141     operator uint32() const { return value; }
142 };
143
144
145 struct MidiMessage{
146     MidiMessage() {}
147     explicit MidiMessage( uint32 value_ ) : value( value_ ) {}
148     uint32 value;
149
150     operator uint32() const { return value; }
151 };
152
153
154 struct TimeTag{
155     TimeTag() {}
156     explicit TimeTag( uint64 value_ ) : value( value_ ) {}
157     uint64 value;
158
159     operator uint64() const { return value; }
160 };
161
162
163 struct Symbol{
164     Symbol() {}
165     explicit Symbol( const char* value_ ) : value( value_ ) {}
166     const char* value;
167
168     operator const char *() const { return value; }
169 };
170
171
172 struct Blob{
173     Blob() {}
174     explicit Blob( const void* data_, unsigned long size_ )
175             : data( data_ ), size( size_ ) {}
176     const void* data;
177     unsigned long size;
178 };
179
180 } // namespace osc
181
182
183 #endif /* INCLUDED_OSCTYPES_H */