Feature.hpp
Go to the documentation of this file.
00001 /*=============================================================================
00002   Copyright (C) 2012 Allied Vision Technologies.  All Rights Reserved.
00003 
00004   Redistribution of this file, in original or modified form, without
00005   prior written consent of Allied Vision Technologies is prohibited.
00006 
00007 -------------------------------------------------------------------------------
00008 
00009   File:        Feature.hpp
00010 
00011   Description: Inline wrapper functions for class AVT::VmbAPI::Feature.
00012 
00013 -------------------------------------------------------------------------------
00014 
00015   THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
00016   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
00017   NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR  PURPOSE ARE
00018   DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 
00019   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
00020   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00021   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED  
00022   AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 
00023   TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
00024   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025 
00026 =============================================================================*/
00027 
00028 #ifndef AVT_VMBAPI_FEATURE_HPP
00029 #define AVT_VMBAPI_FEATURE_HPP
00030 //
00031 // Inline wrapper functions that allocate memory for STL objects in the application's context
00032 // and to pass data across DLL boundaries using arrays
00033 //
00034 inline VmbErrorType Feature::GetValues( StringVector &rValues )
00035 {
00036     VmbErrorType    res;
00037     VmbUint32_t     nSize;
00038 
00039     res = GetValues( (const char **)NULL, nSize );
00040     if ( VmbErrorSuccess == res )
00041     {
00042         if ( 0 != nSize)
00043         {
00044             try
00045             {
00046                 std::vector<const char*> data( nSize );
00047                 res = GetValues( &data[0], nSize );
00048                 if ( VmbErrorSuccess == res )
00049                 {
00050                     StringVector tmpValues( data.size() );
00051                     std::copy( data.begin(), data.end(), tmpValues.begin() );
00052                     rValues.swap( tmpValues);
00053                 }
00054             }
00055             catch(...)
00056             {
00057                 return VmbErrorResources;
00058             }
00059         }
00060         else
00061         {
00062             rValues.clear();
00063         }
00064     }
00065 
00066     return res;
00067 }
00068 
00069 inline VmbErrorType Feature::GetEntries( EnumEntryVector &rEntries )
00070 {
00071     VmbErrorType    res;
00072     VmbUint32_t     nSize;
00073 
00074     res = GetEntries( (EnumEntry*)NULL, nSize );
00075     if ( VmbErrorSuccess == res )
00076     {
00077         if( 0 != nSize )
00078         {
00079             try
00080             {
00081                 EnumEntryVector tmpEntries( nSize );
00082                 res = GetEntries( &tmpEntries[0], nSize );
00083                 if( VmbErrorSuccess == res)
00084                 {
00085                     rEntries.swap( tmpEntries );
00086                 }
00087             }
00088             catch(...)
00089             {
00090                 return VmbErrorResources;
00091             }
00092         }
00093         else
00094         {
00095             rEntries.clear();
00096         }
00097     }
00098 
00099     return res;
00100 }
00101 
00102 inline VmbErrorType Feature::GetValues( Int64Vector &rValues )
00103 {
00104     VmbErrorType res;
00105     VmbUint32_t nSize;
00106 
00107     res = GetValues( (VmbInt64_t*)NULL, nSize );
00108     if ( VmbErrorSuccess == res )
00109     {
00110         if( 0 != nSize)
00111         {
00112             try
00113             {
00114                 Int64Vector tmpValues( nSize );
00115                 res = GetValues( &tmpValues[0], nSize );
00116                 if( VmbErrorSuccess == res)
00117                 {
00118                     rValues.swap( tmpValues );
00119                 }
00120             }
00121             catch(...)
00122             {
00123                 return VmbErrorResources;
00124             }
00125         }
00126         else
00127         {
00128             rValues.clear();
00129         }
00130     }
00131 
00132     return res;
00133 }
00134 
00135 inline VmbErrorType Feature::GetValue( std::string &rStrValue ) const
00136 {
00137     VmbErrorType    res;
00138     VmbUint32_t     nLength;
00139 
00140     res = GetValue( (char * const)NULL, nLength );
00141     if ( VmbErrorSuccess == res )
00142     {
00143         if ( 0 != nLength )
00144         {
00145             try
00146             {
00147                 std::vector<std::string::value_type> tmpValue( nLength + 1, '\0' );
00148                 res = GetValue( &tmpValue[0], nLength );
00149                 if ( VmbErrorSuccess == res )
00150                 {
00151                     rStrValue = &*tmpValue.begin();
00152                 }
00153             }
00154             catch(...)
00155             {
00156                 return VmbErrorResources;
00157             }
00158         }
00159         else
00160         {
00161             rStrValue.clear();
00162         }
00163     }
00164 
00165     return res;
00166 }
00167 
00168 inline VmbErrorType Feature::GetValue( UcharVector &rValue ) const
00169 {
00170     VmbUint32_t i;
00171     return GetValue( rValue, i );
00172 }
00173 inline VmbErrorType Feature::GetValue( UcharVector &rValue, VmbUint32_t &rnSizeFilled ) const
00174 {
00175     VmbErrorType    res;
00176     VmbUint32_t     nSize;
00177 
00178     res = GetValue( NULL, nSize, rnSizeFilled );
00179     if ( VmbErrorSuccess == res )
00180     {
00181         if( 0 != nSize)
00182         {
00183             try
00184             {
00185                 UcharVector tmpValue( nSize );
00186                 res = GetValue( &tmpValue[0], nSize, rnSizeFilled );
00187                 if( VmbErrorSuccess == res )
00188                 {
00189                     rValue.swap( tmpValue);
00190                 }
00191             }
00192             catch(...)
00193             {
00194                 return VmbErrorResources;
00195             }
00196         }
00197         else
00198         {
00199             rValue.clear();
00200         }
00201     }
00202 
00203     return res;
00204 }
00205 
00206 inline VmbErrorType Feature::SetValue( const UcharVector &rValue )
00207 {
00208     if ( rValue.empty() )
00209     {
00210         return VmbErrorBadParameter;
00211     }
00212     return SetValue( &rValue[0], (VmbUint32_t)rValue.size() );
00213 }
00214 
00215 inline VmbErrorType Feature::GetName( std::string &rStrName ) const
00216 {
00217     VmbErrorType    res;
00218     VmbUint32_t     nLength;
00219 
00220     res = GetName( NULL, nLength );
00221     if ( VmbErrorSuccess == res )
00222     {
00223         if ( 0 != nLength )
00224         {
00225             try
00226             {
00227                 std::vector<std::string::value_type> tmpName( nLength + 1, '\0' );
00228                 res = GetName( &tmpName[0], nLength );
00229                 if( VmbErrorSuccess == res)
00230                 {
00231                     rStrName = &*tmpName.begin();
00232                 }
00233             }
00234             catch(...)
00235             {
00236                 return VmbErrorResources;
00237             }
00238         }
00239         else
00240         {
00241             rStrName.clear();
00242         }
00243     }
00244 
00245     return res;
00246 }
00247 
00248 inline VmbErrorType Feature::GetDisplayName( std::string &rStrDisplayName ) const
00249 {
00250     VmbErrorType    res;
00251     VmbUint32_t     nLength;
00252 
00253     res = GetDisplayName( NULL, nLength );
00254     if ( VmbErrorSuccess == res )
00255     {
00256         if ( 0 != nLength )
00257         {
00258             try
00259             {
00260                 std::vector<std::string::value_type> tmpDisplayName( nLength + 1, '\0' );
00261                 res = GetDisplayName( &tmpDisplayName[0], nLength );
00262                 if( VmbErrorSuccess == res )
00263                 {
00264                     rStrDisplayName = &*tmpDisplayName.begin();
00265                 }
00266             }
00267             catch(...)
00268             {
00269                 return VmbErrorResources;
00270             }
00271         }
00272         else
00273         {
00274             rStrDisplayName.clear();
00275         }
00276     }
00277 
00278     return res;
00279 }
00280 
00281 inline VmbErrorType Feature::GetCategory( std::string &rStrCategory ) const
00282 {
00283     VmbErrorType    res;
00284     VmbUint32_t     nLength;
00285 
00286     res = GetCategory( NULL, nLength );
00287     if ( VmbErrorSuccess == res )
00288     {
00289         if ( 0 != nLength )
00290         {
00291             try
00292             {
00293                 std::vector<std::string::value_type> tmpCategory( nLength + 1, '\0' );
00294                 res = GetCategory( &tmpCategory[0], nLength );
00295                 if( VmbErrorSuccess == res )
00296                 {
00297                     rStrCategory = &*tmpCategory.begin();
00298                 }
00299             }
00300             catch(...)
00301             {
00302                 return VmbErrorResources;
00303             }
00304         }
00305         else
00306         {
00307             rStrCategory.clear();
00308         }
00309     }
00310 
00311     return res;
00312 }
00313 
00314 inline VmbErrorType Feature::GetUnit( std::string &rStrUnit ) const
00315 {
00316     VmbErrorType    res;
00317     VmbUint32_t     nLength;
00318 
00319     res = GetUnit( NULL, nLength );
00320     if ( VmbErrorSuccess == res )
00321     {
00322         if ( 0 != nLength )
00323         {
00324             try
00325             {
00326                 std::vector<std::string::value_type> tmpUnit( nLength + 1, '\0' );
00327                 res = GetUnit( &tmpUnit[0], nLength );
00328                 if( VmbErrorSuccess == res )
00329                 {
00330                     rStrUnit = &*tmpUnit.begin();
00331                 }
00332             }
00333             catch(...)
00334             {
00335                 return VmbErrorResources;
00336             }
00337         }
00338         else
00339         {
00340             rStrUnit.clear();
00341         }
00342     }
00343 
00344     return res;
00345 }
00346 
00347 inline VmbErrorType Feature::GetRepresentation( std::string &rStrRepresentation ) const
00348 {
00349     VmbErrorType    res;
00350     VmbUint32_t     nLength;
00351 
00352     res = GetRepresentation( NULL, nLength );
00353     if ( VmbErrorSuccess == res )
00354     {
00355         if ( 0 != nLength )
00356         {
00357             try
00358             {
00359                 std::vector<std::string::value_type> tmpRepresentation( nLength + 1, '\0' );
00360                 res = GetRepresentation( &tmpRepresentation[0], nLength );
00361                 if( VmbErrorSuccess == res )
00362                 {
00363                     rStrRepresentation = &*tmpRepresentation.begin();
00364                 }
00365             }
00366             catch(...)
00367             {
00368                 return VmbErrorResources;
00369             }
00370         }
00371         else
00372         {
00373             rStrRepresentation.clear();
00374         }
00375     }
00376 
00377     return res;
00378 }
00379 
00380 inline VmbErrorType Feature::GetToolTip( std::string &rStrToolTip ) const
00381 {
00382     VmbErrorType    res;
00383     VmbUint32_t     nLength;
00384 
00385     res = GetToolTip( NULL, nLength );
00386     if ( VmbErrorSuccess == res )
00387     {
00388         if ( 0 != nLength )
00389         {
00390             try
00391             {
00392                 std::vector<std::string::value_type> tmpToolTip( nLength + 1, '\0');
00393                 res = GetToolTip( &tmpToolTip[0], nLength );
00394                 if( VmbErrorSuccess == res )
00395                 {
00396                     rStrToolTip = &*tmpToolTip.begin();
00397                 }
00398             }
00399             catch(...)
00400             {
00401                 return VmbErrorResources;
00402             }
00403         }
00404         else
00405         {
00406             rStrToolTip.clear();
00407         }
00408     }
00409 
00410     return res;
00411 }
00412 
00413 inline VmbErrorType Feature::GetDescription( std::string &rStrDescription ) const
00414 {
00415     VmbErrorType    res;
00416     VmbUint32_t     nLength;
00417 
00418     res = GetDescription( NULL, nLength );
00419     if ( VmbErrorSuccess == res )
00420     {
00421         if ( 0 != nLength )
00422         {
00423             try
00424             {
00425                 std::vector<std::string::value_type> tmpDescription( nLength + 1, '\0');
00426                 res = GetDescription( &tmpDescription[0], nLength );
00427                 if( VmbErrorSuccess == res )
00428                 {
00429                     rStrDescription = &*tmpDescription.begin();
00430                 }
00431             }
00432             catch(...)
00433             {
00434                 return VmbErrorResources;
00435             }
00436         }
00437         else
00438         {
00439             rStrDescription.clear();
00440         }
00441     }
00442 
00443     return res;
00444 }
00445 
00446 inline VmbErrorType Feature::GetSFNCNamespace( std::string &rStrSFNCNamespace ) const
00447 {
00448     VmbErrorType    res;
00449     VmbUint32_t     nLength;
00450 
00451     res = GetSFNCNamespace( NULL, nLength );
00452     if ( VmbErrorSuccess == res )
00453     {
00454         if ( 0 != nLength )
00455         {
00456             try
00457             {
00458                 std::vector<std::string::value_type> tmpSFNCNamespace( nLength + 1, '\0' );
00459                 res = GetSFNCNamespace( &tmpSFNCNamespace[0], nLength );
00460                 if( VmbErrorSuccess == res )
00461                 {
00462                     rStrSFNCNamespace = &*tmpSFNCNamespace.begin();
00463                 }
00464             }
00465             catch(...)
00466             {
00467                 return VmbErrorResources;
00468             }
00469         }
00470         else
00471         {
00472             rStrSFNCNamespace.clear();
00473         }
00474     }
00475 
00476     return res;
00477 }
00478 
00479 inline VmbErrorType Feature::GetAffectedFeatures( FeaturePtrVector &rAffectedFeatures )
00480 {
00481     VmbErrorType    res;
00482     VmbUint32_t     nSize;
00483 
00484     res = GetAffectedFeatures( NULL, nSize );
00485     if ( VmbErrorSuccess == res )
00486     {
00487         if( 0 != nSize)
00488         {
00489             try
00490             {
00491                 FeaturePtrVector tmpAffectedFeatures( nSize );
00492                 res = GetAffectedFeatures( &tmpAffectedFeatures[0], nSize );
00493                 if( VmbErrorSuccess == res )
00494                 {
00495                     rAffectedFeatures.swap( tmpAffectedFeatures );
00496                 }
00497             }
00498             catch(...)
00499             {
00500                 return VmbErrorResources;
00501             }
00502         }
00503         else
00504         {
00505             rAffectedFeatures.clear();
00506         }
00507     }
00508 
00509     return res;
00510 }
00511 
00512 inline VmbErrorType Feature::GetSelectedFeatures( FeaturePtrVector &rSelectedFeatures )
00513 {
00514     VmbErrorType    res;
00515     VmbUint32_t     nSize;
00516 
00517     res = GetSelectedFeatures( NULL, nSize );
00518     if ( VmbErrorSuccess == res )
00519     {
00520         if( 0 != nSize )
00521         {
00522             try
00523             {
00524                 FeaturePtrVector tmpSelectedFeatures( nSize );
00525                 res = GetSelectedFeatures( &tmpSelectedFeatures[0], nSize );
00526                 if( VmbErrorSuccess == res )
00527                 {
00528                     rSelectedFeatures.swap ( tmpSelectedFeatures );
00529                 }
00530             }
00531             catch(...)
00532             {
00533                 return VmbErrorResources;
00534             }
00535         }
00536         else
00537         {
00538             rSelectedFeatures.clear();
00539         }
00540     }
00541 
00542     return res;
00543 }
00544 
00545 #endif


avt_vimba_camera
Author(s): Miquel Massot , Allied Vision Technologies
autogenerated on Thu Jun 6 2019 18:23:39