TDOptions.h
#pragma once
/**
* \class CTDOptions TDOptions.h
* \brief mamage options in TenderShower project
*/
class CTDOptions
{
private:
CTDOptions(void);
~CTDOptions(void);
public:
static CTDOptions * GetInstance();
// static void ReleaseInstance();
public:
//THIDNormFaceGeoFormat* GetFaceGeoFormat();
bool LoadSystemConfig();
void SaveSystemConfig();
//////////////////////////////////////////////
inline CString GetDBLastUpateTime() const
{
return m_strLastUpdataTime;
}
inline int GetDBMaxIndex() const
{
return m_nMaxDBIndex;
}
void SetDBLastUpdateTime( CString strUpdateTime);
void SetFPNum(int nFPNum);
private:
TCHAR m_pPathName[MAX_PATH];
CString m_strLastUpdataTime;
int m_nMaxDBIndex;
};
#define TDGI CTDOptions::GetInstance()
TDOptions.cpp
#include "stdafx.h"
#include "TDOptions.h"
//CTDOptions* CTDOptions::m_pSingleInstance = NULL;
CTDOptions::CTDOptions(void)
{
// m_nFeatureSize = THIDGetFaceFeatureSize();
memcpy(m_pPathName, g_strModelPath,MAX_PATH*sizeof(TCHAR));
::PathAppend(m_pPathName, _T("RegistVerySyConfig.ini"));
}
CTDOptions::~CTDOptions(void)
{
}
CTDOptions * CTDOptions::GetInstance()
{
static CTDOptions stance;
return &stance;
}
bool CTDOptions::LoadSystemConfig()
{
if (!PathFileExists(m_pPathName))
{
return false;
}
TCHAR szTempBuffer[100] = {0};
GetPrivateProfileString(_T("DBParam"),_T("LastUpateTime"),
_T("2015-09-01 12:00:00"), szTempBuffer,100, m_pPathName);
m_strLastUpdataTime= szTempBuffer;
m_nMaxDBIndex= GetPrivateProfileInt(_T("DBParam"), _T("MaxIndex"), 0, m_pPathName );
return true;
}
void CTDOptions::SetDBLastUpdateTime(CString strUpdateTime)
{
WritePrivateProfileString(_T("DBParam"),
_T("LastUpateTime"), strUpdateTime, m_pPathName);
}
void CTDOptions::SetFPNum(int nFPNum)
{
// 将其值写入配置文件中
CString strTemp;
strTemp.Format(_T("%d"), nFPNum);
WritePrivateProfileString(_T("LocalDBNum"),
_T("FPNum"), strTemp, m_pPathName);
}
RegistVerySyConfig.ini
# 0 1 2 3 4 5 6 7 8 9
[DBParam]
#注释1
LastUpateTime=1
#注释2
MaxIndex=0