GME  13
MgaMetaFolder.cpp
Go to the documentation of this file.
00001 
00002 #include "stdafx.h"
00003 #include "MgaMetaFolder.h"
00004 #include "MgaMetaProject.h"
00005 
00006 // --------------------------- CMgaMetaFolder
00007 
00008 // ------- Traverse
00009 
00010 STDMETHODIMP CMgaMetaFolder::get_DefinedFolderByName(BSTR name, VARIANT_BOOL inscope, IMgaMetaFolder **p)
00011 {
00012         CHECK_OUT(p);
00013 
00014         COMTRY
00015         {
00016                 CCoreObjectPtr self(GetUnknown());
00017 
00018                 CComBstrObj_lightequal equal( GetUnknown());
00019                 coreobjects_type coreobjects;
00020                 self.GetCollectionValue(ATTRID_DEFFOLDER_PTR, coreobjects);
00021 
00022                 coreobjects_iterator i = coreobjects.begin();
00023                 coreobjects_iterator e = coreobjects.end();
00024                 while( i != e )
00025                 {
00026                         CComBstrObj n;
00027                         (*i).GetStringValue(ATTRID_NAME, PutOut(n));
00028                         
00029                         if( equal( n, name))//if( n == name )
00030                                 COMRETURN( ::QueryInterface(*i, p) );
00031 
00032                         ++i;
00033                 }
00034 
00035                 if( inscope != VARIANT_FALSE )
00036                 {
00037                         CComObjPtr<IMgaMetaFolder> parent;
00038                         COMTHROW( get_DefinedIn(PutOut(parent)) );
00039                         
00040                         if( parent != NULL )
00041                                 COMRETURN( parent->get_DefinedFolderByName(name, inscope, p) );
00042                 }
00043 
00044                 COMRETURN(E_NOTFOUND);
00045         }
00046         COMCATCH(;)
00047 }
00048 
00049 STDMETHODIMP CMgaMetaFolder::get_DefinedFCOByName(BSTR name, VARIANT_BOOL inscope, IMgaMetaFCO **p)
00050 {
00051         CHECK_OUT(p);
00052 
00053         COMTRY
00054         {
00055                 CCoreObjectPtr self(GetUnknown());
00056 
00057                 CComBstrObj_lightequal equal( GetUnknown());
00058                 coreobjects_type coreobjects;
00059                 self.GetCollectionValue(ATTRID_DEFFCO_PTR, coreobjects);
00060 
00061                 coreobjects_iterator i = coreobjects.begin();
00062                 coreobjects_iterator e = coreobjects.end();
00063                 while( i != e )
00064                 {
00065                         CComBstrObj n;
00066                         (*i).GetStringValue(ATTRID_NAME, PutOut(n));
00067                         
00068                         if( equal( n, name))//if( n == name )
00069                                 COMRETURN( ::QueryInterface(*i, p) );
00070 
00071                         ++i;
00072                 }
00073 
00074                 if( inscope != VARIANT_FALSE )
00075                 {
00076                         CComObjPtr<IMgaMetaFolder> parent;
00077                         COMTHROW( get_DefinedIn(PutOut(parent)) );
00078                         
00079                         if( parent != NULL )
00080                                 COMRETURN( parent->get_DefinedFCOByName(name, inscope, p) );
00081                 }
00082 
00083                 COMRETURN(E_NOTFOUND);
00084         }
00085         COMCATCH(;)
00086 }
00087 
00088 STDMETHODIMP CMgaMetaFolder::get_DefinedAttributeByName(BSTR name,
00089         VARIANT_BOOL inscope, IMgaMetaAttribute **p)
00090 {
00091         CHECK_OUT(p);
00092 
00093         COMTRY
00094         {
00095                 CCoreObjectPtr self(GetUnknown());
00096 
00097                 coreobjects_type coreobjects;
00098                 self.GetCollectionValue(ATTRID_DEFATTR_PTR, coreobjects);
00099 
00100                 coreobjects_iterator i = coreobjects.begin();
00101                 coreobjects_iterator e = coreobjects.end();
00102                 while( i != e )
00103                 {
00104                         CComBstrObj n;
00105                         (*i).GetStringValue(ATTRID_NAME, PutOut(n));
00106                         
00107                         if( n == name )
00108                                 COMRETURN( ::QueryInterface(*i, p) );
00109 
00110                         ++i;
00111                 }
00112 
00113                 if( inscope != VARIANT_FALSE )
00114                 {
00115                         CComObjPtr<IMgaMetaFolder> parent;
00116                         COMTHROW( get_DefinedIn(PutOut(parent)) );
00117                         
00118                         if( parent != NULL )
00119                                 COMRETURN( parent->get_DefinedAttributeByName(name, inscope, p) );
00120                 }
00121 
00122                 COMRETURN(E_NOTFOUND);
00123         }
00124         COMCATCH(;)
00125 }
00126 
00127 void CMgaMetaFolder::Traverse(CMgaMetaProject *metaproject, CCoreObjectPtr &me)
00128 {
00129         ASSERT( metaproject != NULL );
00130         ASSERT( me != NULL );
00131 
00132         CMgaMetaBase::Traverse(metaproject, me);
00133 
00134         TraverseCollection(metaproject, me, ATTRID_DEFFOLDER_PTR);
00135         TraverseCollection(metaproject, me, ATTRID_DEFFCO_PTR);
00136         TraverseCollection(metaproject, me, ATTRID_DEFATTR_PTR);
00137         TraverseCollection(metaproject, me, ATTRID_FOLDERLINK_CHILD_PTR);
00138         TraverseCollection(metaproject, me, ATTRID_ROOTOBJLINK_FOLDER_PTR);
00139 }