SharedMemoryBlock.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef SHARED_MEMORY_BLOCK_H
  2. #define SHARED_MEMORY_BLOCK_H
  3. #define SHARED_MEMORY_MAGIC_NUMBER 64738
  4. #define SHARED_MEMORY_MAX_COMMANDS 4
  5. #define SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE (256*1024)
  6. #include "SharedMemoryCommands.h"
  7. struct SharedMemoryBlock
  8. {
  9. int m_magicId;
  10. struct SharedMemoryCommand m_clientCommands[SHARED_MEMORY_MAX_COMMANDS];
  11. struct SharedMemoryStatus m_serverCommands[SHARED_MEMORY_MAX_COMMANDS];
  12. int m_numClientCommands;
  13. int m_numProcessedClientCommands;
  14. int m_numServerCommands;
  15. int m_numProcessedServerCommands;
  16. //m_bulletStreamDataClientToServer is a way for the client to create collision shapes, rigid bodies and constraints
  17. //the Bullet data structures are more general purpose than the capabilities of a URDF file.
  18. char m_bulletStreamDataClientToServer[SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE];
  19. //m_bulletStreamDataServerToClient is used to send (debug) data from server to client, for
  20. //example to provide all details of a multibody including joint/link names, after loading a URDF file.
  21. char m_bulletStreamDataServerToClientRefactor[SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE];
  22. };
  23. //http://stackoverflow.com/questions/24736304/unable-to-use-inline-in-declaration-get-error-c2054
  24. #ifdef _WIN32
  25. __inline
  26. #else
  27. inline
  28. #endif
  29. void InitSharedMemoryBlock(struct SharedMemoryBlock* sharedMemoryBlock)
  30. {
  31. sharedMemoryBlock->m_numClientCommands = 0;
  32. sharedMemoryBlock->m_numServerCommands = 0;
  33. sharedMemoryBlock->m_numProcessedClientCommands=0;
  34. sharedMemoryBlock->m_numProcessedServerCommands=0;
  35. sharedMemoryBlock->m_magicId = SHARED_MEMORY_MAGIC_NUMBER;
  36. }
  37. #define SHARED_MEMORY_SIZE sizeof(SharedMemoryBlock)
  38. #endif //SHARED_MEMORY_BLOCK_H