// Settings.cpp: implementation of the CSettings class.
// develop by artbear
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"

//#include <Windows.h>
#include "Settings.h"


//_____________________________________________________________________________
//
// CSettings Maps
//_____________________________________________________________________________
//
BEGIN_BL_METH_MAP(CSettings) 
    BL_METH("Get",	"Получить",		1,	NULL,		funcGet,		NULL)
    BL_METH("Get",	"Состояние",		1,	NULL,		funcGet,		NULL)
    BL_METH("Set",	"Включить",		2,	procSet,	NULL,		NULL)
END_BL_METH_MAP() 

BEGIN_BL_PROP_MAP(CSettings)
END_BL_PROP_MAP()

IMPLEMENT_MY_CONTEXT(CSettings, "SettingsManager", "УправлениеНастройками", 1, NULL, NULL, -1);

LPCSTR CSettings::m_voidKey = "";

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CSettings::CSettings()
{
}

CSettings::~CSettings()
{
}

// Сервисные функции 
LPCSTR CSettings::ResolveKey(LPCSTR key)
{
	if (!key)
		key = m_voidKey;

	return key;
}

LPCSTR CSettings::ResolveKey(CValue* pcvKey)
{
	LPCSTR key = NULL;

	if ( !pcvKey->IsEmpty() )
		key = (LPCSTR)pcvKey->GetString();
	else
		key = ResolveKey(key);

	return key;
}

// функции объекта
BOOL CSettings::funcGet(CValue &RetVal, CValue **params)
{
	LPCSTR key = ResolveKey(params[0]);

	BOOL flag = pMainAddIn->Property[key];
	RetVal = flag;
	return true;
}

BOOL CSettings::procSet(CValue **params)
{
	return true;
}