GME  13
MgaMetaBase.cpp
Go to the documentation of this file.
00001 
00002 #include "stdafx.h"
00003 #include "MgaMetaBase.h"
00004 #include "MgaMetaProject.h"
00005 #include "MgaMetaFolder.h"
00006 
00007 // --------------------------- CMgaMetaBase
00008 
00009 CMgaMetaBase::~CMgaMetaBase()
00010 {
00011         if (metaprojectref != NULL)
00012                 metaproject->UnregisterMetaBase(metaref, this);
00013 
00014 #ifdef _DEBUG
00015         metaref = 0;
00016 #endif
00017 }
00018 
00019 HRESULT CMgaMetaBase::PutMetaRef_(metaref_type p)
00020 {
00021         ASSERT( metaprojectref != NULL );
00022 
00023         if( p == metaref )
00024                 return S_OK;
00025 
00026     COMTRY {
00027 
00028         metaproject->RegisterMetaBase(p, this);
00029         metaproject->UnregisterMetaBase(metaref, this);
00030 
00031         metaref = p;
00032     } COMCATCH(;)
00033 }
00034 
00035 void CMgaMetaBase::Traverse(CMgaMetaProject *metaproject, CCoreObjectPtr &me)
00036 {
00037         ASSERT( metaproject != NULL );
00038 
00039         me.Load();
00040         metaref_type metaref = me.GetLongValue(ATTRID_METAREF);
00041 
00042         CComObjPtr<IMgaMetaBase> ibase;
00043         COMTHROW( ::QueryInterface(me, ibase) );
00044         ASSERT( ibase != NULL );
00045 
00046 #ifdef _ATL_DEBUG_INTERFACES
00047         IUnknown* pUnk = ((ATL::_QIThunk *)(ibase.p))->m_pUnk;
00048         CMgaMetaBase *base = (CMgaMetaBase *)(IMgaMetaBase*)(pUnk);
00049 #else
00050         CMgaMetaBase *base = static_cast<CMgaMetaBase*>((IMgaMetaBase*)ibase);
00051 #endif
00052         ASSERT( base != NULL );
00053 
00054         ASSERT( base->metaproject == NULL );
00055 
00056 #ifdef _ATL_DEBUG_INTERFACES
00057         CComQIPtr<IMgaMetaBase> base2;
00058         base->QueryInterface(&base2.p);
00059         metaproject->RegisterMetaBase(metaref, base2);
00060 #else
00061         metaproject->RegisterMetaBase(metaref, base);
00062 #endif
00063 
00064         base->metaprojectref = metaproject;
00065         base->metaref = metaref;
00066 
00067         TraverseCollection(metaproject, me, ATTRID_REGNODES_COLL);
00068         TraverseCollection(metaproject, me, ATTRID_CONSTRAINT_PTR);
00069 }