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.h 00010 00011 Description: Definition of base class AVT::VmbAPI::Feature. 00012 This class wraps every call to BaseFeature resp. its concrete 00013 subclass. That way polymorphism is hidden away from the user. 00014 00015 00016 ------------------------------------------------------------------------------- 00017 00018 THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED 00019 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE, 00020 NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00021 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 00022 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00023 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00024 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00025 AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 00026 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00027 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00028 00029 =============================================================================*/ 00030 00031 #ifndef AVT_VMBAPI_FEATURE_H 00032 #define AVT_VMBAPI_FEATURE_H 00033 00034 #include <vector> 00035 #include <map> 00036 00037 #include <VimbaC/Include/VimbaC.h> 00038 #include <VimbaCPP/Include/VimbaCPPCommon.h> 00039 #include <VimbaCPP/Include/SharedPointerDefines.h> 00040 #include <VimbaCPP/Include/IFeatureObserver.h> 00041 #include <VimbaCPP/Include/EnumEntry.h> 00042 00043 namespace AVT { 00044 namespace VmbAPI { 00045 00046 class BaseFeature; 00047 00048 typedef std::vector<FeaturePtr> FeaturePtrVector; 00049 typedef std::map<std::string, FeaturePtr> FeaturePtrMap; 00050 00051 class Feature 00052 { 00053 public: 00054 Feature( const VmbFeatureInfo_t *pFeatureInfo, FeatureContainer *pFeatureContainer ); 00055 virtual ~Feature(); 00056 00057 // 00058 // Method: GetValue() 00059 // 00060 // Purpose: Queries the value of a feature of type VmbInt64 00061 // 00062 // Parameters: 00063 // 00064 // [out] VmbInt64_t& value The feature's value 00065 // 00066 IMEXPORT VmbErrorType GetValue( VmbInt64_t &value ) const; 00067 00068 // 00069 // Method: GetValue() 00070 // 00071 // Purpose: Queries the value of a feature of type double 00072 // 00073 // Parameters: 00074 // 00075 // [out] double& value The feature's value 00076 // 00077 IMEXPORT VmbErrorType GetValue( double &value ) const; 00078 00079 // 00080 // Method: GetValue() 00081 // 00082 // Purpose: Queries the value of a feature of type string 00083 // 00084 // Parameters: 00085 // 00086 // [out] std::string& value The feature's value 00087 // 00088 // Details: When an empty string is returned, its size 00089 // indicates the maximum length 00090 VmbErrorType GetValue( std::string &value ) const; 00091 00092 // 00093 // Method: GetValue() 00094 // 00095 // Purpose: Queries the value of a feature of type bool 00096 // 00097 // Parameters: 00098 // 00099 // [out] bool& value The feature's value 00100 // 00101 IMEXPORT VmbErrorType GetValue( bool &value ) const; 00102 00103 // 00104 // Method: GetValue() 00105 // 00106 // Purpose: Queries the value of a feature of type UcharVector 00107 // 00108 // Parameters: 00109 // 00110 // [out] UcharVector& value The feature's value 00111 // 00112 VmbErrorType GetValue( UcharVector &value ) const; 00113 00114 // 00115 // Method: GetValue() 00116 // 00117 // Purpose: Queries the value of a feature of type const UcharVector 00118 // 00119 // Parameters: 00120 // 00121 // [out] UcharVector& value The feature's value 00122 // [out] VmbUint32_t& sizeFilled The number of actually received values 00123 // 00124 VmbErrorType GetValue( UcharVector &value, VmbUint32_t &sizeFilled ) const; 00125 00126 // 00127 // Method: GetValues() 00128 // 00129 // Purpose: Queries the values of a feature of type Int64Vector 00130 // 00131 // Parameters: 00132 // 00133 // [out] Int64Vector& values The feature's values 00134 // 00135 VmbErrorType GetValues( Int64Vector &values ); 00136 00137 // 00138 // Method: GetValues() 00139 // 00140 // Purpose: Queries the values of a feature of type StringVector 00141 // 00142 // Parameters: 00143 // 00144 // [out] StringVector& values The feature's values 00145 // 00146 VmbErrorType GetValues( StringVector &values ); 00147 00148 // 00149 // Method: GetEntry() 00150 // 00151 // Purpose: Queries a single enum entry of a feature of type Enumeration 00152 // 00153 // Parameters: 00154 // 00155 // [out] EnumEntry& entry An enum feature's enum entry 00156 // [in ] const char* pEntryName The name of the enum entry 00157 // 00158 IMEXPORT VmbErrorType GetEntry( EnumEntry &entry, const char *pEntryName ) const; 00159 00160 // 00161 // Method: GetEntries() 00162 // 00163 // Purpose: Queries all enum entries of a feature of type Enumeration 00164 // 00165 // Parameters: 00166 // 00167 // [out] EnumEntryVector& entries An enum feature's enum entries 00168 // 00169 VmbErrorType GetEntries( EnumEntryVector &entries ); 00170 00171 // 00172 // Method: GetRange() 00173 // 00174 // Purpose: Queries the range of a feature of type double 00175 // 00176 // Parameters: 00177 // 00178 // [out] double& minimum The feature's min value 00179 // [out] double& maximum The feature's max value 00180 // 00181 IMEXPORT VmbErrorType GetRange( double &minimum, double &maximum ) const; 00182 00183 // 00184 // Method: GetRange() 00185 // 00186 // Purpose: Queries the range of a feature of type VmbInt64 00187 // 00188 // Parameters: 00189 // 00190 // [out] VmbInt64_t& minimum The feature's min value 00191 // [out] VmbInt64_t& maximum The feature's max value 00192 // 00193 IMEXPORT VmbErrorType GetRange( VmbInt64_t &minimum, VmbInt64_t &maximum ) const; 00194 00195 // 00196 // Method: SetValue() 00197 // 00198 // Purpose: Sets the value of a feature of type VmbInt32 00199 // 00200 // Parameters: 00201 // 00202 // [in ] const VmbInt32_t& value The feature's value 00203 // 00204 IMEXPORT VmbErrorType SetValue( const VmbInt32_t &value ); 00205 00206 // 00207 // Method: SetValue() 00208 // 00209 // Purpose: Sets the value of a feature of type VmbInt64 00210 // 00211 // Parameters: 00212 // 00213 // [in ] const VmbInt64_t& value The feature's value 00214 // 00215 IMEXPORT VmbErrorType SetValue( const VmbInt64_t &value ); 00216 00217 // 00218 // Method: SetValue() 00219 // 00220 // Purpose: Sets the value of a feature of type double 00221 // 00222 // Parameters: 00223 // 00224 // [in ] const double& value The feature's value 00225 // 00226 IMEXPORT VmbErrorType SetValue( const double &value ); 00227 00228 // 00229 // Method: SetValue() 00230 // 00231 // Purpose: Sets the value of a feature of type char* 00232 // 00233 // Parameters: 00234 // 00235 // [in ] const char* pValue The feature's value 00236 // 00237 IMEXPORT VmbErrorType SetValue( const char *pValue ); 00238 00239 // 00240 // Method: SetValue() 00241 // 00242 // Purpose: Sets the value of a feature of type bool 00243 // 00244 // Parameters: 00245 // 00246 // [in ] bool value The feature's value 00247 // 00248 IMEXPORT VmbErrorType SetValue( bool value ); 00249 00250 // 00251 // Method: SetValue() 00252 // 00253 // Purpose: Sets the value of a feature of type UcharVector 00254 // 00255 // Parameters: 00256 // 00257 // [in ] const UcharVector& value The feature's value 00258 // 00259 VmbErrorType SetValue( const UcharVector &value ); 00260 00261 // Method: HasIncrement() 00262 // 00263 // Purpose: Gets the support state increment of a feature 00264 // 00265 // Parameters: 00266 // 00267 // [out] VmbBool_t& incrementsupported The feature's increment support state 00268 // 00269 IMEXPORT VmbErrorType HasIncrement( VmbBool_t &incrementSupported ) const; 00270 00271 00272 // 00273 // Method: GetIncrement() 00274 // 00275 // Purpose: Gets the increment of a feature of type VmbInt64 00276 // 00277 // Parameters: 00278 // 00279 // [out] VmbInt64_t& increment The feature's increment 00280 // 00281 IMEXPORT VmbErrorType GetIncrement( VmbInt64_t &increment ) const; 00282 00283 // Method: GetIncrement() 00284 // 00285 // Purpose: Gets the increment of a feature of type double 00286 // 00287 // Parameters: 00288 // 00289 // [out] double& increment The feature's increment 00290 // 00291 IMEXPORT VmbErrorType GetIncrement( double &increment ) const; 00292 00293 // 00294 // Method: IsValueAvailable() 00295 // 00296 // Purpose: Indicates whether an existing enumeration value is currently available. 00297 // An enumeration value might not be selectable due to the camera's 00298 // current configuration. 00299 // 00300 // Parameters: 00301 // 00302 // [in ] const char* pValue The enumeration value as string 00303 // [out] bool& available True when the given value is available 00304 // 00305 // Returns: 00306 // 00307 // - VmbErrorSuccess: If no error 00308 // - VmbErrorInvalidValue: If the given value is not a valid enumeration value for this enum 00309 // - VmbErrorApiNotStarted: VmbStartup() was not called before the current command 00310 // - VmbErrorInvalidAccess: Operation is invalid with the current access mode 00311 // - VmbErrorWrongType: The feature is not an enumeration 00312 // 00313 IMEXPORT VmbErrorType IsValueAvailable( const char *pValue, bool &available ) const; 00314 00315 // 00316 // Method: IsValueAvailable() 00317 // 00318 // Purpose: Indicates whether an existing enumeration value is currently available. 00319 // An enumeration value might not be selectable due to the camera's 00320 // current configuration. 00321 // 00322 // Parameters: 00323 // 00324 // [in ] const VmbInt64_t value The enumeration value as int 00325 // [out] bool& available True when the given value is available 00326 // 00327 // Returns: 00328 // 00329 // - VmbErrorSuccess: If no error 00330 // - VmbErrorInvalidValue: If the given value is not a valid enumeration value for this enum 00331 // - VmbErrorApiNotStarted: VmbStartup() was not called before the current command 00332 // - VmbErrorInvalidAccess: Operation is invalid with the current access mode 00333 // - VmbErrorWrongType: The feature is not an enumeration 00334 // 00335 IMEXPORT VmbErrorType IsValueAvailable( const VmbInt64_t value, bool &available ) const; 00336 00337 // 00338 // Method: RunCommand() 00339 // 00340 // Purpose: Executes a feature of type Command 00341 // 00342 IMEXPORT VmbErrorType RunCommand(); 00343 00344 // 00345 // Method: IsCommandDone() 00346 // 00347 // Purpose: Indicates whether the execution of a feature of type Command has finished 00348 // 00349 // Parameters: 00350 // 00351 // [out] bool& isDone True when execution has finished 00352 // 00353 IMEXPORT VmbErrorType IsCommandDone( bool &isDone ) const; 00354 00355 // 00356 // Method: GetName() 00357 // 00358 // Purpose: Queries a feature's name 00359 // 00360 // Parameters: 00361 // 00362 // [out] std::string& name The feature's name 00363 // 00364 VmbErrorType GetName( std::string &name ) const; 00365 00366 // 00367 // Method: GetDisplayName() 00368 // 00369 // Purpose: Queries a feature's display name 00370 // 00371 // Parameters: 00372 // 00373 // [out] std::string& displayName The feature's display name 00374 // 00375 VmbErrorType GetDisplayName( std::string &displayName ) const; 00376 00377 // 00378 // Method: GetDataType() 00379 // 00380 // Purpose: Queries a feature's type 00381 // 00382 // Parameters: 00383 // 00384 // [out] VmbFeatureDataType& dataType The feature's type 00385 // 00386 IMEXPORT VmbErrorType GetDataType( VmbFeatureDataType &dataType ) const; 00387 00388 // 00389 // Method: GetFlags() 00390 // 00391 // Purpose: Queries a feature's access status 00392 // 00393 // Parameters: 00394 // 00395 // [out] VmbFeatureFlagsType& flags The feature's access status 00396 // 00397 IMEXPORT VmbErrorType GetFlags( VmbFeatureFlagsType &flags ) const; 00398 00399 // 00400 // Method: GetCategory() 00401 // 00402 // Purpose: Queries a feature's category in the feature tress 00403 // 00404 // Parameters: 00405 // 00406 // [out] std::string& category The feature's position in the feature tree 00407 // 00408 VmbErrorType GetCategory( std::string &category ) const; 00409 00410 // 00411 // Method: GetPollingTime() 00412 // 00413 // Purpose: Queries a feature's polling time 00414 // 00415 // Parameters: 00416 // 00417 // [out] VmbUint32_t& pollingTime The interval to poll the feature 00418 // 00419 IMEXPORT VmbErrorType GetPollingTime( VmbUint32_t &pollingTime ) const; 00420 00421 // 00422 // Method: GetUnit() 00423 // 00424 // Purpose: Queries a feature's unit 00425 // 00426 // Parameters: 00427 // 00428 // [out] std::string& unit The feature's unit 00429 // 00430 VmbErrorType GetUnit( std::string &unit ) const; 00431 00432 // 00433 // Method: GetRepresentation() 00434 // 00435 // Purpose: Queries a feature's representation 00436 // 00437 // Parameters: 00438 // 00439 // [out] std::string& representation The feature's representation 00440 // 00441 VmbErrorType GetRepresentation( std::string &representation ) const; 00442 00443 // 00444 // Method: GetVisibility() 00445 // 00446 // Purpose: Queries a feature's visibility 00447 // 00448 // Parameters: 00449 // 00450 // [out] VmbFeatureVisibilityType& visibility The feature's visibility 00451 // 00452 IMEXPORT VmbErrorType GetVisibility( VmbFeatureVisibilityType &visibility ) const; 00453 00454 // 00455 // Method: GetToolTip() 00456 // 00457 // Purpose: Queries a feature's tool tip to display in the GUI 00458 // 00459 // Parameters: 00460 // 00461 // [out] std::string& toolTip The feature's tool tip 00462 // 00463 VmbErrorType GetToolTip( std::string &toolTip ) const; 00464 00465 // 00466 // Method: GetDescription() 00467 // 00468 // Purpose: Queries a feature's description 00469 // 00470 // Parameters: 00471 // 00472 // [out] std::string& description The feature'sdescription 00473 // 00474 VmbErrorType GetDescription( std::string &description ) const; 00475 00476 // 00477 // Method: GetSFNCNamespace() 00478 // 00479 // Purpose: Queries a feature's Standard Feature Naming Convention namespace 00480 // 00481 // Parameters: 00482 // 00483 // [out] std::string& sFNCNamespace The feature's SFNC namespace 00484 // 00485 VmbErrorType GetSFNCNamespace( std::string &sFNCNamespace ) const; 00486 00487 // 00488 // Method: GetAffectedFeatures() 00489 // 00490 // Purpose: Queries the feature's that are dependent from the current feature 00491 // 00492 // Parameters: 00493 // 00494 // [out] FeaturePtrVector& affectedFeatures The features that get invalidated through the current feature 00495 // 00496 VmbErrorType GetAffectedFeatures( FeaturePtrVector &affectedFeatures ); 00497 00498 // 00499 // Method: GetSelectedFeatures() 00500 // 00501 // Purpose: Gets the features that get selected by the current feature 00502 // 00503 // Parameters: 00504 // 00505 // [out] FeaturePtrVector& selectedFeatures The selected features 00506 // 00507 VmbErrorType GetSelectedFeatures( FeaturePtrVector &selectedFeatures ); 00508 00509 // 00510 // Method: IsReadable() 00511 // 00512 // Purpose: Queries the read access status of a feature 00513 // 00514 // Parameters: 00515 // 00516 // [out] bool& isReadable True when feature can be read 00517 // 00518 IMEXPORT VmbErrorType IsReadable( bool &isReadable ); 00519 00520 // 00521 // Method: IsWritable() 00522 // 00523 // Purpose: Queries the write access status of a feature 00524 // 00525 // Parameters: 00526 // 00527 // [out] bool& isWritable True when feature can be written 00528 // 00529 IMEXPORT VmbErrorType IsWritable( bool &isWritable ); 00530 00531 // 00532 // Method: IsStreamable() 00533 // 00534 // Purpose: Queries whether a feature's value can be transferred as a stream 00535 // 00536 // Parameters: 00537 // 00538 // [out] bool& isStreamable True when streamable 00539 // 00540 IMEXPORT VmbErrorType IsStreamable( bool &isStreamable ) const; 00541 00542 // 00543 // Method: RegisterObserver() 00544 // 00545 // Purpose: Registers an observer that notifies the application whenever a features value changes 00546 // 00547 // Parameters: 00548 // 00549 // [out] const IFeatureObserverPtr& pObserver The observer to be registered 00550 // 00551 // Returns: 00552 // 00553 // - VmbErrorSuccess: If no error 00554 // - VmbErrorBadParameter: "pObserver" is NULL. 00555 // 00556 IMEXPORT VmbErrorType RegisterObserver( const IFeatureObserverPtr &pObserver ); 00557 00558 // 00559 // Method: UnregisterObserver() 00560 // 00561 // Purpose: Unregisters an observer 00562 // 00563 // Parameters: 00564 // 00565 // [out] const IFeatureObserverPtr& pObserver The observer to be unregistered 00566 // 00567 // Returns: 00568 // 00569 // - VmbErrorSuccess: If no error 00570 // - VmbErrorBadParameter: "pObserver" is NULL. 00571 // 00572 IMEXPORT VmbErrorType UnregisterObserver( const IFeatureObserverPtr &pObserver ); 00573 00574 void ResetFeatureContainer(); 00575 00576 private: 00577 BaseFeature *m_pImpl; 00578 00579 // No default ctor 00580 Feature(); 00581 // No copy ctor 00582 Feature( const Feature& ); 00583 // No assignment operator 00584 Feature& operator=( const Feature& ); 00585 00586 // Array functions to pass data across DLL boundaries 00587 IMEXPORT VmbErrorType GetValue( char * const pValue, VmbUint32_t &length ) const; 00588 IMEXPORT VmbErrorType GetValue( VmbUchar_t *pValue, VmbUint32_t &size, VmbUint32_t &sizeFilled ) const; 00589 IMEXPORT VmbErrorType GetValues( const char **pValues, VmbUint32_t &size ); 00590 IMEXPORT VmbErrorType GetValues( VmbInt64_t *pValues, VmbUint32_t &Size ); 00591 00592 IMEXPORT VmbErrorType GetEntries( EnumEntry *pEnumEntries, VmbUint32_t &size ); 00593 00594 IMEXPORT VmbErrorType SetValue( const VmbUchar_t *pValue, VmbUint32_t size ); 00595 00596 IMEXPORT VmbErrorType GetName( char * const pName, VmbUint32_t &length ) const; 00597 IMEXPORT VmbErrorType GetDisplayName( char * const pDisplayName, VmbUint32_t &length ) const; 00598 IMEXPORT VmbErrorType GetCategory( char * const pCategory, VmbUint32_t &length ) const; 00599 IMEXPORT VmbErrorType GetUnit( char * const pUnit, VmbUint32_t &length ) const; 00600 IMEXPORT VmbErrorType GetRepresentation( char * const pRepresentation, VmbUint32_t &length ) const; 00601 IMEXPORT VmbErrorType GetToolTip( char * const pToolTip, VmbUint32_t &length ) const; 00602 IMEXPORT VmbErrorType GetDescription( char * const pDescription, VmbUint32_t &length ) const; 00603 IMEXPORT VmbErrorType GetSFNCNamespace( char * const pSFNCNamespace, VmbUint32_t &length ) const; 00604 IMEXPORT VmbErrorType GetAffectedFeatures( FeaturePtr *pAffectedFeatures, VmbUint32_t &nSize ); 00605 IMEXPORT VmbErrorType GetSelectedFeatures( FeaturePtr *pSelectedFeatures, VmbUint32_t &nSize ); 00606 }; 00607 00608 #include <VimbaCPP/Include/Feature.hpp> 00609 00610 }} // namespace AVT::VmbAPI 00611 00612 #endif