You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.0 KiB

8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __ARGUS_DATABASE_CONNECTOR_HEADER__
  2. #define __ARGUS_DATABASE_CONNECTOR_HEADER__
  3. #include "../components/base/basicSettingsProvider.h"
  4. #include "../data/mysql/database_class.h"
  5. #define ONE_DAY_HISTORY 86400
  6. #define ONE_HOUR_HISTORY 3600
  7. #define ONE_SECOND_HISTORY 1
  8. typedef struct S_CamRecordDBC{
  9. int id;
  10. bool online;
  11. char uuid[CLOG];
  12. char ip[16];
  13. char username[CLOG];
  14. char password[CLOG];
  15. }CamRecordDBC;
  16. typedef struct S_EventRecordDBC{
  17. int ts_s;
  18. int ts_ms;
  19. int type;
  20. }EventRecordDBC;
  21. typedef std::vector<CamRecordDBC*> vectorCamRecords;
  22. typedef std::vector<EventRecordDBC*> vectorEventRecords;
  23. class ARGUS_DBC{
  24. private:
  25. basicLogCollection * m_pLog;
  26. config_setting_t * m_pSettings;
  27. int m_nSiteID;
  28. MySQL_Connector * m_pDatabase;
  29. bool m_bIsConnected;
  30. char m_pDbHost[CLOG];
  31. char m_pDbUsername[CLOG];
  32. char m_pDbPassword[CLOG];
  33. char m_pDbDatabase[CLOG];
  34. public:
  35. explicit ARGUS_DBC( config_setting_t * Settings );
  36. ~ARGUS_DBC();
  37. /* Functionality */
  38. bool connect( void );
  39. bool getConnectionStatus(void){return m_bIsConnected;};
  40. bool setOnlineStatus( bool Status );
  41. int getIPCamCount( int siteID );
  42. bool getIPCamRecords( vectorCamRecords &VR );
  43. bool updateIPCam( CSTR uuid, CSTR Addr );
  44. bool updateNetworkNode( bool OnlineStatus );
  45. bool getLastEvents( vectorEventRecords &VR, int tss, int tsms );
  46. bool transferEvtToArchive( int SECONDS = ONE_DAY_HISTORY );
  47. };
  48. #endif