HSerializedItem.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /***********************************************************
  2. * File generated by the HALCON-Compiler hcomp version 22.05
  3. * Usage: Interface to C++
  4. *
  5. * Software by: MVTec Software GmbH, www.mvtec.com
  6. ***********************************************************/
  7. #ifndef HCPP_HSERIALIZEDITEM
  8. #define HCPP_HSERIALIZEDITEM
  9. namespace HalconCpp
  10. {
  11. // Represents an instance of a serialized item.
  12. #if defined(_WIN32)
  13. class HSerializedItem : public HHandle
  14. #else
  15. class LIntExport HSerializedItem : public HHandle
  16. #endif
  17. {
  18. public:
  19. // Create an uninitialized instance
  20. LIntExport inline HSerializedItem():HHandle() {}
  21. // Copy constructor
  22. LIntExport inline HSerializedItem(const HSerializedItem& source) : HHandle(source) {}
  23. // Destructor must be defined explicitly to force certain compilers to emit
  24. // the virtual table of a class in the object file and to be able to set
  25. // the appropriate visibility attribute
  26. LIntExport ~HSerializedItem();
  27. // Copy constructor
  28. LIntExport HSerializedItem(const HHandle& handle);
  29. // Create HSerializedItem from handle, taking ownership
  30. LIntExport explicit HSerializedItem(Hlong handle);
  31. bool operator==(const HHandle& obj) const
  32. {
  33. return HHandleBase::operator==(obj);
  34. }
  35. bool operator!=(const HHandle& obj) const
  36. {
  37. return HHandleBase::operator!=(obj);
  38. }
  39. protected:
  40. // Verify matching semantic type ('serialized_item')!
  41. LIntExport virtual void AssertType(Hphandle handle) const;
  42. public:
  43. /*****************************************************************************
  44. * Operator-based class constructors
  45. *****************************************************************************/
  46. // create_serialized_item_ptr: Create a serialized item.
  47. LIntExport explicit HSerializedItem(void* Pointer, Hlong Size, const HString& Copy);
  48. // create_serialized_item_ptr: Create a serialized item.
  49. LIntExport explicit HSerializedItem(void* Pointer, Hlong Size, const char* Copy);
  50. #ifdef _WIN32
  51. // create_serialized_item_ptr: Create a serialized item.
  52. LIntExport explicit HSerializedItem(void* Pointer, Hlong Size, const wchar_t* Copy);
  53. #endif
  54. /***************************************************************************
  55. * Serialization *
  56. ***************************************************************************/
  57. #define H_SERIAL_HEADER_SIZE 16
  58. static LIntExport char*
  59. DeserializeInitFromHeader(char* header, bool streamIsOk, uint64_t* size);
  60. static LIntExport HSerializedItem DeserializeBufferToItem(uint64_t size,
  61. bool streamIsOk,
  62. char* serialized);
  63. #ifndef HCPP_NO_USE_IOSTREAM
  64. void inline Serialize(std::ostream& stream);
  65. static HSerializedItem inline Deserialize(std::istream& stream);
  66. #endif
  67. /***************************************************************************
  68. * Operators *
  69. ***************************************************************************/
  70. // Receive a serialized item over a socket connection.
  71. LIntExport void ReceiveSerializedItem(const HSocket& Socket);
  72. // Send a serialized item over a socket connection.
  73. LIntExport void SendSerializedItem(const HSocket& Socket) const;
  74. // Write a serialized item to a file.
  75. LIntExport void FwriteSerializedItem(const HFile& FileHandle) const;
  76. // Read a serialized item from a file.
  77. LIntExport void FreadSerializedItem(const HFile& FileHandle);
  78. // Delete a serialized item.
  79. static LIntExport void ClearSerializedItem(const HSerializedItemArray& SerializedItemHandle);
  80. // Delete a serialized item.
  81. LIntExport void ClearSerializedItem() const;
  82. // Access the data pointer of a serialized item.
  83. LIntExport void* GetSerializedItemPtr(Hlong* Size) const;
  84. // Create a serialized item.
  85. LIntExport void CreateSerializedItemPtr(void* Pointer, Hlong Size, const HString& Copy);
  86. // Create a serialized item.
  87. LIntExport void CreateSerializedItemPtr(void* Pointer, Hlong Size, const char* Copy);
  88. #ifdef _WIN32
  89. // Create a serialized item.
  90. LIntExport void CreateSerializedItemPtr(void* Pointer, Hlong Size, const wchar_t* Copy);
  91. #endif
  92. };
  93. // forward declarations and types for internal array implementation
  94. template<class T> class HSmartPtr;
  95. template<class T> class HHandleBaseArrayRef;
  96. typedef HHandleBaseArrayRef<HSerializedItem> HSerializedItemArrayRef;
  97. typedef HSmartPtr< HSerializedItemArrayRef > HSerializedItemArrayPtr;
  98. // Represents multiple tool instances
  99. class LIntExport HSerializedItemArray : public HHandleBaseArray
  100. {
  101. public:
  102. // Create empty array
  103. HSerializedItemArray();
  104. // Create array from native array of tool instances
  105. HSerializedItemArray(const HSerializedItem* classes, Hlong length);
  106. // Copy constructor
  107. HSerializedItemArray(const HSerializedItemArray &tool_array);
  108. // Destructor
  109. virtual ~HSerializedItemArray();
  110. // Assignment operator
  111. HSerializedItemArray &operator=(const HSerializedItemArray &tool_array);
  112. // Clears array and all tool instances
  113. virtual void Clear();
  114. // Get array of native tool instances
  115. const HSerializedItem* Tools() const;
  116. // Get number of tools
  117. virtual Hlong Length() const;
  118. // Create tool array from tuple of handles
  119. virtual void SetFromTuple(const HTuple& handles);
  120. // Get tuple of handles for tool array
  121. virtual HTuple ConvertToTuple() const;
  122. protected:
  123. // Smart pointer to internal data container
  124. HSerializedItemArrayPtr *mArrayPtr;
  125. };
  126. }
  127. #endif