SharedMemoryBlock.h 1.6 KB

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