GME  13
MgaMetaAttribute.cpp
Go to the documentation of this file.
00001 
00002 #include "stdafx.h"
00003 #include "MgaMetaAttribute.h"
00004 
00005 // --------------------------- CMgaMetaAttribute
00006 
00007 STDMETHODIMP CMgaMetaAttribute::get_UsedIn(IMgaMetaFCOs **p)
00008 {
00009         CHECK_OUT(p);
00010 
00011         COMTRY
00012         {
00013                 CCoreObjectPtr me(GetUnknown());
00014                 ASSERT( me != NULL );
00015 
00016                 coreobjects_type coreobjects;
00017                 me.GetCollectionValue(ATTRID_ATTRLINK_ATTR_PTR, coreobjects);
00018 
00019                 typedef CCoreCollection<IMgaMetaFCOs, std::vector<IMgaMetaFCO*>, IMgaMetaFCO, IMgaMetaFCO> COMTYPE;
00020 
00021                 CComObjPtr<COMTYPE> coll;
00022                 CreateComObject(coll);
00023 
00024                 coreobjects_iterator i = coreobjects.begin();
00025                 coreobjects_iterator e = coreobjects.end();
00026                 while( i != e )
00027                 {
00028                         CCoreObjectPtr obj;
00029                         (*i).GetPointerValue(ATTRID_ATTRLINK_USEDIN_PTR, obj);
00030 
00031                         CComObjPtr<IMgaMetaFCO> q;
00032                         if( SUCCEEDED( ::QueryInterface(obj, q)) )
00033                                 coll->Add(q);
00034 
00035                         ++i;
00036                 }
00037 
00038                 MoveTo(coll, p);
00039         }
00040         COMCATCH(;)
00041 }
00042 
00043 STDMETHODIMP CMgaMetaAttribute::get_DefaultValue(VARIANT *p) 
00044 {
00045         CHECK_OUT(p);
00046 
00047         COMTRY 
00048         {
00049                 CCoreObjectPtr self(GetUnknown());
00050 
00051                 CComVariant v;
00052                 self.GetVariantValue(ATTRID_VALUE, PutOut(v));
00053                 ASSERT( v.vt == VT_BSTR );
00054 
00055                 attval_enum attval = static_cast<attval_enum>
00056                         (self.GetLongValue(ATTRID_ATTVALTYPE));
00057 
00058                 ChangeAttrValueType(v, attval);
00059                 MoveTo(&v, p);
00060         }
00061         COMCATCH(;)
00062 }
00063 
00064 STDMETHODIMP CMgaMetaAttribute::get_ValueType(attval_enum *p) 
00065 {
00066         CHECK_OUT(p);
00067 
00068         COMTRY 
00069         {
00070                 CCoreObjectPtr self(GetUnknown());
00071                 *p = static_cast<attval_enum>(self.GetLongValue(ATTRID_ATTVALTYPE));
00072         } COMCATCH(;);
00073 }
00074 
00075 STDMETHODIMP CMgaMetaAttribute::get_Viewable(VARIANT_BOOL *p)
00076 {
00077         CHECK_OUT(p);
00078 
00079         COMTRY 
00080         {
00081                 CCoreObjectPtr self(GetUnknown());
00082                 *p = self.GetLongValue(ATTRID_VIEWABLE)? VARIANT_TRUE : VARIANT_FALSE;
00083         } COMCATCH(;);
00084 }
00085 
00086 // ------- Traverse
00087 
00088 void CMgaMetaAttribute::Traverse(CMgaMetaProject *metaproject, CCoreObjectPtr &me)
00089 {
00090         ASSERT( metaproject != NULL );
00091         ASSERT( me != NULL );
00092 
00093         CMgaMetaBase::Traverse(metaproject, me);
00094 
00095         TraverseCollection(metaproject, me, ATTRID_ATTRLINK_ATTR_PTR);
00096         TraverseCollection(metaproject, me, ATTRID_ENUMITEMS_COLL);
00097 }