GME  13
MgaConnection.h
Go to the documentation of this file.
00001 // MgaConnection.h : Declaration of the CMgaConnection
00002 
00003 #ifndef __MGACONNECTION_H_
00004 #define __MGACONNECTION_H_
00005 
00006 #include "resource.h"       // main symbols
00007 #include "MgaFCO.h"
00008 
00010 // CMgaConnection
00011 
00012 
00013 
00014 class ATL_NO_VTABLE CMgaConnection : 
00015         public CComCoClass<CMgaConnection, &__uuidof(MgaSimpleConnection)>,
00016         public IMgaFCOImpl< 
00017                 CComObjectRootEx<CComSingleThreadModel>,
00018                 IDispatchImpl<IMgaSimpleConnection, &__uuidof(IMgaSimpleConnection), &__uuidof(__MGALib)> >,
00019         public ISupportErrorInfoImpl<&__uuidof(IMgaConnection)>
00020 {
00021 public:
00022         static HRESULT WINAPI simpletest(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw) {
00023                                 FCO *f = reinterpret_cast<CMgaConnection*>(pv)->innFCO;
00024                                 if(!f->simpleconn()) return E_NOINTERFACE; // this breaks COM rules
00025                                 IUnknown* pUnk = (IUnknown*)((int)pv+dw);
00026                                 pUnk->AddRef();
00027                                 *ppv = pUnk;
00028                                 return S_OK;
00029         }
00030 
00031         CMgaConnection() {      }
00032 
00033         
00034 DECLARE_PROTECT_FINAL_CONSTRUCT()
00035 
00036 BEGIN_COM_MAP(CMgaConnection)
00037         COM_INTERFACE_ENTRY(IMgaConnection)
00038         COM_INTERFACE_ENTRY(IDispatch)
00039         COM_INTERFACE_ENTRY_IID(__uuidof(IMgaFCO),IMgaConnection)
00040         COM_INTERFACE_ENTRY_IID(__uuidof(IMgaObject),IMgaConnection)
00041         COM_INTERFACE_ENTRY_IID(IID_ISupportErrorInfo, IMyErrorInfoBase)
00042         COM_INTERFACE_ENTRY_FUNC(__uuidof(IMgaSimpleConnection), offsetofclass(IMgaSimpleConnection, _ComMapClass), simpletest)
00043 END_COM_MAP()
00044 
00045 // IMgaSimpleConnection
00046 public:
00047         HRESULT findroleobj(BSTR rolename, ICoreObject **tt);
00048 
00049         STDMETHOD(get_NamedRole)(BSTR rolename, IMgaFCO **pVal) { 
00050                                                                                         return inFCO->get_NamedRoleTarget(rolename,pVal); }
00051         STDMETHOD(get_NamedRoleReferences)(BSTR rolename, IMgaFCOs **pVal) {
00052                                                                                         return inFCO->get_NamedRoleReferences( rolename,pVal); }
00053 
00054         STDMETHOD(get_Src)(IMgaFCO **pVal) { return inFCO->get_NamedRoleTarget(inFCO->SrcName, pVal); }
00055         STDMETHOD(get_Dst)(IMgaFCO **pVal) { return inFCO->get_NamedRoleTarget(inFCO->DstName, pVal); }
00056         STDMETHOD(get_SrcReferences)(IMgaFCOs **pVal) { return get_NamedRoleReferences(inFCO->SrcName, pVal); }
00057         STDMETHOD(get_DstReferences)(IMgaFCOs **pVal) { return get_NamedRoleReferences(inFCO->DstName, pVal); }
00058 
00059         STDMETHOD(SetSrc)(IMgaFCOs *refs, IMgaFCO * newVal)  { 
00060                                                                                 return inFCO->put_NamedRole(inFCO->SrcName, refs, newVal); }
00061         STDMETHOD(SetDst)(IMgaFCOs *refs, IMgaFCO * newVal) { 
00062                                                                                 return inFCO->put_NamedRole(inFCO->DstName, refs, newVal); }
00063         STDMETHOD(AddConnPoint)(BSTR rolename, long maxinrole, IMgaFCO *target, IMgaFCOs *refs, IMgaConnPoint **pVal) {
00064                                                                                 return inFCO->AddConnPoint(rolename, maxinrole, target, refs, pVal); }
00065         STDMETHOD(get_ConnPoints)(IMgaConnPoints **pVal) {
00066                                                                                 return inFCO->get_ConnPoints(pVal); }
00067 
00068         STDMETHOD(CompareToBase)(IMgaConnPoint *p, short *status)               { return inFCO->ConnCompareToBase(p,status); }
00069     STDMETHOD(RevertToBase)(IMgaConnPoint *p)                                           { return inFCO->ConnRevertToBase(p); }
00070 };
00071 
00072 
00073 
00075 // CMgaConnPoint
00076 class ATL_NO_VTABLE CMgaConnPoint : 
00077         public CComCoClass<CMgaConnPoint, &__uuidof(MgaConnPoint)>,
00078         public CComObjectRootEx<CComSingleThreadModel>,
00079         public IDispatchImpl<IMgaConnPoint, &__uuidof(IMgaConnPoint), &__uuidof(__MGALib)>,
00080         public ISupportErrorInfoImpl<&__uuidof(IMgaConnPoint)>
00081 {
00082 public:
00083         DEFSIG;
00084         CMgaConnPoint() {
00085                 INITSIG('C');
00086         }
00087 
00088         CComPtr<FCO> fco;
00089         CoreObj cobj;
00090         static void GetConnPoint(FCO *f, CoreObj &c, IMgaConnPoint **cp);
00091         ~CMgaConnPoint();
00092 
00093 DECLARE_PROTECT_FINAL_CONSTRUCT()
00094 
00095 BEGIN_COM_MAP(CMgaConnPoint)
00096         COM_INTERFACE_ENTRY(IMgaConnPoint)
00097         COM_INTERFACE_ENTRY(IDispatch)
00098         COM_INTERFACE_ENTRY_IID(IID_ISupportErrorInfo, IMyErrorInfoBase)
00099 END_COM_MAP()
00100 
00101 // IMgaConnPoint
00102 public:
00103         STDMETHOD(get_Owner)(IMgaConnection **pVal);
00104         STDMETHOD(get_ConnRole)(BSTR *pVal);
00105         STDMETHOD(put_ConnRole)(BSTR newVal);
00106         STDMETHOD(get_Target)(IMgaFCO **pVal);
00107         STDMETHOD(get_References)(IMgaFCOs **pVal);
00108         STDMETHOD(Remove)();
00109 };
00110 
00111 void MgaConnPointDelete(CoreObj& cobj);
00112 
00113 
00114 class AddConnPTask : public DeriveTreeTask {
00115         CComBSTR rolename;
00116         long maxinrole;
00117 
00118         bool Do(CoreObj self, std::vector<CoreObj> *peers);
00119 
00120 public:
00121         AddConnPTask(long mr, BSTR rn) : maxinrole(mr), rolename(rn) { endreserve = 1; }
00122         CoreObj retval;
00123 };
00124 
00125 #endif //__MGACONNECTION_H_