In This Topic
    PriceFilter.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/PriceFilter.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                    : PriceFilter
    // Long Name               : PriceFilter
    // Element Name            : PriceFilter
    // Class Namespace         : MusicStoreLib
    // Namespace Alias         : 
    // Schema Namespace        : 
    // Mapped Class Name       : CPriceFilter
    // Mapped Class Full Name  : MusicStoreLib::CPriceFilter
    // Mapped Class File Name  : CPriceFilter
    // IsAbstract              : False
    // IsElement               : True
    // IsComplexType           : True
    
    namespace MusicStoreLib
    {
    
    LtXmlLib20Data::CParentElementInfo* CPriceFilter::ms_pParentElementInfo = NULL;
    LtXmlLib20Data::CAttributeInfo** CPriceFilter::ms_ppAttributeInfo = NULL;
    LtXmlLib20Data::CElementInfo** CPriceFilter::ms_ppElementInfo = NULL;
    
    CPriceFilterPtr CPriceFilter::CreateInstance(LPCTSTR lpctElementName/*=_T("PriceFilter")*/)
    {
        return new MusicStoreLib::CPriceFilter(lpctElementName);
    }
    
    /*  
     * Constructor for CPriceFilter
     *
     * 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
     */
    CPriceFilter::CPriceFilter(LPCTSTR lpctElementName/*=_T("PriceFilter")*/)
     : CInstanceMonitor(_T("CPriceFilter"))
    {
        m_elementName = lpctElementName;
        Init();
    }
    
    CPriceFilter::~CPriceFilter()
    {
        Cleanup();
    }
    
    void CPriceFilter::Cleanup()
    {
        // unregister for any events we have asked for
        // cos there'll be no one left to hear soon
    }
    
    void CPriceFilter::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 CPriceFilter::Init()
    {
        Cleanup();
    
        this->m_MinPrice = 0;
        this->m_IsValidMinPrice = false;
        this->m_MaxPrice = 0;
        this->m_IsValidMaxPrice = false;
        
    
    
    // ##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 CPriceFilter::AccessProperty(int iPropertyIndex, bool bRead, LtXmlLib20::LtVariant& rValue)
    {
        if (bRead)
        {
            switch(iPropertyIndex)
            {
            case 1:
                if (IsValidMinPrice())
                    rValue.SetR8(GetMinPrice());
                else
                    rValue.SetInvalid();
                break;
            case 2:
                if (IsValidMaxPrice())
                    rValue.SetR8(GetMaxPrice());
                else
                    rValue.SetInvalid();
                break;
            default:
                throw LtXmlLib20::CLtException(_T("Unknown Property Index"));
            };
        }
        else
        {
            switch(iPropertyIndex)
            {
            case 1:
                if (rValue.IsValid())
                    SetMinPrice(rValue.GetR8());
                else
                    SetValidMinPrice(false);
                break;
            case 2:
                if (rValue.IsValid())
                    SetMaxPrice(rValue.GetR8());
                else
                    SetValidMaxPrice(false);
                break;
            default:
                throw LtXmlLib20::CLtException(_T("Unknown Property Index"));
            }
        }
    }
    
    /*
     * Represents an optional Element in the XML document
     *
     * 
     * This property is represented as an Element in the XML.
     * It is optional, initially it is not valid.
     */
    DOUBLE CPriceFilter::GetMinPrice() const
    {
        if (m_IsValidMinPrice == false)
            throw LtXmlLib20::CLtInvalidStateException(_T("The Property GetMinPrice is not valid. SetMinPrice must be called first"));
        return this->m_MinPrice;
    }
    void CPriceFilter::SetMinPrice(DOUBLE value)
    { 
        this->m_IsValidMinPrice = true;
    
        this->m_MinPrice = value; 
    }
    
    /*
     * Indicates if GetMinPrice contains a valid value.
     *
     * true if the value for GetMinPrice 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 GetMinPrice
     * will raise an exception.
     */
    bool CPriceFilter::IsValidMinPrice() const
    { 
        return m_IsValidMinPrice;
    }
    void CPriceFilter::SetValidMinPrice(bool value)
    { 
        if (value != m_IsValidMinPrice)
        {
            this->m_MinPrice = 0;
            m_IsValidMinPrice = value;
        }
    }
    
    /*
     * Represents an optional Element in the XML document
     *
     * 
     * This property is represented as an Element in the XML.
     * It is optional, initially it is not valid.
     */
    DOUBLE CPriceFilter::GetMaxPrice() const
    {
        if (m_IsValidMaxPrice == false)
            throw LtXmlLib20::CLtInvalidStateException(_T("The Property GetMaxPrice is not valid. SetMaxPrice must be called first"));
        return this->m_MaxPrice;
    }
    void CPriceFilter::SetMaxPrice(DOUBLE value)
    { 
        this->m_IsValidMaxPrice = true;
    
        this->m_MaxPrice = value; 
    }
    
    /*
     * Indicates if GetMaxPrice contains a valid value.
     *
     * true if the value for GetMaxPrice 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 GetMaxPrice
     * will raise an exception.
     */
    bool CPriceFilter::IsValidMaxPrice() const
    { 
        return m_IsValidMaxPrice;
    }
    void CPriceFilter::SetValidMaxPrice(bool value)
    { 
        if (value != m_IsValidMaxPrice)
        {
            this->m_MaxPrice = 0;
            m_IsValidMaxPrice = value;
        }
    }
    
    /*
     * Allows the class to be copied
     * Performs a 'deep copy' of all the data in the class (and its children)
     */
    MusicStoreLib::CPriceFilterPtr CPriceFilter::Clone() const
    {
        MusicStoreLib::CPriceFilterPtr newObject = CreateInstance(m_elementName.c_str());
    
        int index = 0;
        newObject->m_MinPrice = m_MinPrice;
        newObject->m_IsValidMinPrice = m_IsValidMinPrice;
        newObject->m_MaxPrice = m_MaxPrice;
        newObject->m_IsValidMaxPrice = m_IsValidMaxPrice;
    
    
    // ##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 CPriceFilter::GetTargetNamespace() const
    {
        return _T("");
    }   
    
    std::tstring CPriceFilter::GetNamespace() const
    {
        return _T("");
    }   
    
    LtXmlLib20::CXmlObjectBase* CPriceFilter::GetBase()
    {
        return this;
    }   
    
    void CPriceFilter::CleanMetaData()
    {
        LtXmlLib20::CXmlGeneratedClass::CleanMetaData(ms_pParentElementInfo, ms_ppElementInfo, ms_ppAttributeInfo);
    }
    
    LtXmlLib20Data::CParentElementInfo* CPriceFilter::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("PriceFilter"),                   
                                                                                _T(""), 
                                                                                true,
                                                                                false,
                                                                                -1,
                                                                                LtXmlLib20::ItemType_none,
                                                                                LtXmlLib20::CWhitespaceUtils::WhitespaceRule_None,
                                                                                NULL,
                                                                                false);
            }
            m_csInit.Leave();
        }
        
        return ms_pParentElementInfo;
    }
    
    LtXmlLib20Data::CElementInfo** CPriceFilter::GetClassElementInfo() const
    {
        if (ms_ppElementInfo == NULL)
        {
            m_csInit.Enter();
            if (ms_ppElementInfo == NULL)
            {
                ms_ppElementInfo = new LtXmlLib20Data::CElementInfo*[3];
            
                ms_ppElementInfo[0] = new LtXmlLib20Data::CElementInfoSeqPrimOpt(_T("MinPrice"), _T(""), 1, false, LtXmlLib20::ItemType_r8, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Collapse, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
                ms_ppElementInfo[1] = new LtXmlLib20Data::CElementInfoSeqPrimOpt(_T("MaxPrice"), _T(""), 2, false, LtXmlLib20::ItemType_r8, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Collapse, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
                ms_ppElementInfo[2] = NULL;
            }
            m_csInit.Leave();
        }
        return ms_ppElementInfo;
    }
    
    LtXmlLib20Data::CAttributeInfo**    CPriceFilter::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;
    }
    
    // ##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