/**********************************************************************************************
 * Copyright (c) 2001-2017 Liquid Technologies Limited. All rights reserved.
 * See www.liquid-technologies.com for product details.
 *
 * Please see products End User License Agreement for distribution permissions.
 *
 * WARNING: THIS FILE IS GENERATED
 * Changes made outside of ##HAND_CODED_BLOCK_START blocks will be overwritten
 *
 * Generation  :  by Liquid XML Data Binder 15.0.1.7161
 * Using Schema: D:\Development2017\Liquid\Tools\DataBindingSamples\Samples\DerivedByExtension\Schema\DerivedByExtension.xsd
 **********************************************************************************************/
#include "StdAfx.h" 
#pragma warning (push) 
#pragma warning (disable:4251)  // template export warning 
#pragma warning (disable:4786)  // long debug names 
#include "../DerivedByExtensionLib.h" 
#include "../DerivedByExtensionLib/GBR_Address.h" 

// ##HAND_CODED_BLOCK_START ID="Additional Includes"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS

// Add Additional Includes here...

// ##HAND_CODED_BLOCK_END ID="Additional Includes"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS

// Name                    : GBR_Address
// Long Name               : GBR_Address
// Element Name            : GBR_Address
// Class Namespace         : DerivedByExtensionLib
// Namespace Alias         : 
// Schema Namespace        : 
// Mapped Class Name       : CGBR_Address
// Mapped Class Full Name  : DerivedByExtensionLib::CGBR_Address
// Mapped Class File Name  : CGBR_Address
// IsAbstract              : False
// IsElement               : True
// IsComplexType           : True

