GME  13
MgaResolver.h
Go to the documentation of this file.
00001 // MgaResolver.h : Declaration of the CMgaResolver
00002 
00003 #ifndef __MGARESOLVER_H_
00004 #define __MGARESOLVER_H_
00005 
00006 #include "resource.h"       // main symbols
00007 #include "Gme.h"
00008 
00009 #define RESOLV_ERR_COM_ERR 0x87640001 // COM function call error
00010 
00011 #define RESOLV_ERR_get_FolderByStr    0x87640002 // function failed in resolving
00012 #define RESOLV_ERR_get_AttrByStr      0x87640012 // function failed in resolving
00013 #define RESOLV_ERR_get_KindByStr      0x87640022 // function failed in resolving
00014 #define RESOLV_ERR_get_RoleByStr      0x87640032 // function failed in resolving
00015 #define RESOLV_ERR_get_RoleByMeta     0x87640042 // function failed in resolving
00016 #define RESOLV_ERR_get_ConnRoleByMeta 0x87640102 // function failed in resolving
00017 #define RESOLV_ERR_get_RefRoleByMeta  0x87640112 // function failed in resolving
00018 #define RESOLV_ERR_get_RolesByMetas   0x87640122 // function failed in resolving
00019 
00021 
00022 #define map_type_FolderByStr CTypedPtrList<CPtrList, Cmap_elmt_type_FolderByStr*>
00023 #define map_type_KindByStr CTypedPtrList<CPtrList, Cmap_elmt_type_KindByStr*>
00024 #define map_type_RoleByStr CTypedPtrList<CPtrList, Cmap_elmt_type_RoleByStr*>
00025 #define map_type_AttrByStr CTypedPtrList<CPtrList, Cmap_elmt_type_AttrByStr*>
00026 #define map_type_RoleByPathStr CTypedPtrList<CPtrList, Cmap_elmt_type_RoleByPathStr*>
00027 
00029 
00030 class Cmap_elmt_type_FolderByStr {
00031 
00032 public:
00033         // from:
00034         CComPtr<IMgaMetaFolder> m_parent;
00035         CString m_kind;
00036         // to:
00037         CComPtr<IMgaMetaFolder> p;
00038 public:
00039         Cmap_elmt_type_FolderByStr(IMgaMetaFolder * immf, CString _m_kind) : 
00040           m_kind(_m_kind), m_parent(immf) {}
00041 
00042         bool operator==(const Cmap_elmt_type_FolderByStr & c2) const {
00043                 if      (
00044                         (m_parent == c2.m_parent)
00045                         &&
00046                         (m_kind == c2.m_kind)
00047                         )
00048                         return true;
00049                 else
00050                         return false;
00051         }
00052 };
00053 
00054 
00055 
00056 class Cmap_elmt_type_KindByStr {
00057 
00058 public:
00059         // from:
00060         CComPtr<IMgaMetaFolder> m_parent;
00061         CString m_kind;
00062         objtype_enum m_objtype;
00063         // to:
00064         CComPtr<IMgaMetaFCO> p;
00065 public:
00066         Cmap_elmt_type_KindByStr(IMgaMetaFolder * immf, CString _m_kind, objtype_enum _m_objtype) : 
00067           m_kind(_m_kind), m_parent(immf), m_objtype(_m_objtype) {}
00068 
00069         bool operator==(const Cmap_elmt_type_KindByStr & c2) const {
00070                 if      (
00071                         (m_parent == c2.m_parent)
00072                         &&
00073                         (m_kind == c2.m_kind)
00074                         &&
00075                         (m_objtype == c2.m_objtype)
00076                         )
00077                         return true;
00078                 else
00079                         return false;
00080         }
00081 
00082 };
00083 
00084 class Cmap_elmt_type_RoleByStr {
00085 
00086 public:
00087         // from:
00088         CComPtr<IMgaMetaModel> m_parent;
00089         CString m_kind;
00090         objtype_enum m_objtype;
00091         CString m_role;
00092         CString m_aspect;
00093         // to:
00094         CComPtr<IMgaMetaRole> p;
00095 public:
00096         Cmap_elmt_type_RoleByStr(IMgaMetaModel * immfco, CString _m_kind,
00097                 objtype_enum _objtype, CString role, CString aspect) : 
00098           m_kind(_m_kind), m_parent(immfco), m_objtype(_objtype),
00099           m_role(role), m_aspect(aspect) {}
00100 
00101         bool operator==(const Cmap_elmt_type_RoleByStr & c2) const {
00102                 if      (
00103                         (m_parent == c2.m_parent)
00104                         &&
00105                         (m_kind == c2.m_kind)
00106                         &&
00107                         (m_objtype == c2.m_objtype)
00108                         &&
00109                         (m_role == c2.m_role)
00110                         &&
00111                         (m_aspect == c2.m_aspect)
00112                         )
00113                         return true;
00114                 else
00115                         return false;
00116         }
00117         
00118 };
00119 
00120 class Cmap_elmt_type_AttrByStr {
00121 
00122 public:
00123         // from:
00124         CComPtr<IMgaMetaFCO> m_parent;
00125         CString m_kind;
00126         // to:
00127         CComPtr<IMgaMetaAttribute> p;
00128 public:
00129         Cmap_elmt_type_AttrByStr(IMgaMetaFCO * immfco, CString _m_kind) : 
00130           m_kind(_m_kind), m_parent(immfco) {}
00131 
00132         bool operator==(const Cmap_elmt_type_AttrByStr & c2) const {
00133                 if      (
00134                         (m_parent == c2.m_parent)
00135                         &&
00136                         (m_kind == c2.m_kind)
00137                         )
00138                         return true;
00139                 else
00140                         return false;
00141         }
00142 };
00143 
00144 class Cmap_elmt_type_RoleByPathStr { 
00145         // from: 
00146 public:
00147         CString m_path;
00148         objtype_enum m_objtype;
00149         CComPtr<IMgaMetaBase> m_parent; 
00150         // to:
00151         CComPtr<IMgaMetaRole> p;
00152 public:
00153         Cmap_elmt_type_RoleByPathStr(CString _m_path, IMgaMetaBase *parent, objtype_enum _objtype) : 
00154                         m_path(_m_path), m_parent(parent), m_objtype(_objtype) {}
00155 
00156         bool operator==(const Cmap_elmt_type_RoleByPathStr & c2) const {
00157                         return m_path == c2.m_path && 
00158                                 m_objtype == c2.m_objtype &&
00159                                 m_parent == c2.m_parent;
00160         }
00161 };
00162 
00163 
00165 // CMgaResolver
00166 class ATL_NO_VTABLE CMgaResolver : 
00167         public CComObjectRootEx<CComSingleThreadModel>,
00168         public CComCoClass<CMgaResolver, &__uuidof(MgaResolver)>,
00169         public IDispatchImpl<IMgaResolver, &__uuidof(IMgaResolver), &__uuidof(__MGAUtilLib)>,
00170         public ISupportErrorInfoImpl<&__uuidof(IMgaResolver)>
00171 {
00172 public:
00173         CMgaResolver() : mb_is_interactive(true), mb_use_sticky(false)
00174                 , mb_name_alteration_sticky( false)
00175                 , m_alter_option( CH_NONE)
00176         {
00177         }
00178 
00179         ~CMgaResolver() { this->Clear(); }
00180 
00181 DECLARE_REGISTRY_RESOURCEID(IDR_MGARESOLVER)
00182 DECLARE_PROTECT_FINAL_CONSTRUCT()
00183 
00184 BEGIN_COM_MAP(CMgaResolver)
00185         COM_INTERFACE_ENTRY(IMgaResolver)
00186         COM_INTERFACE_ENTRY(IDispatch)
00187         COM_INTERFACE_ENTRY(ISupportErrorInfo)
00188 END_COM_MAP()
00189 
00190 public:
00191         // enums
00192         typedef enum { CH_NONE, CH_PREFIX, CH_TRUNCATE, CH_MIGRATE } alter_mode_enum;
00193 
00194 private:
00195         // namespace related methods
00196         bool isAlterationSet() const;
00197         void setAlteration( alter_mode_enum v);
00198 
00199         CComBSTR prefixIt(CComBSTR pIn);
00200         CComBSTR truncIt(CComBSTR pIn);
00201 
00202         // namespace related vars
00203         alter_mode_enum      m_alter_option;
00204         CComBSTR             m_prefix;
00205         CComBSTR             m_trunc;
00206         bool                 mb_name_alteration_sticky;
00207 
00208         bool mb_is_interactive, mb_use_sticky;
00209         void clear_mappings();
00210 
00211         map_type_FolderByStr map_FolderByStr;
00212         map_type_KindByStr   map_KindByStr;
00213         map_type_RoleByStr   map_RoleByStr;
00214         map_type_AttrByStr   map_AttrByStr;
00215         map_type_RoleByPathStr  map_RoleByPathStr;
00216 
00217         bool map_get_FolderByStr(IMgaMetaFolder *&parent, BSTR kind, IMgaMetaFolder **p);
00218         bool map_get_AttrByStr(IMgaMetaFCO *&parent, BSTR kind, IMgaMetaAttribute **p);
00219         bool map_get_KindByStr(IMgaMetaFolder *&parent, BSTR kind, objtype_enum objtype, IMgaMetaFCO **p);
00220         bool map_get_RoleByStr(IMgaMetaModel *&parent, BSTR kind, objtype_enum objtype,
00221                 BSTR &role, BSTR &aspect, IMgaMetaRole **p);
00222         bool map_get_RoleByPathStr(BSTR path, IMgaMetaBase *parent, objtype_enum objtype, IMgaMetaRole **p);
00223 
00224         bool map_put_FolderByStr(IMgaMetaFolder *&parent , BSTR kind, IMgaMetaFolder *p);
00225         bool map_put_AttrByStr(IMgaMetaFCO *&parent, BSTR kind, IMgaMetaAttribute *p);
00226         bool map_put_KindByStr(IMgaMetaFolder *&parent, BSTR kind, objtype_enum objtype, IMgaMetaFCO *p);
00227         bool map_put_RoleByStr(IMgaMetaModel *&parent, BSTR kind, objtype_enum objtype,
00228                 BSTR &role, BSTR &aspect, IMgaMetaRole *p);
00229         bool map_put_RoleByPathStr(BSTR path, IMgaMetaBase *parent, objtype_enum objtype, IMgaMetaRole *p);
00230 
00231         CComPtr<IGMEOLEApp>     get_GME(CComPtr<IMgaProject> project);
00232 
00233 
00234 // IMgaResolver
00235 public:
00236 
00237         STDMETHOD(Clear)();
00238         STDMETHOD(put_IsInteractive)(VARIANT_BOOL p);
00239         STDMETHOD(get_IsInteractive)(VARIANT_BOOL *p);
00240 
00241         STDMETHOD(put_IsStickyEnabled)(VARIANT_BOOL p);
00242         STDMETHOD(get_IsStickyEnabled)(VARIANT_BOOL *p);
00243 
00244         STDMETHOD(getUserOptions)();
00245 
00246         STDMETHOD(get_FolderByStr)(IMgaFolder *parent, BSTR kind, IMgaMetaFolder **p);
00247         STDMETHOD(GetFolderByStrDisp)(IMgaFolder *parent, BSTR kind, IMgaMetaFolder **p) { return get_FolderByStr( parent, kind, p); }
00248         STDMETHOD(get_KindByStr)(IMgaFolder *parent, BSTR kind, objtype_enum objtype, IMgaMetaFCO **p);
00249         STDMETHOD(GetKindByStrDisp)(IMgaFolder *parent, BSTR kind, objtype_enum objtype, IMgaMetaFCO **p) { return get_KindByStr( parent, kind, objtype, p); }
00250         STDMETHOD(get_RoleByStr)(IMgaModel *parent, BSTR kind, objtype_enum objtype,
00251                 BSTR role, BSTR aspect, IMgaMetaRole **p);
00252         STDMETHOD(GetRoleByStrDisp)(IMgaModel *parent, BSTR kind, objtype_enum objtype,
00253                 BSTR role, BSTR aspect, IMgaMetaRole **p) { return get_RoleByStr( parent, kind, objtype, role, aspect, p); }
00254         STDMETHOD(get_AttrByStr)(IMgaFCO *parent, BSTR kind, IMgaMetaAttribute **p);
00255         STDMETHOD(GetAttrByStrDisp)(IMgaFCO *parent, BSTR kind, IMgaMetaAttribute **p) { return get_AttrByStr( parent, kind, p); }
00256 
00257         STDMETHOD(get_RoleByMeta)(IMgaModel *parent, IMgaMetaFCO *kind, objtype_enum objtype,
00258                 IMgaMetaRole *role, IMgaMetaAspect *aspect, IMgaMetaRole **p);
00259 
00260         STDMETHOD(GetRoleByMetaDisp)(IMgaModel *parent, IMgaMetaFCO *kind, objtype_enum objtype,
00261                 IMgaMetaRole *role, IMgaMetaAspect *aspect, IMgaMetaRole **p) { return get_RoleByMeta( parent, kind, objtype, role, aspect, p); }
00262 
00263         STDMETHOD(get_ConnRoleByMeta)(IMgaModel *parent, IMgaMetaAspect *aspect, 
00264                 IMgaFCO *src, IMgaFCO *src_port, IMgaFCO *dst, IMgaFCO *dst_port, IMgaMetaRole **p);
00265         STDMETHOD(GetConnRoleByMetaDisp)(IMgaModel *parent, IMgaMetaAspect *aspect, 
00266                 IMgaFCO *src, IMgaFCO *src_port, IMgaFCO *dst, IMgaFCO *dst_port, IMgaMetaRole **p) { return get_ConnRoleByMeta( parent, aspect, src, src_port, dst, dst_port, p); }
00267         STDMETHOD(get_RefRoleByMeta)(IMgaModel *parent, IMgaMetaAspect *aspect, 
00268                 IMgaFCO *src, IMgaMetaRole **p);
00269         STDMETHOD(GetRefRoleByMetaDisp)(IMgaModel *parent, IMgaMetaAspect *aspect, 
00270                 IMgaFCO *src, IMgaMetaRole **p) { return get_RefRoleByMeta( parent, aspect, src, p); }
00271 
00272         STDMETHOD(get_RolesByMetas)(IMgaModel *dst_parent, IMgaFCOs *src, 
00273                 IMgaMetaAspect * aspect, BSTR sz_aspect, IMgaMetaRoles ** p);
00274 
00275         STDMETHOD(GetRolesByMetasDisp)(IMgaModel *dst_parent, IMgaFCOs *src, 
00276                 IMgaMetaAspect * aspect, BSTR sz_aspect, IMgaMetaRoles ** p) { return get_RolesByMetas( dst_parent, src, aspect, sz_aspect, p); }
00277 
00278 };
00279 
00280 #endif //__MGARESOLVER_H_