Interface.hpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*=============================================================================
  2. Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
  3. Redistribution of this file, in original or modified form, without
  4. prior written consent of Allied Vision Technologies is prohibited.
  5. -------------------------------------------------------------------------------
  6. File: Interface.hpp
  7. Description: Inline wrapper functions for class AVT::VmbAPI::Interface.
  8. -------------------------------------------------------------------------------
  9. THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  10. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
  11. NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  12. DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  13. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  14. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  15. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  16. AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  17. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  18. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19. =============================================================================*/
  20. #ifndef AVT_VMBAPI_INTERFACE_HPP
  21. #define AVT_VMBAPI_INTERFACE_HPP
  22. //
  23. // Inline wrapper functions that allocate memory for STL objects in the application's context
  24. // and to pass data across DLL boundaries using arrays
  25. //
  26. // HINT: This information remains static throughout the object's lifetime
  27. inline VmbErrorType Interface::GetID( std::string &rStrID ) const
  28. {
  29. VmbErrorType res;
  30. VmbUint32_t nLength;
  31. res = GetID( NULL, nLength );
  32. if ( VmbErrorSuccess == res)
  33. {
  34. if( 0 != nLength)
  35. {
  36. try
  37. {
  38. std::vector<std::string::value_type> tmpID( nLength + 1, '\0' );
  39. res = GetID( &tmpID[0], nLength );
  40. if( VmbErrorSuccess == res )
  41. {
  42. rStrID = &*tmpID.begin();
  43. }
  44. }
  45. catch(...)
  46. {
  47. return VmbErrorResources;
  48. }
  49. }
  50. else
  51. {
  52. rStrID.clear();
  53. }
  54. }
  55. return res;
  56. }
  57. // HINT: This information remains static throughout the object's lifetime
  58. inline VmbErrorType Interface::GetName( std::string &rStrName ) const
  59. {
  60. VmbErrorType res;
  61. VmbUint32_t nLength;
  62. res = GetName( NULL, nLength );
  63. if ( VmbErrorSuccess == res )
  64. {
  65. if( 0 != nLength )
  66. {
  67. try
  68. {
  69. std::vector<std::string::value_type> tmpName( nLength + 1, '\0' );
  70. res = GetName( &tmpName[0], nLength );
  71. if( VmbErrorSuccess == res )
  72. {
  73. rStrName = &*tmpName.begin();
  74. }
  75. }
  76. catch(...)
  77. {
  78. return VmbErrorResources;
  79. }
  80. }
  81. else
  82. {
  83. rStrName.clear();
  84. }
  85. }
  86. return res;
  87. }
  88. // HINT: This information remains static throughout the object's lifetime
  89. inline VmbErrorType Interface::GetSerialNumber( std::string &rStrSerial ) const
  90. {
  91. VmbErrorType res;
  92. VmbUint32_t nLength;
  93. res = GetSerialNumber( NULL, nLength );
  94. if ( VmbErrorSuccess == res )
  95. {
  96. if( 0 != nLength)
  97. {
  98. try
  99. {
  100. std::vector<std::string::value_type> tmpSerial( nLength + 1, '\0');
  101. res = GetSerialNumber( &tmpSerial[0], nLength );
  102. if( VmbErrorSuccess == res )
  103. {
  104. rStrSerial = &*tmpSerial.begin();
  105. }
  106. }
  107. catch(...)
  108. {
  109. return VmbErrorResources;
  110. }
  111. }
  112. else
  113. {
  114. rStrSerial.clear();
  115. }
  116. }
  117. return res;
  118. }
  119. #endif