FeatureContainer.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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: FeatureContainer.hpp
  7. Description: Inline wrapper functions for class
  8. AVT::VmbAPI::FeatureContainer.
  9. -------------------------------------------------------------------------------
  10. THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  11. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
  12. NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  13. DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  14. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  15. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  16. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  17. AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  18. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  19. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20. =============================================================================*/
  21. #ifndef AVT_VMBAPI_FEATURECONTAINER_HPP
  22. #define AVT_VMBAPI_FEATURECONTAINER_HPP
  23. //
  24. // Inline wrapper functions that allocate memory for STL objects in the application's context
  25. // and to pass data across DLL boundaries using arrays
  26. //
  27. // HINT: Once queried this information remains static throughout the object's lifetime
  28. inline VmbErrorType FeatureContainer::GetFeatures( FeaturePtrVector &features )
  29. {
  30. VmbErrorType res;
  31. VmbUint32_t nSize;
  32. res = GetFeatures( NULL, nSize );
  33. if ( VmbErrorSuccess == res )
  34. {
  35. if( 0 != nSize)
  36. {
  37. try
  38. {
  39. FeaturePtrVector tmpFeatures( nSize );
  40. res = GetFeatures( &tmpFeatures[0], nSize );
  41. if( VmbErrorSuccess == res)
  42. {
  43. features.swap( tmpFeatures );
  44. }
  45. }
  46. catch(...)
  47. {
  48. return VmbErrorResources;
  49. }
  50. }
  51. else
  52. {
  53. features.clear();
  54. }
  55. }
  56. return res;
  57. }
  58. #endif