/************************************************************************/
/*  Copyright (C), 2016-2020, [IT], ��������Ȩ��;
/*  ģ �� ����;
/*  ��    ������ǰ��Ŀ���ݿ����ʵ��;
/*
/*  ��    ����[V];	
/*  ��    �ߣ�[IT];
/*  ��    �ڣ�[11/13/2016];
/*
/*
/*  ע    �⣺;
/*
/*  �޸ļ�¼��[IT];
/*  �޸����ڣ�;
/*  �޸İ汾��;
/*  �޸����ݣ�;
/************************************************************************/
#ifndef __DATA_IMPL__
#define __DATA_IMPL__

#pragma once

#include "TableInfo.h"

class CDataImpl
{
	CDataImpl(void);
public:
	static CDataImpl* GetInstance()
	{
		static CDataImpl *pObj = NULL;
		if ( pObj == NULL )
		{
			pObj = new CDataImpl;
			pObj->Open();
		}

		return pObj;
	}

	virtual ~CDataImpl(void);

	// ˽�б���;
private:
	sqlite3		*m_psqlite3;
	CHAR		*m_pszErrmsg;

	// �û�����;
public:
	BOOL Open();
	void Close();

	// begin;
	BOOL TransactionBegin()
	{
		INT nRet = sqlite3_exec(m_psqlite3, "begin", 0, 0, &m_pszErrmsg);
		return ( nRet == 0 ) ? TRUE : FALSE;
	}

	BOOL TransactionCommit()
	{
		INT nRet = sqlite3_exec(m_psqlite3, "commit", 0, 0, &m_pszErrmsg);
		return ( nRet == 0 ) ? TRUE : FALSE;
	}

	// commit;
	// ִ�����;
	BOOL ExecteSQL(IN LPCSTR lpSQL);

	// ��ѯģ���;
	INT QueryModInfo(IN OUT std::vector<STModInfo*> &vtModInfo);
	// �������;
	BOOL InsertModInfo(IN STModInfo &stModInfo);
	BOOL InsertModInfo(IN LPCSTR lpModName, IN LPCSTR lpModAddress, IN LPCSTR lpModVerion);
	// ������;
	BOOL UpdateModInfo(IN STModInfo &stModInfo);
	BOOL UpdateModInfo(IN LPCSTR lpModName, IN LPCSTR lpModAddress, IN LPCSTR lpModVerion);
	// ɾ��ģ��;
	BOOL DeleteModInfo(IN STModInfo &stModInfo);
	BOOL DeleteModInfo(IN LPCSTR lpModName);
};

#endif