ICommand.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. //-----------------------------------------------------------------------------
  2. // (c) 2006 by Basler Vision Technologies
  3. // Section: Vision Components
  4. // Project: GenApi
  5. // Author: Hartmut Nebelung
  6. // $Header$
  7. //
  8. // License: This file is published under the license of the EMVA GenICam Standard Group.
  9. // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
  10. // If for some reason you are missing this file please contact the EMVA or visit the website
  11. // (http://www.genicam.org) for a full copy.
  12. //
  13. // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
  14. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  15. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
  17. // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  18. // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19. // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  20. // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  21. // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  22. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  23. // POSSIBILITY OF SUCH DAMAGE.
  24. //-----------------------------------------------------------------------------
  25. /*!
  26. \file
  27. \brief Definition of ICommand interface
  28. \ingroup GenApi_PublicInterface
  29. */
  30. #ifndef GENAPI_ICOMMAND_H
  31. #define GENAPI_ICOMMAND_H
  32. #include <GenApi/GenApiDll.h>
  33. #include <GenApi/Types.h>
  34. #include <GenApi/IValue.h>
  35. #pragma warning ( push )
  36. #pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY
  37. namespace GENAPI_NAMESPACE
  38. {
  39. //*************************************************************
  40. // ICommand interface
  41. //*************************************************************
  42. //! Interface for command like properties
  43. //! \ingroup GenApi_PublicInterface
  44. interface GENAPI_DECL_ABSTRACT ICommand : virtual public IValue
  45. {
  46. public:
  47. //! Execute the command
  48. /*!
  49. \param Verify Enables AccessMode and Range verification (default = true)
  50. */
  51. virtual void Execute(bool Verify = true) = 0;
  52. //! Execute the command
  53. virtual void operator()() = 0;
  54. //! Query whether the command is executed
  55. /*!
  56. \param Verify Enables Range verification (default = false). The AccessMode is always checked
  57. \return True if the Execute command has finished; false otherwise
  58. */
  59. virtual bool IsDone(bool Verify = true) = 0;
  60. };
  61. //*************************************************************
  62. // CCommandRef class
  63. //*************************************************************
  64. #ifndef DOXYGEN_IGNORE
  65. /**
  66. \internal
  67. \brief Reference to an IInteger pointer
  68. \ingroup GenApi_PublicImpl
  69. */
  70. template <class T>
  71. class CCommandRefT : public CValueRefT<T>
  72. {
  73. typedef CValueRefT<T> ref;
  74. public:
  75. /*--------------------------------------------------------*/
  76. // ICommand
  77. /*--------------------------------------------------------*/
  78. //! Execute the command
  79. virtual void Execute(bool Verify = true)
  80. {
  81. if(ref::m_Ptr)
  82. return ref::m_Ptr->Execute(Verify);
  83. else
  84. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  85. }
  86. //! Execute the command
  87. virtual void operator()()
  88. {
  89. if(ref::m_Ptr)
  90. ref::m_Ptr->operator()();
  91. else
  92. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  93. }
  94. //! Query whether the command is executed
  95. virtual bool IsDone(bool Verify = true)
  96. {
  97. if(ref::m_Ptr)
  98. return ref::m_Ptr->IsDone(Verify);
  99. else
  100. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  101. }
  102. };
  103. //! Reference to an ICommand pointer
  104. //! \ingroup GenApi_PublicImpl
  105. typedef CCommandRefT<ICommand> CCommandRef;
  106. #endif
  107. }
  108. #pragma warning ( pop )
  109. #endif // ifndef GENAPI_ICOMMAND_H