In This Topic
#include "StdAfx.h"
#pragma warning (push)
#pragma warning (disable:4251)
#pragma warning (disable:4786)
#include "../MusicStoreLib.h"
#include "../MusicStoreLib/Result.h"
namespace MusicStoreLib
{
LtXmlLib20Data::CParentElementInfo* CResult::ms_pParentElementInfo = NULL;
LtXmlLib20Data::CAttributeInfo** CResult::ms_ppAttributeInfo = NULL;
LtXmlLib20Data::CElementInfo** CResult::ms_ppElementInfo = NULL;
CResultPtr CResult::CreateInstance(LPCTSTR lpctElementName)
{
return new MusicStoreLib::CResult(lpctElementName);
}
CResult::CResult(LPCTSTR lpctElementName)
: CInstanceMonitor(_T("CResult"))
, m_SearchDate(LtXmlLib20::CDateTime::dt_date)
{
m_elementName = lpctElementName;
Init();
}
CResult::~CResult()
{
Cleanup();
}
void CResult::Cleanup()
{
// unregister for any events we have asked for
// cos there'll be no one left to hear soon
this->m_Product = NULL;
}
void CResult::OnEvent(LtXmlLib20::CXmlObjectBase* pMsgSource, LtXmlLib20::IEventSink::MsgType eMsgType, void* pData)
{
if (eMsgType == LtXmlLib20::IEventSink::MT_CollectionChangeEvent)
{
}
}
void CResult::Init()
{
Cleanup();
this->m_SearchDate = LtXmlLib20::CDateTime(LtXmlLib20::CDateTime::dt_date);
this->m_Product = dynamic_cast<MusicStoreLib::CAlbumTypeCol*>(MusicStoreLib::CClassFactory::CreateClassCollection(MusicStoreLib::CClassFactory::ClsName_CAlbumTypeCol, _T("Product"), _T(""), 0, -1).Ptr());
}
void CResult::AccessProperty(int iPropertyIndex, bool bRead, LtXmlLib20::LtVariant& rValue)
{
if (bRead)
{
switch(iPropertyIndex)
{
case 1:
rValue.SetDate(GetSearchDate());
break;
case 2:
rValue.SetXmlCollection(GetProduct().Ptr());
break;
default:
throw LtXmlLib20::CLtException(_T("Unknown Property Index"));
};
}
else
{
switch(iPropertyIndex)
{
case 1:
SetSearchDate(rValue.GetDate());
break;
case 2:
throw LtXmlLib20::CLtException(_T("Collections can not be set"));
break;
default:
throw LtXmlLib20::CLtException(_T("Unknown Property Index"));
}
}
}
LtXmlLib20::CDateTime CResult::GetSearchDate() const
{
return this->m_SearchDate;
}
void CResult::SetSearchDate(LtXmlLib20::CDateTime value)
{
this->m_SearchDate.SetDateTime(value, this->m_SearchDate.GetType());
}
MusicStoreLib::CAlbumTypeColPtr CResult::GetProduct() const
{
return this->m_Product;
}
MusicStoreLib::CResultPtr CResult::Clone() const
{
MusicStoreLib::CResultPtr newObject = CreateInstance(m_elementName.c_str());
int index = 0;
newObject->m_SearchDate = m_SearchDate;
for (index = 0; index < m_Product->GetCount(); index++)
newObject->m_Product->Add(dynamic_cast<MusicStoreLib::CAlbumType*>(m_Product->Item(index)->Clone().Ptr()));
return newObject.Ptr();
}
std::tstring CResult::GetTargetNamespace() const
{
return _T("");
}
std::tstring CResult::GetNamespace() const
{
return _T("");
}
LtXmlLib20::CXmlObjectBase* CResult::GetBase()
{
return this;
}
void CResult::CleanMetaData()
{
LtXmlLib20::CXmlGeneratedClass::CleanMetaData(ms_pParentElementInfo, ms_ppElementInfo, ms_ppAttributeInfo);
}
LtXmlLib20Data::CParentElementInfo* CResult::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("Result"),
_T(""),
true,
false,
-1,
LtXmlLib20::ItemType_none,
LtXmlLib20::CWhitespaceUtils::WhitespaceRule_None,
NULL,
false);
}
m_csInit.Leave();
}
return ms_pParentElementInfo;
}
LtXmlLib20Data::CElementInfo** CResult::GetClassElementInfo() const
{
if (ms_ppElementInfo == NULL)
{
m_csInit.Enter();
if (ms_ppElementInfo == NULL)
{
ms_ppElementInfo = new LtXmlLib20Data::CElementInfo*[3];
ms_ppElementInfo[0] = new LtXmlLib20Data::CElementInfoSeqPrimMnd(_T("SearchDate"), _T(""), 1, false, LtXmlLib20::ItemType_date, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Collapse, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
ms_ppElementInfo[1] = new LtXmlLib20Data::CElementInfoSeqClsCol(_T("Product"), _T(""), 2, LtXmlLib20Data::XmlElementType_ELEMENT);
ms_ppElementInfo[2] = NULL;
}
m_csInit.Leave();
}
return ms_ppElementInfo;
}
LtXmlLib20Data::CAttributeInfo** CResult::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;
}
};