DataPacket.h 809 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * TI Voxel Lib component.
  3. *
  4. * Copyright (c) 2014 Texas Instruments Inc.
  5. */
  6. #ifndef VOXEL_DATA_PACKET_H
  7. #define VOXEL_DATA_PACKET_H
  8. #include "Common.h"
  9. #include "SerializedObject.h"
  10. #include "Logger.h"
  11. namespace Voxel
  12. {
  13. struct VOXEL_EXPORT DataPacket
  14. {
  15. char magic[6]; // supposed to be VOXEL
  16. uint8_t type; // PacketType
  17. uint32_t size;
  18. SerializedObject object;
  19. DataPacket() { strcpy(magic, "VOXEL"); }
  20. bool readHeader(SerializedObject &in);
  21. bool readHeader(InputStream &in);
  22. bool read(SerializedObject &in);
  23. bool read(InputStream &in);
  24. bool write(SerializedObject &out);
  25. bool write(OutputStream &out);
  26. inline bool verifyMagic() { return magic[0] == 'V' && magic[1] == 'O' && magic[2] == 'X' && magic[3] == 'E' && magic[4] == 'L'; }
  27. };
  28. }
  29. #endif