VimbaSystem.hpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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: VimbaSystem.hpp
  7. Description: Inline wrapper functions for class AVT::VmbAPI::VimbaSystem.
  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_VIMBASYSTEM_HPP
  21. #define AVT_VMBAPI_VIMBASYSTEM_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. inline VmbErrorType VimbaSystem::GetInterfaces( InterfacePtrVector &rInterfaces )
  27. {
  28. VmbErrorType res;
  29. VmbUint32_t nSize;
  30. res = GetInterfaces( NULL, nSize );
  31. if ( VmbErrorSuccess == res )
  32. {
  33. if( 0 != nSize)
  34. {
  35. try
  36. {
  37. InterfacePtrVector tmpInterfaces( nSize );
  38. res = GetInterfaces( &tmpInterfaces[0], nSize );
  39. if( VmbErrorSuccess == res )
  40. {
  41. rInterfaces.swap( tmpInterfaces);
  42. }
  43. }
  44. catch(...)
  45. {
  46. return VmbErrorResources;
  47. }
  48. }
  49. else
  50. {
  51. rInterfaces.clear();
  52. }
  53. }
  54. return res;
  55. }
  56. inline VmbErrorType VimbaSystem::GetCameras( CameraPtrVector &rCameras )
  57. {
  58. VmbErrorType res;
  59. VmbUint32_t nSize;
  60. res = GetCameras( NULL, nSize );
  61. if ( VmbErrorSuccess == res)
  62. {
  63. if( 0 != nSize)
  64. {
  65. try
  66. {
  67. CameraPtrVector tmpCameras( nSize );
  68. res = GetCameras( &tmpCameras[0], nSize );
  69. if( VmbErrorSuccess == res )
  70. {
  71. if( nSize < tmpCameras.size() )
  72. {
  73. tmpCameras.resize( nSize);
  74. }
  75. rCameras.swap( tmpCameras );
  76. }
  77. }
  78. catch(...)
  79. {
  80. return VmbErrorResources;
  81. }
  82. }
  83. else
  84. {
  85. rCameras.clear();
  86. }
  87. }
  88. return res;
  89. }
  90. #endif