1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #pragma once
- //#pragma warning(disable:4251)
- #include <stdio.h>
- #include <windows.h>
- #include <mutex>
- #include <vector>
- #include <functional>
- #include "string.h"
- #include "CError.h"
- #include "sqlite3.h"
- #include "dt.h"
- #include "CppSQLite3.h"
- #ifdef DATABASEOPERATE_DLL
- #define DLL_DATABASEOPERATE_API __declspec(dllexport)
- #else
- #define DLL_DATABASEOPERATE_API
- #endif
- typedef std::function<void(string strDbName, string strTableName)> DataNoticeCallbackFun;
- namespace ns_db
- {
- typedef struct _TABLE_INFO_BASE
- {
- INT iNo_;
- _TABLE_INFO_BASE()
- {
- iNo_ = 100;
- }
- } TABLE_INFO_BASE;
- class DLL_DATABASEOPERATE_API CDataBaseOperate
- {
- private:
- bool m_bIsInit;
- //static void* context;
- static void* m_pPubSocket;
- static void* m_pSubscriberSocket;
- protected:
- CDataBaseOperate(string sPathFile);
- ~CDataBaseOperate();
- virtual LONG SaveDB() = 0;
- virtual LONG LoadDB() = 0;
- bool Open();
- void Close();
- CppSQLite3DB m_DB;
- std::string m_sPathFile = "";
- //设置表的缓存数据
- LONG SetTableData(string strTableName, vector<TABLE_INFO_BASE>* vecDB, vector<TABLE_INFO_BASE>* vecTemp, bool bAppend = false);
- public:
- string GetDbName() { return m_sPathFile; };
- //保存数据到数据库
- LONG SaveDataToDB();
- //从数据库加载数据
- LONG LoadDataByDB();
- //数据更改后发布通知
- LONG DataChangNotice(string strTableName);
- //接收数据更改后的通知
- void RecvDataChangNotice(string strTableName, DataNoticeCallbackFun callBackFun);
- };
- }
|