In This Topic
#include "StdAfx.h"
#pragma warning (push)
#pragma warning (disable:4251)
#pragma warning (disable:4786)
#include "../SimpleHierarchyLib.h"
#include "../SimpleHierarchyLib/ItemType.h"
namespace SimpleHierarchyLib
{
LtXmlLib20Data::CParentElementInfo* CItemType::ms_pParentElementInfo = NULL;
LtXmlLib20Data::CAttributeInfo** CItemType::ms_ppAttributeInfo = NULL;
LtXmlLib20Data::CElementInfo** CItemType::ms_ppElementInfo = NULL;
CItemTypePtr CItemType::CreateInstance(LPCTSTR lpctElementName)
{
return new SimpleHierarchyLib::CItemType(lpctElementName);
}
CItemType::CItemType(LPCTSTR lpctElementName)
: CInstanceMonitor(_T("CItemType"))
{
m_elementName = lpctElementName;
Init();
}
CItemType::~CItemType()
{
Cleanup();
}
void CItemType::Cleanup()
{
// unregister for any events we have asked for
// cos there'll be no one left to hear soon
}
void CItemType::OnEvent(LtXmlLib20::CXmlObjectBase* pMsgSource, LtXmlLib20::IEventSink::MsgType eMsgType, void* pData)
{
if (eMsgType == LtXmlLib20::IEventSink::MT_CollectionChangeEvent)
{
}
}
void CItemType::Init()
{
Cleanup();
this->m_StockCode = 0;
this->m_Description = _T("");
this->m_UnitCost = 0;
this->m_Quantity = 0;
}
void CItemType::AccessProperty(int iPropertyIndex, bool bRead, LtXmlLib20::LtVariant& rValue)
{
if (bRead)
{
switch(iPropertyIndex)
{
case 1:
rValue.SetUI8(GetStockCode());
break;
case 2:
rValue.SetString(GetDescription());
break;
case 3:
rValue.SetI8(GetUnitCost());
break;
case 4:
rValue.SetUI4(GetQuantity());
break;
default:
throw LtXmlLib20::CLtException(_T("Unknown Property Index"));
};
}
else
{
switch(iPropertyIndex)
{
case 1:
SetStockCode(rValue.GetUI8());
break;
case 2:
SetDescription(rValue.GetString());
break;
case 3:
SetUnitCost(rValue.GetI8());
break;
case 4:
SetQuantity(rValue.GetUI4());
break;
default:
throw LtXmlLib20::CLtException(_T("Unknown Property Index"));
}
}
}
DWORDLONG CItemType::GetStockCode() const
{
return this->m_StockCode;
}
void CItemType::SetStockCode(DWORDLONG value)
{
this->m_StockCode = value;
}
std::tstring CItemType::GetDescription() const
{
return this->m_Description;
}
void CItemType::SetDescription(std::tstring value)
{
// Apply whitespace rules appropriately
value = LtXmlLib20::CWhitespaceUtils::Preserve(value);
this->m_Description = value;
}
LONGLONG CItemType::GetUnitCost() const
{
return this->m_UnitCost;
}
void CItemType::SetUnitCost(LONGLONG value)
{
this->m_UnitCost = value;
}
DWORD CItemType::GetQuantity() const
{
return this->m_Quantity;
}
void CItemType::SetQuantity(DWORD value)
{
this->m_Quantity = value;
}
SimpleHierarchyLib::CItemTypePtr CItemType::Clone() const
{
SimpleHierarchyLib::CItemTypePtr newObject = CreateInstance(m_elementName.c_str());
int index = 0;
newObject->m_StockCode = m_StockCode;
newObject->m_Description = m_Description;
newObject->m_UnitCost = m_UnitCost;
newObject->m_Quantity = m_Quantity;
return newObject.Ptr();
}
std::tstring CItemType::GetTargetNamespace() const
{
return _T("");
}
std::tstring CItemType::GetNamespace() const
{
return _T("");
}
LtXmlLib20::CXmlObjectBase* CItemType::GetBase()
{
return this;
}
void CItemType::CleanMetaData()
{
LtXmlLib20::CXmlGeneratedClass::CleanMetaData(ms_pParentElementInfo, ms_ppElementInfo, ms_ppAttributeInfo);
}
LtXmlLib20Data::CParentElementInfo* CItemType::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("ItemType"),
_T(""),
true,
false,
-1,
LtXmlLib20::ItemType_none,
LtXmlLib20::CWhitespaceUtils::WhitespaceRule_None,
NULL,
false);
}
m_csInit.Leave();
}
return ms_pParentElementInfo;
}
LtXmlLib20Data::CElementInfo** CItemType::GetClassElementInfo() const
{
if (ms_ppElementInfo == NULL)
{
m_csInit.Enter();
if (ms_ppElementInfo == NULL)
{
ms_ppElementInfo = new LtXmlLib20Data::CElementInfo*[5];
ms_ppElementInfo[0] = new LtXmlLib20Data::CElementInfoSeqPrimMnd(_T("StockCode"), _T(""), 1, false, LtXmlLib20::ItemType_ui8, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Collapse, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
ms_ppElementInfo[1] = new LtXmlLib20Data::CElementInfoSeqPrimMnd(_T("Description"), _T(""), 2, false, LtXmlLib20::ItemType_string, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Preserve, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
ms_ppElementInfo[2] = new LtXmlLib20Data::CElementInfoSeqPrimMnd(_T("UnitCost"), _T(""), 3, false, LtXmlLib20::ItemType_i8, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Collapse, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
ms_ppElementInfo[3] = new LtXmlLib20Data::CElementInfoSeqPrimMnd(_T("Quantity"), _T(""), 4, false, LtXmlLib20::ItemType_ui4, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Collapse, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
ms_ppElementInfo[4] = NULL;
}
m_csInit.Leave();
}
return ms_ppElementInfo;
}
LtXmlLib20Data::CAttributeInfo** CItemType::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;
}
};