HDevThread.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*****************************************************************************
  2. * HDevThread.h
  3. *****************************************************************************
  4. *
  5. * Project: Halcon/C++
  6. * Description: Helper class for export of HDevelop's parallel
  7. * language extensions.
  8. *
  9. * (c) 2014-2020 by MVTec Software GmbH
  10. * www.mvtec.com
  11. *
  12. *****************************************************************************
  13. *
  14. *
  15. *****************************************************************************/
  16. #ifndef HCPP_DEV_THREAD_H
  17. #define HCPP_DEV_THREAD_H
  18. namespace HalconCpp
  19. {
  20. class LIntExport HDevThreadContext
  21. {
  22. public:
  23. HDevThreadContext();
  24. ~HDevThreadContext();
  25. void* GetHandle() const
  26. {
  27. return mContextHandle;
  28. }
  29. private:
  30. void* mContextHandle;
  31. };
  32. class HDevInputParam;
  33. class HDevOutputParam;
  34. class LIntExport HDevThread
  35. {
  36. public:
  37. // Manage threads and procedure calls
  38. explicit HDevThread(const HDevThreadContext& context,
  39. const void* proc, Hlong num_in, Hlong num_out);
  40. ~HDevThread();
  41. void Start();
  42. void ParStart(HTuple *par_handle);
  43. static void ParJoin(const HTuple& par_handles);
  44. void Exit(void);
  45. void CallProc();
  46. bool IsDirectCall() const {return mDirectCall;}
  47. // Store copy of input parameter value in thread-specific context
  48. void SetInputIconicParamObject(Hlong par_index, const HObject& obj);
  49. void SetInputIconicParamVector(Hlong par_index,
  50. const HObjectVector& vector);
  51. void SetInputCtrlParamTuple(Hlong par_index, const HTuple& tuple);
  52. void SetInputCtrlParamVector(Hlong par_index,
  53. const HTupleVector& vector);
  54. // Access thread-specific copy of input value
  55. const HObject& GetInputIconicParamObject(Hlong par_index) const;
  56. const HObjectVector& GetInputIconicParamVector(Hlong par_index) const;
  57. const HTuple& GetInputCtrlParamTuple(Hlong par_index) const;
  58. const HTupleVector& GetInputCtrlParamVector(Hlong par_index) const;
  59. // Bind variable reference to output parameter
  60. void BindOutputIconicParamObject(Hlong par_index, bool global,
  61. HObject* obj);
  62. void BindOutputIconicParamVector(Hlong par_index, bool global,
  63. HObjectVector* vector,
  64. HTuple index = HTuple());
  65. void BindOutputCtrlParamTuple(Hlong par_index, bool global, HTuple* obj);
  66. void BindOutputCtrlParamVector(Hlong par_index, bool global,
  67. HTupleVector* vector,
  68. HTuple index = HTuple());
  69. // Store result of procedure call into bound output variables
  70. void StoreOutputIconicParamObject(Hlong par_index, const HObject& obj);
  71. void StoreOutputIconicParamVector(Hlong par_index,
  72. const HObjectVector& vector);
  73. void StoreOutputCtrlParamTuple(Hlong par_index, const HTuple& tuple);
  74. void StoreOutputCtrlParamVector(Hlong par_index,
  75. const HTupleVector& vector);
  76. protected:
  77. void* mThreadHandle;
  78. const void* mProc;
  79. bool mDirectCall;
  80. Hlong mNumParamsInput;
  81. Hlong mNumParamsOutput;
  82. HDevInputParam** mParamsInput;
  83. HDevOutputParam** mParamsOutput;
  84. };
  85. } // namespace HalconCpp
  86. #endif