In This Topic
#include "StdAfx.h"
#pragma warning (push)
#pragma warning (disable:4251)
#pragma warning (disable:4786)
#include "../MusicStoreLib.h"
#include "../MusicStoreLib/PriceFilter.h"
namespace MusicStoreLib
{
LtXmlLib20Data::CParentElementInfo* CPriceFilter::ms_pParentElementInfo = NULL;
LtXmlLib20Data::CAttributeInfo** CPriceFilter::ms_ppAttributeInfo = NULL;
LtXmlLib20Data::CElementInfo** CPriceFilter::ms_ppElementInfo = NULL;
CPriceFilterPtr CPriceFilter::CreateInstance(LPCTSTR lpctElementName)
{
return new MusicStoreLib::CPriceFilter(lpctElementName);
}
CPriceFilter::CPriceFilter(LPCTSTR lpctElementName)
: CInstanceMonitor(_T("CPriceFilter"))
{
m_elementName = lpctElementName;
Init();
}
CPriceFilter::~CPriceFilter()
{
Cleanup();
}
void CPriceFilter::Cleanup()
{
// unregister for any events we have asked for
// cos there'll be no one left to hear soon
}
void CPriceFilter::OnEvent(LtXmlLib20::CXmlObjectBase* pMsgSource, LtXmlLib20::IEventSink::MsgType eMsgType, void* pData)
{
if (eMsgType == LtXmlLib20::IEventSink::MT_CollectionChangeEvent)
{
}
}
void CPriceFilter::Init()
{
Cleanup();
this->m_MinPrice = 0;
this->m_IsValidMinPrice = false;
this->m_MaxPrice = 0;
this->m_IsValidMaxPrice = false;
}
void CPriceFilter::AccessProperty(int iPropertyIndex, bool bRead, LtXmlLib20::LtVariant& rValue)
{
if (bRead)
{
switch(iPropertyIndex)
{
case 1:
if (IsValidMinPrice())
rValue.SetR8(GetMinPrice());
else
rValue.SetInvalid();
break;
case 2:
if (IsValidMaxPrice())
rValue.SetR8(GetMaxPrice());
else
rValue.SetInvalid();
break;
default:
throw LtXmlLib20::CLtException(_T("Unknown Property Index"));
};
}
else
{
switch(iPropertyIndex)
{
case 1:
if (rValue.IsValid())
SetMinPrice(rValue.GetR8());
else
SetValidMinPrice(false);
break;
case 2:
if (rValue.IsValid())
SetMaxPrice(rValue.GetR8());
else
SetValidMaxPrice(false);
break;
default:
throw LtXmlLib20::CLtException(_T("Unknown Property Index"));
}
}
}
DOUBLE CPriceFilter::GetMinPrice() const
{
if (m_IsValidMinPrice == false)
throw LtXmlLib20::CLtInvalidStateException(_T("The Property GetMinPrice is not valid. SetMinPrice must be called first"));
return this->m_MinPrice;
}
void CPriceFilter::SetMinPrice(DOUBLE value)
{
this->m_IsValidMinPrice = true;
this->m_MinPrice = value;
}
bool CPriceFilter::IsValidMinPrice() const
{
return m_IsValidMinPrice;
}
void CPriceFilter::SetValidMinPrice(bool value)
{
if (value != m_IsValidMinPrice)
{
this->m_MinPrice = 0;
m_IsValidMinPrice = value;
}
}
DOUBLE CPriceFilter::GetMaxPrice() const
{
if (m_IsValidMaxPrice == false)
throw LtXmlLib20::CLtInvalidStateException(_T("The Property GetMaxPrice is not valid. SetMaxPrice must be called first"));
return this->m_MaxPrice;
}
void CPriceFilter::SetMaxPrice(DOUBLE value)
{
this->m_IsValidMaxPrice = true;
this->m_MaxPrice = value;
}
bool CPriceFilter::IsValidMaxPrice() const
{
return m_IsValidMaxPrice;
}
void CPriceFilter::SetValidMaxPrice(bool value)
{
if (value != m_IsValidMaxPrice)
{
this->m_MaxPrice = 0;
m_IsValidMaxPrice = value;
}
}
MusicStoreLib::CPriceFilterPtr CPriceFilter::Clone() const
{
MusicStoreLib::CPriceFilterPtr newObject = CreateInstance(m_elementName.c_str());
int index = 0;
newObject->m_MinPrice = m_MinPrice;
newObject->m_IsValidMinPrice = m_IsValidMinPrice;
newObject->m_MaxPrice = m_MaxPrice;
newObject->m_IsValidMaxPrice = m_IsValidMaxPrice;
return newObject.Ptr();
}
std::tstring CPriceFilter::GetTargetNamespace() const
{
return _T("");
}
std::tstring CPriceFilter::GetNamespace() const
{
return _T("");
}
LtXmlLib20::CXmlObjectBase* CPriceFilter::GetBase()
{
return this;
}
void CPriceFilter::CleanMetaData()
{
LtXmlLib20::CXmlGeneratedClass::CleanMetaData(ms_pParentElementInfo, ms_ppElementInfo, ms_ppAttributeInfo);
}
LtXmlLib20Data::CParentElementInfo* CPriceFilter::GetClassInfo() const
{
if (ms_pParentElementInfo == NULL)
{
m_csInit.Enter();
if (ms_pParentElementInfo == NULL)
{
ms_pParentElementInfo = new LtXmlLib20Data::CParentElementInfo(
LtXmlLib20Data::XmlElementGroupType_SEQUENCE,
LtXmlLib20Data::XmlElementType_ELEMENT,
_T("PriceFilter"),
_T(""),
true,
false,
-1,
LtXmlLib20::ItemType_none,
LtXmlLib20::CWhitespaceUtils::WhitespaceRule_None,
NULL,
false);
}
m_csInit.Leave();
}
return ms_pParentElementInfo;
}
LtXmlLib20Data::CElementInfo** CPriceFilter::GetClassElementInfo() const
{
if (ms_ppElementInfo == NULL)
{
m_csInit.Enter();
if (ms_ppElementInfo == NULL)
{
ms_ppElementInfo = new LtXmlLib20Data::CElementInfo*[3];
ms_ppElementInfo[0] = new LtXmlLib20Data::CElementInfoSeqPrimOpt(_T("MinPrice"), _T(""), 1, false, LtXmlLib20::ItemType_r8, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Collapse, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
ms_ppElementInfo[1] = new LtXmlLib20Data::CElementInfoSeqPrimOpt(_T("MaxPrice"), _T(""), 2, false, LtXmlLib20::ItemType_r8, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Collapse, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
ms_ppElementInfo[2] = NULL;
}
m_csInit.Leave();
}
return ms_ppElementInfo;
}
LtXmlLib20Data::CAttributeInfo** CPriceFilter::GetClassAttributeInfo() const
{
if (ms_ppAttributeInfo == NULL)
{
m_csInit.Enter();
if (ms_ppAttributeInfo == NULL)
{
ms_ppAttributeInfo = new LtXmlLib20Data::CAttributeInfo*[1];
ms_ppAttributeInfo[0] = NULL;
}
m_csInit.Leave();
}
return ms_ppAttributeInfo;
}
};