HMessage.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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_HMESSAGE
  8. #define HCPP_HMESSAGE
  9. namespace HalconCpp
  10. {
  11. // Represents an instance of a data container to be sent via message queues.
  12. class LIntExport HMessage : public HHandle
  13. {
  14. public:
  15. // Copy constructor
  16. HMessage(const HMessage& source) : HHandle(source) {}
  17. // Copy constructor
  18. HMessage(const HHandle& handle);
  19. // Create HMessage from handle, taking ownership
  20. explicit HMessage(Hlong handle);
  21. bool operator==(const HHandle& obj) const
  22. {
  23. return HHandleBase::operator==(obj);
  24. }
  25. bool operator!=(const HHandle& obj) const
  26. {
  27. return HHandleBase::operator!=(obj);
  28. }
  29. protected:
  30. // Verify matching semantic type ('message')!
  31. virtual void AssertType(Hphandle handle) const;
  32. public:
  33. /*****************************************************************************
  34. * Operator-based class constructors
  35. *****************************************************************************/
  36. // create_message: Create a new empty message.
  37. explicit HMessage();
  38. // read_message: Read a message from a file.
  39. explicit HMessage(const HString& FileName, const HTuple& GenParamName, const HTuple& GenParamValue);
  40. // read_message: Read a message from a file.
  41. explicit HMessage(const HString& FileName, const HString& GenParamName, const HString& GenParamValue);
  42. // read_message: Read a message from a file.
  43. explicit HMessage(const char* FileName, const char* GenParamName, const char* GenParamValue);
  44. #ifdef _WIN32
  45. // read_message: Read a message from a file.
  46. explicit HMessage(const wchar_t* FileName, const wchar_t* GenParamName, const wchar_t* GenParamValue);
  47. #endif
  48. /***************************************************************************
  49. * Operators *
  50. ***************************************************************************/
  51. // Query message parameters or information about the message.
  52. HTuple GetMessageParam(const HString& GenParamName, const HTuple& Key) const;
  53. // Query message parameters or information about the message.
  54. HTuple GetMessageParam(const HString& GenParamName, const HString& Key) const;
  55. // Query message parameters or information about the message.
  56. HTuple GetMessageParam(const char* GenParamName, const char* Key) const;
  57. #ifdef _WIN32
  58. // Query message parameters or information about the message.
  59. HTuple GetMessageParam(const wchar_t* GenParamName, const wchar_t* Key) const;
  60. #endif
  61. // Set message parameter or invoke commands on the message.
  62. void SetMessageParam(const HString& GenParamName, const HTuple& Key, const HTuple& GenParamValue) const;
  63. // Set message parameter or invoke commands on the message.
  64. void SetMessageParam(const HString& GenParamName, const HString& Key, const HTuple& GenParamValue) const;
  65. // Set message parameter or invoke commands on the message.
  66. void SetMessageParam(const char* GenParamName, const char* Key, const HTuple& GenParamValue) const;
  67. #ifdef _WIN32
  68. // Set message parameter or invoke commands on the message.
  69. void SetMessageParam(const wchar_t* GenParamName, const wchar_t* Key, const HTuple& GenParamValue) const;
  70. #endif
  71. // Retrieve an object associated with the key from the message.
  72. HObject GetMessageObj(const HTuple& Key) const;
  73. // Retrieve an object associated with the key from the message.
  74. HObject GetMessageObj(const HString& Key) const;
  75. // Retrieve an object associated with the key from the message.
  76. HObject GetMessageObj(const char* Key) const;
  77. #ifdef _WIN32
  78. // Retrieve an object associated with the key from the message.
  79. HObject GetMessageObj(const wchar_t* Key) const;
  80. #endif
  81. // Add a key/object pair to the message.
  82. void SetMessageObj(const HObject& ObjectData, const HTuple& Key) const;
  83. // Add a key/object pair to the message.
  84. void SetMessageObj(const HObject& ObjectData, const HString& Key) const;
  85. // Add a key/object pair to the message.
  86. void SetMessageObj(const HObject& ObjectData, const char* Key) const;
  87. #ifdef _WIN32
  88. // Add a key/object pair to the message.
  89. void SetMessageObj(const HObject& ObjectData, const wchar_t* Key) const;
  90. #endif
  91. // Retrieve a tuple associated with the key from the message.
  92. HTuple GetMessageTuple(const HTuple& Key) const;
  93. // Retrieve a tuple associated with the key from the message.
  94. HTuple GetMessageTuple(const HString& Key) const;
  95. // Retrieve a tuple associated with the key from the message.
  96. HTuple GetMessageTuple(const char* Key) const;
  97. #ifdef _WIN32
  98. // Retrieve a tuple associated with the key from the message.
  99. HTuple GetMessageTuple(const wchar_t* Key) const;
  100. #endif
  101. // Add a key/tuple pair to the message.
  102. void SetMessageTuple(const HTuple& Key, const HTuple& TupleData) const;
  103. // Add a key/tuple pair to the message.
  104. void SetMessageTuple(const HString& Key, const HTuple& TupleData) const;
  105. // Add a key/tuple pair to the message.
  106. void SetMessageTuple(const char* Key, const HTuple& TupleData) const;
  107. #ifdef _WIN32
  108. // Add a key/tuple pair to the message.
  109. void SetMessageTuple(const wchar_t* Key, const HTuple& TupleData) const;
  110. #endif
  111. // Close a message handle and release all associated resources.
  112. static void ClearMessage(const HMessageArray& MessageHandle);
  113. // Close a message handle and release all associated resources.
  114. void ClearMessage() const;
  115. // Create a new empty message.
  116. void CreateMessage();
  117. // Read a message from a file.
  118. void ReadMessage(const HString& FileName, const HTuple& GenParamName, const HTuple& GenParamValue);
  119. // Read a message from a file.
  120. void ReadMessage(const HString& FileName, const HString& GenParamName, const HString& GenParamValue);
  121. // Read a message from a file.
  122. void ReadMessage(const char* FileName, const char* GenParamName, const char* GenParamValue);
  123. #ifdef _WIN32
  124. // Read a message from a file.
  125. void ReadMessage(const wchar_t* FileName, const wchar_t* GenParamName, const wchar_t* GenParamValue);
  126. #endif
  127. // Write a message to a file.
  128. void WriteMessage(const HString& FileName, const HTuple& GenParamName, const HTuple& GenParamValue) const;
  129. // Write a message to a file.
  130. void WriteMessage(const HString& FileName, const HString& GenParamName, const HString& GenParamValue) const;
  131. // Write a message to a file.
  132. void WriteMessage(const char* FileName, const char* GenParamName, const char* GenParamValue) const;
  133. #ifdef _WIN32
  134. // Write a message to a file.
  135. void WriteMessage(const wchar_t* FileName, const wchar_t* GenParamName, const wchar_t* GenParamValue) const;
  136. #endif
  137. };
  138. // forward declarations and types for internal array implementation
  139. template<class T> class HSmartPtr;
  140. template<class T> class HHandleBaseArrayRef;
  141. typedef HHandleBaseArrayRef<HMessage> HMessageArrayRef;
  142. typedef HSmartPtr< HMessageArrayRef > HMessageArrayPtr;
  143. // Represents multiple tool instances
  144. class LIntExport HMessageArray : public HHandleBaseArray
  145. {
  146. public:
  147. // Create empty array
  148. HMessageArray();
  149. // Create array from native array of tool instances
  150. HMessageArray(HMessage* classes, Hlong length);
  151. // Copy constructor
  152. HMessageArray(const HMessageArray &tool_array);
  153. // Destructor
  154. virtual ~HMessageArray();
  155. // Assignment operator
  156. HMessageArray &operator=(const HMessageArray &tool_array);
  157. // Clears array and all tool instances
  158. virtual void Clear();
  159. // Get array of native tool instances
  160. const HMessage* Tools() const;
  161. // Get number of tools
  162. virtual Hlong Length() const;
  163. // Create tool array from tuple of handles
  164. virtual void SetFromTuple(const HTuple& handles);
  165. // Get tuple of handles for tool array
  166. virtual HTuple ConvertToTuple() const;
  167. protected:
  168. // Smart pointer to internal data container
  169. HMessageArrayPtr *mArrayPtr;
  170. };
  171. }
  172. #endif