]> git.sesse.net Git - casparcg/blob - protocol/osc/oscpack/OscTypes.h
2.1.0: Merged osc network communication. Now works as monitor-exp.
[casparcg] / protocol / osc / oscpack / OscTypes.h
1 /*\r
2         oscpack -- Open Sound Control packet manipulation library\r
3         http://www.audiomulch.com/~rossb/oscpack\r
4 \r
5         Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>\r
6 \r
7         Permission is hereby granted, free of charge, to any person obtaining\r
8         a copy of this software and associated documentation files\r
9         (the "Software"), to deal in the Software without restriction,\r
10         including without limitation the rights to use, copy, modify, merge,\r
11         publish, distribute, sublicense, and/or sell copies of the Software,\r
12         and to permit persons to whom the Software is furnished to do so,\r
13         subject to the following conditions:\r
14 \r
15         The above copyright notice and this permission notice shall be\r
16         included in all copies or substantial portions of the Software.\r
17 \r
18         Any person wishing to distribute modifications to the Software is\r
19         requested to send the modifications to the original developer so that\r
20         they can be incorporated into the canonical version.\r
21 \r
22         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
23         EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
24         MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\r
25         IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR\r
26         ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF\r
27         CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
28         WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
29 */\r
30 #ifndef INCLUDED_OSCTYPES_H\r
31 #define INCLUDED_OSCTYPES_H\r
32 \r
33 \r
34 namespace osc{\r
35 \r
36 // basic types\r
37 \r
38 #if defined(__BORLANDC__) || defined(_MSC_VER)\r
39 \r
40 typedef __int64 int64;\r
41 typedef unsigned __int64 uint64;\r
42 \r
43 #elif defined(__x86_64__) || defined(_M_X64)\r
44 \r
45 typedef long int64;\r
46 typedef unsigned long uint64;\r
47 \r
48 #else\r
49 \r
50 typedef long long int64;\r
51 typedef unsigned long long uint64;\r
52 \r
53 #endif\r
54 \r
55 \r
56 \r
57 #if defined(__x86_64__) || defined(_M_X64)\r
58 \r
59 typedef signed int int32;\r
60 typedef unsigned int uint32;\r
61 \r
62 #else\r
63 \r
64 typedef signed long int32;\r
65 typedef unsigned long uint32;\r
66 \r
67 #endif\r
68 \r
69 \r
70 \r
71 enum TypeTagValues {\r
72     TRUE_TYPE_TAG = 'T',\r
73     FALSE_TYPE_TAG = 'F',\r
74     NIL_TYPE_TAG = 'N',\r
75     INFINITUM_TYPE_TAG = 'I',\r
76     INT32_TYPE_TAG = 'i',\r
77     FLOAT_TYPE_TAG = 'f',\r
78     CHAR_TYPE_TAG = 'c',\r
79     RGBA_COLOR_TYPE_TAG = 'r',\r
80     MIDI_MESSAGE_TYPE_TAG = 'm',\r
81     INT64_TYPE_TAG = 'h',\r
82     TIME_TAG_TYPE_TAG = 't',\r
83     DOUBLE_TYPE_TAG = 'd',\r
84     STRING_TYPE_TAG = 's',\r
85     SYMBOL_TYPE_TAG = 'S',\r
86     BLOB_TYPE_TAG = 'b'\r
87 };\r
88 \r
89 \r
90 \r
91 // i/o manipulators used for streaming interfaces\r
92 \r
93 struct BundleInitiator{\r
94     explicit BundleInitiator( uint64 timeTag_ ) : timeTag( timeTag_ ) {}\r
95     uint64 timeTag;\r
96 };\r
97 \r
98 extern BundleInitiator BeginBundleImmediate;\r
99 \r
100 inline BundleInitiator BeginBundle( uint64 timeTag=1 )\r
101 {\r
102     return BundleInitiator(timeTag);\r
103 }\r
104 \r
105 \r
106 struct BundleTerminator{\r
107 };\r
108 \r
109 extern BundleTerminator EndBundle;\r
110 \r
111 struct BeginMessage{\r
112     explicit BeginMessage( const char *addressPattern_ ) : addressPattern( addressPattern_ ) {}\r
113     const char *addressPattern;\r
114 };\r
115 \r
116 struct MessageTerminator{\r
117 };\r
118 \r
119 extern MessageTerminator EndMessage;\r
120 \r
121 \r
122 // osc specific types. they are defined as structs so they can be used\r
123 // as separately identifiable types with the streaming operators.\r
124 \r
125 struct NilType{\r
126 };\r
127 \r
128 extern NilType Nil;\r
129 \r
130 \r
131 struct InfinitumType{\r
132 };\r
133 \r
134 extern InfinitumType Infinitum;\r
135 \r
136 struct RgbaColor{\r
137     RgbaColor() {}\r
138     explicit RgbaColor( uint32 value_ ) : value( value_ ) {}\r
139     uint32 value;\r
140 \r
141     operator uint32() const { return value; }\r
142 };\r
143 \r
144 \r
145 struct MidiMessage{\r
146     MidiMessage() {}\r
147     explicit MidiMessage( uint32 value_ ) : value( value_ ) {}\r
148     uint32 value;\r
149 \r
150     operator uint32() const { return value; }\r
151 };\r
152 \r
153 \r
154 struct TimeTag{\r
155     TimeTag() {}\r
156     explicit TimeTag( uint64 value_ ) : value( value_ ) {}\r
157     uint64 value;\r
158 \r
159     operator uint64() const { return value; }\r
160 };\r
161 \r
162 \r
163 struct Symbol{\r
164     Symbol() {}\r
165     explicit Symbol( const char* value_ ) : value( value_ ) {}\r
166     const char* value;\r
167 \r
168     operator const char *() const { return value; }\r
169 };\r
170 \r
171 \r
172 struct Blob{\r
173     Blob() {}\r
174     explicit Blob( const void* data_, unsigned long size_ )\r
175             : data( data_ ), size( size_ ) {}\r
176     const void* data;\r
177     unsigned long size;\r
178 };\r
179 \r
180 } // namespace osc\r
181 \r
182 \r
183 #endif /* INCLUDED_OSCTYPES_H */\r