SapMetadata.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #ifndef _SAPMETADATA_H_
  2. #define _SAPMETADATA_H_
  3. #include "SapClassBasicDef.h"
  4. //
  5. // Interface that any compliant device must implement
  6. //
  7. class SAPCLASSBASIC_CLASS ISapMetadata
  8. {
  9. public:
  10. virtual ~ISapMetadata(){};
  11. virtual BOOL Enable(BOOL enable) = 0;
  12. virtual BOOL IsEnabled() const = 0;
  13. virtual UINT GetSelectorCount() const = 0;
  14. virtual BOOL GetSelectorName(UINT selectorIndex, char* name, UINT nameLength) const = 0;
  15. virtual BOOL Select(UINT selectorIndex, BOOL select) = 0;
  16. virtual BOOL IsSelected(UINT selectorIndex) = 0;
  17. virtual BOOL Extract(UINT bufferIndex) = 0;
  18. virtual BOOL Extract(UINT bufferIndex, UINT lineIndex) = 0;
  19. virtual UINT GetExtractedResultCount() const = 0;
  20. virtual BOOL GetExtractedResult(UINT resultIndex, char* name, UINT nameLength, char* value, UINT valueLength) const = 0;
  21. virtual BOOL SaveToCSV(const char* filename) = 0;
  22. };
  23. //
  24. // SapMetadata class declaration
  25. //
  26. class SAPCLASSBASIC_CLASS SapMetadata : public SapManager, ISapMetadata
  27. {
  28. public:
  29. // Metadata types
  30. typedef int MetadataType;
  31. enum _MetadataType
  32. {
  33. MetadataUnknown,
  34. MetadataPerFrame,
  35. MetadataPerLine
  36. };
  37. public:
  38. // Constructor/Destructor
  39. SapMetadata(SapAcqDevice* pAcqDevice, SapBuffer* pBuffer, BOOL alwaysAllocExtraLines = TRUE);
  40. virtual ~SapMetadata();
  41. // Helper function to verify the acquisiton device supports metadata
  42. static BOOL IsMetadataSupported(SapAcqDevice* pAcqDevice);
  43. // Helper function to verify the acquisiton device metadata support is enabled
  44. static BOOL IsMetadataEnabled(SapAcqDevice* pAcqDevice);
  45. // Helper function to check the metadata type the acquisiton device supports
  46. static MetadataType GetMetadataType(SapAcqDevice* pAcqDevice);
  47. // Module create/destroy
  48. BOOL Create();
  49. BOOL Destroy();
  50. // Get the metadata type of this created module
  51. MetadataType GetMetadataType() const;
  52. // Enable/Disable metadata for this acquisition device
  53. BOOL Enable(BOOL enable = TRUE);
  54. BOOL IsEnabled() const;
  55. // Get the list of metadata selectors this acquisition device provides
  56. UINT GetSelectorCount() const;
  57. BOOL GetSelectorName(UINT selectorIndex, char* name, UINT nameLength) const;
  58. // Enable/Disable a specific selector
  59. BOOL Select(UINT selectorIndex, BOOL select = TRUE);
  60. BOOL IsSelected(UINT selectorIndex);
  61. // Extract the metadata items from the buffer
  62. BOOL Extract();
  63. BOOL Extract(UINT bufferIndex);
  64. BOOL Extract(UINT bufferIndex, UINT lineIndex);
  65. // Get the list of extracted metadata items
  66. UINT GetExtractedResultCount() const;
  67. BOOL GetExtractedResult(UINT resultIndex, char* name, UINT nameLength, char* value, UINT valueLength) const;
  68. // Export the previously extracted metadata items to a comma separated values file
  69. // for later exploitation with a spreadsheet software
  70. BOOL SaveToCSV(const char* filename);
  71. protected:
  72. // Utility methods
  73. static BOOL IsDeviceVendorSupported(SapAcqDevice* pAcqDevice);
  74. private:
  75. SapAcqDevice* m_pAcqDevice;
  76. SapBuffer* m_pBuffer;
  77. ISapMetadata* m_pAgent;
  78. MetadataType m_type;
  79. BOOL m_alwaysAllocExtraLines;
  80. };
  81. #endif