HObjectBase.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*****************************************************************************
  2. * HObjectBase.h
  3. *****************************************************************************
  4. *
  5. * Project: HALCON/C++
  6. * Description: Base class for all iconic objects
  7. *
  8. * (c) 2010-2020 by MVTec Software GmbH
  9. * www.mvtec.com
  10. *
  11. *****************************************************************************
  12. *
  13. *
  14. *****************************************************************************/
  15. #ifndef HCPP_OBJECT_BASE_H
  16. #define HCPP_OBJECT_BASE_H
  17. namespace HalconCpp
  18. {
  19. class LIntExport HObjectBase
  20. {
  21. public:
  22. static const Hkey UNDEF;
  23. // Create an uninitialized object
  24. HObjectBase();
  25. // Create object from object id. For copy=false, takes
  26. // over management of input key
  27. HObjectBase(Hkey key, bool copy = true);
  28. // Copy constructor
  29. HObjectBase(const HObjectBase& obj);
  30. // Destructor
  31. ~HObjectBase();
  32. // Assignment
  33. HObjectBase& operator=(const HObjectBase& obj);
  34. // Comparison operators
  35. bool operator==(const HObjectBase& obj) const;
  36. bool operator!=(const HObjectBase& obj) const;
  37. // Set object from object id. For copy=false takes
  38. // over management of input key
  39. void SetKey(Hkey key, bool copy = true);
  40. // Return the managed key
  41. Hkey Key() const;
  42. // Return a copy of the managed key, which can
  43. // (and needs to) be disposed of separately
  44. Hkey CopyKey() const;
  45. // Return true if this object instance manages a valid key.
  46. bool IsInitialized() const;
  47. // Key life cycle will no longer be managed by this object
  48. void Detach();
  49. // Clear managed key and free resources if attached
  50. void Clear();
  51. /******************************************************************/
  52. /* Internal operations, exposed for use by extension package only */
  53. /******************************************************************/
  54. // Load output object from HALCON operator call
  55. void Load(Hproc_handle proc, int par_index, Herror err) const;
  56. // Store as input object for HALCON operator call
  57. Herror Store(Hproc_handle proc, int par_index) const;
  58. #if defined(HCPP_LEGACY_API)
  59. void AdaptId(Hkey key)
  60. {
  61. SetKey(key, false);
  62. }
  63. Hkey Id() const
  64. {
  65. return Key();
  66. }
  67. void Reset()
  68. {
  69. Clear();
  70. }
  71. #endif
  72. protected:
  73. Hkey mKey;
  74. bool mAttached;
  75. };
  76. }
  77. #endif