In This Topic
#include "StdAfx.h"
#pragma warning (push)
#pragma warning (disable:4251)
#pragma warning (disable:4786)
#include "../SimpleHierarchyLib.h"
#include "../SimpleHierarchyLib/VISA.h"
namespace SimpleHierarchyLib
{
LtXmlLib21Data::CParentElementInfo* CVISA::ms_pParentElementInfo = NULL;
LtXmlLib21Data::CAttributeInfo** CVISA::ms_ppAttributeInfo = NULL;
LtXmlLib21Data::CElementInfo** CVISA::ms_ppElementInfo = NULL;
CVISAPtr CVISA::CreateInstance(LPCTSTR lpctElementName)
{
return new SimpleHierarchyLib::CVISA(lpctElementName);
}
CVISA::CVISA(LPCTSTR lpctElementName)
: CInstanceMonitor(_T("CVISA"))
, m_Expiry(LtXmlLib21::CDateTime::dt_gYearMonth)
{
m_elementName = lpctElementName;
Init();
}
CVISA::~CVISA()
{
Cleanup();
}
void CVISA::Cleanup()
{
// unregister for any events we have asked for
// cos there'll be no one left to hear soon
}
void CVISA::OnEvent(LtXmlLib21::CXmlObjectBase* pMsgSource, LtXmlLib21::IEventSink::MsgType eMsgType, void* pData)
{
if (eMsgType == LtXmlLib21::IEventSink::MT_CollectionChangeEvent)
{
}
}
void CVISA::Init()
{
Cleanup();
this->m_CardNo = _T("");
this->m_Expiry = LtXmlLib21::CDateTime(LtXmlLib21::CDateTime::dt_gYearMonth);
}
void CVISA::AccessProperty(int iPropertyIndex, bool bRead, LtXmlLib21::LtVariant& rValue)
{
if (bRead)
{
switch(iPropertyIndex)
{
case 1:
rValue.SetString(GetCardNo());
break;
case 2:
rValue.SetYearMonth(GetExpiry());
break;
default:
throw LtXmlLib21::CLtException(_T("Unknown Property Index"));
};
}
else
{
switch(iPropertyIndex)
{
case 1:
SetCardNo(rValue.GetString());
break;
case 2:
SetExpiry(rValue.GetYearMonth());
break;
default:
throw LtXmlLib21::CLtException(_T("Unknown Property Index"));
}
}
}
std::tstring CVISA::GetCardNo() const
{
return this->m_CardNo;
}
void CVISA::SetCardNo(std::tstring value)
{
// Apply whitespace rules appropriately
value = LtXmlLib21::CWhitespaceUtils::Preserve(value);
this->m_CardNo = value;
}
LtXmlLib21::CDateTime CVISA::GetExpiry() const
{
return this->m_Expiry;
}
void CVISA::SetExpiry(LtXmlLib21::CDateTime value)
{
this->m_Expiry.SetDateTime(value, this->m_Expiry.GetType());
}
SimpleHierarchyLib::CVISAPtr CVISA::Clone() const
{
SimpleHierarchyLib::CVISAPtr newObject = CreateInstance(m_elementName.c_str());
int index = 0;
newObject->m_CardNo = m_CardNo;
newObject->m_Expiry = m_Expiry;
return newObject.Ptr();
}
std::tstring CVISA::GetTargetNamespace() const
{
return _T("");
}
std::tstring CVISA::GetNamespace() const
{
return _T("");
}
LtXmlLib21::CXmlObjectBase* CVISA::GetBase()
{
return this;
}
void CVISA::CleanMetaData()
{
LtXmlLib21::CXmlGeneratedClass::CleanMetaData(ms_pParentElementInfo, ms_ppElementInfo, ms_ppAttributeInfo);
}
LtXmlLib21Data::CParentElementInfo* CVISA::GetClassInfo() const
{
if (ms_pParentElementInfo == NULL)
{
m_csInit.Enter();
if (ms_pParentElementInfo == NULL)
{
ms_pParentElementInfo = new LtXmlLib21Data::CParentElementInfo(
LtXmlLib21Data::XmlElementGroupType_SEQUENCE,
LtXmlLib21Data::XmlElementType_ELEMENT,
_T("VISA"),
_T(""),
true,
false,
-1,
LtXmlLib21::ItemType_none,
LtXmlLib21::CWhitespaceUtils::WhitespaceRule_None,
NULL,
false);
}
m_csInit.Leave();
}
return ms_pParentElementInfo;
}
LtXmlLib21Data::CElementInfo** CVISA::GetClassElementInfo() const
{
if (ms_ppElementInfo == NULL)
{
m_csInit.Enter();
if (ms_ppElementInfo == NULL)
{
ms_ppElementInfo = new LtXmlLib21Data::CElementInfo*[1];
ms_ppElementInfo[0] = NULL;
}
m_csInit.Leave();
}
return ms_ppElementInfo;
}
LtXmlLib21Data::CAttributeInfo** CVISA::GetClassAttributeInfo() const
{
if (ms_ppAttributeInfo == NULL)
{
m_csInit.Enter();
if (ms_ppAttributeInfo == NULL)
{
ms_ppAttributeInfo = new LtXmlLib21Data::CAttributeInfo*[3];
ms_ppAttributeInfo[0] = new LtXmlLib21Data::CAttributeInfoPrimitive(_T("CardNo"), _T(""), 1, false, LtXmlLib21::ItemType_string, NULL, LtXmlLib21::CWhitespaceUtils::WhitespaceRule_Preserve, LtXmlLib21::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
ms_ppAttributeInfo[1] = new LtXmlLib21Data::CAttributeInfoPrimitive(_T("Expiry"), _T(""), 2, false, LtXmlLib21::ItemType_yearMonth, NULL, LtXmlLib21::CWhitespaceUtils::WhitespaceRule_Collapse, LtXmlLib21::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
ms_ppAttributeInfo[2] = NULL;
}
m_csInit.Leave();
}
return ms_ppAttributeInfo;
}
};