namespace DerivedByExtensionLib
{

LtXmlLib15Data::CParentElementInfo* CGBR_Address::ms_pParentElementInfo = NULL;
LtXmlLib15Data::CAttributeInfo** CGBR_Address::ms_ppAttributeInfo = NULL;
LtXmlLib15Data::CElementInfo** CGBR_Address::ms_ppElementInfo = NULL;

CGBR_AddressPtr CGBR_Address::CreateInstance(LPCTSTR lpctElementName/*=_T("GBR_Address")*/)
{
    return new DerivedByExtensionLib::CGBR_Address(lpctElementName);
}

/*  
 * Constructor for CGBR_Address
 *
 * The class is created with all the mandatory fields populated with the
 * default data.
 * All Collection objects are created.
 * However any 1-n relationships (these are represented as collections) are
 * empty. To comply with the schema these must be populated before the xml
 * obtained from ToXml is valid against the schema D:\Development2017\Liquid\Tools\DataBindingSamples\Samples\DerivedByExtension\Schema\DerivedByExtension.xsd
 */
CGBR_Address::CGBR_Address(LPCTSTR lpctElementName/*=_T("GBR_Address")*/)
 : CInstanceMonitor(_T("CGBR_Address"))
{
    m_elementName = lpctElementName;
    Init();
}

CGBR_Address::~CGBR_Address()
{
    Cleanup();
}

void CGBR_Address::Cleanup()
{
    // unregister for any events we have asked for
    // cos there'll be no one left to hear soon
}

void CGBR_Address::OnEvent(LtXmlLib15::CXmlObjectBase* pMsgSource, LtXmlLib15::IEventSink::MsgType eMsgType, void* pData)
{
    if (eMsgType == LtXmlLib15::IEventSink::MT_CollectionChangeEvent)
    {
    }
}

/*
 * Initializes the class
 *
 * The Creates all the mandatory fields (populated with the default data) 
 * All Collection object are created.
 * However any 1-n relationships (these are represented as collections) are
 * empty. To comply with the schema these must be populated before the xml
 * obtained from ToXml is valid against the schema D:\Development2017\Liquid\Tools\DataBindingSamples\Samples\DerivedByExtension\Schema\DerivedByExtension.xsd.
 */
void CGBR_Address::Init()
{
    Cleanup();

    this->m_Name = _T("");
    this->m_Street = _T("");
    this->m_City = _T("");
    this->m_County = _T("");
    this->m_PostCode = _T("");
    


// ##HAND_CODED_BLOCK_START ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS

// Add Additional Init Settings...

// ##HAND_CODED_BLOCK_END ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS
}
    

void CGBR_Address::AccessProperty(int iPropertyIndex, bool bRead, LtXmlLib15::LtVariant& rValue)
{
    if (bRead)
    {
        switch(iPropertyIndex)
        {
        case 1:
                rValue.SetString(GetName());
            break;
        case 2:
                rValue.SetString(GetStreet());
            break;
        case 3:
                rValue.SetString(GetCity());
            break;
        case 4:
                rValue.SetString(GetCounty());
            break;
        case 5:
                rValue.SetString(GetPostCode());
            break;
        default:
            throw LtXmlLib15::CLtException(_T("Unknown Property Index"));
        };
    }
    else
    {
        switch(iPropertyIndex)
        {
        case 1:
            SetName(rValue.GetString());
            break;
        case 2:
            SetStreet(rValue.GetString());
            break;
        case 3:
            SetCity(rValue.GetString());
            break;
        case 4:
            SetCounty(rValue.GetString());
            break;
        case 5:
            SetPostCode(rValue.GetString());
            break;
        default:
            throw LtXmlLib15::CLtException(_T("Unknown Property Index"));
        }
    }
}

/*
 * Represents a mandatory Element in the XML document
 *
 * 
 * This property is represented as an Element in the XML.
 * It is mandatory and therefore must be populated within the XML.
 * It is defaulted to _T("").
 */
std::tstring CGBR_Address::GetName() const
{
    return this->m_Name;
}
void CGBR_Address::SetName(std::tstring value)
{ 
    // Apply whitespace rules appropriately
    value = LtXmlLib15::CWhitespaceUtils::Preserve(value); 
    LtXmlLib15::LtVariant var;
    var.SetString(value);
    GetClassElementInfo()[0]->CheckRestriction(var);
    this->m_Name = value; 
}

/*
 * Represents a mandatory Element in the XML document
 *
 * 
 * This property is represented as an Element in the XML.
 * It is mandatory and therefore must be populated within the XML.
 * It is defaulted to _T("").
 */
std::tstring CGBR_Address::GetStreet() const
{
    return this->m_Street;
}
void CGBR_Address::SetStreet(std::tstring value)
{ 
    // Apply whitespace rules appropriately
    value = LtXmlLib15::CWhitespaceUtils::Preserve(value); 
    LtXmlLib15::LtVariant var;
    var.SetString(value);
    GetClassElementInfo()[1]->CheckRestriction(var);
    this->m_Street = value; 
}

/*
 * Represents a mandatory Element in the XML document
 *
 * 
 * This property is represented as an Element in the XML.
 * It is mandatory and therefore must be populated within the XML.
 * It is defaulted to _T("").
 */
std::tstring CGBR_Address::GetCity() const
{
    return this->m_City;
}
void CGBR_Address::SetCity(std::tstring value)
{ 
    // Apply whitespace rules appropriately
    value = LtXmlLib15::CWhitespaceUtils::Preserve(value); 
    LtXmlLib15::LtVariant var;
    var.SetString(value);
    GetClassElementInfo()[2]->CheckRestriction(var);
    this->m_City = value; 
}

/*
 * Represents a mandatory Element in the XML document
 *
 * 
 * This property is represented as an Element in the XML.
 * It is mandatory and therefore must be populated within the XML.
 * It is defaulted to _T("").
 */
std::tstring CGBR_Address::GetCounty() const
{
    return this->m_County;
}
void CGBR_Address::SetCounty(std::tstring value)
{ 
    // Apply whitespace rules appropriately
    value = LtXmlLib15::CWhitespaceUtils::Preserve(value); 
    LtXmlLib15::LtVariant var;
    var.SetString(value);
    GetClassElementInfo()[3]->CheckRestriction(var);
    this->m_County = value; 
}

/*
 * Represents a mandatory Element in the XML document
 *
 * 
 * This property is represented as an Element in the XML.
 * It is mandatory and therefore must be populated within the XML.
 * It is defaulted to _T("").
 */
std::tstring CGBR_Address::GetPostCode() const
{
    return this->m_PostCode;
}
void CGBR_Address::SetPostCode(std::tstring value)
{ 
    // Apply whitespace rules appropriately
    value = LtXmlLib15::CWhitespaceUtils::Preserve(value); 
    LtXmlLib15::LtVariant var;
    var.SetString(value);
    GetClassElementInfo()[4]->CheckRestriction(var);
    this->m_PostCode = value; 
}

/*
 * Allows the class to be copied
 * Performs a 'deep copy' of all the data in the class (and its children)
 */
DerivedByExtensionLib::IAddressPtr CGBR_Address::Clone() const
{
    DerivedByExtensionLib::CGBR_AddressPtr newObject = CreateInstance(m_elementName.c_str());

    int index = 0;
    newObject->m_Name = m_Name;
    newObject->m_Street = m_Street;
    newObject->m_City = m_City;
    newObject->m_County = m_County;
    newObject->m_PostCode = m_PostCode;


// ##HAND_CODED_BLOCK_START ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS

// Add Additional clone code here...

// ##HAND_CODED_BLOCK_END ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS

    return newObject.Ptr();
}

std::tstring CGBR_Address::GetTargetNamespace() const
{
    return _T("");
}   

std::tstring CGBR_Address::GetNamespace() const
{
    return _T("");
}   

LtXmlLib15::CXmlObjectBase* CGBR_Address::GetBase()
{
    return this;
}   

void CGBR_Address::CleanMetaData()
{
    LtXmlLib15::CXmlGeneratedClass::CleanMetaData(ms_pParentElementInfo, ms_ppElementInfo, ms_ppAttributeInfo);
}

LtXmlLib15Data::CParentElementInfo* CGBR_Address::GetClassInfo() const
{
    if (ms_pParentElementInfo == NULL)
    {
        m_csInit.Enter();
        if (ms_pParentElementInfo == NULL)
        {
            ms_pParentElementInfo = new LtXmlLib15Data::CParentElementInfo(
                                                                            LtXmlLib15Data::XmlElementGroupType_SEQUENCE,
                                                                            LtXmlLib15Data::XmlElementType_ELEMENT, 
                                                                            _T("GBR_Address"),                   
                                                                            _T(""), 
                                                                            true,
                                                                            true,
                                                                            -1,
                                                                            LtXmlLib15::ItemType_none,
                                                                            NULL,
                                                                            false);
        }
        m_csInit.Leave();
    }
    
    return ms_pParentElementInfo;
}

LtXmlLib15Data::CElementInfo** CGBR_Address::GetClassElementInfo() const
{
    if (ms_ppElementInfo == NULL)
    {
        m_csInit.Enter();
        if (ms_ppElementInfo == NULL)
        {
            ms_ppElementInfo = new LtXmlLib15Data::CElementInfo*[6];
        
            ms_ppElementInfo[0] = new LtXmlLib15Data::CElementInfoSeqPrimMnd(_T("Name"), _T(""), 1, false, LtXmlLib15::ItemType_string, NULL, LtXmlLib15::CWhitespaceUtils::WhitespaceRule_Preserve, LtXmlLib15::CPrimitiveRestrictions(_T(""), _T("-1"), _T("-1"), _T(""), _T(""), _T(""), _T(""), _T("-1"), _T("-1"), _T("-1")));
            ms_ppElementInfo[1] = new LtXmlLib15Data::CElementInfoSeqPrimMnd(_T("Street"), _T(""), 2, false, LtXmlLib15::ItemType_string, NULL, LtXmlLib15::CWhitespaceUtils::WhitespaceRule_Preserve, LtXmlLib15::CPrimitiveRestrictions(_T(""), _T("-1"), _T("-1"), _T(""), _T(""), _T(""), _T(""), _T("-1"), _T("-1"), _T("-1")));
            ms_ppElementInfo[2] = new LtXmlLib15Data::CElementInfoSeqPrimMnd(_T("City"), _T(""), 3, false, LtXmlLib15::ItemType_string, NULL, LtXmlLib15::CWhitespaceUtils::WhitespaceRule_Preserve, LtXmlLib15::CPrimitiveRestrictions(_T(""), _T("-1"), _T("-1"), _T(""), _T(""), _T(""), _T(""), _T("-1"), _T("-1"), _T("-1")));
            ms_ppElementInfo[3] = new LtXmlLib15Data::CElementInfoSeqPrimMnd(_T("County"), _T(""), 4, false, LtXmlLib15::ItemType_string, NULL, LtXmlLib15::CWhitespaceUtils::WhitespaceRule_Preserve, LtXmlLib15::CPrimitiveRestrictions(_T(""), _T("-1"), _T("-1"), _T(""), _T(""), _T(""), _T(""), _T("-1"), _T("-1"), _T("-1")));
            ms_ppElementInfo[4] = new LtXmlLib15Data::CElementInfoSeqPrimMnd(_T("PostCode"), _T(""), 5, false, LtXmlLib15::ItemType_string, NULL, LtXmlLib15::CWhitespaceUtils::WhitespaceRule_Preserve, LtXmlLib15::CPrimitiveRestrictions(_T(""), _T("-1"), _T("-1"), _T(""), _T(""), _T(""), _T(""), _T("-1"), _T("-1"), _T("-1")));
            ms_ppElementInfo[5] = NULL;
        }
        m_csInit.Leave();
    }
    return ms_ppElementInfo;
}

LtXmlLib15Data::CAttributeInfo**    CGBR_Address::GetClassAttributeInfo() const
{
    if (ms_ppAttributeInfo == NULL)
    {
        m_csInit.Enter();
        if (ms_ppAttributeInfo == NULL)
        {
            ms_ppAttributeInfo = new LtXmlLib15Data::CAttributeInfo*[1];
            ms_ppAttributeInfo[0] = NULL;
        }
        m_csInit.Leave();
    }
    return ms_ppAttributeInfo;
}

// ##HAND_CODED_BLOCK_START ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS

// Add Additional Methods here...

// ##HAND_CODED_BLOCK_END ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS

}; // namespace