HDict.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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_HDICT
  8. #define HCPP_HDICT
  9. namespace HalconCpp
  10. {
  11. // Represents an instance of a Dictionary.
  12. class LIntExport HDict : public HHandle
  13. {
  14. public:
  15. // Copy constructor
  16. HDict(const HDict& source) : HHandle(source) {}
  17. // Copy constructor
  18. HDict(const HHandle& handle);
  19. // Create HDict from handle, taking ownership
  20. explicit HDict(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 ('dict')!
  31. virtual void AssertType(Hphandle handle) const;
  32. public:
  33. /*****************************************************************************
  34. * Operator-based class constructors
  35. *****************************************************************************/
  36. // create_dict: Create a new empty dictionary.
  37. explicit HDict();
  38. // read_dict: Read a dictionary from a file.
  39. explicit HDict(const HString& FileName, const HTuple& GenParamName, const HTuple& GenParamValue);
  40. // read_dict: Read a dictionary from a file.
  41. explicit HDict(const HString& FileName, const HString& GenParamName, const HString& GenParamValue);
  42. // read_dict: Read a dictionary from a file.
  43. explicit HDict(const char* FileName, const char* GenParamName, const char* GenParamValue);
  44. #ifdef _WIN32
  45. // read_dict: Read a dictionary from a file.
  46. explicit HDict(const wchar_t* FileName, const wchar_t* GenParamName, const wchar_t* GenParamValue);
  47. #endif
  48. /***************************************************************************
  49. * Operators *
  50. ***************************************************************************/
  51. // Copy a dictionary.
  52. HDict CopyDict(const HTuple& GenParamName, const HTuple& GenParamValue) const;
  53. // Copy a dictionary.
  54. HDict CopyDict(const HString& GenParamName, const HString& GenParamValue) const;
  55. // Copy a dictionary.
  56. HDict CopyDict(const char* GenParamName, const char* GenParamValue) const;
  57. #ifdef _WIN32
  58. // Copy a dictionary.
  59. HDict CopyDict(const wchar_t* GenParamName, const wchar_t* GenParamValue) const;
  60. #endif
  61. // Create a new empty dictionary.
  62. void CreateDict();
  63. // Retrieve an object associated with the key from the dictionary.
  64. HObject GetDictObject(const HTuple& Key) const;
  65. // Retrieve an object associated with the key from the dictionary.
  66. HObject GetDictObject(const HString& Key) const;
  67. // Retrieve an object associated with the key from the dictionary.
  68. HObject GetDictObject(const char* Key) const;
  69. #ifdef _WIN32
  70. // Retrieve an object associated with the key from the dictionary.
  71. HObject GetDictObject(const wchar_t* Key) const;
  72. #endif
  73. // Query dictionary parameters or information about a dictionary.
  74. HTuple GetDictParam(const HString& GenParamName, const HTuple& Key) const;
  75. // Query dictionary parameters or information about a dictionary.
  76. HTuple GetDictParam(const HString& GenParamName, const HString& Key) const;
  77. // Query dictionary parameters or information about a dictionary.
  78. HTuple GetDictParam(const char* GenParamName, const char* Key) const;
  79. #ifdef _WIN32
  80. // Query dictionary parameters or information about a dictionary.
  81. HTuple GetDictParam(const wchar_t* GenParamName, const wchar_t* Key) const;
  82. #endif
  83. // Retrieve a tuple associated with the key from the dictionary.
  84. HTuple GetDictTuple(const HTuple& Key) const;
  85. // Retrieve a tuple associated with the key from the dictionary.
  86. HTuple GetDictTuple(const HString& Key) const;
  87. // Retrieve a tuple associated with the key from the dictionary.
  88. HTuple GetDictTuple(const char* Key) const;
  89. #ifdef _WIN32
  90. // Retrieve a tuple associated with the key from the dictionary.
  91. HTuple GetDictTuple(const wchar_t* Key) const;
  92. #endif
  93. // Read a dictionary from a file.
  94. void ReadDict(const HString& FileName, const HTuple& GenParamName, const HTuple& GenParamValue);
  95. // Read a dictionary from a file.
  96. void ReadDict(const HString& FileName, const HString& GenParamName, const HString& GenParamValue);
  97. // Read a dictionary from a file.
  98. void ReadDict(const char* FileName, const char* GenParamName, const char* GenParamValue);
  99. #ifdef _WIN32
  100. // Read a dictionary from a file.
  101. void ReadDict(const wchar_t* FileName, const wchar_t* GenParamName, const wchar_t* GenParamValue);
  102. #endif
  103. // Remove keys from a dictionary.
  104. void RemoveDictKey(const HTuple& Key) const;
  105. // Remove keys from a dictionary.
  106. void RemoveDictKey(const HString& Key) const;
  107. // Remove keys from a dictionary.
  108. void RemoveDictKey(const char* Key) const;
  109. #ifdef _WIN32
  110. // Remove keys from a dictionary.
  111. void RemoveDictKey(const wchar_t* Key) const;
  112. #endif
  113. // Add a key/object pair to the dictionary.
  114. void SetDictObject(const HObject& Object, const HTuple& Key) const;
  115. // Add a key/object pair to the dictionary.
  116. void SetDictObject(const HObject& Object, const HString& Key) const;
  117. // Add a key/object pair to the dictionary.
  118. void SetDictObject(const HObject& Object, const char* Key) const;
  119. #ifdef _WIN32
  120. // Add a key/object pair to the dictionary.
  121. void SetDictObject(const HObject& Object, const wchar_t* Key) const;
  122. #endif
  123. // Add a key/tuple pair to the dictionary.
  124. void SetDictTuple(const HTuple& Key, const HTuple& Tuple) const;
  125. // Add a key/tuple pair to the dictionary.
  126. void SetDictTuple(const HString& Key, const HTuple& Tuple) const;
  127. // Add a key/tuple pair to the dictionary.
  128. void SetDictTuple(const char* Key, const HTuple& Tuple) const;
  129. #ifdef _WIN32
  130. // Add a key/tuple pair to the dictionary.
  131. void SetDictTuple(const wchar_t* Key, const HTuple& Tuple) const;
  132. #endif
  133. // Write a dictionary to a file.
  134. void WriteDict(const HString& FileName, const HTuple& GenParamName, const HTuple& GenParamValue) const;
  135. // Write a dictionary to a file.
  136. void WriteDict(const HString& FileName, const HString& GenParamName, const HString& GenParamValue) const;
  137. // Write a dictionary to a file.
  138. void WriteDict(const char* FileName, const char* GenParamName, const char* GenParamValue) const;
  139. #ifdef _WIN32
  140. // Write a dictionary to a file.
  141. void WriteDict(const wchar_t* FileName, const wchar_t* GenParamName, const wchar_t* GenParamValue) const;
  142. #endif
  143. };
  144. // forward declarations and types for internal array implementation
  145. template<class T> class HSmartPtr;
  146. template<class T> class HHandleBaseArrayRef;
  147. typedef HHandleBaseArrayRef<HDict> HDictArrayRef;
  148. typedef HSmartPtr< HDictArrayRef > HDictArrayPtr;
  149. // Represents multiple tool instances
  150. class LIntExport HDictArray : public HHandleBaseArray
  151. {
  152. public:
  153. // Create empty array
  154. HDictArray();
  155. // Create array from native array of tool instances
  156. HDictArray(HDict* classes, Hlong length);
  157. // Copy constructor
  158. HDictArray(const HDictArray &tool_array);
  159. // Destructor
  160. virtual ~HDictArray();
  161. // Assignment operator
  162. HDictArray &operator=(const HDictArray &tool_array);
  163. // Clears array and all tool instances
  164. virtual void Clear();
  165. // Get array of native tool instances
  166. const HDict* Tools() const;
  167. // Get number of tools
  168. virtual Hlong Length() const;
  169. // Create tool array from tuple of handles
  170. virtual void SetFromTuple(const HTuple& handles);
  171. // Get tuple of handles for tool array
  172. virtual HTuple ConvertToTuple() const;
  173. protected:
  174. // Smart pointer to internal data container
  175. HDictArrayPtr *mArrayPtr;
  176. };
  177. }
  178. #endif