AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RemoteDebugBase.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXNET_REMOTEDEBUGBASE_H
18 #define AGXNET_REMOTEDEBUGBASE_H
19 
20 #ifdef _MSC_VER
21 # pragma warning(push)
22 # pragma warning( disable : 4290)
23 # pragma warning( disable: 4275 ) // warning C4275: non dll-interface class
24 #endif
25 
26 #include <agx/agxPhysics_export.h>
27 #include <agx/Thread.h>
28 #include <agxNet/Compress.h>
29 #include <agxNet/Socket.h>
30 #include <agx/Referenced.h>
31 #include <agx/Thread.h>
32 #include <agx/List.h>
33 
37 namespace agxNet
38 {
39 
42  {
43  public:
44 
46  struct Header
47  {
48  Header() : numBytes(0), mode(0), compressed(false) {}
49  enum Mode
50  {
51  READY_TO_RECEIVE=121,
52  NEW_FRAME=111
53  };
54 
55  uint32_t numBytes;
56  uint8_t mode;
57  bool compressed;
58  char md5[32];
59  };
60 
61 #ifdef _MSC_VER
62 # pragma warning(push)
63 # pragma warning( disable : 4250) // 'agxNet::RemoteDebugBase::DataBlock' : inherits 'std::basic_istream<_Elem,_Traits>::std::basic_istream<_Elem,_Traits>::_Add_vtordisp1' via dominance
64 #endif
65 
66 
67  struct DataBlock : public agx::Referenced, public std::stringstream
68  {
69  };
71 
72 #ifdef _MSC_VER
73 # pragma warning(pop)
74 #endif
75 
76  public:
77 
80 
85  void pushBlock( DataBlock *data );
86 
90  DataBlockRef getBlock( );
91  void run();
92 
94  virtual bool isConnected();
95 
97  bool hasData();
98 
100  void setMaxQueueSize( size_t numElements ) { m_queueSize = numElements; }
101 
103  size_t getMaxQueueSize( ) const { return m_queueSize; }
104 
106  size_t getQueueSize();
107 
109  void shutdown();
110 
111  protected:
112 
113 
114  bool isShutdown();
115 
116  virtual void waitForDataAndTransfer()=0;
117  virtual bool waitForConnection()=0;
118 
125  size_t sendData( const uint8_t* data, size_t numBytes );
126 
133  size_t receiveData( uint8_t* data, size_t numBytes );
134 
135  virtual ~RemoteDebugBase();
136 
140  virtual void dropConnection();
141 
142  protected:
143 
144  void waitForData();
145  void releaseData();
146  virtual void handleConnectionDrop();
147 
150 
153  size_t m_queueSize;
155 
156 
157  private:
159  DataQueue m_queue;
160 
161  };
162 
163 }
164 
165 #ifdef _MSC_VER
166 # pragma warning(pop)
167 #endif
168 
169 
170 #endif
Basic wrapper class aroud std::thread.
Definition: Thread.h:81
Header used for sending data over sockets.
void AGXPHYSICS_EXPORT shutdown()
Shutdown agx.
void setMaxQueueSize(size_t numElements)
bool AGXPHYSICS_EXPORT isShutdown()
#define AGXPHYSICS_EXPORT
Block synchronization primitive.
Base class providing referencing counted objects.
Definition: Referenced.h:113
agx::ref_ptr< DataBlock > DataBlockRef
Base class for multi threaded transferring simulation between a server and a client using sockets...
size_t getMaxQueueSize() const
std::mutex Mutex
Definition: Referenced.h:93