/**********************************************************************************************
 * 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\SimpleSequence\Schema\SimpleSequence.xsd
 **********************************************************************************************/
#include "StdAfx.h" 
#pragma warning (push) 
#pragma warning (disable:4251)  // template export warning 
#pragma warning (disable:4786)  // long debug names 
#include "../SimpleSequenceLib.h" 
#include "../SimpleSequenceLib/DVD.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                    : DVD
// Long Name               : DVD
// Element Name            : DVD
// Class Namespace         : SimpleSequenceLib
// Namespace Alias         : 
// Schema Namespace        : 
// Mapped Class Name       : CDVD
// Mapped Class Full Name  : SimpleSequenceLib::CDVD
// Mapped Class File Name  : CDVD
// IsAbstract              : False
// IsElement               : True
// IsComplexType           : False

namespace SimpleSequenceLib
{

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

CDVDPtr CDVD::CreateInstance(LPCTSTR lpctElementName/*=_T("DVD")*/)
{
    return new SimpleSequenceLib::CDVD(lpctElementName);
}

/*  
 * Constructor for CDVD
 *
 * 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\SimpleSequence\Schema\SimpleSequence.xsd
 */
CDVD::CDVD(LPCTSTR lpctElementName/*=_T("DVD")*/)
 : CInstanceMonitor(_T("CDVD"))
 , m_ReleaseDate(LtXmlLib15::CDateTime::dt_date)
{
    m_elementName = lpctElementName;
    Init();
}

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

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

void CDVD::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\SimpleSequence\Schema\SimpleSequence.xsd.
 */
void CDVD::Init()
{
    Cleanup();

    this->m_Genre = _T("");
    this->m_IsValidGenre = false;
    this->m_Cost = 0;
    this->m_Title = _T("");
    this->m_Description = _T("");
    this->m_ReleaseDate = LtXmlLib15::CDateTime(LtXmlLib15::CDateTime::dt_date);
    


// ##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 CDVD::AccessProperty(int iPropertyIndex, bool bRead, LtXmlLib15::LtVariant& rValue)
{
    if (bRead)
    {
        switch(iPropertyIndex)
        {
        case 1:
            if (IsValidGenre())
                rValue.SetString(GetGenre());
            else
                rValue.SetInvalid();
            break;
        case 2:
                rValue.SetR8(GetCost());
            break;
        case 3:
                rValue.SetString(GetTitle());
            break;
        case 4:
                rValue.SetString(GetDescription());
            break;
        case 5:
                rValue.SetDate(GetReleaseDate());
            break;
        default:
            throw LtXmlLib15::CLtException(_T("Unknown Property Index"));
        };
    }
    else
    {
        switch(iPropertyIndex)
        {
        case 1:
            if (rValue.IsValid())
                SetGenre(rValue.GetString());
            else
                SetValidGenre(false);
            break;
        case 2:
            SetCost(rValue.GetR8());
            break;
        case 3:
            SetTitle(rValue.GetString());
            break;
        case 4:
            SetDescription(rValue.GetString());
            break;
        case 5:
            SetReleaseDate(rValue.GetDate());
            break;
        default:
            throw LtXmlLib15::CLtException(_T("Unknown Property Index"));
        }
    }
}

/*
 * Represents an optional Attribute in the XML document
 *
 * 
 * This property is represented as an Attribute in the XML.
 * It is optional, initially it is not valid.
 */
std::tstring CDVD::GetGenre() const
{
    if (m_IsValidGenre == false)
        throw LtXmlLib15::CLtInvalidStateException(_T("The Property GetGenre is not valid. SetGenre must be called first"));
    return this->m_Genre;
}
void CDVD::SetGenre(std::tstring value)
{ 
    // Apply whitespace rules appropriately
    value = LtXmlLib15::CWhitespaceUtils::Preserve(value); 
    LtXmlLib15::LtVariant var;
    var.SetString(value);
    ((LtXmlLib15Data::CAttributeInfoPrimitive*)GetClassAttributeInfo()[0])->CheckRestriction(var);
    this->m_IsValidGenre = true;

    this->m_Genre = value; 
}

/*
 * Indicates if GetGenre contains a valid value.
 *
 * true if the value for GetGenre is valid, false if not.
 * If this is set to true then the property is considered valid, and assigned its
 * default value (_T("")).
 * If its set to false then its made invalid, and subsequent calls to GetGenre
 * will raise an exception.
 */
bool CDVD::IsValidGenre() const
{ 
    return m_IsValidGenre;
}
void CDVD::SetValidGenre(bool value)
{ 
    if (value != m_IsValidGenre)
    {
        this->m_Genre = _T("");
        m_IsValidGenre = value;
    }
}

/*
 * Represents a mandatory Attribute in the XML document
 *
 * 
 * This property is represented as an Attribute in the XML.
 * It is mandatory and therefore must be populated within the XML.
 * It is defaulted to 0.
 */
DOUBLE CDVD::GetCost() const
{
    return this->m_Cost;
}
void CDVD::SetCost(DOUBLE value)
{ 
    LtXmlLib15::LtVariant var;
    var.SetR8(value);
    ((LtXmlLib15Data::CAttributeInfoPrimitive*)GetClassAttributeInfo()[1])->CheckRestriction(var);
    this->m_Cost = 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 CDVD::GetTitle() const
{
    return this->m_Title;
}
void CDVD::SetTitle(std::tstring value)
{ 
    // Apply whitespace rules appropriately
    value = LtXmlLib15::CWhitespaceUtils::Preserve(value); 
    LtXmlLib15::LtVariant var;
    var.SetString(value);
    GetClassElementInfo()[0]->CheckRestriction(var);
    this->m_Title = 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 CDVD::GetDescription() const
{
    return this->m_Description;
}
void CDVD::SetDescription(std::tstring value)
{ 
    // Apply whitespace rules appropriately
    value = LtXmlLib15::CWhitespaceUtils::Preserve(value); 
    LtXmlLib15::LtVariant var;
    var.SetString(value);
    GetClassElementInfo()[1]->CheckRestriction(var);
    this->m_Description = 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 LtXmlLib15::CDateTime(LtXmlLib15::CDateTime::dt_date).
 */
LtXmlLib15::CDateTime CDVD::GetReleaseDate() const
{
    return this->m_ReleaseDate;
}
void CDVD::SetReleaseDate(LtXmlLib15::CDateTime value)
{ 
    LtXmlLib15::LtVariant var;
    var.SetDate(value);
    GetClassElementInfo()[2]->CheckRestriction(var);
    this->m_ReleaseDate.SetDateTime(value, this->m_ReleaseDate.GetType()); 
}

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

    int index = 0;
    newObject->m_Genre = m_Genre;
    newObject->m_IsValidGenre = m_IsValidGenre;
    newObject->m_Cost = m_Cost;
    newObject->m_Title = m_Title;
    newObject->m_Description = m_Description;
    newObject->m_ReleaseDate = m_ReleaseDate;


// ##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 CDVD::GetTargetNamespace() const
{
    return _T("");
}   

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

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

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

LtXmlLib15Data::CParentElementInfo* CDVD::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("DVD"),                   
                                                                            _T(""), 
                                                                            true,
                                                                            false,
                                                                            -1,
                                                                            LtXmlLib15::ItemType_none,
                                                                            NULL,
                                                                            false);
        }
        m_csInit.Leave();
    }
    
    return ms_pParentElementInfo;
}

LtXmlLib15Data::CElementInfo** CDVD::GetClassElementInfo() const
{
    if (ms_ppElementInfo == NULL)
    {
        m_csInit.Enter();
        if (ms_ppElementInfo == NULL)
        {
            ms_ppElementInfo = new LtXmlLib15Data::CElementInfo*[4];
        
            ms_ppElementInfo[0] = new LtXmlLib15Data::CElementInfoSeqPrimMnd(_T("Title"), _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[1] = new LtXmlLib15Data::CElementInfoSeqPrimMnd(_T("Description"), _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[2] = new LtXmlLib15Data::CElementInfoSeqPrimMnd(_T("ReleaseDate"), _T(""), 5, false, LtXmlLib15::ItemType_date, NULL, LtXmlLib15::CWhitespaceUtils::WhitespaceRule_Collapse, LtXmlLib15::CPrimitiveRestrictions(_T(""), _T("-1"), _T("-1"), _T(""), _T(""), _T(""), _T(""), _T("-1"), _T("-1"), _T("-1")));
            ms_ppElementInfo[3] = NULL;
        }
        m_csInit.Leave();
    }
    return ms_ppElementInfo;
}

LtXmlLib15Data::CAttributeInfo**    CDVD::GetClassAttributeInfo() const
{
    if (ms_ppAttributeInfo == NULL)
    {
        m_csInit.Enter();
        if (ms_ppAttributeInfo == NULL)
        {
            ms_ppAttributeInfo = new LtXmlLib15Data::CAttributeInfo*[3];
            ms_ppAttributeInfo[0] = new LtXmlLib15Data::CAttributeInfoPrimitive(_T("Genre"), _T(""), 1, true, 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")), NULL);
            ms_ppAttributeInfo[1] = new LtXmlLib15Data::CAttributeInfoPrimitive(_T("Cost"), _T(""), 2, false, LtXmlLib15::ItemType_r8, NULL, LtXmlLib15::CWhitespaceUtils::WhitespaceRule_Collapse, LtXmlLib15::CPrimitiveRestrictions(_T(""), _T("-1"), _T("-1"), _T(""), _T(""), _T(""), _T(""), _T("-1"), _T("-1"), _T("-1")), NULL);
            ms_ppAttributeInfo[2] = 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