Priya_11 0 Newbie Poster
class CIMSSubscription : public CBaseRecClass
{
public:
    CIMSSubscription() : CBaseRecClass(ClassRecSubsIMS) {}
    CIMSSubscription(const string & sIMSI, const string & sPubId);
    ~CIMSSubscription() { m_mPrivateId2SubsIMS.erase(m_sPrivateId); }

    struct PublicIdInfo
    {

        hssCx::ns1__tServiceProfile *   pServiceProfile;    // 23.228 5.2.1a Public user Ids belong to registration set
                                                            // *may* point to different or the same service profiles
        string                          sRecName;

        PublicIdInfo() : bBarringIndication(false), eIdType(DISTINCT_PUBLIC_USER_IDENTITY), pServiceProfile(0) {}
        PublicIdInfo(soap * pSoap, const string & sPubId, const string & _sRecName, const bool bBarred = false, const IdentityType eType = DISTINCT_PUBLIC_USER_IDENTITY)
                : sIdentity(sPubId), bBarringIndication(bBarred), eIdType(eType), pServiceProfile(0), sRecName(_sRecName)
        {
            pServiceProfile = hssCx::soap_new_ns1__tServiceProfile(pSoap, -1);
        }

                // REF LINE #2
        ~PublicIdInfo() {   if (pServiceProfile)
                            {
                             soap_delete_ns1__tServiceProfile(pServiceProfile->soap, pServiceProfile);} }

        const string PublicIdTypeAsText() const;
    };

    struct PublicRegInfo
    {
        enum IMSRegStatus { IMSRegStatusNone, IMSRegStatusRegistered, IMSRegStatusUnregistered };

        IMSRegStatus                                eRegStatus;
        string                                      sS_CSCF;
        bool                                        bIsIMSAuthPending;
        u32                                         nRegisterSetNum;
        map<string, PublicIdInfo>                    mPublicId2PublicIdInfo; // implicit registration set if > 1 entry in map
        string                                      sRecName;

        PublicRegInfo() {}
        PublicRegInfo(const string & sPubId, const string & _sRecName)
                : eRegStatus(IMSRegStatusNone), bIsIMSAuthPending(false), nRegisterSetNum(0), sRecName(_sRecName)
        {
            static u16 nSeedRegisterSetNum = 1;
            nRegisterSetNum = nSeedRegisterSetNum++;

                        // REF LINE:1
            mPublicId2PublicIdInfo[sPubId] = PublicIdInfo(new soap(SOAP_IO_KEEPALIVE), sPubId, _sRecName);
        }

        PublicRegInfo * FindNoneBarredPublicId() const;
        PublicIdInfo * GetPublicIdInfo(const string & sPubId) const;
        string DownloadIMSUserProfile(const string & sPrivateId) const;
        const string IMSRegStatusAsText() const;
    };

    const string & GetPrivateId () const { return m_sPrivateId; }
    bool FindAnyRegisteredS_CSCF(string & sS_CSCF) const;
    bool FindAnyUnregisteredS_CSCF(string & sS_CSCF) const;
    PublicRegInfo * GetPublicRegInfo(const string & sPublicId) const;
    const string IMSSubscriptionAsText() const;

    static bool GetPublicRegInfoFromPublicId(const string & sPublicId, PublicRegInfo & stPublicInfo, CIMSSubscription & cSubsIMS);
private:
    string m_sPrivateId;
    vector<PublicRegInfo> m_vPublicRegInfo;

    static map<string, CIMSSubscription*> m_mPrivateId2SubsIMS;
};

When creating the new class of the type CIMSSubscription, the breakpoint gets hit at "REF LINE1", ie mPublicId2PublicIdInfo[sPubId] = PublicIdInfo(new soap(SOAP_IO_KEEPALIVE), sPubId, _sRecName); where the map mPublicId2PublicIdInfo gets filled. And during this time the construtor for the PublicIdInfo called and finally the destructor for the PublicIdInfo is called. But when calling the destructor for the "PublicIdInfo" it is also deleting a pointer "pServiceProfile" which is also stored in the mPublicId2PublicIdInfo.

So my question is how to add a new map element to "mPublicId2PublicIdInfo" without calling the destructor for the element "PublicIdInfo" ?

thanks a lot for helping a non C++ guy (but with domain knowlege ) in the C++ world

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.