GME  13
MgaMetaConnection.cpp
Go to the documentation of this file.
00001 
00002 #include "stdafx.h"
00003 #include "MgaMetaConnection.h"
00004 #include "MgaMetaConnJoint.h"
00005 #include <functional>
00006 
00007 // --------------------------- CMgaMetaConnection
00008 
00009 STDMETHODIMP CMgaMetaConnection::CheckPaths(BSTR paths, VARIANT_BOOL *p)
00010 {
00011         CHECK_OUT(p);
00012 
00013         COMTRY
00014         {
00015                 ASSERT( metaprojectref != NULL );
00016 
00017                 jointpaths_type jointpaths;
00018                 metaproject->CreateJointPaths(paths, jointpaths);
00019 
00020                 CCoreObjectPtr self(GetUnknown());
00021 
00022                 *p = CheckPaths(self, jointpaths) ? VARIANT_TRUE : VARIANT_FALSE;
00023         }
00024         COMCATCH(;)
00025 }
00026 
00027 bool CMgaMetaConnection::CheckPaths(CCoreObjectPtr &self, jointpaths_type jointpaths)
00028 {
00029         coreobjects_type objects;
00030         self.GetCollectionValue(ATTRID_CONNJOINTS_COLL, objects);
00031 
00032         coreobjects_iterator i = objects.begin();
00033         coreobjects_iterator e = objects.end();
00034         while( i != e )
00035         {
00036                 if( CMgaMetaConnJoint::CheckPaths(*i, jointpaths) )
00037                         return true;
00038 
00039                 ++i;
00040         }
00041 
00042         return false;
00043 }
00044 
00045 // ------- Edit
00046 
00047 STDMETHODIMP CMgaMetaConnection::CreateJoint(IMgaMetaConnJoint **p)
00048 {
00049         CHECK_OUT(p);
00050 
00051         ASSERT( metaprojectref != NULL );
00052 
00053         COMTRY
00054         {
00055                 CCoreObjectPtr self(GetUnknown());
00056                 ASSERT( self != NULL );
00057 
00058                 CCoreObjectPtr joint;
00059                 metaproject->CreateMetaObj(METAID_METACONNJOINT, joint);
00060 
00061                 joint.PutPointerValue(ATTRID_CONNJOINTS_COLL, self);
00062 
00063                 COMTHROW( ::QueryInterface(joint, p) );
00064         }
00065         COMCATCH(;)
00066 }
00067 
00068 // ------- Traverse
00069 
00070 void CMgaMetaConnection::Traverse(CMgaMetaProject *metaproject, CCoreObjectPtr &me)
00071 {
00072         ASSERT( metaproject != NULL );
00073         ASSERT( me != NULL );
00074 
00075         CMgaMetaFCO::Traverse(metaproject, me);
00076 
00077         TraverseCollection(metaproject, me, ATTRID_CONNJOINTS_COLL);
00078 }