TransferBase.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // TransferBase.h
  3. // cocos2d_libs
  4. //
  5. // Created by 徐俊杰 on 2020/6/11.
  6. //
  7. #ifndef TransferBase_h
  8. #define TransferBase_h
  9. //#include "cocos2d.h"
  10. #include "rparticle/Macros/RParticleMacros.h"
  11. NS_RRP_BEGIN
  12. class TransferBase
  13. {
  14. public:
  15. // TransferBase();
  16. // ~TransferBase();
  17. /// If true, the transfer is reading data from a source. (Could be fread from a file or reading from a block of memory)
  18. /// @note There are transfers for which neither IsReading() nor IsWriting() is true (for example when generating a typetree).
  19. /// IsReading is NOT the inverse of IsWriting.
  20. bool IsReading () { return false; }
  21. /// Are we transferring data with endianess swapping. (We might neither endianess swap on write or read based on IsReading / IsWriting)
  22. /// The endianess conversion is done by the TransferBackend, but there are some special cases where you might want to handle it yourself.
  23. /// (For example a texture data is transferred a single UInt8* array, so all endianess swapping is the responsibiltiy of the texture transfer function.)
  24. bool ConvertEndianess () { return false; }
  25. /// @name Versioning
  26. /// @{
  27. /// Sets the "version of the class currently transferred"
  28. void SetVersion (int) {}
  29. /// Returns if the transferred data's version is the version used by the source code
  30. bool IsVersionSmallerOrEqual (int /*version*/) { return false; }
  31. /// Deprecated: use IsVersionSmallerOrEqual instead.
  32. bool IsOldVersion (int /*version*/) { return false; }
  33. bool IsCurrentVersion () { return true; }
  34. /// @}
  35. /// @name Transfers
  36. /// @{
  37. /// Alignment in the serialization system is done manually.
  38. /// The serialization system only ever cares about 4 byte alignment.
  39. /// When writing data that has an alignment of less than 4 bytes, followed by data that has 4 byte alignment,
  40. /// then Align must be called before the 4 byte aligned data.
  41. /// TRANSFER (1byte);
  42. /// TRANSFER (1byte);
  43. /// transfer.Align ();
  44. /// TRANSFER (4byte);
  45. void Align () {}
  46. /// @}
  47. private:
  48. };
  49. NS_RRP_END
  50. #endif /* TransferBase_h */