HSerializedItem.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /***********************************************************
  2. * File generated by the HALCON-Compiler hcomp version 20.11
  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 * DeserializeInitFromHeader(char* header, bool streamIsOk, HUINT8 *size);
  59. static LIntExport HSerializedItem DeserializeBufferToItem(HUINT8 size, bool streamIsOk, char *serialized);
  60. #ifndef HCPP_NO_USE_IOSTREAM
  61. void inline Serialize(std::ostream& stream);
  62. static HSerializedItem inline Deserialize(std::istream& stream);
  63. #endif
  64. /***************************************************************************
  65. * Operators *
  66. ***************************************************************************/
  67. // Receive a serialized item over a socket connection.
  68. LIntExport void ReceiveSerializedItem(const HSocket& Socket);
  69. // Send a serialized item over a socket connection.
  70. LIntExport void SendSerializedItem(const HSocket& Socket) const;
  71. // Write a serialized item to a file.
  72. LIntExport void FwriteSerializedItem(const HFile& FileHandle) const;
  73. // Read a serialized item from a file.
  74. LIntExport void FreadSerializedItem(const HFile& FileHandle);
  75. // Delete a serialized item.
  76. static LIntExport void ClearSerializedItem(const HSerializedItemArray& SerializedItemHandle);
  77. // Delete a serialized item.
  78. LIntExport void ClearSerializedItem() const;
  79. // Access the data pointer of a serialized item.
  80. LIntExport void* GetSerializedItemPtr(Hlong* Size) const;
  81. // Create a serialized item.
  82. LIntExport void CreateSerializedItemPtr(void* Pointer, Hlong Size, const HString& Copy);
  83. // Create a serialized item.
  84. LIntExport void CreateSerializedItemPtr(void* Pointer, Hlong Size, const char* Copy);
  85. #ifdef _WIN32
  86. // Create a serialized item.
  87. LIntExport void CreateSerializedItemPtr(void* Pointer, Hlong Size, const wchar_t* Copy);
  88. #endif
  89. };
  90. // forward declarations and types for internal array implementation
  91. template<class T> class HSmartPtr;
  92. template<class T> class HHandleBaseArrayRef;
  93. typedef HHandleBaseArrayRef<HSerializedItem> HSerializedItemArrayRef;
  94. typedef HSmartPtr< HSerializedItemArrayRef > HSerializedItemArrayPtr;
  95. // Represents multiple tool instances
  96. class LIntExport HSerializedItemArray : public HHandleBaseArray
  97. {
  98. public:
  99. // Create empty array
  100. HSerializedItemArray();
  101. // Create array from native array of tool instances
  102. HSerializedItemArray(HSerializedItem* classes, Hlong length);
  103. // Copy constructor
  104. HSerializedItemArray(const HSerializedItemArray &tool_array);
  105. // Destructor
  106. virtual ~HSerializedItemArray();
  107. // Assignment operator
  108. HSerializedItemArray &operator=(const HSerializedItemArray &tool_array);
  109. // Clears array and all tool instances
  110. virtual void Clear();
  111. // Get array of native tool instances
  112. const HSerializedItem* Tools() const;
  113. // Get number of tools
  114. virtual Hlong Length() const;
  115. // Create tool array from tuple of handles
  116. virtual void SetFromTuple(const HTuple& handles);
  117. // Get tuple of handles for tool array
  118. virtual HTuple ConvertToTuple() const;
  119. protected:
  120. // Smart pointer to internal data container
  121. HSerializedItemArrayPtr *mArrayPtr;
  122. };
  123. }
  124. #endif