GME  13
MgaMetaBase.h
Go to the documentation of this file.
00001 
00002 #ifndef MGA_MGAMETABASE_H
00003 #define MGA_MGAMETABASE_H
00004 
00005 #include "MgaMetaProject.h"
00006 #include "MgaMetaRegNode.h"
00007 
00008 // --------------------------- CMgaMetaBase
00009 
00010 class ATL_NO_VTABLE CMgaMetaBase :
00011         public IDispatchImpl<IMgaMetaBase, &__uuidof(IMgaMetaBase), &__uuidof(__MGAMetaLib)>,
00012         public CMgaMetaRegNodes
00013 {
00014 public:
00015         CMgaMetaBase() { }
00016         ~CMgaMetaBase();
00017 
00018 public:
00019         HRESULT PutMetaRef_(metaref_type p);
00020 
00021         static void Traverse(CMgaMetaProject *metaproject, CCoreObjectPtr &me);
00022 
00023         CComPtr<IMgaMetaProject> metaprojectref;
00024         CMgaMetaProject* getMetaProject() {
00025                 return static_cast<CMgaMetaProject*>(static_cast<IMgaMetaProject*>(metaprojectref));
00026         }
00027         __declspec(property(get = getMetaProject)) CMgaMetaProject *metaproject;
00028         metaref_type metaref;
00029 };
00030 
00031 // --------------------------- DECLARE
00032 
00033 #define DECLARE_MGAMETABASE() \
00034 DECLARE_PROTECT_FINAL_CONSTRUCT() \
00035 DECLARE_MGAMETAREGNODES() \
00036 \
00037 public: \
00038         STDMETHOD(get_MetaRef)(metaref_type *p) \
00039         {  \
00040                 CHECK_OUT(p); \
00041                 *p = metaref; \
00042                 return S_OK; \
00043         } \
00044         STDMETHOD(put_MetaRef)(metaref_type p) \
00045         { HRESULT hr = PutMetaRef_(p); \
00046                 if(hr == S_OK) hr = ComPutAttrValue(GetUnknown(), ATTRID_METAREF, p); \
00047                 return hr; \
00048         } \
00049 \
00050         STDMETHOD(get_MetaProject)(IMgaMetaProject **p) \
00051         { \
00052                 CHECK_OUT(p); \
00053                 CopyTo(metaproject, p); \
00054                 return S_OK; \
00055         } \
00056 \
00057         STDMETHOD(get_Name)(BSTR *p) \
00058         { \
00059                 COMTRY { \
00060                         CComBSTR pn; \
00061                         COMTHROW( ComGetAttrValue(GetUnknown(), ATTRID_NAME, &pn)); \
00062                         CComBSTR tn = truncateName( GetUnknown(), pn); \
00063                         *p = tn.Detach(); \
00064                 } COMCATCH(;) \
00065         } \
00066 \
00067         STDMETHOD(put_Name)(BSTR p) \
00068         { return ComPutAttrValue(GetUnknown(), ATTRID_NAME, p); } \
00069 \
00070         STDMETHOD(get_DisplayedName)(BSTR *p) \
00071         { \
00072                 COMTRY { \
00073                         CComBSTR pn; \
00074                         COMTHROW( ComGetDisplayedName( GetUnknown(), ATTRID_DISPNAME, ATTRID_NAME, &pn)); \
00075                         CComBSTR tn = truncateName( GetUnknown(), pn); \
00076                         *p = tn.Detach(); \
00077                 } COMCATCH(;) \
00078         } \
00079 \
00080         STDMETHOD(put_DisplayedName)(BSTR p) \
00081         { return ComPutAttrValue(GetUnknown(), ATTRID_DISPNAME, p); } \
00082 \
00083         STDMETHOD(get_ObjType)(objtype_enum *p) \
00084         { return ComGetObjType(GetUnknown(), p); } \
00085 \
00086         STDMETHOD(get_Constraints)(IMgaMetaConstraints **p)  \
00087         { return ComGetCollectionValue<IMgaMetaConstraint>( \
00088                 GetUnknown(), ATTRID_CONSTRAINT_PTR, p); } \
00089 \
00090         STDMETHOD(CreateConstraint)(IMgaMetaConstraint **p) \
00091         { return ComCreateMetaObj(GetUnknown(), METAID_METACONSTRAINT, ATTRID_CONSTRAINT_PTR, p); } \
00092 \
00093         STDMETHOD(Delete)() \
00094         { return ComDeleteObject(GetUnknown()); }
00095 
00096 #endif//MGA_MGAMETABASE_H