00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "stdafx.h"
00023 #include "MONImpl.h"
00024
00025 #include "Utils.h"
00026
00027 #define COMTHROW(x) BONCOMTHROW(x)
00028
00029 #include "Exceptions.h"
00030
00031 inline std::string _ref2str( long lRef )
00032 {
00033 char chBuffer[ 50 ];
00034 sprintf( chBuffer, "%d", lRef );
00035 return chBuffer;
00036 }
00037
00038 inline std::string _slashes( const std::string& str )
00039 {
00040 std::string str2 = str;
00041 for ( int i = 0 ; i < str2.size() ; i++ )
00042 if ( str2[ i ] == '\\' )
00043 str2[ i ] = '/';
00044 return str2;
00045 }
00046
00047 inline MON::ProjectImpl* _getProject( IMgaMetaBase* spObject, MON::ProjectImpl* pProject )
00048 {
00049 if ( pProject )
00050 return pProject;
00051 MON::ProjectPtr spProject;
00052 COMCHECK2( spObject, spObject->get_MetaProject( spProject.Addr() ) );
00053 return MON::ProjectImpl::attach( spProject );
00054 }
00055
00056 namespace MON
00057 {
00058
00059
00060
00061
00062
00063
00064
00065 ProjectImpl::ProjectMap ProjectImpl::mapProjects;
00066
00067 ProjectImpl::ProjectImpl( IMgaMetaProject* spProject )
00068 : Util::GenRefCounted( true, NULL ), m_spProject( spProject )
00069 {
00070 for ( int iType = OT_Model ; iType <= OT_Part ; iType++ )
00071 m_mapObjectsByType.insert( Type2ObjectsMap::value_type( iType, ProjectImpl::ObjectSet() ) );
00072
00073 mapProjects.insert( ProjectMap::value_type( spProject, this ) );
00074 }
00075
00076 ProjectImpl* ProjectImpl::attach( IMgaMetaProject* spProject )
00077 {
00078 ProjectImpl::ProjectMap::iterator it = mapProjects.find( spProject );
00079 if ( it != mapProjects.end() )
00080 return it->second;
00081
00082 ProjectImpl* pProject = new ProjectImpl( spProject );
00083
00084 FolderPtr spRootFolder;
00085 COMCHECK2( spProject, spProject->get_RootFolder( spRootFolder.Addr() ) );
00086 pProject->m_pRootFolder = pProject->processFolder( spRootFolder );
00087
00088 const ProjectImpl::ObjectSet& setRefs = pProject->getObjects( OT_Reference );
00089 for ( ProjectImpl::ObjectSet::const_iterator itRef = setRefs.begin() ; itRef != setRefs.end() ; ++itRef )
00090 pProject->processReference( (ReferenceImpl*) *itRef );
00091
00092 const ProjectImpl::ObjectSet& setSets = pProject->getObjects( OT_Set );
00093 for ( ProjectImpl::ObjectSet::const_iterator itSet = setSets.begin() ; itSet != setSets.end() ; ++itSet )
00094 pProject->processSet( (SetImpl*) *itSet );
00095
00096 const ProjectImpl::ObjectSet& setConns = pProject->getObjects( OT_Connection );
00097 for ( ProjectImpl::ObjectSet::const_iterator itConn = setConns.begin() ; itConn != setConns.end() ; ++itConn )
00098 pProject->processConnection( (ConnectionImpl*) *itConn );
00099
00100 const ProjectImpl::ObjectSet& setMods = pProject->getObjects( OT_Model );
00101 for ( ProjectImpl::ObjectSet::const_iterator itMod = setMods.begin() ; itMod != setMods.end() ; ++itMod )
00102 pProject->processModel( (ModelImpl*) *itMod );
00103
00104 return pProject;
00105 }
00106
00107 FolderImpl* ProjectImpl::processFolder( const FolderPtr& spFolder )
00108 {
00109 long lRef;
00110 COMCHECK2( spFolder, spFolder->get_MetaRef( &lRef ) );
00111 if ( m_mapObjectsByRef.find( lRef ) != m_mapObjectsByRef.end() )
00112 return ( FolderImpl* ) m_mapObjectsByRef[ lRef ];
00113
00114 FolderImpl* pFolder = FolderImpl::attachI( spFolder, this );
00115 insertObject( pFolder );
00116
00117 Util::ComPtr<IMgaMetaFolders> spFolders;
00118 COMCHECK2( spFolder, spFolder->get_LegalChildFolders( spFolders.Addr() ) );
00119 MGACOLL_ITERATE( IMgaMetaFolder, spFolders.p ) {
00120 FolderImpl* pChild = processFolder( MGACOLL_ITER.p );
00121 m_setFolderContainments.insert( new FolderContainmentImpl( pFolder, pChild ) );
00122 } MGACOLL_ITERATE_END;
00123
00124 Util::ComPtr<IMgaMetaFCOs> spFCOs;
00125 COMCHECK2( spFolder, spFolder->get_LegalRootObjects( spFCOs.Addr() ) );
00126 MGACOLL_ITERATE( IMgaMetaFCO, spFCOs.p ) {
00127 FCOImpl* pChild = processFCO( MGACOLL_ITER.p );
00128 m_setFolderContainments.insert( new FolderContainmentImpl( pFolder, pChild ) );
00129 } MGACOLL_ITERATE_END;
00130
00131 return pFolder;
00132 }
00133
00134 FCOImpl* ProjectImpl::processFCO( const FCOPtr& spFCO )
00135 {
00136 long lRef;
00137 COMCHECK2( spFCO, spFCO->get_MetaRef( &lRef ) );
00138 if ( m_mapObjectsByRef.find( lRef ) != m_mapObjectsByRef.end() )
00139 return ( FCOImpl* ) m_mapObjectsByRef[ lRef ];
00140
00141 objtype_enum eType;
00142 COMCHECK2( spFCO, spFCO->get_ObjType( &eType ) );
00143 FCOImpl* pFCO;
00144 switch ( eType ) {
00145 case OBJTYPE_MODEL : {
00146 CComQIPtr<IMgaMetaModel> spModel = spFCO.p;
00147 pFCO = processModel( spModel.p );
00148 break;
00149 }
00150 case OBJTYPE_ATOM : {
00151 CComQIPtr<IMgaMetaAtom> spAtom = spFCO.p;
00152 pFCO = processAtom( spAtom.p );
00153 break;
00154 }
00155 case OBJTYPE_CONNECTION : {
00156 CComQIPtr<IMgaMetaConnection> spConnection = spFCO.p;
00157 pFCO = processConnection( spConnection.p );
00158 break;
00159 }
00160 case OBJTYPE_REFERENCE : {
00161 CComQIPtr<IMgaMetaReference> spReference = spFCO.p;
00162 pFCO = processReference( spReference.p );
00163 break;
00164 }
00165 case OBJTYPE_SET : {
00166 CComQIPtr<IMgaMetaSet> spSet = spFCO.p;
00167 pFCO = processSet( spSet.p );
00168 break;
00169 }
00170 }
00171
00172 Util::ComPtr<IMgaMetaAttributes> spAttributes;
00173 COMCHECK2( spFCO, spFCO->get_Attributes( spAttributes.Addr() ) );
00174 MGACOLL_ITERATE( IMgaMetaAttribute, spAttributes.p ) {
00175 Util::ComPtr<IMgaMetaFCOs> spFCOs;
00176 COMCHECK2( MGACOLL_ITER, MGACOLL_ITER->get_UsedIn( spFCOs.Addr() ) );
00177 long lCount = 0;
00178 COMCHECK2( spFCOs, spFCOs->get_Count( &lCount ) );
00179 AttributeImpl* pAttribute = processAttribute( MGACOLL_ITER.p, ( lCount == 1 ) ? pFCO : NULL );
00180 if ( lCount == 1 )
00181 pFCO->m_setAttributes.insert( pAttribute );
00182 else
00183 m_setAttributeAggregations.insert( new AttributeAggregationImpl( pFCO, pAttribute ) );
00184 } MGACOLL_ITERATE_END;
00185
00186 return pFCO;
00187 }
00188
00189 AtomImpl* ProjectImpl::processAtom( const AtomPtr& spAtom )
00190 {
00191 AtomImpl* pAtom = AtomImpl::attachI( spAtom, this );
00192 insertObject( pAtom );
00193 return pAtom;
00194 }
00195
00196 ModelImpl* ProjectImpl::processModel( const ModelPtr& spModel )
00197 {
00198 ModelImpl* pModel = ModelImpl::attachI( spModel, this );
00199 insertObject( pModel );
00200
00201 Util::ComPtr<IMgaMetaRoles> spRoles;
00202 COMCHECK2( spModel, spModel->get_Roles( spRoles.Addr() ) );
00203 MGACOLL_ITERATE( IMgaMetaRole, spRoles.p ) {
00204 FCOPtr spFCO;
00205 COMCHECK2( MGACOLL_ITER, MGACOLL_ITER->get_Kind( spFCO.Addr() ) );
00206 FCOImpl* pFCO = processFCO( spFCO );
00207 ContainmentImpl* pContainment = ContainmentImpl::attachI( MGACOLL_ITER, this );
00208 pContainment->m_pParent = pModel;
00209 pContainment->m_pChild = pFCO;
00210 insertObject( pContainment );
00211 } MGACOLL_ITERATE_END;
00212
00213 return pModel;
00214 }
00215
00216 void ProjectImpl::processModel( ModelImpl* pModel )
00217 {
00218 Util::ComPtr<IMgaMetaAspects> spAspects;
00219 COMCHECK2( pModel->getModelI(), pModel->getModelI()->get_Aspects( spAspects.Addr() ) );
00220 MGACOLL_ITERATE( IMgaMetaAspect, spAspects.p ) {
00221 AspectImpl* pAspect = processAspect( MGACOLL_ITER );
00222 ModelInAspectImpl* pModelInAspect = new ModelInAspectImpl( pAspect, pModel );
00223 m_setModelInAspects.insert( pModelInAspect );
00224 } MGACOLL_ITERATE_END;
00225 }
00226
00227 ConnectionImpl* ProjectImpl::processConnection( const ConnectionPtr& spConnection )
00228 {
00229 ConnectionImpl* pConnection = ConnectionImpl::attachI( spConnection, this );
00230 insertObject( pConnection );
00231 return pConnection;
00232 }
00233
00234 void ProjectImpl::processConnection( ConnectionImpl* pConnection )
00235 {
00236 Util::ComPtr<IMgaMetaConnJoints> spJoints;
00237 COMCHECK2( pConnection->getConnectionI(), pConnection->getConnectionI()->get_Joints( spJoints.Addr() ) );
00238
00239 long lJointNum;
00240 COMCHECK2( spJoints, spJoints->get_Count( &lJointNum ) );
00241 pConnection->m_bBidirectional = lJointNum == 2;
00242
00243 int i = 0;
00244 MGACOLL_ITERATE( IMgaMetaConnJoint, spJoints.p ) {
00245 Util::ComPtr<IMgaMetaConnJoint> spJoint = MGACOLL_ITER.p;
00246
00247 ConnectionSpecImpl* pSpec = new ConnectionSpecImpl( pConnection, i++ );
00248 pConnection->m_setConnSpecs.insert( pSpec );
00249
00250 Util::ComPtr<IMgaMetaPointerSpecs> spSpecs;
00251 COMCHECK2( spJoint, spJoint->get_PointerSpecs( spSpecs.Addr() ) );
00252
00253 MGACOLL_ITERATE( IMgaMetaPointerSpec, spSpecs.p ) {
00254 Util::ComPtr<IMgaMetaPointerSpec> spSpec = MGACOLL_ITER.p;
00255 CComBSTR bstrSpecName;
00256 COMCHECK2( spSpec, spSpec->get_Name( &bstrSpecName ) );
00257
00258 ConnectionRoleImpl* pRole = new ConnectionRoleImpl( pSpec, Util::Copy( bstrSpecName ) );
00259 pSpec->m_setRoles.insert( pRole );
00260
00261 Util::ComPtr<IMgaMetaPointerItems> spItems;
00262 COMCHECK2( spSpec, spSpec->get_Items( spItems.Addr() ) );
00263
00264 std::set<ContainmentImpl*> setRolesFull;
00265
00266 MGACOLL_ITERATE( IMgaMetaPointerItem, spItems.p ) {
00267 CComBSTR bstrDesc;
00268 COMCHECK2( MGACOLL_ITER, MGACOLL_ITER->get_Desc( &bstrDesc ) );
00269 std::set<ContainmentImpl*> setRoles = getLocalRoles( pConnection, Util::Copy( bstrDesc ) );
00270 for ( std::set<ContainmentImpl*>::iterator it = setRoles.begin() ; it != setRoles.end() ; ++it )
00271 setRolesFull.insert( *it );
00272 } MGACOLL_ITERATE_END;
00273
00274 for ( std::set<ContainmentImpl*>::iterator it = setRolesFull.begin() ; it != setRolesFull.end() ; ++it ) {
00275 m_setConnectionEnds.insert( new ConnectionEndImpl( pRole, *it ) );
00276 }
00277
00278 } MGACOLL_ITERATE_END;
00279
00280 } MGACOLL_ITERATE_END;
00281 }
00282
00283 ReferenceImpl* ProjectImpl::processReference( const ReferencePtr& spReference )
00284 {
00285 ReferenceImpl* pReference = ReferenceImpl::attachI( spReference, this );
00286 insertObject( pReference );
00287 return pReference;
00288 }
00289
00290 void ProjectImpl::processReference( ReferenceImpl* pReference )
00291 {
00292 Util::ComPtr<IMgaMetaPointerSpec> spSpec;
00293 COMCHECK2( pReference->getReferenceI(), pReference->getReferenceI()->get_RefSpec( spSpec.Addr() ) );
00294 Util::ComPtr<IMgaMetaPointerItems> spItems;
00295 COMCHECK2( spSpec, spSpec->get_Items( spItems.Addr() ) );
00296 MGACOLL_ITERATE( IMgaMetaPointerItem, spItems.p ) {
00297 CComBSTR bstrDesc;
00298 COMCHECK2( MGACOLL_ITER, MGACOLL_ITER->get_Desc( &bstrDesc ) );
00299 FCOImpl * refd = (FCOImpl *) findByName( Util::Copy( bstrDesc));
00300 if ( refd)
00301 m_setReferenceAssocs.insert( new ReferenceAssocImpl( pReference, refd) );
00302 } MGACOLL_ITERATE_END;
00303 }
00304
00305 SetImpl* ProjectImpl::processSet( const SetPtr& spSet )
00306 {
00307 SetImpl* pSet = SetImpl::attachI( spSet, this );
00308 insertObject( pSet );
00309 return pSet;
00310 }
00311
00312 void ProjectImpl::processSet( SetImpl* pSet )
00313 {
00314 Util::ComPtr<IMgaMetaPointerSpec> spSpec;
00315 COMCHECK2( pSet->getSetI(), pSet->getSetI()->get_MemberSpec( spSpec.Addr() ) );
00316 Util::ComPtr<IMgaMetaPointerItems> spItems;
00317 COMCHECK2( spSpec, spSpec->get_Items( spItems.Addr() ) );
00318 MGACOLL_ITERATE( IMgaMetaPointerItem, spItems.p ) {
00319 CComBSTR bstrDesc;
00320 COMCHECK2( MGACOLL_ITER, MGACOLL_ITER->get_Desc( &bstrDesc ) );
00321 std::set<ContainmentImpl*> setRoles = getLocalRoles( pSet, Util::Copy( bstrDesc ) );
00322 for ( std::set<ContainmentImpl*>::iterator it = setRoles.begin() ; it != setRoles.end() ; it++ )
00323 m_setSetMemberships.insert( new SetMembershipImpl( pSet, *it ) );
00324 } MGACOLL_ITERATE_END;
00325 }
00326
00327 AttributeImpl* ProjectImpl::processAttribute( const AttributePtr& spAttribute, FCOImpl* pOwner )
00328 {
00329 long lRef;
00330 COMCHECK2( spAttribute, spAttribute->get_MetaRef( &lRef ) );
00331 if ( m_mapObjectsByRef.find( lRef ) != m_mapObjectsByRef.end() )
00332 return ( AttributeImpl* ) m_mapObjectsByRef[ lRef ];
00333
00334 AttributeImpl* pAttribute = AttributeImpl::attachI( spAttribute, this, pOwner );
00335 insertObject( pAttribute );
00336 return pAttribute;
00337 }
00338
00339 AspectImpl* ProjectImpl::processAspect( const AspectPtr& spAspect )
00340 {
00341 long lRef;
00342 COMCHECK2( spAspect, spAspect->get_MetaRef( &lRef ) );
00343 if ( m_mapObjectsByRef.find( lRef ) != m_mapObjectsByRef.end() )
00344 return ( AspectImpl* ) m_mapObjectsByRef[ lRef ];
00345
00346 AspectImpl* pAspect = AspectImpl::attachI( spAspect, this );
00347 insertObject( pAspect );
00348
00349 Util::ComPtr<IMgaMetaParts> spParts;
00350 COMCHECK2( spAspect, spAspect->get_Parts( spParts.Addr() ) );
00351 MGACOLL_ITERATE( IMgaMetaPart, spParts.p ) {
00352 ContainmentPartImpl* pPart = ContainmentPartImpl::attachI( MGACOLL_ITER, this );
00353 ContainmentPtr spRole;
00354 COMCHECK2( MGACOLL_ITER, MGACOLL_ITER->get_Role( spRole.Addr() ) );
00355 pPart->m_pContainment = ContainmentImpl::attachI( spRole, this );
00356 pPart->m_pAspect = pAspect;
00357 insertObject( pPart );
00358 } MGACOLL_ITERATE_END;
00359
00360 return pAspect;
00361 }
00362
00363 void ProjectImpl::insertObject( ObjectImpl* pObject )
00364 {
00365 m_mapObjectsByRef[ pObject->getRef() ] = pObject;
00366 ObjectType eType = pObject->getType();
00367 m_mapObjectsByType[ eType ].insert( pObject );
00368
00369 if ( eType >= OT_Model && eType <= OT_Folder || eType == OT_Aspect )
00370 m_mapObjectsByName[ pObject->getName() ] = pObject;
00371 }
00372
00373 std::set<ContainmentImpl*> ProjectImpl::getGlobalRoles( const std::string& strDescIn ) const
00374 {
00375 std::set<ContainmentImpl*> setRoles;
00376 size_t iPos = strDescIn.find( " " );
00377 std::string strDesc = ( iPos == std::string::npos ) ? strDescIn : strDescIn.substr( 0, iPos );
00378 for ( std::set<ObjectImpl*>::const_iterator it = ( (ProjectImpl* ) this )->m_mapObjectsByType[ OT_Role ].begin() ; it != ( (ProjectImpl* ) this )->m_mapObjectsByType[ OT_Role ].end() ; ++it ) {
00379 if ( ( ( ContainmentImpl*) (*it) )->getChild()->getName() == strDesc )
00380 setRoles.insert( (ContainmentImpl*) *it );
00381 }
00382 return getRoles( setRoles, ( iPos == std::string::npos ) ? "" : strDescIn.substr( iPos + 1 ), false );
00383 }
00384
00385 std::set<ContainmentImpl*> ProjectImpl::getLocalRoles( FCOImpl* pKind, const std::string& strDescIn ) const
00386 {
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397 std::set<ModelImpl*> setModels;
00398 std::set<ObjectImpl*>::const_iterator it;
00399 for ( it = ( (ProjectImpl* ) this )->m_mapObjectsByType[ OT_Role ].begin() ; it != ( (ProjectImpl* ) this )->m_mapObjectsByType[ OT_Role ].end() ; ++it )
00400 if ( ( ( ContainmentImpl*) (*it) )->getChild() == pKind )
00401 setModels.insert( ( ( ContainmentImpl*) (*it) )->getParent() );
00402
00403
00404 std::set<ContainmentImpl*> setRoles;
00405 if ( setModels.empty() )
00406 return setRoles;
00407
00408 size_t iPos = strDescIn.find( " " );
00409
00410 std::string strDesc = ( iPos == std::string::npos ) ? strDescIn : strDescIn.substr( 0, iPos );
00411
00412
00413 for ( it = ( (ProjectImpl* ) this )->m_mapObjectsByType[ OT_Role ].begin() ; it != ( (ProjectImpl* ) this )->m_mapObjectsByType[ OT_Role ].end() ; ++it ) {
00414
00415 if ( (*it)->getName() == strDesc ) {
00416 bool bFound = false;
00417
00418 for ( std::set<ModelImpl*>::iterator it2 = setModels.begin() ; it2 != setModels.end() ; it2++ )
00419 if ( ( ( ContainmentImpl*) (*it) )->getParent() == *it2 ) {
00420 bFound = true;
00421 break;
00422 }
00423 if ( bFound )
00424 {
00425
00426 setRoles.insert( (ContainmentImpl*) *it );
00427 }
00428 }
00429 }
00430
00431 std::set<ContainmentImpl*> res = getRoles( setRoles, ( iPos == std::string::npos ) ? "" : strDescIn.substr( iPos + 1 ), true );
00432
00433 return res;
00434 }
00435
00436 std::set<ContainmentImpl*> ProjectImpl::getRoles( const std::set<ContainmentImpl*>& setIn, const std::string& strDescIn, bool bResolveReference ) const
00437 {
00438
00439
00440
00441
00442
00443 if ( strDescIn.empty() )
00444 return setIn;
00445
00446 size_t iPos = strDescIn.find( " " );
00447
00448 std::string strDesc = ( iPos == std::string::npos ) ? strDescIn : strDescIn.substr( 0, iPos );
00449
00450
00451 std::set<ContainmentImpl*> setRolesResolved;
00452 std::set<FolderContainmentImpl*> setFolderRolesResolved;
00453
00454
00455
00456
00457
00458 getRolesResolved( setIn, bResolveReference, setRolesResolved, setFolderRolesResolved );
00459
00460 std::set<ContainmentImpl*> setRolesOut;
00461 if ( setRolesResolved.empty() && setFolderRolesResolved.empty())
00462 return setRolesOut;
00463
00464
00465 for ( std::set<ObjectImpl*>::const_iterator it = ( (ProjectImpl* ) this )->m_mapObjectsByType[ OT_Role ].begin() ; it != ( (ProjectImpl* ) this )->m_mapObjectsByType[ OT_Role ].end() ; ++it ) {
00466
00467 if ( ( ( ContainmentImpl*) (*it) )->getName() == strDesc ) {
00468 bool bFound = false;
00469
00470
00471
00472 for ( std::set<ContainmentImpl*>::iterator it2 = setRolesResolved.begin() ; it2 != setRolesResolved.end() ; ++it2 )
00473 if ( ( ( ContainmentImpl*) (*it) )->getParent() == (*it2)->getChild() ) {
00474 bFound = true;
00475 break;
00476 }
00477
00478
00479
00480 for ( std::set<FolderContainmentImpl*>::iterator it3 = setFolderRolesResolved.begin() ; !bFound && it3 != setFolderRolesResolved.end() ; ++it3 )
00481 if ( ( ( ContainmentImpl*) (*it) )->getParent() == (*it3)->getChild() ) {
00482 bFound = true;
00483 break;
00484 }
00485
00486
00487
00488 if ( bFound )
00489 {
00490 setRolesOut.insert( (ContainmentImpl*) *it );
00491 std::string pn = ((ContainmentImpl*) *it)->getParent()->getName();
00492 std::string cn = ((ContainmentImpl*) *it)->getChild()->getName();
00493 }
00494 }
00495 }
00496
00497
00498 return getRoles( setRolesOut, ( iPos == std::string::npos ) ? "" : strDescIn.substr( iPos + 1 ), bResolveReference );
00499 }
00500
00501 void ProjectImpl::getRolesResolved(
00502 const std::set<ContainmentImpl*>& setIn,
00503 bool bResolveReference,
00504 std::set<ContainmentImpl*>& setRolesRes,
00505 std::set<FolderContainmentImpl*>& setFolderRolesRes
00506 ) const
00507 {
00508 if ( setIn.empty() )
00509 return;
00510
00511
00512 for ( std::set<ContainmentImpl*>::const_iterator it = setIn.begin() ; it != setIn.end() ; ++it )
00513 {
00514 std::string rolrname = (*it)->getChild()->getName();
00515 if ( (*it)->getChild()->getType() == OT_Model )
00516 setRolesRes.insert( *it );
00517 else if ( bResolveReference && (*it)->getChild()->getType() == OT_Reference )
00518 {
00519
00520
00521
00522
00523 for ( std::set<ReferenceAssocImpl*>::const_iterator itr = m_setReferenceAssocs.begin() ; itr != m_setReferenceAssocs.end() ; ++itr )
00524 {
00525
00526 if ((*itr)->getReference() == (*it)->getChild())
00527 {
00528
00529 FCOImpl * referee = (*itr)->getTarget();
00530
00531 if ( referee->getType() == OT_Model )
00532 {
00533
00534
00535
00536 std::set<ContainmentImpl*> the_roles_of_referee;
00537
00538
00539 for ( std::set<ObjectImpl*>::const_iterator role_it = ( (ProjectImpl* ) this )->m_mapObjectsByType[ OT_Role ].begin() ; role_it != ( (ProjectImpl* ) this )->m_mapObjectsByType[ OT_Role ].end() ; ++role_it )
00540 {
00541
00542
00543 {
00544
00545 if ( ( ( ContainmentImpl*) (*role_it) )->getChild() == referee )
00546 {
00547 the_roles_of_referee.insert( ( ContainmentImpl*) (*role_it) );
00548 }
00549 }
00550 }
00551
00552
00553 std::set<FolderContainmentImpl *> the_folder_roles_of_referee;
00554
00555 for ( std::set<FolderContainmentImpl*>::const_iterator fold_cont_it = m_setFolderContainments.begin(); fold_cont_it != m_setFolderContainments.end(); ++fold_cont_it)
00556 {
00557
00558
00559 {
00560
00561 if ( ( *fold_cont_it )->getChild() == referee )
00562 {
00563 the_folder_roles_of_referee.insert( *fold_cont_it );
00564 }
00565 }
00566 }
00567
00568
00569
00570
00571 for ( std::set<ContainmentImpl*>::iterator the_it = the_roles_of_referee.begin(); the_it != the_roles_of_referee.end(); ++the_it )
00572 setRolesRes.insert( *the_it );
00573
00574 for ( std::set<FolderContainmentImpl*>::iterator the_it2 = the_folder_roles_of_referee.begin(); the_it2 != the_folder_roles_of_referee.end(); ++the_it2 )
00575 setFolderRolesRes.insert( *the_it2 );
00576 }
00577 }
00578 }
00579 }
00580 }
00581 return;
00582 }
00583
00584
00585 ProjectImpl::~ProjectImpl()
00586 {
00587 mapProjects.erase( m_spProject );
00588 m_spProject = NULL;
00589 for ( int iType = OT_Model ; iType <= OT_Part ; iType++ )
00590 for ( ObjectSet::iterator it = m_mapObjectsByType[ iType ].begin() ; it != m_mapObjectsByType[ iType ].end() ; ++it )
00591 delete *it;
00592 for ( std::set<FolderContainmentImpl*>::iterator fciI = m_setFolderContainments.begin() ; fciI != m_setFolderContainments.end() ; ++fciI )
00593 delete *fciI;
00594 for ( std::set<ReferenceAssocImpl*>::iterator raiI = m_setReferenceAssocs.begin() ; raiI != m_setReferenceAssocs.end() ; ++raiI )
00595 delete *raiI;
00596 for ( std::set<SetMembershipImpl*>::iterator smiI = m_setSetMemberships.begin() ; smiI != m_setSetMemberships.end() ; ++smiI )
00597 delete *smiI;
00598 for ( std::set<AttributeAggregationImpl*>::iterator aaiI = m_setAttributeAggregations.begin() ; aaiI != m_setAttributeAggregations.end() ; ++aaiI )
00599 delete *aaiI;
00600 for ( std::set<ConnectionEndImpl*>::iterator ceriI = m_setConnectionEnds.begin() ; ceriI != m_setConnectionEnds.end() ; ++ceriI )
00601 delete *ceriI;
00602 for ( std::set<ModelInAspectImpl*>::iterator miaI = m_setModelInAspects.begin() ; miaI != m_setModelInAspects.end() ; ++miaI )
00603 delete *miaI;
00604 }
00605
00606 bool ProjectImpl::setDeleted()
00607 {
00608 return isDeleted();
00609 }
00610
00611 ProjectPtr ProjectImpl::getProjectI() const
00612 {
00613 return m_spProject;
00614 }
00615
00616 std::string ProjectImpl::getName() const
00617 {
00618 CComBSTR bstrName;
00619 COMCHECK2( m_spProject, m_spProject->get_Name( &bstrName ) );
00620 return Util::Copy( bstrName );
00621 }
00622
00623 std::string ProjectImpl::getDisplayedName() const
00624 {
00625 CComBSTR bstrDName;
00626 COMCHECK2( m_spProject, m_spProject->get_DisplayedName( &bstrDName ) );
00627 return Util::Copy( bstrDName );
00628 }
00629
00630 std::string ProjectImpl::getAuthor() const
00631 {
00632 CComBSTR bstrAuthor;
00633 COMCHECK2( m_spProject, m_spProject->get_Author( &bstrAuthor ) );
00634 return Util::Copy( bstrAuthor );
00635 }
00636
00637 std::string ProjectImpl::getComment() const
00638 {
00639 CComBSTR bstrComment;
00640 COMCHECK2( m_spProject, m_spProject->get_Comment( &bstrComment ) );
00641 return Util::Copy( bstrComment );
00642 }
00643
00644 std::string ProjectImpl::getCreationTime() const
00645 {
00646 CComBSTR bstrTime;
00647 COMCHECK2( m_spProject, m_spProject->get_CreatedAt( &bstrTime ) );
00648 return Util::Copy( bstrTime );
00649 }
00650
00651 FolderImpl* ProjectImpl::getRootFolder() const
00652 {
00653 return m_pRootFolder;
00654 }
00655
00656 std::string ProjectImpl::getInfoString( bool bWithIdentifiers ) const
00657 {
00658 std::string strInfo( "MON::Project [" );
00659 if ( bWithIdentifiers )
00660 strInfo += "name: ";
00661 return strInfo + getName() + "]";
00662 }
00663
00664 const ProjectImpl::ObjectSet& ProjectImpl::getObjects( ObjectType eType ) const
00665 {
00666 return ( (ProjectImpl*) this )->m_mapObjectsByType[ (int) eType ];
00667 }
00668
00669 const std::set<FolderContainmentImpl*>& ProjectImpl::getFolderContainments() const
00670 {
00671 return m_setFolderContainments;
00672 }
00673
00674 const std::set<AttributeAggregationImpl*>& ProjectImpl::getAttributeAggregations() const
00675 {
00676 return m_setAttributeAggregations;
00677 }
00678
00679 const std::set<ReferenceAssocImpl*>& ProjectImpl::getReferenceAssocs() const
00680 {
00681 return m_setReferenceAssocs;
00682 }
00683
00684 const std::set<SetMembershipImpl*>& ProjectImpl::getSetMemberships() const
00685 {
00686 return m_setSetMemberships;
00687 }
00688
00689 const std::set<ConnectionEndImpl*>& ProjectImpl::getConnectionEnds() const
00690 {
00691 return m_setConnectionEnds;
00692 }
00693
00694 const std::set<ModelInAspectImpl*>& ProjectImpl::getModelInAspects() const
00695 {
00696 return m_setModelInAspects;
00697 }
00698
00699 ObjectImpl* ProjectImpl::findByRef( long lRef ) const
00700 {
00701 return ( m_mapObjectsByRef.find( lRef ) != m_mapObjectsByRef.end() ) ? ( (ProjectImpl*) this )->m_mapObjectsByRef[ lRef ] : NULL;
00702 }
00703
00704 ObjectImpl* ProjectImpl::findByName( const std::string& strName ) const
00705 {
00706 return ( m_mapObjectsByName.find( strName ) != m_mapObjectsByName.end() ) ? ( (ProjectImpl*) this )->m_mapObjectsByName[ strName ] : NULL;
00707 }
00708
00709
00710
00711
00712
00713
00714
00715
00716 ObjectImpl::ObjectMap ObjectImpl::mapObjects;
00717
00718 ObjectImpl::ObjectImpl( IMgaMetaBase* spObject, ProjectImpl* pProject )
00719 : Util::GenRefCounted( false, pProject ), m_pProject( pProject ), m_spObject( spObject )
00720 {
00721 mapObjects.insert( ObjectImpl::ObjectMap::value_type( spObject, this ) );
00722 }
00723
00724 ObjectImpl* ObjectImpl::attachI( IMgaMetaBase* spObject, ProjectImpl* pProject )
00725 {
00726 CComQIPtr<IMgaMetaFCO> spFCO = spObject;
00727 if ( spFCO )
00728 return FCOImpl::attachI( spFCO, pProject );
00729 CComQIPtr<IMgaMetaFolder> spFolder = spObject;
00730 if ( spFolder )
00731 return FolderImpl::attachI( spFolder, pProject );
00732 CComQIPtr<IMgaMetaAttribute> spAttribute = spObject;
00733 if ( spAttribute )
00734 return AttributeImpl::attachI( spAttribute, pProject );
00735 CComQIPtr<IMgaMetaAspect> spAspect = spObject;
00736 if ( spAspect )
00737 return AspectImpl::attachI( spAspect, pProject );
00738 CComQIPtr<IMgaMetaRole> spRole = spObject;
00739 if ( spRole )
00740 return ContainmentImpl::attachI( spRole, pProject );
00741 CComQIPtr<IMgaMetaPart> spPart = spObject;
00742 if ( spPart )
00743 return ContainmentPartImpl::attachI( spPart, pProject );
00744 ASSERTTHROW( Util::Exception( "Unprocessed Object Type" ) );
00745 }
00746
00747 ObjectImpl* ObjectImpl::attach( IMgaMetaBase* spObject )
00748 {
00749 return attachI( spObject );
00750 }
00751
00752 ObjectImpl* ObjectImpl::find( IMgaMetaBase* spObject )
00753 {
00754 ObjectImpl::ObjectMap::iterator it = mapObjects.find( spObject );
00755 return ( it == mapObjects.end() ) ? NULL : it->second;
00756 }
00757
00758 ObjectImpl::~ObjectImpl()
00759 {
00760 for ( RegistryMap::iterator it = m_mapRegistry.begin() ; it != m_mapRegistry.end() ; ++it )
00761 delete it->second;
00762 m_mapRegistry.clear();
00763
00764 mapObjects.erase( ObjectPtr( m_spObject ) );
00765 m_spObject = NULL;
00766
00767 }
00768
00769 bool ObjectImpl::setDeleted()
00770 {
00771 return isDeleted();
00772 }
00773
00774 ObjectPtr ObjectImpl::getObjectI() const
00775 {
00776 return m_spObject;
00777 }
00778
00779 ProjectImpl* ObjectImpl::getProject() const
00780 {
00781 return m_pProject;
00782 }
00783
00784 long ObjectImpl::getRef() const
00785 {
00786 long lRef;
00787 COMCHECK2( m_spObject, m_spObject->get_MetaRef( &lRef ) );
00788 return lRef;
00789 }
00790
00791 std::string ObjectImpl::getName() const
00792 {
00793 CComBSTR bstrName;
00794 COMCHECK2( m_spObject, m_spObject->get_Name( &bstrName ) );
00795 return Util::Copy( bstrName );
00796 }
00797
00798 std::string ObjectImpl::getDisplayedName() const
00799 {
00800 CComBSTR bstrDName;
00801 COMCHECK2( m_spObject, m_spObject->get_DisplayedName( &bstrDName ) );
00802 return Util::Copy( bstrDName );
00803 }
00804
00805 ObjectType ObjectImpl::getType() const
00806 {
00807 objtype_enum eType;
00808 COMCHECK2( m_spObject, m_spObject->get_ObjType( &eType ) );
00809 return ( ObjectType ) eType;
00810 }
00811
00812 std::string ObjectImpl::getInfoStringHelper( const std::string& strStereotype, bool bWithIdentifiers, bool bWithRef ) const
00813 {
00814 std::string strInfo( "MON::" + strStereotype + " [" );
00815 if ( bWithIdentifiers )
00816 strInfo += "name: ";
00817 strInfo += getName();
00818 if ( bWithRef ) {
00819 strInfo += ", ";
00820 if ( bWithIdentifiers )
00821 strInfo += "ref: ";
00822 strInfo += _ref2str( getRef() );
00823 }
00824 return strInfo + "]";
00825 }
00826
00827 RegistryNodeImpl* ObjectImpl::getRegistryNode( const std::string& strPath )
00828 {
00829 std::string strPath2 = _slashes( strPath );
00830 if ( strPath2.empty() || strPath2 == "/" )
00831 strPath2 = "/";
00832 else
00833 if ( strPath2[ strPath2.size() - 1 ] == '/' )
00834 strPath2 = strPath2.substr( 0, strPath2.size() - 1 );
00835
00836 RegistryMap::iterator it = m_mapRegistry.find( strPath2 );
00837 if ( it != m_mapRegistry.end() )
00838 return it->second;
00839
00840 RegistryNodeImpl* pNode = NULL;
00841 if ( strPath2 == "/" )
00842 pNode = new RegistryNodeImpl( NULL, this, strPath2 );
00843 else {
00844 strPath2 = strPath2.substr( 1 );
00845 RegNodePtr spNode;
00846 COMCHECK2( m_spObject, m_spObject->get_RegistryNode( Util::Copy( strPath2 ), spNode.Addr() ) );
00847 pNode = new RegistryNodeImpl( spNode, this, strPath2.substr( 0, strPath.rfind( '/' ) + 1 ) );
00848 }
00849 m_mapRegistry.insert( RegistryMap::value_type( strPath2, pNode ) );
00850 return pNode;
00851 }
00852
00853
00854
00855
00856
00857
00858
00859 FolderImpl::FolderImpl( IMgaMetaFolder* spFolder, ProjectImpl* pProject )
00860 : ObjectImpl( spFolder, pProject )
00861 {
00862 Util::ComPtr<IMgaConstraints> spConstraints;
00863 COMCHECK2( spFolder, spFolder->get_Constraints( spConstraints.Addr() ) );
00864 MGACOLL_ITERATE( IMgaConstraint, spConstraints.p ) {
00865 constraint_type_enum eType;
00866 COMCHECK2( MGACOLL_ITER, MGACOLL_ITER->get_Type( &eType ) );
00867 if ( eType != CONSTRAINT_TYPE_FUNCTION )
00868 m_setConstraints.insert( new ConstraintImpl( MGACOLL_ITER, this ) );
00869 } MGACOLL_ITERATE_END;
00870 }
00871
00872 FolderImpl* FolderImpl::attachI( IMgaMetaFolder* spFolder, ProjectImpl* pProject )
00873 {
00874 if ( ! spFolder )
00875 return NULL;
00876 ObjectImpl* pObject = find( spFolder );
00877 if ( pObject )
00878 return (FolderImpl*) pObject;
00879 pProject = _getProject( spFolder, pProject );
00880 return new FolderImpl( spFolder, pProject );
00881 }
00882
00883 FolderImpl* FolderImpl::attach( IMgaMetaFolder* spFolder )
00884 {
00885 return attachI( spFolder );
00886 }
00887
00888 FolderImpl::~FolderImpl()
00889 {
00890 for ( std::set<ConstraintImpl*>::iterator it = m_setConstraints.begin() ; it != m_setConstraints.end() ; ++it )
00891 delete *it;
00892 }
00893
00894 std::string FolderImpl::getInfoString( bool bWithIdentifiers, bool bWithRef ) const
00895 {
00896 return getInfoStringHelper( "Folder", bWithIdentifiers, bWithRef );
00897 }
00898
00899 FolderPtr FolderImpl::getFolderI() const
00900 {
00901 CComQIPtr<IMgaMetaFolder> spFolder = getObjectI().p;
00902 return spFolder.p;
00903 }
00904
00905 std::set<ConstraintImpl*> FolderImpl::getConstraints() const
00906 {
00907 return m_setConstraints;
00908 }
00909
00910
00911
00912
00913
00914
00915
00916 FCOImpl::FCOImpl( IMgaMetaFCO* spFCO, ProjectImpl* pProject )
00917 : ObjectImpl( spFCO, pProject )
00918 {
00919 Util::ComPtr<IMgaConstraints> spConstraints;
00920 COMCHECK2( spFCO, spFCO->get_Constraints( spConstraints.Addr() ) );
00921 MGACOLL_ITERATE( IMgaConstraint, spConstraints.p ) {
00922 constraint_type_enum eType;
00923 COMCHECK2( MGACOLL_ITER, MGACOLL_ITER->get_Type( &eType ) );
00924 if ( eType != CONSTRAINT_TYPE_FUNCTION )
00925 m_setConstraints.insert( new ConstraintImpl( MGACOLL_ITER, this ) );
00926 } MGACOLL_ITERATE_END;
00927 }
00928
00929 FCOImpl* FCOImpl::attachI( IMgaMetaFCO* spFCO, ProjectImpl* pProject )
00930 {
00931 CComQIPtr<IMgaMetaAtom> spAtom = spFCO;
00932 if ( spAtom )
00933 return AtomImpl::attachI( spAtom, pProject );
00934 CComQIPtr<IMgaMetaModel> spModel = spFCO;
00935 if ( spModel )
00936 return ModelImpl::attachI( spModel, pProject );
00937 CComQIPtr<IMgaMetaConnection> spConnection = spFCO;
00938 if ( spConnection )
00939 return ConnectionImpl::attachI( spConnection, pProject );
00940 CComQIPtr<IMgaMetaReference> spReference = spFCO;
00941 if ( spReference )
00942 return ReferenceImpl::attachI( spReference, pProject );
00943 CComQIPtr<IMgaMetaSet> spSet = spFCO;
00944 if ( spSet )
00945 return SetImpl::attachI( spSet, pProject );
00946 ASSERTTHROW( Util::Exception( "Unprocessed FCO type!" ) );
00947 }
00948
00949 FCOImpl* FCOImpl::attach( IMgaMetaFCO* spFCO )
00950 {
00951 return attachI( spFCO );
00952 }
00953
00954 FCOImpl* FCOImpl::find( IMgaMetaFCO* spFCO )
00955 {
00956 return (FCOImpl*) ObjectImpl::find( spFCO );
00957 }
00958
00959 FCOImpl::~FCOImpl()
00960 {
00961 for ( std::set<ConstraintImpl*>::iterator it = m_setConstraints.begin() ; it != m_setConstraints.end() ; ++it )
00962 delete *it;
00963 }
00964
00965 FCOPtr FCOImpl::getFCOI() const
00966 {
00967 CComQIPtr<IMgaMetaFCO> spFCO = getObjectI().p;
00968 return spFCO.p;
00969 }
00970
00971 std::set<ConstraintImpl*> FCOImpl::getConstraints() const
00972 {
00973 return m_setConstraints;
00974 }
00975
00976 const std::set<AttributeImpl*>& FCOImpl::getAttributes() const
00977 {
00978 return m_setAttributes;
00979 }
00980
00981
00982
00983
00984
00985
00986
00987 AtomImpl::AtomImpl( IMgaMetaAtom* spAtom, ProjectImpl* pProject )
00988 : FCOImpl( spAtom, pProject )
00989 {
00990 }
00991
00992 AtomImpl* AtomImpl::attachI( IMgaMetaAtom* spAtom, ProjectImpl* pProject )
00993 {
00994 if ( ! spAtom )
00995 return NULL;
00996 FCOImpl* pFCO = FCOImpl::find( spAtom );
00997 if ( pFCO )
00998 return (AtomImpl*) pFCO;
00999 pProject = _getProject( spAtom, pProject );
01000 return new AtomImpl( spAtom, pProject );
01001 }
01002
01003 AtomImpl* AtomImpl::attach( IMgaMetaAtom* spAtom )
01004 {
01005 return attachI( spAtom );
01006 }
01007
01008 AtomImpl::~AtomImpl()
01009 {
01010 }
01011
01012 AtomPtr AtomImpl::getAtomI() const
01013 {
01014 CComQIPtr<IMgaMetaAtom> spAtom = getObjectI().p;
01015 return spAtom.p;
01016 }
01017
01018 std::string AtomImpl::getInfoString( bool bWithIdentifiers, bool bWithRef ) const
01019 {
01020 return getInfoStringHelper( "Atom", bWithIdentifiers, bWithRef );
01021 }
01022
01023
01024
01025
01026
01027
01028
01029 ModelImpl::ModelImpl( IMgaMetaModel* spModel, ProjectImpl* pProject )
01030 : FCOImpl( spModel, pProject )
01031 {
01032 }
01033
01034 ModelImpl* ModelImpl::attachI( IMgaMetaModel* spModel, ProjectImpl* pProject )
01035 {
01036 if ( ! spModel )
01037 return NULL;
01038 FCOImpl* pFCO = FCOImpl::find( spModel );
01039 if ( pFCO )
01040 return (ModelImpl*) pFCO;
01041 pProject = _getProject( spModel, pProject );
01042 return new ModelImpl( spModel, pProject );
01043 }
01044
01045 ModelImpl* ModelImpl::attach( IMgaMetaModel* spModel )
01046 {
01047 return attachI( spModel );
01048 }
01049
01050 ModelImpl::~ModelImpl()
01051 {
01052 }
01053
01054 ModelPtr ModelImpl::getModelI() const
01055 {
01056 CComQIPtr<IMgaMetaModel> spModel = getObjectI().p;
01057 return spModel.p;
01058 }
01059
01060 std::string ModelImpl::getInfoString( bool bWithIdentifiers, bool bWithRef ) const
01061 {
01062 return getInfoStringHelper( "Model", bWithIdentifiers, bWithRef );
01063 }
01064
01065
01066
01067
01068
01069
01070
01071 SetImpl::SetImpl( IMgaMetaSet* spSet, ProjectImpl* pProject )
01072 : FCOImpl( spSet, pProject )
01073 {
01074 }
01075
01076 SetImpl* SetImpl::attachI( IMgaMetaSet* spSet, ProjectImpl* pProject )
01077 {
01078 if ( ! spSet )
01079 return NULL;
01080 FCOImpl* pFCO = FCOImpl::find( spSet );
01081 if ( pFCO )
01082 return (SetImpl*) pFCO;
01083 pProject = _getProject( spSet, pProject );
01084 return new SetImpl( spSet, pProject );
01085 }
01086
01087 SetImpl* SetImpl::attach( IMgaMetaSet* spSet )
01088 {
01089 return attachI( spSet );
01090 }
01091
01092 SetImpl::~SetImpl()
01093 {
01094 }
01095
01096 SetPtr SetImpl::getSetI() const
01097 {
01098 CComQIPtr<IMgaMetaSet> spSet = getObjectI().p;
01099 return spSet.p;
01100 }
01101
01102 std::string SetImpl::getInfoString( bool bWithIdentifiers, bool bWithRef ) const
01103 {
01104 return getInfoStringHelper( "Set", bWithIdentifiers, bWithRef );
01105 }
01106
01107
01108
01109
01110
01111
01112
01113 ReferenceImpl::ReferenceImpl( IMgaMetaReference* spReference, ProjectImpl* pProject )
01114 : FCOImpl( spReference, pProject )
01115 {
01116 }
01117
01118 ReferenceImpl* ReferenceImpl::attachI( IMgaMetaReference* spReference, ProjectImpl* pProject )
01119 {
01120 if ( ! spReference )
01121 return NULL;
01122 FCOImpl* pFCO = FCOImpl::find( spReference );
01123 if ( pFCO )
01124 return (ReferenceImpl*) pFCO;
01125 pProject = _getProject( spReference, pProject );
01126 return new ReferenceImpl( spReference, pProject );
01127 }
01128
01129 ReferenceImpl* ReferenceImpl::attach( IMgaMetaReference* spReference )
01130 {
01131 return attachI( spReference );
01132 }
01133
01134 ReferenceImpl::~ReferenceImpl()
01135 {
01136 }
01137
01138 ReferencePtr ReferenceImpl::getReferenceI() const
01139 {
01140 CComQIPtr<IMgaMetaReference> spReference = getObjectI().p;
01141 return spReference.p;
01142 }
01143
01144 std::string ReferenceImpl::getInfoString( bool bWithIdentifiers, bool bWithRef ) const
01145 {
01146 return getInfoStringHelper( "Reference", bWithIdentifiers, bWithRef );
01147 }
01148
01149
01150
01151
01152
01153
01154
01155 ConnectionImpl::ConnectionImpl( IMgaMetaConnection* spConnection, ProjectImpl* pProject )
01156 : FCOImpl( spConnection, pProject )
01157 {
01158 }
01159
01160 ConnectionImpl* ConnectionImpl::attachI( IMgaMetaConnection* spConnection, ProjectImpl* pProject )
01161 {
01162 if ( ! spConnection )
01163 return NULL;
01164 FCOImpl* pFCO = FCOImpl::find( spConnection );
01165 if ( pFCO )
01166 return (ConnectionImpl*) pFCO;
01167 pProject = _getProject( spConnection, pProject );
01168 return new ConnectionImpl( spConnection, pProject );
01169 }
01170
01171 ConnectionImpl* ConnectionImpl::attach( IMgaMetaConnection* spConnection )
01172 {
01173 return attachI( spConnection );
01174 }
01175
01176 ConnectionImpl::~ConnectionImpl()
01177 {
01178 for ( std::set<ConnectionSpecImpl*>::iterator it = m_setConnSpecs.begin() ; it != m_setConnSpecs.end() ; ++it )
01179 delete *it;
01180 }
01181
01182 ConnectionPtr ConnectionImpl::getConnectionI() const
01183 {
01184 CComQIPtr<IMgaMetaConnection> spConnection = getObjectI().p;
01185 return spConnection.p;
01186 }
01187
01188 const std::set<ConnectionSpecImpl*>& ConnectionImpl::getConnectionSpecs() const
01189 {
01190 return m_setConnSpecs;
01191 }
01192
01193 bool ConnectionImpl::isSimple() const
01194 {
01195 VARIANT_BOOL vbSimple;
01196 COMCHECK2( getConnectionI(), getConnectionI()->get_IsSimple( &vbSimple ) );
01197 return vbSimple == VARIANT_TRUE;
01198 }
01199
01200 bool ConnectionImpl::isBidirectional() const
01201 {
01202 return m_bBidirectional;
01203 }
01204
01205 std::string ConnectionImpl::getInfoString( bool bWithIdentifiers, bool bWithRef ) const
01206 {
01207 return getInfoStringHelper( "Connection", bWithIdentifiers, bWithRef );
01208 }
01209
01210
01211
01212
01213
01214
01215
01216 ContainmentImpl::ContainmentImpl( IMgaMetaRole* spRole, ProjectImpl* pProject )
01217 : ObjectImpl( spRole, pProject ), m_pParent( NULL ), m_pChild( NULL )
01218 {
01219 }
01220
01221 ContainmentImpl* ContainmentImpl::attachI( IMgaMetaRole* spRole, ProjectImpl* pProject )
01222 {
01223 if ( ! spRole )
01224 return NULL;
01225 ObjectImpl* pObject = find( spRole );
01226 if ( pObject )
01227 return (ContainmentImpl*) pObject;
01228 pProject = _getProject( spRole, pProject );
01229 return new ContainmentImpl( spRole, pProject );
01230 }
01231
01232 ContainmentImpl* ContainmentImpl::attach( IMgaMetaRole* spRole )
01233 {
01234 return attachI( spRole );
01235 }
01236
01237 ContainmentImpl::~ContainmentImpl()
01238 {
01239 }
01240
01241 ContainmentPtr ContainmentImpl::getContainmentI() const
01242 {
01243 CComQIPtr<IMgaMetaRole> spContainment = getObjectI().p;
01244 return spContainment.p;
01245 }
01246
01247 ModelImpl* ContainmentImpl::getParent() const
01248 {
01249 if ( ! m_pParent ) {
01250 ModelPtr spModel;
01251 COMCHECK2( getContainmentI(), getContainmentI()->get_ParentModel( spModel.Addr() ) );
01252 ( (ContainmentImpl*) this )->m_pParent = ModelImpl::attachI( spModel, getProject() );
01253 }
01254 return m_pParent;
01255 }
01256
01257 FCOImpl* ContainmentImpl::getChild() const
01258 {
01259 if ( ! m_pChild ) {
01260 FCOPtr spFCO;
01261 COMCHECK2( getContainmentI(), getContainmentI()->get_Kind( spFCO.Addr() ) );
01262 ( (ContainmentImpl*) this )->m_pChild = (FCOImpl*) find( spFCO );
01263 }
01264 return m_pChild;
01265 }
01266
01267 std::string ContainmentImpl::getInfoString( bool bWithIdentifiers, bool bWithRef ) const
01268 {
01269 std::string strInfo( "MON::Containment [" );
01270 if ( bWithIdentifiers )
01271 strInfo += "model: ";
01272 strInfo += getParent()->getInfoString( bWithIdentifiers, bWithRef ) + ", ";
01273 if ( bWithIdentifiers )
01274 strInfo += "name: ";
01275 strInfo += getName();
01276 if ( bWithRef ) {
01277 strInfo += ", ";
01278 if ( bWithIdentifiers )
01279 strInfo += "ref: ";
01280 strInfo += _ref2str( getRef() );
01281 }
01282 return strInfo + "]";
01283 }
01284
01285
01286
01287
01288
01289
01290
01291 AttributeImpl::AttributeImpl( IMgaMetaAttribute* spAttribute, ProjectImpl* pProject, FCOImpl* pOwner )
01292 : ObjectImpl( spAttribute, pProject ), m_pOwner( pOwner )
01293 {
01294 }
01295
01296 AttributeImpl* AttributeImpl::attachI( IMgaMetaAttribute* spAttribute, ProjectImpl* pProject, FCOImpl* pFCO )
01297 {
01298 if ( ! spAttribute )
01299 return NULL;
01300 ObjectImpl* pObject = find( spAttribute );
01301 if ( pObject )
01302 return (AttributeImpl*) pObject;
01303 pProject = _getProject( spAttribute, pProject );
01304 return new AttributeImpl( spAttribute, pProject, pFCO );
01305 }
01306
01307 AttributeImpl* AttributeImpl::attach( IMgaMetaAttribute* spAttribute )
01308 {
01309 return attachI( spAttribute );
01310 }
01311
01312 AttributeImpl::~AttributeImpl()
01313 {
01314 }
01315
01316 AttributePtr AttributeImpl::getAttributeI() const
01317 {
01318 CComQIPtr<IMgaMetaAttribute> spAttribute = getObjectI().p;
01319 return spAttribute.p;
01320 }
01321
01322 FCOImpl* AttributeImpl::getOwner() const
01323 {
01324 return m_pOwner;
01325 }
01326
01327 Util::Variant AttributeImpl::getDefaultValue() const
01328 {
01329 CComVariant varValue;
01330 COMCHECK2( getAttributeI(), getAttributeI()->get_DefaultValue( &varValue ) );
01331 switch ( varValue.vt ) {
01332 case VT_EMPTY :
01333 return Util::Variant();
01334 case VT_I4 :
01335 return varValue.lVal;
01336 case VT_R8 :
01337 return varValue.dblVal;
01338 case VT_BSTR :
01339 return Util::Copy( CComBSTR( varValue.bstrVal ) );
01340 case VT_BOOL :
01341 return varValue.boolVal == VARIANT_TRUE;
01342 default :
01343 ASSERTTHROW( Util::Exception( "Unprocessed Attribute Default Value!" ) );
01344 }
01345 }
01346
01347 AttributeType AttributeImpl::getValueType() const
01348 {
01349 attval_enum eType;
01350 COMCHECK2( getAttributeI(), getAttributeI()->get_ValueType( &eType ) );
01351 if ( eType == ATTVAL_REFERENCE || eType == ATTVAL_DYNAMIC || eType == ATTVAL_NULL )
01352 ASSERTTHROW( Util::Exception( "Unprocessed Attribute Type!" ) );
01353 return (AttributeType) eType;
01354 }
01355
01356 std::vector<AttributeImpl::NameValue> AttributeImpl::getEnumItems() const
01357 {
01358 if ( getValueType() != AT_Enumeration )
01359 ASSERTTHROW( Util::Exception( "Only Enumeration Attribute has EnumerationItems!" ) );
01360
01361 std::vector<AttributeImpl::NameValue> vecResult;
01362 Util::ComPtr<IMgaMetaEnumItems> spItems;
01363 COMCHECK2( getAttributeI(), getAttributeI()->get_EnumItems( spItems.Addr() ) );
01364
01365 MGACOLL_ITERATE( IMgaMetaEnumItem, spItems.p ) {
01366 CComBSTR bstrName;
01367 COMCHECK2( MGACOLL_ITER, MGACOLL_ITER->get_DisplayedName( &bstrName ) );
01368 CComBSTR bstrValue;
01369 COMCHECK2( MGACOLL_ITER, MGACOLL_ITER->get_Value( &bstrValue ) );
01370 vecResult.push_back( AttributeImpl::NameValue( Util::Copy( bstrName ), Util::Copy( bstrValue ) ) );
01371 } MGACOLL_ITERATE_END;
01372
01373 return vecResult;
01374 }
01375
01376 std::string AttributeImpl::getInfoString( bool bWithIdentifiers, bool bWithRef ) const
01377 {
01378 return getInfoStringHelper( "Attribute", bWithIdentifiers, bWithRef );
01379 }
01380
01381
01382
01383
01384
01385
01386
01387 AspectImpl::AspectImpl( IMgaMetaAspect* spAspect, ProjectImpl* pProject )
01388 : ObjectImpl( spAspect, pProject )
01389 {
01390 }
01391
01392 AspectImpl* AspectImpl::attachI( IMgaMetaAspect* spAspect, ProjectImpl* pProject )
01393 {
01394 if ( ! spAspect )
01395 return NULL;
01396 ObjectImpl* pObject = find( spAspect );
01397 if ( pObject )
01398 return (AspectImpl*) pObject;
01399 pProject = _getProject( spAspect, pProject );
01400 return new AspectImpl( spAspect, pProject );
01401 }
01402
01403 AspectImpl* AspectImpl::attach( IMgaMetaAspect* spAspect )
01404 {
01405 return attachI( spAspect );
01406 }
01407
01408 AspectImpl::~AspectImpl()
01409 {
01410 }
01411
01412 AspectPtr AspectImpl::getAspectI() const
01413 {
01414 CComQIPtr<IMgaMetaAspect> spAspect = getObjectI().p;
01415 return spAspect.p;
01416 }
01417
01418 std::string AspectImpl::getInfoString( bool bWithIdentifiers, bool bWithRef ) const
01419 {
01420 return getInfoStringHelper( "Aspect", bWithIdentifiers, bWithRef );
01421 }
01422
01423
01424
01425
01426
01427
01428
01429 ContainmentPartImpl::ContainmentPartImpl( IMgaMetaPart* spPart, ProjectImpl* pProject )
01430 : ObjectImpl( spPart, pProject )
01431 {
01432 }
01433
01434 ContainmentPartImpl* ContainmentPartImpl::attachI( IMgaMetaPart* spPart, ProjectImpl* pProject )
01435 {
01436 if ( ! spPart )
01437 return NULL;
01438 ObjectImpl* pObject = find( spPart );
01439 if ( pObject )
01440 return (ContainmentPartImpl*) pObject;
01441 pProject = _getProject( spPart, pProject );
01442 return new ContainmentPartImpl( spPart, pProject );
01443 }
01444
01445 ContainmentPartImpl::~ContainmentPartImpl()
01446 {
01447 }
01448
01449 ContainmentPartImpl* ContainmentPartImpl::attach( IMgaMetaPart* spPart )
01450 {
01451 return attachI( spPart );
01452 }
01453
01454 PartPtr ContainmentPartImpl::getPartI() const
01455 {
01456 CComQIPtr<IMgaMetaPart> spPart = getObjectI().p;
01457 return spPart.p;
01458 }
01459
01460 bool ContainmentPartImpl::isPrimary() const
01461 {
01462 VARIANT_BOOL vbPrimary;
01463 COMCHECK2( getPartI(), getPartI()->get_IsPrimary( &vbPrimary ) );
01464 return vbPrimary == VARIANT_TRUE;
01465 }
01466
01467 bool ContainmentPartImpl::isLinked() const
01468 {
01469 VARIANT_BOOL vbLinked;
01470 COMCHECK2( getPartI(), getPartI()->get_IsLinked( &vbLinked ) );
01471 return vbLinked == VARIANT_TRUE;
01472 }
01473
01474 ContainmentImpl* ContainmentPartImpl::getContainment() const
01475 {
01476 if ( ! m_pContainment ) {
01477 ContainmentPtr spRole;
01478 COMCHECK2( getPartI(), getPartI()->get_Role( spRole.Addr() ) );
01479 ( (ContainmentPartImpl*) this )->m_pContainment = ContainmentImpl::attachI( spRole, getProject() );
01480 }
01481 return m_pContainment;
01482 }
01483
01484 AspectImpl* ContainmentPartImpl::getAspect() const
01485 {
01486 if ( ! m_pAspect ) {
01487 AspectPtr spAspect;
01488 COMCHECK2( getPartI(), getPartI()->get_ParentAspect( spAspect.Addr() ) );
01489 ( (ContainmentPartImpl*) this )->m_pAspect = AspectImpl::attachI( spAspect, getProject() );
01490 }
01491 return m_pAspect;
01492 }
01493
01494 std::string ContainmentPartImpl::getInfoString( bool bWithIdentifiers, bool bWithRef ) const
01495 {
01496 std::string strInfo( "MON::ContainmentPart [" );
01497 if ( bWithIdentifiers )
01498 strInfo += "containment: ";
01499 strInfo += getContainment()->getInfoString( bWithIdentifiers, bWithRef ) + ", ";
01500 if ( bWithIdentifiers )
01501 strInfo += "aspect: ";
01502 strInfo += getAspect()->getInfoString( bWithIdentifiers, bWithRef ) + ", ";
01503 if ( bWithRef ) {
01504 strInfo += ", ";
01505 if ( bWithIdentifiers )
01506 strInfo += "ref: ";
01507 strInfo += _ref2str( getRef() );
01508 }
01509 return strInfo + "]";
01510 }
01511
01512
01513
01514
01515
01516
01517
01518 FolderContainmentImpl::FolderContainmentImpl( FolderImpl* pParent, ObjectImpl* pChild )
01519 : m_pParent( pParent ), m_pChild( pChild )
01520 {
01521 }
01522
01523 FolderContainmentImpl::~FolderContainmentImpl()
01524 {
01525 }
01526
01527 bool FolderContainmentImpl::setDeleted()
01528 {
01529 return isDeleted();
01530 }
01531
01532 ProjectImpl* FolderContainmentImpl::getProject() const
01533 {
01534 return m_pParent->getProject();
01535 }
01536
01537 FolderImpl* FolderContainmentImpl::getParent() const
01538 {
01539 return m_pParent;
01540 }
01541
01542 ObjectImpl* FolderContainmentImpl::getChild() const
01543 {
01544 return m_pChild;
01545 }
01546
01547 std::string FolderContainmentImpl::getInfoString( bool bWithIdentifiers, bool bWithRef ) const
01548 {
01549 std::string strInfo( "MON::FolderContainment [" );
01550 if ( bWithIdentifiers )
01551 strInfo += "folder: ";
01552 strInfo += m_pParent->getInfoString( bWithIdentifiers, bWithRef ) + ", ";
01553 if ( bWithIdentifiers )
01554 strInfo += "child: ";
01555 return strInfo + m_pChild->getInfoString( bWithIdentifiers, bWithRef ) + "]";
01556 }
01557
01558
01559
01560
01561
01562
01563
01564 AttributeAggregationImpl::AttributeAggregationImpl( FCOImpl* pFCO, AttributeImpl* pAttribute )
01565 : Util::GenRefCounted( false, pFCO->getProject() ), m_pFCO( pFCO ), m_pAttribute( pAttribute )
01566 {
01567 }
01568
01569 AttributeAggregationImpl::~AttributeAggregationImpl()
01570 {
01571 }
01572
01573 bool AttributeAggregationImpl::setDeleted()
01574 {
01575 return isDeleted();
01576 }
01577
01578 ProjectImpl* AttributeAggregationImpl::getProject() const
01579 {
01580 return m_pFCO->getProject();
01581 }
01582
01583 FCOImpl* AttributeAggregationImpl::getFCO() const
01584 {
01585 return m_pFCO;
01586 }
01587
01588 AttributeImpl* AttributeAggregationImpl::getAttribute() const
01589 {
01590 return m_pAttribute;
01591 }
01592
01593 std::string AttributeAggregationImpl::getInfoString( bool bWithIdentifiers, bool bWithRef ) const
01594 {
01595 std::string strInfo( "MON::AttributeAggregation [" );
01596 if ( bWithIdentifiers )
01597 strInfo += "fco: ";
01598 strInfo += m_pFCO->getInfoString( bWithIdentifiers, bWithRef ) + ", ";
01599 if ( bWithIdentifiers )
01600 strInfo += "attribute: ";
01601 return strInfo + m_pAttribute->getInfoString( bWithIdentifiers, bWithRef ) + "]";
01602 }
01603
01604
01605
01606
01607
01608
01609
01610 ReferenceAssocImpl::ReferenceAssocImpl( ReferenceImpl* pReference, FCOImpl* pTarget )
01611 : Util::GenRefCounted( false, pReference->getProject() ), m_pReference( pReference ), m_pTarget( pTarget )
01612 {
01613 }
01614
01615 ReferenceAssocImpl::~ReferenceAssocImpl()
01616 {
01617 }
01618
01619 bool ReferenceAssocImpl::setDeleted()
01620 {
01621 return isDeleted();
01622 }
01623
01624 ProjectImpl* ReferenceAssocImpl::getProject() const
01625 {
01626 return m_pReference->getProject();
01627 }
01628
01629 ReferenceImpl* ReferenceAssocImpl::getReference() const
01630 {
01631 return m_pReference;
01632 }
01633
01634 FCOImpl* ReferenceAssocImpl::getTarget() const
01635 {
01636 return m_pTarget;
01637 }
01638
01639 std::string ReferenceAssocImpl::getInfoString( bool bWithIdentifiers, bool bWithRef ) const
01640 {
01641 std::string strInfo( "MON::ReferenceAssociation [" );
01642 if ( bWithIdentifiers )
01643 strInfo += "reference: ";
01644 strInfo += m_pReference->getInfoString( bWithIdentifiers, bWithRef ) + ", ";
01645 if ( bWithIdentifiers )
01646 strInfo += "target: ";
01647 return strInfo + m_pTarget->getInfoString( bWithIdentifiers, bWithRef ) + "]";
01648 }
01649
01650
01651
01652
01653
01654
01655
01656 SetMembershipImpl::SetMembershipImpl( SetImpl* pSet, ContainmentImpl* pMember )
01657 : Util::GenRefCounted( false, pSet->getProject() ), m_pSet( pSet ), m_pMember( pMember )
01658 {
01659 }
01660
01661 SetMembershipImpl::~SetMembershipImpl()
01662 {
01663 }
01664
01665 bool SetMembershipImpl::setDeleted()
01666 {
01667 return isDeleted();
01668 }
01669
01670 ProjectImpl* SetMembershipImpl::getProject() const
01671 {
01672 return m_pSet->getProject();
01673 }
01674
01675 SetImpl* SetMembershipImpl::getSet() const
01676 {
01677 return m_pSet;
01678 }
01679
01680 ContainmentImpl* SetMembershipImpl::getMember() const
01681 {
01682 return m_pMember;
01683 }
01684
01685 std::string SetMembershipImpl::getInfoString( bool bWithIdentifiers, bool bWithRef ) const
01686 {
01687 std::string strInfo( "MON::SetMembership [" );
01688 if ( bWithIdentifiers )
01689 strInfo += "set: ";
01690 strInfo += m_pSet->getInfoString( bWithIdentifiers, bWithRef ) + ", ";
01691 if ( bWithIdentifiers )
01692 strInfo += "member: ";
01693 return strInfo + m_pMember->getInfoString( bWithIdentifiers, bWithRef ) + "]";
01694 }
01695
01696
01697
01698
01699
01700
01701
01702 ConnectionSpecImpl::ConnectionSpecImpl( ConnectionImpl* pConnection, int iNum )
01703 : Util::GenRefCounted( false, pConnection ), m_pConnection( pConnection ), m_iNum( iNum )
01704 {
01705 }
01706
01707 ConnectionSpecImpl::~ConnectionSpecImpl()
01708 {
01709 for ( std::set<ConnectionRoleImpl*>::iterator it = m_setRoles.begin() ; it != m_setRoles.end() ; it++ )
01710 delete *it;
01711 }
01712
01713 bool ConnectionSpecImpl::setDeleted()
01714 {
01715 return isDeleted();
01716 }
01717
01718 ProjectImpl* ConnectionSpecImpl::getProject() const
01719 {
01720 return m_pConnection->getProject();
01721 }
01722
01723 ConnectionImpl* ConnectionSpecImpl::getConnection() const
01724 {
01725 return m_pConnection;
01726 }
01727
01728 int ConnectionSpecImpl::getNumber() const
01729 {
01730 return m_iNum;
01731 }
01732
01733 const std::set<ConnectionRoleImpl*>& ConnectionSpecImpl::getRoles() const
01734 {
01735 return m_setRoles;
01736 }
01737
01738 std::string ConnectionSpecImpl::getInfoString( bool bWithIdentifiers, bool bWithRef ) const
01739 {
01740 std::string strInfo( "MON::ConnectionSpec [" );
01741 if ( bWithIdentifiers )
01742 strInfo += "connection: ";
01743 strInfo += m_pConnection->getInfoString( bWithIdentifiers, bWithRef ) + ", ";
01744 if ( bWithIdentifiers )
01745 strInfo += "number: ";
01746 return strInfo + _ref2str( (long) m_iNum ) + "]";
01747 }
01748
01749
01750
01751
01752
01753
01754
01755 ConnectionRoleImpl::ConnectionRoleImpl( ConnectionSpecImpl* pConnection, const std::string& strRole )
01756 : Util::GenRefCounted( false, pConnection ), m_pSpec( pConnection ), m_strRole( strRole )
01757 {
01758 }
01759
01760 ConnectionRoleImpl::~ConnectionRoleImpl()
01761 {
01762 }
01763
01764 bool ConnectionRoleImpl::setDeleted()
01765 {
01766 return isDeleted();
01767 }
01768
01769 ProjectImpl* ConnectionRoleImpl::getProject() const
01770 {
01771 return m_pSpec->getConnection()->getProject();
01772 }
01773
01774 ConnectionSpecImpl* ConnectionRoleImpl::getConnectionSpec() const
01775 {
01776 return m_pSpec;
01777 }
01778
01779 std::string ConnectionRoleImpl::getName() const
01780 {
01781 return m_strRole;
01782 }
01783
01784 std::string ConnectionRoleImpl::getInfoString( bool bWithIdentifiers, bool bWithRef ) const
01785 {
01786 std::string strInfo( "MON::ConnectionRole [" );
01787 if ( bWithIdentifiers )
01788 strInfo += "connectionSpec: ";
01789 strInfo += m_pSpec->getInfoString( bWithIdentifiers, bWithRef ) + ", ";
01790 if ( bWithIdentifiers )
01791 strInfo += "name: ";
01792 return strInfo + m_strRole + "]";
01793 }
01794
01795
01796
01797
01798
01799
01800
01801 ConnectionEndImpl::ConnectionEndImpl( ConnectionRoleImpl* pConnectionRole, ContainmentImpl* pRole )
01802 : Util::GenRefCounted( false, pRole->getProject() ), m_pConnRole( pConnectionRole ), m_pRole( pRole )
01803 {
01804 }
01805
01806 ConnectionEndImpl::~ConnectionEndImpl()
01807 {
01808 }
01809
01810 bool ConnectionEndImpl::setDeleted()
01811 {
01812 return isDeleted();
01813 }
01814
01815 ProjectImpl* ConnectionEndImpl::getProject() const
01816 {
01817 return m_pRole->getProject();
01818 }
01819
01820 ConnectionRoleImpl* ConnectionEndImpl::getConnectionRole() const
01821 {
01822 return m_pConnRole;
01823 }
01824
01825 ContainmentImpl* ConnectionEndImpl::getEnd() const
01826 {
01827 return m_pRole;
01828 }
01829
01830 std::string ConnectionEndImpl::getInfoString( bool bWithIdentifiers, bool bWithRef ) const
01831 {
01832 std::string strInfo( "MON::ConnectionEnd [" );
01833 if ( bWithIdentifiers )
01834 strInfo += "connection: ";
01835 strInfo += m_pConnRole->getInfoString( bWithIdentifiers, bWithRef ) + ", ";
01836 if ( bWithIdentifiers )
01837 strInfo += "containment: ";
01838 return strInfo + m_pRole->getInfoString( bWithIdentifiers, bWithRef ) + "]";
01839 }
01840
01841
01842
01843
01844
01845
01846
01847 ModelInAspectImpl::ModelInAspectImpl( AspectImpl* pAspect, ModelImpl* pModel )
01848 : Util::GenRefCounted( false, pAspect->getProject() ), m_pAspect( pAspect ), m_pModel( pModel )
01849 {
01850 }
01851
01852 ModelInAspectImpl::~ModelInAspectImpl()
01853 {
01854 }
01855
01856 bool ModelInAspectImpl::setDeleted()
01857 {
01858 return isDeleted();
01859 }
01860
01861 ProjectImpl* ModelInAspectImpl::getProject() const
01862 {
01863 return m_pAspect->getProject();
01864 }
01865
01866 AspectImpl* ModelInAspectImpl::getAspect() const
01867 {
01868 return m_pAspect;
01869 }
01870
01871 ModelImpl* ModelInAspectImpl::getModel() const
01872 {
01873 return m_pModel;
01874 }
01875
01876 std::string ModelInAspectImpl::getInfoString( bool bWithIdentifiers, bool bWithRef ) const
01877 {
01878 std::string strInfo( "MON::ModelInAspects [" );
01879 if ( bWithIdentifiers )
01880 strInfo += "aspect: ";
01881 strInfo += m_pAspect->getInfoString( bWithIdentifiers, bWithRef ) + ", ";
01882 if ( bWithIdentifiers )
01883 strInfo += "model: ";
01884 return strInfo + m_pModel->getInfoString( bWithIdentifiers, bWithRef ) + "]";
01885 }
01886
01887
01888
01889
01890
01891
01892
01893 RegistryNodeImpl::RegistryNodeImpl( IMgaMetaRegNode* spNode, ObjectImpl* pObject, const std::string& strPath )
01894 : Util::GenRefCounted( false, pObject ), m_spNode( spNode ), m_pObject( pObject ), m_strPath( strPath )
01895 {
01896 }
01897
01898 RegistryNodeImpl::~RegistryNodeImpl()
01899 {
01900 m_pObject = NULL;
01901 m_spNode = NULL;
01902 }
01903
01904 bool RegistryNodeImpl::setDeleted()
01905 {
01906 return isDeleted();
01907 }
01908
01909 ProjectImpl* RegistryNodeImpl::getProject() const
01910 {
01911 return m_pObject->getProject();
01912 }
01913
01914 ObjectImpl* RegistryNodeImpl::getObject() const
01915 {
01916 return m_pObject;
01917 }
01918
01919 RegNodePtr RegistryNodeImpl::getRegNodeI() const
01920 {
01921 return m_spNode;
01922 }
01923
01924 bool RegistryNodeImpl::isRootNode() const
01925 {
01926 return ( m_spNode ) ? false : true;
01927 }
01928
01929 std::string RegistryNodeImpl::getName() const
01930 {
01931 if ( m_spNode ) {
01932 CComBSTR bstrName;
01933 COMCHECK2( m_spNode, m_spNode->get_Name( &bstrName ) );
01934 return Util::Copy( bstrName );
01935 }
01936 return "";
01937 }
01938
01939 std::string RegistryNodeImpl::getPath() const
01940 {
01941 return m_strPath;
01942 }
01943
01944 std::string RegistryNodeImpl::getValue() const
01945 {
01946 if ( m_spNode ) {
01947 CComBSTR bstrValue;
01948 COMCHECK2( m_spNode, m_spNode->get_Value( &bstrValue ) );
01949 return Util::Copy( bstrValue );
01950 }
01951 return "";
01952 }
01953
01954 RegistryNodeImpl* RegistryNodeImpl::getParent() const
01955 {
01956 return ( m_spNode ) ? m_pObject->getRegistryNode( m_strPath ) : NULL;
01957 }
01958
01959 std::set<RegistryNodeImpl*> RegistryNodeImpl::getChildren() const
01960 {
01961 std::set<RegistryNodeImpl*> setNodes;
01962 Util::ComPtr<IMgaMetaRegNodes> spNodes;
01963
01964 if ( m_spNode ) {
01965 COMCHECK2( m_spNode, m_spNode->get_RegistryNodes( spNodes.Addr() ) );
01966 }
01967 else {
01968 COMCHECK2( m_pObject->getObjectI(), m_pObject->getObjectI()->get_RegistryNodes( spNodes.Addr() ) );
01969 }
01970
01971 MGACOLL_ITERATE( IMgaMetaRegNode, spNodes.p ) {
01972 CComBSTR bstrName;
01973 COMCHECK2( MGACOLL_ITER, MGACOLL_ITER->get_Name( &bstrName ) );
01974 setNodes.insert( m_pObject->getRegistryNode( m_strPath + Util::Copy( bstrName ) ) );
01975 } MGACOLL_ITERATE_END;
01976
01977 return setNodes;
01978 }
01979
01980 RegistryNodeImpl* RegistryNodeImpl::getChild( const std::string& strName ) const
01981 {
01982 return m_pObject->getRegistryNode( m_strPath + strName );
01983 }
01984
01985 std::string RegistryNodeImpl::getValueByPath( const std::string& strPath ) const
01986 {
01987 return getChildByPath( strPath )->getValue();
01988 }
01989
01990 RegistryNodeImpl* RegistryNodeImpl::getChildByPath( const std::string& strPath ) const
01991 {
01992 std::string strPath2 = _slashes( strPath );
01993 if ( strPath2.empty() )
01994 return (RegistryNodeImpl*) this;
01995 if ( strPath2[ 0 ] == '/' )
01996 strPath2 = strPath2.substr( 1 );
01997 if ( strPath2.empty() )
01998 return (RegistryNodeImpl*) this;
01999 return m_pObject->getRegistryNode( m_strPath + strPath2 );
02000 }
02001
02002
02003
02004
02005
02006
02007
02008 ConstraintImpl::ConstraintImpl( IMgaConstraint* spConstraint, ObjectImpl* pObject )
02009 : Util::GenRefCounted( false, pObject ), m_spConstraint( spConstraint ), m_pObject( pObject )
02010 {
02011 }
02012
02013 ConstraintImpl::~ConstraintImpl()
02014 {
02015 m_spConstraint = NULL;
02016 m_pObject = NULL;
02017 }
02018
02019 bool ConstraintImpl::setDeleted()
02020 {
02021 return isDeleted();
02022 }
02023
02024 ProjectImpl* ConstraintImpl::getProject() const
02025 {
02026 return m_pObject->getProject();
02027 }
02028
02029 ObjectImpl* ConstraintImpl::getObject() const
02030 {
02031 return m_pObject;
02032 }
02033
02034 ConstraintPtr ConstraintImpl::getConstraintI() const
02035 {
02036 return m_spConstraint;
02037 }
02038
02039 std::string ConstraintImpl::getName() const
02040 {
02041 CComBSTR bstrName;
02042 COMCHECK2( m_spConstraint, m_spConstraint->get_Name( &bstrName ) );
02043 return Util::Copy( bstrName );
02044 }
02045
02046 std::string ConstraintImpl::getDescription() const
02047 {
02048 CComBSTR bstrName;
02049 COMCHECK2( m_spConstraint, m_spConstraint->get_DisplayedName( &bstrName ) );
02050 return Util::Copy( bstrName );
02051 }
02052
02053 std::vector<std::string> ConstraintImpl::getEquation() const
02054 {
02055 CComBSTR bstrExpr;
02056 COMCHECK2( m_spConstraint, m_spConstraint->get_Expression( &bstrExpr ) );
02057 std::string strExpr = Util::Copy( bstrExpr );
02058 std::vector<std::string> vecExpr;
02059
02060 while ( ! strExpr.empty() ) {
02061 size_t iPos = strExpr.find( '\n' );
02062 if ( iPos != std::string::npos ) {
02063 CString strLine = strExpr.substr( 0, iPos ).c_str();
02064 strLine.TrimLeft();
02065 strLine.TrimRight();
02066 if ( ! strLine.IsEmpty() )
02067 vecExpr.push_back( strExpr.substr( 0, iPos ) );
02068 strExpr = strExpr.substr( iPos + 1 );
02069 }
02070 else {
02071 vecExpr.push_back( strExpr );
02072 strExpr = "";
02073 }
02074 }
02075 return vecExpr;
02076 }
02077
02078 std::set<ObjectEventType> ConstraintImpl::getEvents() const
02079 {
02080 std::set<ObjectEventType> setEvents;
02081 unsigned long ulEventMask;
02082 COMCHECK2( m_spConstraint, m_spConstraint->get_EventMask( &ulEventMask ) );
02083
02084 for ( ObjectEventType eType = OET_None ; eType != OET_All ; eType++ )
02085 if ( ulEventMask & eType )
02086 setEvents.insert( eType );
02087 return setEvents;
02088 }
02089
02090 ConstraintPriority ConstraintImpl::getPriority() const
02091 {
02092 long lPriority;
02093 COMCHECK2( m_spConstraint, m_spConstraint->get_Priority( &lPriority ) );
02094 return (ConstraintPriority) lPriority;
02095 }
02096
02097 ConstraintDepth ConstraintImpl::getDepth() const
02098 {
02099 constraint_depth_enum eDepth;
02100 COMCHECK2( m_spConstraint, m_spConstraint->get_Depth( &eDepth ) );
02101 return (ConstraintDepth) eDepth;
02102 }
02103
02104 };