EnumClasses.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. //-----------------------------------------------------------------------------
  2. // (c) 2006 by Basler Vision Technologies
  3. // Section: Vision Components
  4. // Project: GenApi
  5. // Author: Margret Albrecht
  6. // $Header$
  7. //
  8. // License: This file is published under the license of the EMVA GenICam Standard Group.
  9. // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
  10. // If for some reason you are missing this file please contact the EMVA or visit the website
  11. // (http://www.genicam.org) for a full copy.
  12. //
  13. // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
  14. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  15. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
  17. // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  18. // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19. // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  20. // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  21. // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  22. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  23. // POSSIBILITY OF SUCH DAMAGE.
  24. //-----------------------------------------------------------------------------
  25. /*!
  26. \file
  27. \brief Definition of enum classes for Sign, Endianess, Access mode and Visibility
  28. */
  29. #ifndef GENAPI_ENUMCLASSES_H
  30. #define GENAPI_ENUMCLASSES_H
  31. #include <GenApi/Types.h>
  32. namespace GENAPI_NAMESPACE
  33. {
  34. //*************************************************************
  35. // Build in enummeration classes
  36. //*************************************************************
  37. //! ESignClass holds conversion methods for the sign enumeration
  38. class GENAPI_DECL ESignClass
  39. {
  40. public:
  41. //! Converts a string to enum value
  42. static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, ESign *pValue)
  43. {
  44. if (!pValue) return false;
  45. if( ValueStr == "Signed" )
  46. *pValue = Signed;
  47. else if( ValueStr == "Unsigned" )
  48. *pValue = Unsigned;
  49. else
  50. return false;
  51. return true;
  52. }
  53. //! Converts a string to an int32_t property
  54. static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, ESign *pValue)
  55. {
  56. if( ! pValue ) throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" );
  57. if( *pValue == Signed )
  58. ValueStr = "Signed";
  59. else if( *pValue == Unsigned )
  60. ValueStr = "Unsigned";
  61. else
  62. ValueStr = "_UndefinedSign";
  63. }
  64. //! Converts a string to an int32_t property
  65. static GENICAM_NAMESPACE::gcstring ToString(ESign Value)
  66. {
  67. GENICAM_NAMESPACE::gcstring Result;
  68. ToString(Result, &Value);
  69. return Result;
  70. }
  71. };
  72. /**
  73. \brief EEndianessClass holds conversion methods for the endianess enumeration
  74. */
  75. class GENAPI_DECL EEndianessClass
  76. {
  77. public:
  78. //! Converts a string to enum value
  79. static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, EEndianess *pValue)
  80. {
  81. if (!pValue) return false;
  82. if( ValueStr == "BigEndian" )
  83. *pValue = BigEndian;
  84. else if( ValueStr == "LittleEndian" )
  85. *pValue = LittleEndian;
  86. else
  87. return false;
  88. return true;
  89. }
  90. //! Converts a string to an int32_t property
  91. static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, EEndianess *pValue)
  92. {
  93. if( ! pValue ) throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" );
  94. if( *pValue == BigEndian )
  95. ValueStr = "BigEndian";
  96. else if( *pValue == LittleEndian )
  97. ValueStr = "LittleEndian";
  98. else
  99. ValueStr = "_UndefinedEndian";
  100. }
  101. //! Converts a string to an int32_t property
  102. static GENICAM_NAMESPACE::gcstring ToString(EEndianess Value)
  103. {
  104. GENICAM_NAMESPACE::gcstring Result;
  105. ToString(Result, &Value);
  106. return Result;
  107. }
  108. };
  109. /**
  110. \brief ERepresentationClass holds conversion methods for the representation enumeration
  111. */
  112. class GENAPI_DECL ERepresentationClass
  113. {
  114. public:
  115. //! Converts a string to enum value
  116. static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, ERepresentation *pValue)
  117. {
  118. if (!pValue) return false;
  119. if( ValueStr == "Linear" )
  120. *pValue = Linear;
  121. else if( ValueStr == "Logarithmic" )
  122. *pValue = Logarithmic;
  123. else if( ValueStr == "Boolean" )
  124. *pValue = Boolean;
  125. else if( ValueStr == "PureNumber" )
  126. *pValue = PureNumber;
  127. else if( ValueStr == "HexNumber" )
  128. *pValue = HexNumber;
  129. else if( ValueStr == "IPV4Address" )
  130. *pValue = IPV4Address;
  131. else if( ValueStr == "MACAddress" )
  132. *pValue = MACAddress;
  133. else
  134. return false;
  135. return true;
  136. }
  137. //! Converts a string to an int32_t property
  138. static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, ERepresentation *pValue)
  139. {
  140. if( ! pValue ) throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" );
  141. if( *pValue == Linear )
  142. ValueStr = "Linear";
  143. else if( *pValue == Logarithmic )
  144. ValueStr = "Logarithmic";
  145. else if( *pValue == Boolean )
  146. ValueStr = "Boolean";
  147. else if( *pValue == PureNumber )
  148. ValueStr = "PureNumber";
  149. else if( *pValue == HexNumber )
  150. ValueStr = "HexNumber";
  151. else if( *pValue == IPV4Address )
  152. ValueStr = "IPV4Address";
  153. else if( *pValue == MACAddress )
  154. ValueStr = "MACAddress";
  155. else
  156. ValueStr = "_UndefinedRepresentation";
  157. }
  158. //! Converts a string to an int32_t property
  159. static GENICAM_NAMESPACE::gcstring ToString(ERepresentation Value)
  160. {
  161. GENICAM_NAMESPACE::gcstring Result;
  162. ToString(Result, &Value);
  163. return Result;
  164. }
  165. };
  166. /**
  167. \brief EVisibilityClass holds conversion methods for the visibility enumeration
  168. */
  169. class GENAPI_DECL EVisibilityClass
  170. {
  171. public:
  172. //! Converts a string to enum value
  173. static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, EVisibility *pValue)
  174. {
  175. if (!pValue) return false;
  176. if( ValueStr == "Beginner" )
  177. *pValue = Beginner;
  178. else if( ValueStr == "Expert" )
  179. *pValue = Expert;
  180. else if( ValueStr == "Guru" )
  181. *pValue = Guru;
  182. else if( ValueStr == "Invisible" )
  183. *pValue = Invisible;
  184. else
  185. return false;
  186. return true;
  187. }
  188. //! Converts a string to an int32_t property
  189. static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, EVisibility *pValue)
  190. {
  191. if( ! pValue ) throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" );
  192. if( *pValue == Beginner )
  193. ValueStr = "Beginner";
  194. else if( *pValue == Expert )
  195. ValueStr = "Expert";
  196. else if( *pValue == Guru )
  197. ValueStr = "Guru";
  198. else if( *pValue == Invisible )
  199. ValueStr = "Invisible";
  200. else
  201. ValueStr = "_UndefinedVisibility";
  202. }
  203. //! Converts a string to an int32_t property
  204. static GENICAM_NAMESPACE::gcstring ToString(EVisibility Value)
  205. {
  206. GENICAM_NAMESPACE::gcstring Result;
  207. ToString(Result, &Value);
  208. return Result;
  209. }
  210. };
  211. /**
  212. \brief EAccessModeClass holds conversion methods for the access mode enumeration
  213. */
  214. class GENAPI_DECL EAccessModeClass
  215. {
  216. public:
  217. //! Converts a string to enum value
  218. static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, EAccessMode *pValue)
  219. {
  220. if (!pValue) return false;
  221. if( ValueStr == "RW" )
  222. *pValue = RW;
  223. else if( ValueStr == "RO" )
  224. *pValue = RO;
  225. else if( ValueStr == "WO" )
  226. *pValue = WO;
  227. else if( ValueStr == "NA" )
  228. *pValue = NA;
  229. else if( ValueStr == "NI" )
  230. *pValue = NI;
  231. else
  232. return false;
  233. return true;
  234. }
  235. //! Converts a string to an int32_t property
  236. static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, EAccessMode *pValue)
  237. {
  238. if( ! pValue ) throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" );
  239. if( *pValue == RW )
  240. ValueStr = "RW";
  241. else if( *pValue == RO )
  242. ValueStr = "RO";
  243. else if( *pValue == WO )
  244. ValueStr = "WO";
  245. else if( *pValue == NI )
  246. ValueStr = "NI";
  247. else if( *pValue == NA )
  248. ValueStr = "NA";
  249. else
  250. ValueStr = "_UndefinedAccessMode";
  251. }
  252. //! Converts a string to an int32_t property
  253. static GENICAM_NAMESPACE::gcstring ToString(EAccessMode Value)
  254. {
  255. GENICAM_NAMESPACE::gcstring Result;
  256. ToString(Result, &Value);
  257. return Result;
  258. }
  259. };
  260. /**
  261. \brief ECachingModeClass holds conversion methods for the caching mode enumeration
  262. */
  263. class GENAPI_DECL ECachingModeClass
  264. {
  265. public:
  266. //! Converts a string to enum value
  267. static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, ECachingMode *pValue )
  268. {
  269. if( ! pValue ) return false;
  270. if( ValueStr == "NoCache" )
  271. *pValue = NoCache;
  272. else if( ValueStr == "WriteThrough" )
  273. *pValue = WriteThrough;
  274. else if( ValueStr == "WriteAround" )
  275. *pValue = WriteAround;
  276. else
  277. return false;
  278. return true;
  279. }
  280. static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, ECachingMode *pValue)
  281. {
  282. if( ! pValue ) throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" );
  283. if( *pValue == NoCache )
  284. ValueStr = "NoCache";
  285. else if( *pValue == WriteThrough )
  286. ValueStr = "WriteThrough";
  287. else if( *pValue == WriteAround )
  288. ValueStr = "WriteAround";
  289. else
  290. ValueStr = "_UndefinedCachingMode";
  291. }
  292. //! Converts a string to an int32_t property
  293. static GENICAM_NAMESPACE::gcstring ToString(ECachingMode Value)
  294. {
  295. GENICAM_NAMESPACE::gcstring Result;
  296. ToString(Result, &Value);
  297. return Result;
  298. }
  299. };
  300. /**
  301. \brief Holds conversion methods for the namespace enumeration
  302. */
  303. class GENAPI_DECL ENameSpaceClass
  304. {
  305. public:
  306. //! Converts a string to enum value
  307. static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, ENameSpace *pValue)
  308. {
  309. if (!pValue) return false;
  310. if( ValueStr == "Custom" )
  311. *pValue = Custom;
  312. else if( ValueStr == "Standard" )
  313. *pValue = Standard;
  314. else
  315. return false;
  316. return true;
  317. }
  318. //! Converts a string to an int32_t property
  319. static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, ENameSpace *pValue)
  320. {
  321. if( ! pValue ) throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" );
  322. if( *pValue == Custom )
  323. ValueStr = "Custom";
  324. else if( *pValue == Standard )
  325. ValueStr = "Standard";
  326. else
  327. ValueStr = "_UndefinedNameSpace";
  328. }
  329. //! Converts a string to an int32_t property
  330. static GENICAM_NAMESPACE::gcstring ToString(ENameSpace Value)
  331. {
  332. GENICAM_NAMESPACE::gcstring Result;
  333. ToString(Result, &Value);
  334. return Result;
  335. }
  336. };
  337. /**
  338. \brief Holds conversion methods for the standard namespace enumeration
  339. */
  340. class GENAPI_DECL EYesNoClass
  341. {
  342. public:
  343. //! Converts a string to enum value
  344. static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, EYesNo *pValue)
  345. {
  346. if (!pValue) return false;
  347. if( ValueStr == "Yes" )
  348. *pValue = Yes;
  349. else if( ValueStr == "No" )
  350. *pValue = No;
  351. else
  352. return false;
  353. return true;
  354. }
  355. //! Converts a string to an int32_t property
  356. static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, EYesNo *pValue)
  357. {
  358. if( ! pValue ) throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" );
  359. if( *pValue == Yes)
  360. ValueStr = "Yes";
  361. else if( *pValue == No )
  362. ValueStr = "No";
  363. else
  364. ValueStr = "_UndefinedYesNo";
  365. }
  366. //! Converts a string to an int32_t property
  367. static GENICAM_NAMESPACE::gcstring ToString(EYesNo Value)
  368. {
  369. GENICAM_NAMESPACE::gcstring Result;
  370. ToString(Result, &Value);
  371. return Result;
  372. }
  373. };
  374. /**
  375. \brief Holds conversion methods for the standard namespace enumeration
  376. */
  377. class GENAPI_DECL EStandardNameSpaceClass
  378. {
  379. public:
  380. //! Converts a string to enum value
  381. static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, EStandardNameSpace *pValue)
  382. {
  383. if (!pValue) return false;
  384. if( ValueStr == "None" )
  385. *pValue = None;
  386. else if( ValueStr == "GEV" )
  387. *pValue = GEV;
  388. else if( ValueStr == "IIDC" )
  389. *pValue = IIDC;
  390. else if( ValueStr == "CL" )
  391. *pValue = CL;
  392. else if( ValueStr == "USB" )
  393. *pValue = USB;
  394. else
  395. return false;
  396. return true;
  397. }
  398. //! Converts a string to an int32_t property
  399. static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, EStandardNameSpace *pValue)
  400. {
  401. if( ! pValue ) throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" );
  402. if( *pValue == None )
  403. ValueStr = "None";
  404. else if( *pValue == GEV )
  405. ValueStr = "GEV";
  406. else if( *pValue == IIDC )
  407. ValueStr = "IIDC";
  408. else if( *pValue == CL )
  409. ValueStr = "CL";
  410. else if( *pValue == USB )
  411. ValueStr = "USB";
  412. else
  413. ValueStr = "_UndefinedStandardNameSpace";
  414. }
  415. //! Converts a string to an int32_t property
  416. static GENICAM_NAMESPACE::gcstring ToString(EStandardNameSpace Value)
  417. {
  418. GENICAM_NAMESPACE::gcstring Result;
  419. ToString(Result, &Value);
  420. return Result;
  421. }
  422. };
  423. /**
  424. \brief Holds conversion methods for the converter formulas
  425. */
  426. class GENAPI_DECL ESlopeClass
  427. {
  428. public:
  429. //! Converts a string to enum value
  430. static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, ESlope *pValue)
  431. {
  432. if (!pValue)
  433. return false;
  434. if( ValueStr == "Increasing" )
  435. *pValue = Increasing;
  436. else if( ValueStr == "Decreasing" )
  437. *pValue = Decreasing;
  438. else if( ValueStr == "Varying" )
  439. *pValue = Varying;
  440. else if( ValueStr == "Automatic" )
  441. *pValue = Automatic;
  442. else
  443. return false;
  444. return true;
  445. }
  446. //! Converts a string to an int32_t property
  447. static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, ESlope *pValue)
  448. {
  449. if( ! pValue )
  450. throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" );
  451. if( *pValue == Increasing )
  452. ValueStr = "Increasing";
  453. else if( *pValue == Decreasing )
  454. ValueStr = "Decreasing";
  455. else if( *pValue == Varying )
  456. ValueStr = "Varying";
  457. else if( *pValue == Automatic )
  458. ValueStr = "Automatic";
  459. else
  460. ValueStr = "_UndefinedESlope";
  461. }
  462. //! Converts a string to an int32_t property
  463. static GENICAM_NAMESPACE::gcstring ToString(ESlope Value)
  464. {
  465. GENICAM_NAMESPACE::gcstring Result;
  466. ToString(Result, &Value);
  467. return Result;
  468. }
  469. };
  470. /**
  471. \brief Holds conversion methods for the notation type of floats
  472. */
  473. class GENAPI_DECL EDisplayNotationClass
  474. {
  475. public:
  476. //! Converts a string to enum value
  477. static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, EDisplayNotation *pValue)
  478. {
  479. if (!pValue)
  480. return false;
  481. if( ValueStr == "Automatic" )
  482. *pValue = fnAutomatic;
  483. else if( ValueStr == "Fixed" )
  484. *pValue = fnFixed;
  485. else if( ValueStr == "Scientific" )
  486. *pValue = fnScientific;
  487. else
  488. return false;
  489. return true;
  490. }
  491. //! Converts a string to an int32_t property
  492. static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, EDisplayNotation *pValue)
  493. {
  494. if( ! pValue )
  495. throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" );
  496. if( *pValue == fnAutomatic )
  497. ValueStr = "Automatic";
  498. else if( *pValue == fnFixed )
  499. ValueStr = "Fixed";
  500. else if( *pValue == fnScientific )
  501. ValueStr = "Scientific";
  502. else
  503. ValueStr = "_UndefinedEDisplayNotation";
  504. }
  505. //! Converts a string to an int32_t property
  506. static GENICAM_NAMESPACE::gcstring ToString(EDisplayNotation Value)
  507. {
  508. GENICAM_NAMESPACE::gcstring Result;
  509. ToString(Result, &Value);
  510. return Result;
  511. }
  512. };
  513. /**
  514. \brief Holds conversion methods for the notation type of floats
  515. */
  516. class GENAPI_DECL EInputDirectionClass
  517. {
  518. public:
  519. //! Converts a string to enum value
  520. static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, EInputDirection *pValue)
  521. {
  522. if (!pValue)
  523. return false;
  524. if( ValueStr == "From" )
  525. *pValue = idFrom;
  526. else if( ValueStr == "To" )
  527. *pValue = idTo;
  528. else if( ValueStr == "None" )
  529. *pValue = idNone;
  530. else
  531. return false;
  532. return true;
  533. }
  534. //! Converts a string to an int32_t property
  535. static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, EInputDirection *pValue)
  536. {
  537. if( ! pValue )
  538. throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" );
  539. if( *pValue == idFrom )
  540. ValueStr = "From";
  541. else if( *pValue == idTo )
  542. ValueStr = "To";
  543. else if( *pValue == idNone )
  544. ValueStr = "None";
  545. else
  546. ValueStr = "_UndefinedEInputDirection";
  547. }
  548. //! Converts a string to an int32_t property
  549. static GENICAM_NAMESPACE::gcstring ToString(EInputDirection Value)
  550. {
  551. GENICAM_NAMESPACE::gcstring Result;
  552. ToString(Result, &Value);
  553. return Result;
  554. }
  555. };
  556. //! helper class converting EGenApiSchemaVersion from and to string
  557. class GENAPI_DECL EGenApiSchemaVersionClass
  558. {
  559. public:
  560. //! Converts a string to enum value
  561. static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, EGenApiSchemaVersion *pValue)
  562. {
  563. if (!pValue) return false;
  564. if (ValueStr == "v1_0")
  565. *pValue = v1_0;
  566. else if (ValueStr == "v1_1")
  567. *pValue = v1_1;
  568. else
  569. return false;
  570. return true;
  571. }
  572. //! Converts a string to an int32_t property
  573. static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, EGenApiSchemaVersion *pValue)
  574. {
  575. assert(!pValue);
  576. if (*pValue == v1_0)
  577. ValueStr = "v1_0";
  578. else if (*pValue == v1_1)
  579. ValueStr = "v1_1";
  580. else
  581. ValueStr = "_Undefined";
  582. }
  583. //! Converts a string to an int32_t property
  584. static GENICAM_NAMESPACE::gcstring ToString(EGenApiSchemaVersion Value)
  585. {
  586. GENICAM_NAMESPACE::gcstring Result;
  587. ToString(Result, &Value);
  588. return Result;
  589. }
  590. };
  591. }
  592. #endif // ifndef GENAPI_ENUMCLASSES_H