123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546 |
- /*=============================================================================
- Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
- Redistribution of this file, in original or modified form, without
- prior written consent of Allied Vision Technologies is prohibited.
- -------------------------------------------------------------------------------
- File: Feature.hpp
- Description: Inline wrapper functions for class AVT::VmbAPI::Feature.
- -------------------------------------------------------------------------------
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
- NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- =============================================================================*/
- #ifndef AVT_VMBAPI_FEATURE_HPP
- #define AVT_VMBAPI_FEATURE_HPP
- //
- // Inline wrapper functions that allocate memory for STL objects in the application's context
- // and to pass data across DLL boundaries using arrays
- //
- inline VmbErrorType Feature::GetValues( StringVector &rValues )
- {
- VmbErrorType res;
- VmbUint32_t nSize;
- res = GetValues( (const char **)NULL, nSize );
- if ( VmbErrorSuccess == res )
- {
- if ( 0 != nSize)
- {
- try
- {
- std::vector<const char*> data( nSize );
- res = GetValues( &data[0], nSize );
- if ( VmbErrorSuccess == res )
- {
- StringVector tmpValues( data.size() );
- std::copy( data.begin(), data.end(), tmpValues.begin() );
- rValues.swap( tmpValues);
- }
- }
- catch(...)
- {
- return VmbErrorResources;
- }
- }
- else
- {
- rValues.clear();
- }
- }
- return res;
- }
- inline VmbErrorType Feature::GetEntries( EnumEntryVector &rEntries )
- {
- VmbErrorType res;
- VmbUint32_t nSize;
- res = GetEntries( (EnumEntry*)NULL, nSize );
- if ( VmbErrorSuccess == res )
- {
- if( 0 != nSize )
- {
- try
- {
- EnumEntryVector tmpEntries( nSize );
- res = GetEntries( &tmpEntries[0], nSize );
- if( VmbErrorSuccess == res)
- {
- rEntries.swap( tmpEntries );
- }
- }
- catch(...)
- {
- return VmbErrorResources;
- }
- }
- else
- {
- rEntries.clear();
- }
- }
- return res;
- }
- inline VmbErrorType Feature::GetValues( Int64Vector &rValues )
- {
- VmbErrorType res;
- VmbUint32_t nSize;
- res = GetValues( (VmbInt64_t*)NULL, nSize );
- if ( VmbErrorSuccess == res )
- {
- if( 0 != nSize)
- {
- try
- {
- Int64Vector tmpValues( nSize );
- res = GetValues( &tmpValues[0], nSize );
- if( VmbErrorSuccess == res)
- {
- rValues.swap( tmpValues );
- }
- }
- catch(...)
- {
- return VmbErrorResources;
- }
- }
- else
- {
- rValues.clear();
- }
- }
- return res;
- }
- inline VmbErrorType Feature::GetValue( std::string &rStrValue ) const
- {
- VmbErrorType res;
- VmbUint32_t nLength;
- res = GetValue( (char * const)NULL, nLength );
- if ( VmbErrorSuccess == res )
- {
- if ( 0 != nLength )
- {
- try
- {
- std::vector<std::string::value_type> tmpValue( nLength + 1, '\0' );
- res = GetValue( &tmpValue[0], nLength );
- if ( VmbErrorSuccess == res )
- {
- rStrValue = &*tmpValue.begin();
- }
- }
- catch(...)
- {
- return VmbErrorResources;
- }
- }
- else
- {
- rStrValue.clear();
- }
- }
- return res;
- }
- inline VmbErrorType Feature::GetValue( UcharVector &rValue ) const
- {
- VmbUint32_t i;
- return GetValue( rValue, i );
- }
- inline VmbErrorType Feature::GetValue( UcharVector &rValue, VmbUint32_t &rnSizeFilled ) const
- {
- VmbErrorType res;
- VmbUint32_t nSize;
- res = GetValue( NULL, nSize, rnSizeFilled );
- if ( VmbErrorSuccess == res )
- {
- if( 0 != nSize)
- {
- try
- {
- UcharVector tmpValue( nSize );
- res = GetValue( &tmpValue[0], nSize, rnSizeFilled );
- if( VmbErrorSuccess == res )
- {
- rValue.swap( tmpValue);
- }
- }
- catch(...)
- {
- return VmbErrorResources;
- }
- }
- else
- {
- rValue.clear();
- }
- }
- return res;
- }
- inline VmbErrorType Feature::SetValue( const UcharVector &rValue )
- {
- if ( rValue.empty() )
- {
- return VmbErrorBadParameter;
- }
- return SetValue( &rValue[0], (VmbUint32_t)rValue.size() );
- }
- inline VmbErrorType Feature::GetName( std::string &rStrName ) const
- {
- VmbErrorType res;
- VmbUint32_t nLength;
- res = GetName( NULL, nLength );
- if ( VmbErrorSuccess == res )
- {
- if ( 0 != nLength )
- {
- try
- {
- std::vector<std::string::value_type> tmpName( nLength + 1, '\0' );
- res = GetName( &tmpName[0], nLength );
- if( VmbErrorSuccess == res)
- {
- rStrName = &*tmpName.begin();
- }
- }
- catch(...)
- {
- return VmbErrorResources;
- }
- }
- else
- {
- rStrName.clear();
- }
- }
- return res;
- }
- inline VmbErrorType Feature::GetDisplayName( std::string &rStrDisplayName ) const
- {
- VmbErrorType res;
- VmbUint32_t nLength;
- res = GetDisplayName( NULL, nLength );
- if ( VmbErrorSuccess == res )
- {
- if ( 0 != nLength )
- {
- try
- {
- std::vector<std::string::value_type> tmpDisplayName( nLength + 1, '\0' );
- res = GetDisplayName( &tmpDisplayName[0], nLength );
- if( VmbErrorSuccess == res )
- {
- rStrDisplayName = &*tmpDisplayName.begin();
- }
- }
- catch(...)
- {
- return VmbErrorResources;
- }
- }
- else
- {
- rStrDisplayName.clear();
- }
- }
- return res;
- }
- inline VmbErrorType Feature::GetCategory( std::string &rStrCategory ) const
- {
- VmbErrorType res;
- VmbUint32_t nLength;
- res = GetCategory( NULL, nLength );
- if ( VmbErrorSuccess == res )
- {
- if ( 0 != nLength )
- {
- try
- {
- std::vector<std::string::value_type> tmpCategory( nLength + 1, '\0' );
- res = GetCategory( &tmpCategory[0], nLength );
- if( VmbErrorSuccess == res )
- {
- rStrCategory = &*tmpCategory.begin();
- }
- }
- catch(...)
- {
- return VmbErrorResources;
- }
- }
- else
- {
- rStrCategory.clear();
- }
- }
- return res;
- }
- inline VmbErrorType Feature::GetUnit( std::string &rStrUnit ) const
- {
- VmbErrorType res;
- VmbUint32_t nLength;
- res = GetUnit( NULL, nLength );
- if ( VmbErrorSuccess == res )
- {
- if ( 0 != nLength )
- {
- try
- {
- std::vector<std::string::value_type> tmpUnit( nLength + 1, '\0' );
- res = GetUnit( &tmpUnit[0], nLength );
- if( VmbErrorSuccess == res )
- {
- rStrUnit = &*tmpUnit.begin();
- }
- }
- catch(...)
- {
- return VmbErrorResources;
- }
- }
- else
- {
- rStrUnit.clear();
- }
- }
- return res;
- }
- inline VmbErrorType Feature::GetRepresentation( std::string &rStrRepresentation ) const
- {
- VmbErrorType res;
- VmbUint32_t nLength;
- res = GetRepresentation( NULL, nLength );
- if ( VmbErrorSuccess == res )
- {
- if ( 0 != nLength )
- {
- try
- {
- std::vector<std::string::value_type> tmpRepresentation( nLength + 1, '\0' );
- res = GetRepresentation( &tmpRepresentation[0], nLength );
- if( VmbErrorSuccess == res )
- {
- rStrRepresentation = &*tmpRepresentation.begin();
- }
- }
- catch(...)
- {
- return VmbErrorResources;
- }
- }
- else
- {
- rStrRepresentation.clear();
- }
- }
- return res;
- }
- inline VmbErrorType Feature::GetToolTip( std::string &rStrToolTip ) const
- {
- VmbErrorType res;
- VmbUint32_t nLength;
- res = GetToolTip( NULL, nLength );
- if ( VmbErrorSuccess == res )
- {
- if ( 0 != nLength )
- {
- try
- {
- std::vector<std::string::value_type> tmpToolTip( nLength + 1, '\0');
- res = GetToolTip( &tmpToolTip[0], nLength );
- if( VmbErrorSuccess == res )
- {
- rStrToolTip = &*tmpToolTip.begin();
- }
- }
- catch(...)
- {
- return VmbErrorResources;
- }
- }
- else
- {
- rStrToolTip.clear();
- }
- }
- return res;
- }
- inline VmbErrorType Feature::GetDescription( std::string &rStrDescription ) const
- {
- VmbErrorType res;
- VmbUint32_t nLength;
- res = GetDescription( NULL, nLength );
- if ( VmbErrorSuccess == res )
- {
- if ( 0 != nLength )
- {
- try
- {
- std::vector<std::string::value_type> tmpDescription( nLength + 1, '\0');
- res = GetDescription( &tmpDescription[0], nLength );
- if( VmbErrorSuccess == res )
- {
- rStrDescription = &*tmpDescription.begin();
- }
- }
- catch(...)
- {
- return VmbErrorResources;
- }
- }
- else
- {
- rStrDescription.clear();
- }
- }
- return res;
- }
- inline VmbErrorType Feature::GetSFNCNamespace( std::string &rStrSFNCNamespace ) const
- {
- VmbErrorType res;
- VmbUint32_t nLength;
- res = GetSFNCNamespace( NULL, nLength );
- if ( VmbErrorSuccess == res )
- {
- if ( 0 != nLength )
- {
- try
- {
- std::vector<std::string::value_type> tmpSFNCNamespace( nLength + 1, '\0' );
- res = GetSFNCNamespace( &tmpSFNCNamespace[0], nLength );
- if( VmbErrorSuccess == res )
- {
- rStrSFNCNamespace = &*tmpSFNCNamespace.begin();
- }
- }
- catch(...)
- {
- return VmbErrorResources;
- }
- }
- else
- {
- rStrSFNCNamespace.clear();
- }
- }
- return res;
- }
- inline VmbErrorType Feature::GetAffectedFeatures( FeaturePtrVector &rAffectedFeatures )
- {
- VmbErrorType res;
- VmbUint32_t nSize;
- res = GetAffectedFeatures( NULL, nSize );
- if ( VmbErrorSuccess == res )
- {
- if( 0 != nSize)
- {
- try
- {
- FeaturePtrVector tmpAffectedFeatures( nSize );
- res = GetAffectedFeatures( &tmpAffectedFeatures[0], nSize );
- if( VmbErrorSuccess == res )
- {
- rAffectedFeatures.swap( tmpAffectedFeatures );
- }
- }
- catch(...)
- {
- return VmbErrorResources;
- }
- }
- else
- {
- rAffectedFeatures.clear();
- }
- }
- return res;
- }
- inline VmbErrorType Feature::GetSelectedFeatures( FeaturePtrVector &rSelectedFeatures )
- {
- VmbErrorType res;
- VmbUint32_t nSize;
- res = GetSelectedFeatures( NULL, nSize );
- if ( VmbErrorSuccess == res )
- {
- if( 0 != nSize )
- {
- try
- {
- FeaturePtrVector tmpSelectedFeatures( nSize );
- res = GetSelectedFeatures( &tmpSelectedFeatures[0], nSize );
- if( VmbErrorSuccess == res )
- {
- rSelectedFeatures.swap ( tmpSelectedFeatures );
- }
- }
- catch(...)
- {
- return VmbErrorResources;
- }
- }
- else
- {
- rSelectedFeatures.clear();
- }
- }
- return res;
- }
- #endif
|