In This Topic
    AlbumType.cpp
    In This Topic
    /**********************************************************************************************
     * Copyright (c) 2001-2023 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 19.0.14.11049
     * Using Schema: MusicStore.xsd
     **********************************************************************************************/
    #include "StdAfx.h" 
    #pragma warning (push) 
    #pragma warning (disable:4251)  // template export warning 
    #pragma warning (disable:4786)  // long debug names 
    #include "../MusicStoreLib.h" 
    #include "../MusicStoreLib/AlbumType.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                    : AlbumType
    // Long Name               : AlbumType
    // Element Name            : AlbumType
    // Class Namespace         : MusicStoreLib
    // Namespace Alias         : 
    // Schema Namespace        : 
    // Mapped Class Name       : CAlbumType
    // Mapped Class Full Name  : MusicStoreLib::CAlbumType
    // Mapped Class File Name  : CAlbumType
    // IsAbstract              : False
    // IsElement               : True
    // IsComplexType           : True
    
    namespace MusicStoreLib
    {
    
    LtXmlLib20Data::CParentElementInfo* CAlbumType::ms_pParentElementInfo = NULL;
    LtXmlLib20Data::CAttributeInfo** CAlbumType::ms_ppAttributeInfo = NULL;
    LtXmlLib20Data::CElementInfo** CAlbumType::ms_ppElementInfo = NULL;
    
    CAlbumTypePtr CAlbumType::CreateInstance(LPCTSTR lpctElementName/*=_T("AlbumType")*/)
    {
        return new MusicStoreLib::CAlbumType(lpctElementName);
    }
    
    /*  
     * Constructor for CAlbumType
     *
     * 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 MusicStore.xsd
     */
    CAlbumType::CAlbumType(LPCTSTR lpctElementName/*=_T("AlbumType")*/)
     : CInstanceMonitor(_T("CAlbumType"))
    {
        m_elementName = lpctElementName;
        Init();
    }
    
    CAlbumType::~CAlbumType()
    {
        Cleanup();
    }
    
    void CAlbumType::Cleanup()
    {
        // unregister for any events we have asked for
        // cos there'll be no one left to hear soon
        this->m_Track = NULL;
    }
    
    void CAlbumType::OnEvent(LtXmlLib20::CXmlObjectBase* pMsgSource, LtXmlLib20::IEventSink::MsgType eMsgType, void* pData)
    {
        if (eMsgType == LtXmlLib20::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 MusicStore.xsd.
     */
    void CAlbumType::Init()
    {
        Cleanup();
    
        this->m_Label = _T("");
        this->m_RRP = 0;
        this->m_IsValidRRP = false;
        this->m_ProductCode = _T("");
        this->m_AlbumName = _T("");
        this->m_ArtistName = _T("");
        this->m_Track = dynamic_cast<MusicStoreLib::CTrackTypeCol*>(MusicStoreLib::CClassFactory::CreateClassCollection(MusicStoreLib::CClassFactory::ClsName_CTrackTypeCol, _T("Track"), _T(""), 1, -1).Ptr());
        
    
    
    // ##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 CAlbumType::AccessProperty(int iPropertyIndex, bool bRead, LtXmlLib20::LtVariant& rValue)
    {
        if (bRead)
        {
            switch(iPropertyIndex)
            {
            case 1:
                    rValue.SetString(GetLabel());
                break;
            case 2:
                if (IsValidRRP())
                    rValue.SetR8(GetRRP());
                else
                    rValue.SetInvalid();
                break;
            case 3:
                    rValue.SetString(GetProductCode());
                break;
            case 4:
                    rValue.SetString(GetAlbumName());
                break;
            case 5:
                    rValue.SetString(GetArtistName());
                break;
            case 6:
                rValue.SetXmlCollection(GetTrack().Ptr());
                break;
            default:
                throw LtXmlLib20::CLtException(_T("Unknown Property Index"));
            };
        }
        else
        {
            switch(iPropertyIndex)
            {
            case 1:
                SetLabel(rValue.GetString());
                break;
            case 2:
                if (rValue.IsValid())
                    SetRRP(rValue.GetR8());
                else
                    SetValidRRP(false);
                break;
            case 3:
                SetProductCode(rValue.GetString());
                break;
            case 4:
                SetAlbumName(rValue.GetString());
                break;
            case 5:
                SetArtistName(rValue.GetString());
                break;
            case 6:
                throw LtXmlLib20::CLtException(_T("Collections can not be set"));
                break;
            default:
                throw LtXmlLib20::CLtException(_T("Unknown Property Index"));
            }
        }
    }
    
    /*
     * 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 _T("").
     */
    std::tstring CAlbumType::GetLabel() const
    {
        return this->m_Label;
    }
    void CAlbumType::SetLabel(std::tstring value)
    { 
        // Apply whitespace rules appropriately
        value = LtXmlLib20::CWhitespaceUtils::Preserve(value); 
        this->m_Label = value; 
    }
    
    /*
     * 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.
     */
    DOUBLE CAlbumType::GetRRP() const
    {
        if (m_IsValidRRP == false)
            throw LtXmlLib20::CLtInvalidStateException(_T("The Property GetRRP is not valid. SetRRP must be called first"));
        return this->m_RRP;
    }
    void CAlbumType::SetRRP(DOUBLE value)
    { 
        this->m_IsValidRRP = true;
    
        this->m_RRP = value; 
    }
    
    /*
     * Indicates if GetRRP contains a valid value.
     *
     * true if the value for GetRRP is valid, false if not.
     * If this is set to true then the property is considered valid, and assigned its
     * default value (0).
     * If its set to false then its made invalid, and subsequent calls to GetRRP
     * will raise an exception.
     */
    bool CAlbumType::IsValidRRP() const
    { 
        return m_IsValidRRP;
    }
    void CAlbumType::SetValidRRP(bool value)
    { 
        if (value != m_IsValidRRP)
        {
            this->m_RRP = 0;
            m_IsValidRRP = 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 _T("").
     */
    std::tstring CAlbumType::GetProductCode() const
    {
        return this->m_ProductCode;
    }
    void CAlbumType::SetProductCode(std::tstring value)
    { 
        // Apply whitespace rules appropriately
        value = LtXmlLib20::CWhitespaceUtils::Preserve(value); 
        LtXmlLib20::LtVariant var;
        var.SetString(value);
        ((LtXmlLib20Data::CAttributeInfoPrimitive*)GetClassAttributeInfo()[2])->CheckRestriction(var);
        this->m_ProductCode = 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 CAlbumType::GetAlbumName() const
    {
        return this->m_AlbumName;
    }
    void CAlbumType::SetAlbumName(std::tstring value)
    { 
        // Apply whitespace rules appropriately
        value = LtXmlLib20::CWhitespaceUtils::Preserve(value); 
        this->m_AlbumName = 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 CAlbumType::GetArtistName() const
    {
        return this->m_ArtistName;
    }
    void CAlbumType::SetArtistName(std::tstring value)
    { 
        // Apply whitespace rules appropriately
        value = LtXmlLib20::CWhitespaceUtils::Preserve(value); 
        this->m_ArtistName = value; 
    }
    
    /*
     * A collection of CAlbumTypes
     *
     * 
     * This property is represented as an Element in the XML.
     * This collection may contain 1 to Many objects.
     */
    MusicStoreLib::CTrackTypeColPtr CAlbumType::GetTrack() const
    {
        return this->m_Track; 
    }
    
    /*
     * Allows the class to be copied
     * Performs a 'deep copy' of all the data in the class (and its children)
     */
    MusicStoreLib::CAlbumTypePtr CAlbumType::Clone() const
    {
        MusicStoreLib::CAlbumTypePtr newObject = CreateInstance(m_elementName.c_str());
    
        int index = 0;
        newObject->m_Label = m_Label;
        newObject->m_RRP = m_RRP;
        newObject->m_IsValidRRP = m_IsValidRRP;
        newObject->m_ProductCode = m_ProductCode;
        newObject->m_AlbumName = m_AlbumName;
        newObject->m_ArtistName = m_ArtistName;
        for (index = 0; index < m_Track->GetCount(); index++)
            newObject->m_Track->Add(dynamic_cast<MusicStoreLib::CTrackType*>(m_Track->Item(index)->Clone().Ptr()));
    
    
    // ##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 CAlbumType::GetTargetNamespace() const
    {
        return _T("");
    }   
    
    std::tstring CAlbumType::GetNamespace() const
    {
        return _T("");
    }   
    
    LtXmlLib20::CXmlObjectBase* CAlbumType::GetBase()
    {
        return this;
    }   
    
    void CAlbumType::CleanMetaData()
    {
        LtXmlLib20::CXmlGeneratedClass::CleanMetaData(ms_pParentElementInfo, ms_ppElementInfo, ms_ppAttributeInfo);
    }
    
    LtXmlLib20Data::CParentElementInfo* CAlbumType::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("AlbumType"),                     
                                                                                _T(""), 
                                                                                true,
                                                                                false,
                                                                                -1,
                                                                                LtXmlLib20::ItemType_none,
                                                                                LtXmlLib20::CWhitespaceUtils::WhitespaceRule_None,
                                                                                NULL,
                                                                                false);
            }
            m_csInit.Leave();
        }
        
        return ms_pParentElementInfo;
    }
    
    LtXmlLib20Data::CElementInfo** CAlbumType::GetClassElementInfo() const
    {
        if (ms_ppElementInfo == NULL)
        {
            m_csInit.Enter();
            if (ms_ppElementInfo == NULL)
            {
                ms_ppElementInfo = new LtXmlLib20Data::CElementInfo*[4];
            
                ms_ppElementInfo[0] = new LtXmlLib20Data::CElementInfoSeqPrimMnd(_T("AlbumName"), _T(""), 4, false, LtXmlLib20::ItemType_string, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Preserve, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
                ms_ppElementInfo[1] = new LtXmlLib20Data::CElementInfoSeqPrimMnd(_T("ArtistName"), _T(""), 5, 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::CElementInfoSeqClsCol(_T("Track"), _T(""), 6, LtXmlLib20Data::XmlElementType_ELEMENT);
                ms_ppElementInfo[3] = NULL;
            }
            m_csInit.Leave();
        }
        return ms_ppElementInfo;
    }
    
    LtXmlLib20Data::CAttributeInfo**    CAlbumType::GetClassAttributeInfo() const
    {
        if (ms_ppAttributeInfo == NULL)
        {
            m_csInit.Enter();
            if (ms_ppAttributeInfo == NULL)
            {
                ms_ppAttributeInfo = new LtXmlLib20Data::CAttributeInfo*[4];
                ms_ppAttributeInfo[0] = new LtXmlLib20Data::CAttributeInfoPrimitive(_T("Label"), _T(""), 1, false, LtXmlLib20::ItemType_string, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Preserve, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
                ms_ppAttributeInfo[1] = new LtXmlLib20Data::CAttributeInfoPrimitive(_T("RRP"), _T(""), 2, true, LtXmlLib20::ItemType_r8, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Collapse, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
                ms_ppAttributeInfo[2] = new LtXmlLib20Data::CAttributeInfoPrimitive(_T("ProductCode"), _T(""), 3, false, LtXmlLib20::ItemType_string, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Preserve, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), 15, -1, -1), NULL);
                ms_ppAttributeInfo[3] = 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