Permalink
Browse files

temporary fix (avoiding TalkySerialisable. check back to http://www.c…

  • Loading branch information...
1 parent 41b28cb commit f23800286389f76b8aef6581907069206dbcadf1 @elliotwoods committed Oct 13, 2011
Showing with 25 additions and 18 deletions.
  1. +1 −1 src/TalkyBase.h
  2. +13 −1 src/TalkyBuffer.cpp
  3. +7 −12 src/TalkyBuffer.h
  4. +2 −2 src/TalkyMessage.cpp
  5. +2 −2 src/TalkyMessage.h
View
@@ -8,7 +8,7 @@
//
-#define TALKY_SLEEP_TIME 10
+#define TALKY_SLEEP_TIME_MILLIS 10
#define TALKY_RECONNECT_TIME 200
#define TALKY_DEFAULT_PORT 5001
View
@@ -200,7 +200,8 @@ namespace Talky {
//clear our local data and replace
//with section of other buffer's data
- setData(other.getData(), s);
+ setData(other.getReadPointer(), s);
+ other.advanceReadPointer(s);
return true;
}
@@ -305,4 +306,15 @@ namespace Talky {
throw ("TalkyBuffer::advanceReadPointer : Buffer overrun error");
}
+ //------
+
+ TalkyBuffer& operator<<(TalkyBuffer &b, TalkySerialisable const &o) {
+ o.serialiseToBuffer(b);
+ return b;
+ }
+
+ bool operator>>(TalkyBuffer &b, TalkySerialisable& o) {
+ return o.deSerialiseFromBuffer(b);
+ }
+
}
View
@@ -33,7 +33,7 @@ namespace Talky {
virtual bool deSerialiseFromBuffer(TalkyBuffer &b) = 0;
};
- class TalkyBuffer : TalkySerialisable {
+ class TalkyBuffer : public TalkySerialisable {
public:
TalkyBuffer();
TalkyBuffer(BufferOffset size);
@@ -59,22 +59,14 @@ namespace Talky {
bool hasSpaceToRead(BufferOffset size) const;
BufferOffset getRemainingWriteSpace() const;
BufferOffset getRemainingReadSpace() const;
-
+
template<class T>
TalkyBuffer& operator<<(T const &object) {
if (!write(&object, sizeof(T)))
throw("Buffer overrun - insufficient space to write");
return *this;
}
-/* template<class T>
- TalkyBuffer& operator<<(T const object) {
- if (!write(&object, sizeof(T)))
- throw("Buffer overrun - insufficient space to write");
- return *this
- }
-*/
-
template<class T>
bool operator>>(T& object) {
return read(&object, sizeof(T));
@@ -84,7 +76,6 @@ namespace Talky {
string toString(unsigned short maxLength=10) const;
-
/**
Hard ass access. You sure you really want to do this??
We need this in TalkyBase, consider moving to 'friend' class?
@@ -150,5 +141,9 @@ namespace Talky {
BufferOffset writeOffset;
};
-
+
+ ///Overload template when serialising a TalkySerialisable object
+ TalkyBuffer& operator<<(TalkyBuffer& b, TalkySerialisable const &o);
+ ///Overload template when deserialising to a TalkySerialisable object
+ bool operator>>(TalkyBuffer& b, TalkySerialisable &o);
}
View
@@ -120,7 +120,7 @@ namespace Talky {
buf << TALKY_START_TOKEN;
buf << header;
- buf << payload;
+ buf << (TalkySerialisable&) payload;
buf << TALKY_END_TOKEN;
return true;
@@ -139,7 +139,7 @@ namespace Talky {
throw("Message corrupt!");
buf >> header;
- buf >> payload;
+ buf >> (TalkySerialisable&) payload;
buf >> token;
if (token != TALKY_END_TOKEN)
View
@@ -124,8 +124,8 @@ namespace Talky {
//-----
- ///Used when putting a message onto main buffer
+ ///Used when putting a message onto main buffer (tx)
TalkyBuffer& operator<<(TalkyBuffer& b, TalkyMessage const &m);
- ///Used when pulling a message off main buffer
+ ///Used when pulling a message off main buffer (rx)
bool operator>>(TalkyBuffer& b, TalkyMessage &m);
}

0 comments on commit f238002

Please sign in to comment.