Feature.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  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: Feature.h
  7. Description: Definition of base class AVT::VmbAPI::Feature.
  8. This class wraps every call to BaseFeature resp. its concrete
  9. subclass. That way polymorphism is hidden away from the user.
  10. -------------------------------------------------------------------------------
  11. THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  12. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
  13. NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  14. DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  15. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  16. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  17. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  18. AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  19. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  20. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21. =============================================================================*/
  22. #ifndef AVT_VMBAPI_FEATURE_H
  23. #define AVT_VMBAPI_FEATURE_H
  24. #include <vector>
  25. #include <map>
  26. #include <VimbaC/Include/VimbaC.h>
  27. #include <VimbaCPP/Include/VimbaCPPCommon.h>
  28. #include <VimbaCPP/Include/SharedPointerDefines.h>
  29. #include <VimbaCPP/Include/IFeatureObserver.h>
  30. #include <VimbaCPP/Include/EnumEntry.h>
  31. namespace AVT {
  32. namespace VmbAPI {
  33. class BaseFeature;
  34. typedef std::vector<FeaturePtr> FeaturePtrVector;
  35. typedef std::map<std::string, FeaturePtr> FeaturePtrMap;
  36. class Feature
  37. {
  38. public:
  39. Feature( const VmbFeatureInfo_t *pFeatureInfo, FeatureContainer *pFeatureContainer );
  40. virtual ~Feature();
  41. //
  42. // Method: GetValue()
  43. //
  44. // Purpose: Queries the value of a feature of type VmbInt64
  45. //
  46. // Parameters:
  47. //
  48. // [out] VmbInt64_t& value The feature's value
  49. //
  50. IMEXPORT VmbErrorType GetValue( VmbInt64_t &value ) const;
  51. //
  52. // Method: GetValue()
  53. //
  54. // Purpose: Queries the value of a feature of type double
  55. //
  56. // Parameters:
  57. //
  58. // [out] double& value The feature's value
  59. //
  60. IMEXPORT VmbErrorType GetValue( double &value ) const;
  61. //
  62. // Method: GetValue()
  63. //
  64. // Purpose: Queries the value of a feature of type string
  65. //
  66. // Parameters:
  67. //
  68. // [out] std::string& value The feature's value
  69. //
  70. // Details: When an empty string is returned, its size
  71. // indicates the maximum length
  72. VmbErrorType GetValue( std::string &value ) const;
  73. //
  74. // Method: GetValue()
  75. //
  76. // Purpose: Queries the value of a feature of type bool
  77. //
  78. // Parameters:
  79. //
  80. // [out] bool& value The feature's value
  81. //
  82. IMEXPORT VmbErrorType GetValue( bool &value ) const;
  83. //
  84. // Method: GetValue()
  85. //
  86. // Purpose: Queries the value of a feature of type UcharVector
  87. //
  88. // Parameters:
  89. //
  90. // [out] UcharVector& value The feature's value
  91. //
  92. VmbErrorType GetValue( UcharVector &value ) const;
  93. //
  94. // Method: GetValue()
  95. //
  96. // Purpose: Queries the value of a feature of type const UcharVector
  97. //
  98. // Parameters:
  99. //
  100. // [out] UcharVector& value The feature's value
  101. // [out] VmbUint32_t& sizeFilled The number of actually received values
  102. //
  103. VmbErrorType GetValue( UcharVector &value, VmbUint32_t &sizeFilled ) const;
  104. //
  105. // Method: GetValues()
  106. //
  107. // Purpose: Queries the values of a feature of type Int64Vector
  108. //
  109. // Parameters:
  110. //
  111. // [out] Int64Vector& values The feature's values
  112. //
  113. VmbErrorType GetValues( Int64Vector &values );
  114. //
  115. // Method: GetValues()
  116. //
  117. // Purpose: Queries the values of a feature of type StringVector
  118. //
  119. // Parameters:
  120. //
  121. // [out] StringVector& values The feature's values
  122. //
  123. VmbErrorType GetValues( StringVector &values );
  124. //
  125. // Method: GetEntry()
  126. //
  127. // Purpose: Queries a single enum entry of a feature of type Enumeration
  128. //
  129. // Parameters:
  130. //
  131. // [out] EnumEntry& entry An enum feature's enum entry
  132. // [in ] const char* pEntryName The name of the enum entry
  133. //
  134. IMEXPORT VmbErrorType GetEntry( EnumEntry &entry, const char *pEntryName ) const;
  135. //
  136. // Method: GetEntries()
  137. //
  138. // Purpose: Queries all enum entries of a feature of type Enumeration
  139. //
  140. // Parameters:
  141. //
  142. // [out] EnumEntryVector& entries An enum feature's enum entries
  143. //
  144. VmbErrorType GetEntries( EnumEntryVector &entries );
  145. //
  146. // Method: GetRange()
  147. //
  148. // Purpose: Queries the range of a feature of type double
  149. //
  150. // Parameters:
  151. //
  152. // [out] double& minimum The feature's min value
  153. // [out] double& maximum The feature's max value
  154. //
  155. IMEXPORT VmbErrorType GetRange( double &minimum, double &maximum ) const;
  156. //
  157. // Method: GetRange()
  158. //
  159. // Purpose: Queries the range of a feature of type VmbInt64
  160. //
  161. // Parameters:
  162. //
  163. // [out] VmbInt64_t& minimum The feature's min value
  164. // [out] VmbInt64_t& maximum The feature's max value
  165. //
  166. IMEXPORT VmbErrorType GetRange( VmbInt64_t &minimum, VmbInt64_t &maximum ) const;
  167. //
  168. // Method: SetValue()
  169. //
  170. // Purpose: Sets the value of a feature of type VmbInt32
  171. //
  172. // Parameters:
  173. //
  174. // [in ] const VmbInt32_t& value The feature's value
  175. //
  176. IMEXPORT VmbErrorType SetValue( const VmbInt32_t &value );
  177. //
  178. // Method: SetValue()
  179. //
  180. // Purpose: Sets the value of a feature of type VmbInt64
  181. //
  182. // Parameters:
  183. //
  184. // [in ] const VmbInt64_t& value The feature's value
  185. //
  186. IMEXPORT VmbErrorType SetValue( const VmbInt64_t &value );
  187. //
  188. // Method: SetValue()
  189. //
  190. // Purpose: Sets the value of a feature of type double
  191. //
  192. // Parameters:
  193. //
  194. // [in ] const double& value The feature's value
  195. //
  196. IMEXPORT VmbErrorType SetValue( const double &value );
  197. //
  198. // Method: SetValue()
  199. //
  200. // Purpose: Sets the value of a feature of type char*
  201. //
  202. // Parameters:
  203. //
  204. // [in ] const char* pValue The feature's value
  205. //
  206. IMEXPORT VmbErrorType SetValue( const char *pValue );
  207. //
  208. // Method: SetValue()
  209. //
  210. // Purpose: Sets the value of a feature of type bool
  211. //
  212. // Parameters:
  213. //
  214. // [in ] bool value The feature's value
  215. //
  216. IMEXPORT VmbErrorType SetValue( bool value );
  217. //
  218. // Method: SetValue()
  219. //
  220. // Purpose: Sets the value of a feature of type UcharVector
  221. //
  222. // Parameters:
  223. //
  224. // [in ] const UcharVector& value The feature's value
  225. //
  226. VmbErrorType SetValue( const UcharVector &value );
  227. // Method: HasIncrement()
  228. //
  229. // Purpose: Gets the support state increment of a feature
  230. //
  231. // Parameters:
  232. //
  233. // [out] VmbBool_t& incrementsupported The feature's increment support state
  234. //
  235. IMEXPORT VmbErrorType HasIncrement( VmbBool_t &incrementSupported ) const;
  236. //
  237. // Method: GetIncrement()
  238. //
  239. // Purpose: Gets the increment of a feature of type VmbInt64
  240. //
  241. // Parameters:
  242. //
  243. // [out] VmbInt64_t& increment The feature's increment
  244. //
  245. IMEXPORT VmbErrorType GetIncrement( VmbInt64_t &increment ) const;
  246. // Method: GetIncrement()
  247. //
  248. // Purpose: Gets the increment of a feature of type double
  249. //
  250. // Parameters:
  251. //
  252. // [out] double& increment The feature's increment
  253. //
  254. IMEXPORT VmbErrorType GetIncrement( double &increment ) const;
  255. //
  256. // Method: IsValueAvailable()
  257. //
  258. // Purpose: Indicates whether an existing enumeration value is currently available.
  259. // An enumeration value might not be selectable due to the camera's
  260. // current configuration.
  261. //
  262. // Parameters:
  263. //
  264. // [in ] const char* pValue The enumeration value as string
  265. // [out] bool& available True when the given value is available
  266. //
  267. // Returns:
  268. //
  269. // - VmbErrorSuccess: If no error
  270. // - VmbErrorInvalidValue: If the given value is not a valid enumeration value for this enum
  271. // - VmbErrorApiNotStarted: VmbStartup() was not called before the current command
  272. // - VmbErrorInvalidAccess: Operation is invalid with the current access mode
  273. // - VmbErrorWrongType: The feature is not an enumeration
  274. //
  275. IMEXPORT VmbErrorType IsValueAvailable( const char *pValue, bool &available ) const;
  276. //
  277. // Method: IsValueAvailable()
  278. //
  279. // Purpose: Indicates whether an existing enumeration value is currently available.
  280. // An enumeration value might not be selectable due to the camera's
  281. // current configuration.
  282. //
  283. // Parameters:
  284. //
  285. // [in ] const VmbInt64_t value The enumeration value as int
  286. // [out] bool& available True when the given value is available
  287. //
  288. // Returns:
  289. //
  290. // - VmbErrorSuccess: If no error
  291. // - VmbErrorInvalidValue: If the given value is not a valid enumeration value for this enum
  292. // - VmbErrorApiNotStarted: VmbStartup() was not called before the current command
  293. // - VmbErrorInvalidAccess: Operation is invalid with the current access mode
  294. // - VmbErrorWrongType: The feature is not an enumeration
  295. //
  296. IMEXPORT VmbErrorType IsValueAvailable( const VmbInt64_t value, bool &available ) const;
  297. //
  298. // Method: RunCommand()
  299. //
  300. // Purpose: Executes a feature of type Command
  301. //
  302. IMEXPORT VmbErrorType RunCommand();
  303. //
  304. // Method: IsCommandDone()
  305. //
  306. // Purpose: Indicates whether the execution of a feature of type Command has finished
  307. //
  308. // Parameters:
  309. //
  310. // [out] bool& isDone True when execution has finished
  311. //
  312. IMEXPORT VmbErrorType IsCommandDone( bool &isDone ) const;
  313. //
  314. // Method: GetName()
  315. //
  316. // Purpose: Queries a feature's name
  317. //
  318. // Parameters:
  319. //
  320. // [out] std::string& name The feature's name
  321. //
  322. VmbErrorType GetName( std::string &name ) const;
  323. //
  324. // Method: GetDisplayName()
  325. //
  326. // Purpose: Queries a feature's display name
  327. //
  328. // Parameters:
  329. //
  330. // [out] std::string& displayName The feature's display name
  331. //
  332. VmbErrorType GetDisplayName( std::string &displayName ) const;
  333. //
  334. // Method: GetDataType()
  335. //
  336. // Purpose: Queries a feature's type
  337. //
  338. // Parameters:
  339. //
  340. // [out] VmbFeatureDataType& dataType The feature's type
  341. //
  342. IMEXPORT VmbErrorType GetDataType( VmbFeatureDataType &dataType ) const;
  343. //
  344. // Method: GetFlags()
  345. //
  346. // Purpose: Queries a feature's access status
  347. //
  348. // Parameters:
  349. //
  350. // [out] VmbFeatureFlagsType& flags The feature's access status
  351. //
  352. IMEXPORT VmbErrorType GetFlags( VmbFeatureFlagsType &flags ) const;
  353. //
  354. // Method: GetCategory()
  355. //
  356. // Purpose: Queries a feature's category in the feature tress
  357. //
  358. // Parameters:
  359. //
  360. // [out] std::string& category The feature's position in the feature tree
  361. //
  362. VmbErrorType GetCategory( std::string &category ) const;
  363. //
  364. // Method: GetPollingTime()
  365. //
  366. // Purpose: Queries a feature's polling time
  367. //
  368. // Parameters:
  369. //
  370. // [out] VmbUint32_t& pollingTime The interval to poll the feature
  371. //
  372. IMEXPORT VmbErrorType GetPollingTime( VmbUint32_t &pollingTime ) const;
  373. //
  374. // Method: GetUnit()
  375. //
  376. // Purpose: Queries a feature's unit
  377. //
  378. // Parameters:
  379. //
  380. // [out] std::string& unit The feature's unit
  381. //
  382. VmbErrorType GetUnit( std::string &unit ) const;
  383. //
  384. // Method: GetRepresentation()
  385. //
  386. // Purpose: Queries a feature's representation
  387. //
  388. // Parameters:
  389. //
  390. // [out] std::string& representation The feature's representation
  391. //
  392. VmbErrorType GetRepresentation( std::string &representation ) const;
  393. //
  394. // Method: GetVisibility()
  395. //
  396. // Purpose: Queries a feature's visibility
  397. //
  398. // Parameters:
  399. //
  400. // [out] VmbFeatureVisibilityType& visibility The feature's visibility
  401. //
  402. IMEXPORT VmbErrorType GetVisibility( VmbFeatureVisibilityType &visibility ) const;
  403. //
  404. // Method: GetToolTip()
  405. //
  406. // Purpose: Queries a feature's tool tip to display in the GUI
  407. //
  408. // Parameters:
  409. //
  410. // [out] std::string& toolTip The feature's tool tip
  411. //
  412. VmbErrorType GetToolTip( std::string &toolTip ) const;
  413. //
  414. // Method: GetDescription()
  415. //
  416. // Purpose: Queries a feature's description
  417. //
  418. // Parameters:
  419. //
  420. // [out] std::string& description The feature'sdescription
  421. //
  422. VmbErrorType GetDescription( std::string &description ) const;
  423. //
  424. // Method: GetSFNCNamespace()
  425. //
  426. // Purpose: Queries a feature's Standard Feature Naming Convention namespace
  427. //
  428. // Parameters:
  429. //
  430. // [out] std::string& sFNCNamespace The feature's SFNC namespace
  431. //
  432. VmbErrorType GetSFNCNamespace( std::string &sFNCNamespace ) const;
  433. //
  434. // Method: GetAffectedFeatures()
  435. //
  436. // Purpose: Queries the feature's that are dependent from the current feature
  437. //
  438. // Parameters:
  439. //
  440. // [out] FeaturePtrVector& affectedFeatures The features that get invalidated through the current feature
  441. //
  442. VmbErrorType GetAffectedFeatures( FeaturePtrVector &affectedFeatures );
  443. //
  444. // Method: GetSelectedFeatures()
  445. //
  446. // Purpose: Gets the features that get selected by the current feature
  447. //
  448. // Parameters:
  449. //
  450. // [out] FeaturePtrVector& selectedFeatures The selected features
  451. //
  452. VmbErrorType GetSelectedFeatures( FeaturePtrVector &selectedFeatures );
  453. //
  454. // Method: IsReadable()
  455. //
  456. // Purpose: Queries the read access status of a feature
  457. //
  458. // Parameters:
  459. //
  460. // [out] bool& isReadable True when feature can be read
  461. //
  462. IMEXPORT VmbErrorType IsReadable( bool &isReadable );
  463. //
  464. // Method: IsWritable()
  465. //
  466. // Purpose: Queries the write access status of a feature
  467. //
  468. // Parameters:
  469. //
  470. // [out] bool& isWritable True when feature can be written
  471. //
  472. IMEXPORT VmbErrorType IsWritable( bool &isWritable );
  473. //
  474. // Method: IsStreamable()
  475. //
  476. // Purpose: Queries whether a feature's value can be transferred as a stream
  477. //
  478. // Parameters:
  479. //
  480. // [out] bool& isStreamable True when streamable
  481. //
  482. IMEXPORT VmbErrorType IsStreamable( bool &isStreamable ) const;
  483. //
  484. // Method: RegisterObserver()
  485. //
  486. // Purpose: Registers an observer that notifies the application whenever a features value changes
  487. //
  488. // Parameters:
  489. //
  490. // [out] const IFeatureObserverPtr& pObserver The observer to be registered
  491. //
  492. // Returns:
  493. //
  494. // - VmbErrorSuccess: If no error
  495. // - VmbErrorBadParameter: "pObserver" is NULL.
  496. //
  497. IMEXPORT VmbErrorType RegisterObserver( const IFeatureObserverPtr &pObserver );
  498. //
  499. // Method: UnregisterObserver()
  500. //
  501. // Purpose: Unregisters an observer
  502. //
  503. // Parameters:
  504. //
  505. // [out] const IFeatureObserverPtr& pObserver The observer to be unregistered
  506. //
  507. // Returns:
  508. //
  509. // - VmbErrorSuccess: If no error
  510. // - VmbErrorBadParameter: "pObserver" is NULL.
  511. //
  512. IMEXPORT VmbErrorType UnregisterObserver( const IFeatureObserverPtr &pObserver );
  513. void ResetFeatureContainer();
  514. private:
  515. BaseFeature *m_pImpl;
  516. // No default ctor
  517. Feature();
  518. // No copy ctor
  519. Feature( const Feature& );
  520. // No assignment operator
  521. Feature& operator=( const Feature& );
  522. // Array functions to pass data across DLL boundaries
  523. IMEXPORT VmbErrorType GetValue( char * const pValue, VmbUint32_t &length ) const;
  524. IMEXPORT VmbErrorType GetValue( VmbUchar_t *pValue, VmbUint32_t &size, VmbUint32_t &sizeFilled ) const;
  525. IMEXPORT VmbErrorType GetValues( const char **pValues, VmbUint32_t &size );
  526. IMEXPORT VmbErrorType GetValues( VmbInt64_t *pValues, VmbUint32_t &Size );
  527. IMEXPORT VmbErrorType GetEntries( EnumEntry *pEnumEntries, VmbUint32_t &size );
  528. IMEXPORT VmbErrorType SetValue( const VmbUchar_t *pValue, VmbUint32_t size );
  529. IMEXPORT VmbErrorType GetName( char * const pName, VmbUint32_t &length ) const;
  530. IMEXPORT VmbErrorType GetDisplayName( char * const pDisplayName, VmbUint32_t &length ) const;
  531. IMEXPORT VmbErrorType GetCategory( char * const pCategory, VmbUint32_t &length ) const;
  532. IMEXPORT VmbErrorType GetUnit( char * const pUnit, VmbUint32_t &length ) const;
  533. IMEXPORT VmbErrorType GetRepresentation( char * const pRepresentation, VmbUint32_t &length ) const;
  534. IMEXPORT VmbErrorType GetToolTip( char * const pToolTip, VmbUint32_t &length ) const;
  535. IMEXPORT VmbErrorType GetDescription( char * const pDescription, VmbUint32_t &length ) const;
  536. IMEXPORT VmbErrorType GetSFNCNamespace( char * const pSFNCNamespace, VmbUint32_t &length ) const;
  537. IMEXPORT VmbErrorType GetAffectedFeatures( FeaturePtr *pAffectedFeatures, VmbUint32_t &nSize );
  538. IMEXPORT VmbErrorType GetSelectedFeatures( FeaturePtr *pSelectedFeatures, VmbUint32_t &nSize );
  539. };
  540. #include <VimbaCPP/Include/Feature.hpp>
  541. }} // namespace AVT::VmbAPI
  542. #endif