RTFX  0.3
Real time special effects collaborative visualization and production library.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
RTFXMailbox.h
1 #ifndef __RTFX_MAILBOX__
2 #define __RTFX_MAILBOX__
3 
12 #include <iostream>
13 #include <sstream>
14 #include <vector>
15 #include <deque>
16 #include <map>
17 
18 #include "RTFXCamera.h"
19 #include "RTFXLight.h"
20 #include "RTFXGeometry.h"
21 #include "RTFXData.h"
22 #include "RTFXParcel.h"
23 
24 namespace RTFX
25 {
36  class RTFXAPI RTFXMailbox
37  {
38  public:
39 
42  {
43  // Create the storage graph, and turn locks on since multiple threads will be accessing this graph
44  data = new RTFXData();
45  data->SetLocks( true );
46 
47  updater = new RTFXData();
48 
49  compressionType = NONE;
50  isNewRawDataAvailable = false;
51  }
52 
55  {
56  delete data;
57  delete updater;
58  waitingList.clear();
59  }
60 
62  void AddMessage( RTFXData * _newMessage )
63  {
64  // Merge this update with the raw data (ignore updater for now);
65  verbose( ostringstream().flush() << "RTFXMailbox::AddMessage: there are - " << data->GetNumObjects() << " objects." << endl );
66  data->Merge( _newMessage );
67  }
68 
70  RTFXData * GetPointerToMailbox()
71  {
72  // boost::lock_guard<boost::mutex> lock( mailLock );
73  return data;
74  }
75 
77  void GetSerializedMailbox( string &_sdata );
78 
80  void AcceptDataParcel( RTFXParcel _parcel );
81 
113  void ParseBody( string &_message );
114 
116  void DecodeBody( boost::uuids::uuid _messageID, string &_result );
117 
119  char * GetMailboxName() { return mailboxName; }
120 
122  void SetMailboxName( char * _mailboxName )
123  {
124  strcpy( mailboxName, _mailboxName );
125  }
126 
128  void SetDefaultCompressionType( COMPRESSIONTYPE _tmp )
129  {
130  compressionType = _tmp;
131  }
132 
134  COMPRESSIONTYPE GetDefaultCompressionType() { return compressionType; }
135 
137  RTFXBIGINT GetCustomDataCount();
138 
140  void AddCustomData( string _data );
141 
143  string GetCustomData();
144 
146  bool IsNewCustomDataAvailable();
147 
148  private:
149 
152 
154  boost::mutex mailLock;
155 
157  char mailboxName[16];
158 
167  vector< pair<clock_t, RTFXData *> > waitingList;
168 
171 
175 
178  std::map<boost::uuids::uuid, vector<RTFXParcel> > parcelCollection;
179 
182  deque<string> rawDataStorage;
183 
186 
189  };
190 }
191 
192 #endif