| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
#ifndef INCLUDED_OSCOUTBOUNDPACKET_H |
|---|
| 31 |
#define INCLUDED_OSCOUTBOUNDPACKET_H |
|---|
| 32 |
|
|---|
| 33 |
#include "OscTypes.h" |
|---|
| 34 |
#include "OscException.h" |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
namespace osc{ |
|---|
| 38 |
|
|---|
| 39 |
class OutOfBufferMemoryException : public Exception{ |
|---|
| 40 |
public: |
|---|
| 41 |
OutOfBufferMemoryException( const char *w="out of buffer memory" ) |
|---|
| 42 |
: Exception( w ) {} |
|---|
| 43 |
}; |
|---|
| 44 |
|
|---|
| 45 |
class BundleNotInProgressException : public Exception{ |
|---|
| 46 |
public: |
|---|
| 47 |
BundleNotInProgressException( |
|---|
| 48 |
const char *w="call to EndBundle when bundle is not in progress" ) |
|---|
| 49 |
: Exception( w ) {} |
|---|
| 50 |
}; |
|---|
| 51 |
|
|---|
| 52 |
class MessageInProgressException : public Exception{ |
|---|
| 53 |
public: |
|---|
| 54 |
MessageInProgressException( |
|---|
| 55 |
const char *w="opening or closing bundle or message while message is in progress" ) |
|---|
| 56 |
: Exception( w ) {} |
|---|
| 57 |
}; |
|---|
| 58 |
|
|---|
| 59 |
class MessageNotInProgressException : public Exception{ |
|---|
| 60 |
public: |
|---|
| 61 |
MessageNotInProgressException( |
|---|
| 62 |
const char *w="call to EndMessage when message is not in progress" ) |
|---|
| 63 |
: Exception( w ) {} |
|---|
| 64 |
}; |
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
class OutboundPacketStream{ |
|---|
| 68 |
public: |
|---|
| 69 |
OutboundPacketStream( char *buffer, unsigned long capacity ); |
|---|
| 70 |
~OutboundPacketStream(); |
|---|
| 71 |
|
|---|
| 72 |
void Clear(); |
|---|
| 73 |
|
|---|
| 74 |
unsigned int Capacity() const; |
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
unsigned int Size() const; |
|---|
| 78 |
|
|---|
| 79 |
const char *Data() const; |
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
bool IsReady() const; |
|---|
| 84 |
|
|---|
| 85 |
bool IsMessageInProgress() const; |
|---|
| 86 |
bool IsBundleInProgress() const; |
|---|
| 87 |
|
|---|
| 88 |
OutboundPacketStream& operator<<( const BundleInitiator& rhs ); |
|---|
| 89 |
OutboundPacketStream& operator<<( const BundleTerminator& rhs ); |
|---|
| 90 |
|
|---|
| 91 |
OutboundPacketStream& operator<<( const BeginMessage& rhs ); |
|---|
| 92 |
OutboundPacketStream& operator<<( const MessageTerminator& rhs ); |
|---|
| 93 |
|
|---|
| 94 |
OutboundPacketStream& operator<<( bool rhs ); |
|---|
| 95 |
OutboundPacketStream& operator<<( const NilType& rhs ); |
|---|
| 96 |
OutboundPacketStream& operator<<( const InfinitumType& rhs ); |
|---|
| 97 |
OutboundPacketStream& operator<<( int32 rhs ); |
|---|
| 98 |
|
|---|
| 99 |
#ifndef x86_64 |
|---|
| 100 |
OutboundPacketStream& operator<<( int rhs ) |
|---|
| 101 |
{ *this << (int32)rhs; return *this; } |
|---|
| 102 |
#endif |
|---|
| 103 |
|
|---|
| 104 |
OutboundPacketStream& operator<<( float rhs ); |
|---|
| 105 |
OutboundPacketStream& operator<<( char rhs ); |
|---|
| 106 |
OutboundPacketStream& operator<<( const RgbaColor& rhs ); |
|---|
| 107 |
OutboundPacketStream& operator<<( const MidiMessage& rhs ); |
|---|
| 108 |
OutboundPacketStream& operator<<( int64 rhs ); |
|---|
| 109 |
OutboundPacketStream& operator<<( const TimeTag& rhs ); |
|---|
| 110 |
OutboundPacketStream& operator<<( double rhs ); |
|---|
| 111 |
OutboundPacketStream& operator<<( const char* rhs ); |
|---|
| 112 |
OutboundPacketStream& operator<<( const Symbol& rhs ); |
|---|
| 113 |
OutboundPacketStream& operator<<( const Blob& rhs ); |
|---|
| 114 |
|
|---|
| 115 |
private: |
|---|
| 116 |
|
|---|
| 117 |
char *BeginElement( char *beginPtr ); |
|---|
| 118 |
void EndElement( char *endPtr ); |
|---|
| 119 |
|
|---|
| 120 |
bool ElementSizeSlotRequired() const; |
|---|
| 121 |
void CheckForAvailableBundleSpace(); |
|---|
| 122 |
void CheckForAvailableMessageSpace( const char *addressPattern ); |
|---|
| 123 |
void CheckForAvailableArgumentSpace( long argumentLength ); |
|---|
| 124 |
|
|---|
| 125 |
char *data_; |
|---|
| 126 |
char *end_; |
|---|
| 127 |
|
|---|
| 128 |
char *typeTagsCurrent_; |
|---|
| 129 |
char *messageCursor_; |
|---|
| 130 |
char *argumentCurrent_; |
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
uint32 *elementSizePtr_; |
|---|
| 136 |
|
|---|
| 137 |
bool messageIsInProgress_; |
|---|
| 138 |
}; |
|---|
| 139 |
|
|---|
| 140 |
} |
|---|
| 141 |
|
|---|
| 142 |
#endif |
|---|