[GME-commit] GMESRC/SDK/BON BONImpl.cpp,1.14,1.15 Extensions.h,1.11,1.12 MON.cpp,1.5,1.6 MON.h,1.6,1.7 MONImpl.cpp,1.5,1.6 MONImpl.h,1.4,1.5

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Thu Apr 29 14:22:38 CDT 2004


Update of /var/lib/gme/GMESRC/SDK/BON
In directory braindrain:/tmp/cvs-serv26760

Modified Files:
	BONImpl.cpp Extensions.h MON.cpp MON.h MONImpl.cpp MONImpl.h 
Log Message:
MON:
Reference handling modified in MON, from now on the reference will have as target FCOs instead of roles.

Aspect issue:
Aspects cannot be compared based on metaref, since they occur with different metaref inside different models in the paradigm. FCOImpl::isVisible, ::isPort corrected.

BON:
TEST_META_CONFORMANCE_INSIDE_BON macro introduced: if defined in ComponentConfig.h then performs its own tests before invoking com methods.

Extensions.h modifications: static vars made public in order to compile with VC7

Modified Files:
 	BONImpl.cpp Extensions.h MON.cpp MON.h MONImpl.cpp MONImpl.h 


CVS User: zolmol

Index: BONImpl.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/SDK/BON/BONImpl.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** BONImpl.cpp	3 Mar 2004 18:37:07 -0000	1.14
--- BONImpl.cpp	29 Apr 2004 18:22:35 -0000	1.15
***************
*** 2835,2840 ****
  		MON::Aspect meta;
  		if ( ! strAspect.empty() ) {
  			meta = MON::Aspect( getProject()->getProjectMeta().findByName( strAspect ) );
! 			THROW_METAPROJECT_DOES_NOT_HAVE( meta, Aspect, strAspect );
  		}
  		return isPort( meta );
--- 2835,2848 ----
  		MON::Aspect meta;
  		if ( ! strAspect.empty() ) {
+ 			/*commented out by ZolMol, see isVisible()
  			meta = MON::Aspect( getProject()->getProjectMeta().findByName( strAspect ) );
! 			THROW_METAPROJECT_DOES_NOT_HAVE( meta, Aspect, strAspect );*/
! 			getParentModel();
! 			if ( m_parentModel.first ) {
! 				std::set<MON::Aspect> aspects = m_parentModel.second->getModelMeta().aspects();
! 				for( std::set<MON::Aspect>::const_iterator i = aspects.begin(); i != aspects.end(); ++i)
! 					if ( i->name() == strAspect)
! 						meta = *i;
! 			}
  		}
  		return isPort( meta );
***************
*** 2855,2863 ****
  			std::set<MON::Containment> containments;
  			if ( bAsContained )
! 				containments.insert( m_parentModel.first );
  			else
  				containments = getFCOMeta().parentContainments();
  
! 			for ( std::set<MON::Containment>::iterator it = containments.begin() ; it != containments.end() ; ++it ) {
  				std::set<MON::ContainmentPart> parts = it->parts();;
  				for ( std::set<MON::ContainmentPart>::iterator it2 = parts.begin() ; it2 != parts.end() ; ++it2 )
--- 2863,2874 ----
  			std::set<MON::Containment> containments;
  			if ( bAsContained )
! 				containments.insert( getRole());
! 				//commented line below. By ZolMol because of wrong conversion by Containment( MetaObject& )
! 				//containments.insert( m_parentModel.first );
  			else
  				containments = getFCOMeta().parentContainments();
  
! 			for ( std::set<MON::Containment>::iterator it = containments.begin() ; it != containments.end() ; ++it ) 
! 			{
  				std::set<MON::ContainmentPart> parts = it->parts();;
  				for ( std::set<MON::ContainmentPart>::iterator it2 = parts.begin() ; it2 != parts.end() ; ++it2 )
***************
*** 2871,2877 ****
  	bool FCOImpl::isVisible( const std::string& strAspect, bool bAsContained )
  	{
  		MON::Aspect meta = MON::Aspect( getProject()->getProjectMeta().findByName( strAspect ) );
  		THROW_METAPROJECT_DOES_NOT_HAVE( meta, Aspect, strAspect );
! 		return isVisible( meta, bAsContained );
  	}
  
--- 2882,2901 ----
  	bool FCOImpl::isVisible( const std::string& strAspect, bool bAsContained )
  	{
+ 		/* Commented out by ZolMol
  		MON::Aspect meta = MON::Aspect( getProject()->getProjectMeta().findByName( strAspect ) );
  		THROW_METAPROJECT_DOES_NOT_HAVE( meta, Aspect, strAspect );
! 		return isVisible( meta, bAsContained );*/
! 
! 		MON::Aspect meta;
! 
! 		getParentModel();
! 		if ( m_parentModel.first ) {
! 			std::set<MON::Aspect> aspects = m_parentModel.second->getModelMeta().aspects();
! 			for( std::set<MON::Aspect>::const_iterator i = aspects.begin(); i != aspects.end(); ++i)
! 				if ( i->name() == strAspect)
! 					meta = *i;
! 		}
! 
! 		return (meta)?isVisible( meta, bAsContained):false;
  	}
  
***************
*** 5314,5319 ****
--- 5338,5347 ----
  		if ( meta ) {
  			THROW_METAPROJECT_BELONG( meta );
+ 
+ #ifdef TEST_META_CONFORMANCE_INSIDE_BON
  			if ( ! getReferenceMeta().isReferenced( meta ) )
  				ASSERTTHROW( MON::Exception( "? cannot be referenced by ?!", "ss", meta.infoString().c_str(), getObjectMeta().infoString().c_str() ) );
+ #endif
+ 
  		}
  		return getReferredFCOI( meta );
***************
*** 5334,5338 ****
--- 5362,5375 ----
  		if ( fco ) {
  			THROW_PROJECT_BELONG( fco );
+ 
+ #ifdef TEST_META_CONFORMANCE_INSIDE_BON
+ 			// added by ZolMol
+ 			MON::FCO meta = fco->getFCOMeta();
+ 			if ( ! getReferenceMeta().isReferenced( meta ) )
+ 					ASSERTTHROW( MON::Exception( "? cannot be referenced by ?!", "ss", fco->getObjectMeta().infoString().c_str(), getObjectMeta().infoString().c_str() ) );
+ 			// end added part
+ 
  			// CHANGED LINES BEGIN
+ 			/* commented out by ZolMol 
  			MON::Containment role = fco->getRole(); 
  			if ( role ) {
***************
*** 5350,5355 ****
  				if ( ! bFound )
  					ASSERTTHROW( MON::Exception( "? cannot be referenced by ?!", "ss", fco->getObjectMeta().infoString().c_str(), getObjectMeta().infoString().c_str() ) );
! 			}
  			// CHANGED LINES END
  		}
  		if ( ! _isAddOn() ) {
--- 5387,5393 ----
  				if ( ! bFound )
  					ASSERTTHROW( MON::Exception( "? cannot be referenced by ?!", "ss", fco->getObjectMeta().infoString().c_str(), getObjectMeta().infoString().c_str() ) );
! 			} end commended part*/
  			// CHANGED LINES END
+ #endif
  		}
  		if ( ! _isAddOn() ) {
***************
*** 5645,5648 ****
--- 5683,5688 ----
  
  			mapRefSeqs[ it->first ] = FCOsPtr();
+ 			//<!> ZolMol remove upon working with new GME //t //temporary line
+ 			// COMTHROW( mapRefSeqs[ it->first ].CoCreateInstance( L"Mga.MgaFCOs"));
  			if ( it->second->isReferencePort() ) {
  				ReferencePort port( it->second );
***************
*** 5666,5678 ****
  				ASSERTTHROW( Exception( "BON::ConnectionEnd of ? at role [ ? ]  is unspecified.", "ss", meta.infoString().c_str(), itR->name().c_str() ) );
  
  		bool bOK = false;
  		for ( int i = 0 ; i < MON::Connection( meta.child() ).specificationCount() && ! bOK ; i++ ) {
  			bOK = true;
  			roles = MON::Connection( meta.child() ).specification( i ).roles();
! 			for ( itR = roles.begin() ; itR != roles.end() ; itR++ ) {
  				if ( ! itR->isTarget( mapEnds[ itR->name() ]->getRole() ) ) {
  					bOK = false;
  					break;
  				}
  			}
  		}
--- 5706,5732 ----
  				ASSERTTHROW( Exception( "BON::ConnectionEnd of ? at role [ ? ]  is unspecified.", "ss", meta.infoString().c_str(), itR->name().c_str() ) );
  
+ #ifdef TEST_META_CONFORMANCE_INSIDE_BON
+ 
  		bool bOK = false;
  		for ( int i = 0 ; i < MON::Connection( meta.child() ).specificationCount() && ! bOK ; i++ ) {
  			bOK = true;
  			roles = MON::Connection( meta.child() ).specification( i ).roles();
! 			for ( itR = roles.begin() ; itR != roles.end() ; itR++ ) 
! 			{
! #ifndef BON_DEBUG_VERSION
  				if ( ! itR->isTarget( mapEnds[ itR->name() ]->getRole() ) ) {
  					bOK = false;
  					break;
  				}
+ #else
+ 				std::string rn = itR->name();
+ 				FCO me = mapEnds[ rn ];
+ 				MON::Containment ct = me->getRole();
+ 				bool found = itR->isTarget( ct );
+ 				if ( ! found ) {
+ 					bOK = false;
+ 					break;
+ 				}
+ #endif
  			}
  		}
***************
*** 5692,5695 ****
--- 5746,5751 ----
  		}
  
+ #endif
+ 
  		FCOPtr spFCO;
  		COMTHROW( parent->getModelI()->CreateSimpleConn( meta.getContainmentI(), mapEnds[ "src" ]->getFCOI(), mapEnds[ "dst" ]->getFCOI(), mapRefSeqs[ "src" ], mapRefSeqs[ "dst" ], spFCO.Addr() ) );
***************
*** 5788,5791 ****
--- 5844,5849 ----
  			THROW_METAPROJECT_BELONG( meta );
  
+ #ifdef TEST_META_CONFORMANCE_INSIDE_BON
+ 
  		bool bRoleFound  = false;
  		bool bFound = false;
***************
*** 5809,5812 ****
--- 5867,5872 ----
  		if ( ! bFound )
  			ASSERTTHROW( MON::Exception( "? cannot be target of ? with role ?!", "sss", meta.infoString().c_str(), getObjectMeta().infoString().c_str(), strRole.c_str() ) );
+ 
+ #endif
  
  		return getConnectionEndI( strRole, meta );

Index: Extensions.h
===================================================================
RCS file: /var/lib/gme/GMESRC/SDK/BON/Extensions.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Extensions.h	12 Mar 2004 20:37:15 -0000	1.11
--- Extensions.h	29 Apr 2004 18:22:35 -0000	1.12
***************
*** 110,114 ****
  
  		// Object methods
! 		private :
  			static ObjectImpl* createImpl( ObjectType eType, const std::string& strKind, const std::string& strRole );
  
--- 110,114 ----
  
  		// Object methods
! 		public :
  			static ObjectImpl* createImpl( ObjectType eType, const std::string& strKind, const std::string& strRole );
  
***************
*** 128,132 ****
  	{
  		// Member variables
! 		private :
  			static std::vector<std::string> vecKinds;
  			static const ExtensionManager extensionFactory;
--- 128,132 ----
  	{
  		// Member variables
! 		public :
  			static std::vector<std::string> vecKinds;
  			static const ExtensionManager extensionFactory;
***************
*** 139,143 ****
  
  		// Helper methods
! 		private :
  			static ObjectImpl* castObjectImpl( ObjectImpl* pObject )
  			{
--- 139,143 ----
  
  		// Helper methods
! 		public :
  			static ObjectImpl* castObjectImpl( ObjectImpl* pObject )
  			{
***************
*** 264,268 ****
  	{
  		// Member variables
! 		private :
  			static std::vector<std::string> vecKinds;
  			static const ExtensionManager extensionFactory;
--- 264,268 ----
  	{
  		// Member variables
! 		public :
  			static std::vector<std::string> vecKinds;
  			static const ExtensionManager extensionFactory;
***************
*** 274,278 ****
  
  		// Helper methods
! 		private :
  			static ObjectImpl* castObjectImpl( ObjectImpl* pObject )
  			{
--- 274,278 ----
  
  		// Helper methods
! 		public :
  			static ObjectImpl* castObjectImpl( ObjectImpl* pObject )
  			{
***************
*** 440,444 ****
  	{
  		// Member variables
! 		private :
  			static std::vector<std::string> vecKinds;
  			static const ExtensionManager extensionFactory;
--- 440,444 ----
  	{
  		// Member variables
! 		public :
  			static std::vector<std::string> vecKinds;
  			static const ExtensionManager extensionFactory;
***************
*** 450,454 ****
  
  		// Helper methods
! 		private :
  			static ObjectImpl* castObjectImpl( ObjectImpl* pObject )
  			{
--- 450,454 ----
  
  		// Helper methods
! 		public :
  			static ObjectImpl* castObjectImpl( ObjectImpl* pObject )
  			{
***************
*** 633,637 ****
  	{
  		// Member variables
! 		private :
  			static std::vector<std::string> vecKinds;
  			static const ExtensionManager extensionFactory;
--- 633,637 ----
  	{
  		// Member variables
! 		public :
  			static std::vector<std::string> vecKinds;
  			static const ExtensionManager extensionFactory;
***************
*** 644,648 ****
  
  		// Helper methods
! 		private :
  			static ObjectImpl* castObjectImpl( ObjectImpl* pObject )
  			{
--- 644,648 ----
  
  		// Helper methods
! 		public :
  			static ObjectImpl* castObjectImpl( ObjectImpl* pObject )
  			{
***************
*** 767,771 ****
  	{
  		// Member variables
! 		private :
  			static std::vector<std::string> vecKinds;
  			static const ExtensionManager extensionFactory;
--- 767,771 ----
  	{
  		// Member variables
! 		public :
  			static std::vector<std::string> vecKinds;
  			static const ExtensionManager extensionFactory;
***************
*** 777,781 ****
  
  		// Helper methods
! 		private :
  			static ObjectImpl* castObjectImpl( ObjectImpl* pObject )
  			{
--- 777,781 ----
  
  		// Helper methods
! 		public :
  			static ObjectImpl* castObjectImpl( ObjectImpl* pObject )
  			{
***************
*** 944,948 ****
  	{
  		// Member variables
! 		private :
  			static std::vector<std::string> vecKinds;
  			static const ExtensionManager extensionFactory;
--- 944,948 ----
  	{
  		// Member variables
! 		public :
  			static std::vector<std::string> vecKinds;
  			static const ExtensionManager extensionFactory;
***************
*** 954,958 ****
  
  		// Helper methods
! 		private :
  			static ObjectImpl* castObjectImpl( ObjectImpl* pObject )
  			{
--- 954,958 ----
  
  		// Helper methods
! 		public :
  			static ObjectImpl* castObjectImpl( ObjectImpl* pObject )
  			{

Index: MON.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/SDK/BON/MON.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** MON.cpp	3 Feb 2004 10:53:05 -0000	1.5
--- MON.cpp	29 Apr 2004 18:22:35 -0000	1.6
***************
*** 479,493 ****
  	std::set<ReferenceAssociation> FCO::referenceAssociations() const
  	{
! 		FULLFILTER( ReferenceAssocImpl*, ( (ProjectImpl*) project().getCounted() )->getReferenceAssocs(), ReferenceAssociation, (*it)->getTarget()->getChild() == getCounted(), *it );
  	}
  
  	std::set<Reference> FCO::referencedBy() const
  	{
! 		FULLFILTER( ReferenceAssocImpl*, ( (ProjectImpl*) project().getCounted() )->getReferenceAssocs(), Reference, (*it)->getTarget()->getChild() == getCounted(), (*it)->getReference() );
  	}
  
  	bool FCO::isReferencedBy( const Reference& reference ) const
  	{
! 		FINDRELATION( ReferenceAssocImpl*, ( (ProjectImpl*) project().getCounted() )->getReferenceAssocs(), (*it)->getTarget()->getChild() == getCounted() && (*it)->getReference() == reference.getCounted( false ) );
  	}
  
--- 479,493 ----
  	std::set<ReferenceAssociation> FCO::referenceAssociations() const
  	{
! 		FULLFILTER( ReferenceAssocImpl*, ( (ProjectImpl*) project().getCounted() )->getReferenceAssocs(), ReferenceAssociation, (*it)->getTarget() == getCounted(), *it );
  	}
  
  	std::set<Reference> FCO::referencedBy() const
  	{
! 		FULLFILTER( ReferenceAssocImpl*, ( (ProjectImpl*) project().getCounted() )->getReferenceAssocs(), Reference, (*it)->getTarget() == getCounted(), (*it)->getReference() );
  	}
  
  	bool FCO::isReferencedBy( const Reference& reference ) const
  	{
! 		FINDRELATION( ReferenceAssocImpl*, ( (ProjectImpl*) project().getCounted() )->getReferenceAssocs(), (*it)->getTarget() == getCounted() && (*it)->getReference() == reference.getCounted( false ) );
  	}
  
***************
*** 919,922 ****
--- 919,923 ----
  	}
  
+ 	// method used by the BON::SetImpl::addMember and BON::SetImpl::removeMember
  	bool Set::isMember( const Containment& role ) const
  	{
***************
*** 924,927 ****
--- 925,936 ----
  	}
  
+ 	// method added by ZolMol
+ 	// because the BON::SetImpl::getMembers() method uses MON::FCO
+ 	// instead of MON::Containment to inquire Set::isMember
+ 	bool Set::isMember( const FCO& fco ) const
+ 	{
+ 		FINDRELATION( SetMembershipImpl*, ( (ProjectImpl*) project().getCounted() )->getSetMemberships(), (*it)->getSet() == getCounted() && (*it)->getMember()->getChild() == fco.getCounted( false ) );
+ 	}
+ 
  //###############################################################################################################################################
  //
***************
*** 965,976 ****
  	}
  
! 	std::set<Containment> Reference::targetRoles() const
  	{
! 		FULLFILTER( ReferenceAssocImpl*, ( (ProjectImpl*) project().getCounted() )->getReferenceAssocs(), Containment, (*it)->getReference() == getCounted(), (*it)->getTarget() );
  	}
  
! 	bool Reference::isReferenced( const Containment& role ) const
  	{
! 		FINDRELATION( ReferenceAssocImpl*, ( (ProjectImpl*) project().getCounted() )->getReferenceAssocs(), (*it)->getReference() == getCounted() && (*it)->getTarget() == role.getCounted( false ) );
  	}
  
--- 974,986 ----
  	}
  
! 	std::set<FCO> Reference::targetFCOs() const // changed from Containment to FCO by ZolMol
  	{
! 		FULLFILTER( ReferenceAssocImpl*, ( (ProjectImpl*) project().getCounted() )->getReferenceAssocs(), FCO, (*it)->getReference() == getCounted(), (*it)->getTarget() );
! 		// old: FULLFILTER( ReferenceAssocImpl*, ( (ProjectImpl*) project().getCounted() )->getReferenceAssocs(), Containment, (*it)->getReference() == getCounted(), (*it)->getTarget() ); 
  	}
  
! 	bool Reference::isReferenced( const FCO& fco ) const
  	{
! 		FINDRELATION( ReferenceAssocImpl*, ( (ProjectImpl*) project().getCounted() )->getReferenceAssocs(), (*it)->getReference() == getCounted() && (*it)->getTarget() == fco.getCounted( false ) );
  	}
  
***************
*** 987,995 ****
  	}
  
! 	Containment::Containment( const MetaObject& object )
  		: MetaObject( object )
  	{
  		castObjectImpl( OT_Role );
! 	}
  
  	Containment::Containment( IMgaMetaBase* spObject )
--- 997,1005 ----
  	}
  
! 	/*Containment::Containment( const MetaObject& object )
  		: MetaObject( object )
  	{
  		castObjectImpl( OT_Role );
! 	} Commented out by ZolMol */
  
  	Containment::Containment( IMgaMetaBase* spObject )
***************
*** 1360,1364 ****
  	}
  
! 	Containment ReferenceAssociation::target() const
  	{
  		return ( (ReferenceAssocImpl* ) getCounted() )->getTarget();
--- 1370,1374 ----
  	}
  
! 	FCO ReferenceAssociation::target() const //ZolMol changed Containment to FCO
  	{
  		return ( (ReferenceAssocImpl* ) getCounted() )->getTarget();

Index: MON.h
===================================================================
RCS file: /var/lib/gme/GMESRC/SDK/BON/MON.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** MON.h	3 Feb 2004 10:53:05 -0000	1.6
--- MON.h	29 Apr 2004 18:22:35 -0000	1.7
***************
*** 428,431 ****
--- 428,432 ----
  			std::set<Containment>			memberRoles() const;
  			bool 								isMember( const Containment& role ) const;
+ 			bool 								isMember( const FCO& fco ) const; //added by ZolMol
  	};
  
***************
*** 454,459 ****
  		public :
  			std::set<ReferenceAssociation>	refAssociations() const;
! 			std::set<Containment>			targetRoles() const;
! 			bool								isReferenced( const Containment& role ) const;
  	};
  
--- 455,460 ----
  		public :
  			std::set<ReferenceAssociation>	refAssociations() const;
! 			std::set<FCO>					targetFCOs() const; // ZolMol changed Containment to FCO and renamed targetRoles to targetFCOs
! 			bool							isReferenced( const FCO& fco ) const;
  	};
  
***************
*** 470,476 ****
  		public :
  			Containment() { }
! 			Containment( ObjectImpl* pObject );
! 			Containment( const MetaObject& object );
  			Containment( IMgaMetaBase* spObject );
  			Containment& operator = ( const MetaObject& object );
  
--- 471,481 ----
  		public :
  			Containment() { }
! 			Containment( ObjectImpl* pObject ); // still dangerous
! 		private: //ZolMol
! 			Containment( const MetaObject& object ); 
! 			Containment( const FCO& object ); 
! 		public:
  			Containment( IMgaMetaBase* spObject );
+ 		private: //ZolMol
  			Containment& operator = ( const MetaObject& object );
  
***************
*** 650,654 ****
  			Project			project() const;
  			Reference		reference() const;
! 			Containment	target() const;
  	};
  
--- 655,659 ----
  			Project			project() const;
  			Reference		reference() const;
! 			FCO				target() const; //ZolMol changed from Containmnent to FCO
  	};
  

Index: MONImpl.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/SDK/BON/MONImpl.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** MONImpl.cpp	3 Feb 2004 10:53:05 -0000	1.5
--- MONImpl.cpp	29 Apr 2004 18:22:35 -0000	1.6
***************
*** 293,299 ****
  			CComBSTR bstrDesc;
  			COMTHROW( MGACOLL_ITER->get_Desc( &bstrDesc ) );
! 			std::set<ContainmentImpl*> setRoles = getGlobalRoles( Util::Copy( bstrDesc ) );
! 			for ( std::set<ContainmentImpl*>::iterator it = setRoles.begin() ; it != setRoles.end() ; it++ )
! 				m_setReferenceAssocs.insert( new ReferenceAssocImpl( pReference, *it ) );
  		} MGACOLL_ITERATE_END;
  	}
--- 293,299 ----
  			CComBSTR bstrDesc;
  			COMTHROW( MGACOLL_ITER->get_Desc( &bstrDesc ) );
! 			FCOImpl * refd = (FCOImpl *) findByName( Util::Copy( bstrDesc));//m_mapObjectsByName.find( name );
! 			if ( refd)
! 				m_setReferenceAssocs.insert( new ReferenceAssocImpl( pReference, refd) );
  		} MGACOLL_ITERATE_END;
  	}
***************
*** 381,384 ****
--- 381,394 ----
  	std::set<ContainmentImpl*> ProjectImpl::getLocalRoles( FCOImpl* pKind, const std::string& strDescIn ) const
  	{
+ 		//if invoked from processConnection
+ 		// pKind is a connection so it may be contained (usually-normally) by models only
+ 		//       since it doesn't have too much sense to have a connection in a folder
+ 		// strDescIn is an 
+ 		//       "src_fco" or
+ 		//       a pair like "model port"
+ 		//       a pair like "modelreference port"
+ 		//       a pair like "transitivemodelreference port"
+ 
+ 		// "setModels" will contain the models pKind may be part of 
  		std::set<ModelImpl*> setModels;
  		for ( std::set<ObjectImpl*>::const_iterator it = ( (ProjectImpl* ) this )->m_mapObjectsByType[ OT_Role ].begin() ; it != ( (ProjectImpl* ) this )->m_mapObjectsByType[ OT_Role ].end() ; ++it )
***************
*** 386,389 ****
--- 396,400 ----
  				setModels.insert( ( ( ContainmentImpl*) (*it) )->getParent() );
  
+ 		
  		std::set<ContainmentImpl*> setRoles;
  		if ( setModels.empty() )
***************
*** 391,398 ****
--- 402,414 ----
  
  		int iPos = strDescIn.find( " " );
+ 		// strDesc to store the first token
  		std::string strDesc = ( iPos == std::string::npos ) ? strDescIn : strDescIn.substr( 0, iPos );
+ 		
+ 		// for all roles 
  		for ( it = ( (ProjectImpl* ) this )->m_mapObjectsByType[ OT_Role ].begin() ; it != ( (ProjectImpl* ) this )->m_mapObjectsByType[ OT_Role ].end() ; ++it ) {
+ 			// filter with "strDesc"
  			if ( (*it)->getName() == strDesc ) {
  				bool bFound = false;
+ 				// test if role's (*it) parent is in "setModels"
  				for ( std::set<ModelImpl*>::iterator it2 = setModels.begin() ; it2 != setModels.end() ; it2++ )
  					if ( ( ( ContainmentImpl*) (*it) )->getParent() == *it2 ) {
***************
*** 401,456 ****
  					}
  				if ( bFound )
  					setRoles.insert( (ContainmentImpl*) *it );
  			}
  		}
! 		return getRoles( setRoles, ( iPos == std::string::npos ) ? "" : strDescIn.substr( iPos + 1 ), true );
  	}
  
  	std::set<ContainmentImpl*> ProjectImpl::getRoles( const std::set<ContainmentImpl*>& setIn, const std::string& strDescIn, bool bResolveReference ) const
  	{
  		if ( strDescIn.empty() )
  			return setIn;
  		int iPos = strDescIn.find( " " );
  		std::string strDesc = ( iPos == std::string::npos ) ? strDescIn : strDescIn.substr( 0, iPos );
  
! 		std::set<ContainmentImpl*> setRoles = getRolesResolved( setIn, bResolveReference );
  		std::set<ContainmentImpl*> setRolesOut;
! 		if ( setRoles.empty() )
  			return setRolesOut;
  
  		for ( std::set<ObjectImpl*>::const_iterator it = ( (ProjectImpl* ) this )->m_mapObjectsByType[ OT_Role ].begin() ; it != ( (ProjectImpl* ) this )->m_mapObjectsByType[ OT_Role ].end() ; ++it ) {
  			if ( ( ( ContainmentImpl*) (*it) )->getName() == strDesc ) {
  				bool bFound = false;
! 				for ( std::set<ContainmentImpl*>::iterator it2 = setRoles.begin() ; it2 != setRoles.end() ; it2++ )
  					if ( ( ( ContainmentImpl*) (*it) )->getParent() == (*it2)->getChild() ) {
  						bFound = true;
  						break;
  					}
  				if ( bFound )
  					setRolesOut.insert( (ContainmentImpl*) *it );
  			}
  		}
  
  		return getRoles( setRolesOut, ( iPos == std::string::npos ) ? "" : strDescIn.substr( iPos + 1 ), bResolveReference );
  	}
  
! 	std::set<ContainmentImpl*> ProjectImpl::getRolesResolved( const std::set<ContainmentImpl*>& setIn, bool bResolveReference ) const
  	{
  		if ( setIn.empty() )
! 			return setIn;
  
! 		std::set<ContainmentImpl*> setRoles;
! 		for ( std::set<ContainmentImpl*>::const_iterator it = setIn.begin() ; it != setIn.end() ; ++it ) {
! 			if ( (*it)->getChild()->getType() == OT_Model )
! 				setRoles.insert( *it );
! 			else if ( bResolveReference && (*it)->getChild()->getType() == OT_Reference ) {
  				for ( std::set<ReferenceAssocImpl*>::const_iterator itr = m_setReferenceAssocs.begin() ; itr != m_setReferenceAssocs.end() ; ++itr )
! 					if ( (*itr)->getTarget()->getChild()->getType() == OT_Model )
! 						setRoles.insert( (*itr)->getTarget() );
  			}
  		}
! 		return setRoles;
  	}
  
  	ProjectImpl::~ProjectImpl()
  	{
--- 417,591 ----
  					}
  				if ( bFound )
+ 				{
+ 					// insert such role into "setRoles"
  					setRoles.insert( (ContainmentImpl*) *it );
+ 					std::string pn = ((ContainmentImpl*) *it)->getParent()->getName();
+ 					std::string cn = ((ContainmentImpl*) *it)->getChild()->getName();
+ 				}
  			}
  		}
! 		// pass the collected roles and the remaining rolelist ("2nd_token 3rd_token" substr of the strDescIn)
! 		std::set<ContainmentImpl*> res = getRoles( setRoles, ( iPos == std::string::npos ) ? "" : strDescIn.substr( iPos + 1 ), true );
! 		std::set<ContainmentImpl*>::const_iterator it0 = res.begin();
! 		for( ; it0 != res.end(); ++it0)
! 		{
! 			std::string par = (*it0)->getParent()->getName();
! 			std::string chi = (*it0)->getChild()->getName();
! 			int i;
! 			++i;
! 		}
! 
! 		return res;
  	}
  
  	std::set<ContainmentImpl*> ProjectImpl::getRoles( const std::set<ContainmentImpl*>& setIn, const std::string& strDescIn, bool bResolveReference ) const
  	{
+ 		// setIn has the roles conforming to the 1st_token of the original string passed to getLocalRoles
+ 		//       these roles are part of the model the pKind (a connection, set, ...) is part of as well
+ 		//
+ 		// strDescIn has the remaining rolelist (usually the "port")
+ 
  		if ( strDescIn.empty() )
  			return setIn;
+ 
  		int iPos = strDescIn.find( " " );
+ 		// the next token (usually a "port")
  		std::string strDesc = ( iPos == std::string::npos ) ? strDescIn : strDescIn.substr( 0, iPos );
  
! 		// these will store output from getRolesResolved
! 		std::set<ContainmentImpl*> setRolesResolved;
! 		std::set<FolderContainmentImpl*> setFolderRolesResolved;
! 
! 		// selects from setIn 
! 		//		-modelroles contained by setIn
! 		//		-modelroles which are referred by referenceroles in setIn ( for such references it returns all of their role)
! 		// it returns all roles of these (roles, and folderroles)
! 		getRolesResolved( setIn, bResolveReference, setRolesResolved, setFolderRolesResolved );
! 
  		std::set<ContainmentImpl*> setRolesOut;
! 		if ( setRolesResolved.empty() && setFolderRolesResolved.empty())
  			return setRolesOut;
  
+ 		// for all roles
  		for ( std::set<ObjectImpl*>::const_iterator it = ( (ProjectImpl* ) this )->m_mapObjectsByType[ OT_Role ].begin() ; it != ( (ProjectImpl* ) this )->m_mapObjectsByType[ OT_Role ].end() ; ++it ) {
+ 			// filter based on "strDesc"
  			if ( ( ( ContainmentImpl*) (*it) )->getName() == strDesc ) {
  				bool bFound = false;
! 				// 
! 				// test if any of resolved role's (*it2) child equals with the role's (*it) parent 
! 				// like M<>----resolved_role--A1<>---------it--P2 (port)
! 				for ( std::set<ContainmentImpl*>::iterator it2 = setRolesResolved.begin() ; it2 != setRolesResolved.end() ; ++it2 )
  					if ( ( ( ContainmentImpl*) (*it) )->getParent() == (*it2)->getChild() ) {
  						bFound = true;
  						break;
  					}
+ 				// 
+ 				// if not found test if any of the resolved folder_role's (*it3) child equals with the role's (*it) parent 
+ 				// like Folder<>----resolved_role--M1<>---------it--P2 (port)
+ 				for ( std::set<FolderContainmentImpl*>::iterator it3 = setFolderRolesResolved.begin() ; !bFound && it3 != setFolderRolesResolved.end() ; ++it3 )
+ 					if ( ( ( ContainmentImpl*) (*it) )->getParent() == (*it3)->getChild() ) {
+ 						bFound = true;
+ 						break;
+ 					}
+ 				
+ 				// if role (*it) is a role inside any of the resolvedroles then insert into setRolesOut
+ 				// M/F<>---------resolvedrole-M<>-----role-P
  				if ( bFound )
+ 				{
  					setRolesOut.insert( (ContainmentImpl*) *it );
+ 					std::string pn = ((ContainmentImpl*) *it)->getParent()->getName();
+ 					std::string cn = ((ContainmentImpl*) *it)->getChild()->getName();
+ 				}
  			}
  		}
  
+ 		// invoke with the collected roles, with the remaining part of strDescIn (usually "" which returns the "setRolesOut" )
  		return getRoles( setRolesOut, ( iPos == std::string::npos ) ? "" : strDescIn.substr( iPos + 1 ), bResolveReference );
  	}
  
! 	void ProjectImpl::getRolesResolved( 
! 			const std::set<ContainmentImpl*>& setIn, 
! 			bool bResolveReference,
! 			std::set<ContainmentImpl*>& setRolesRes,            // return value
! 			std::set<FolderContainmentImpl*>& setFolderRolesRes // return value
! 		) const
  	{
  		if ( setIn.empty() )
! 			return;
  
! 		// for all roles in setIn
! 		for ( std::set<ContainmentImpl*>::const_iterator it = setIn.begin() ; it != setIn.end() ; ++it ) 
! 		{
! 			std::string rolrname = (*it)->getChild()->getName();
! 			if ( (*it)->getChild()->getType() == OT_Model ) // if contained model
! 				setRolesRes.insert( *it ); 
! 			else if ( bResolveReference && (*it)->getChild()->getType() == OT_Reference ) // if contained reference
! 			{
! 				// the remaining part is not depending on *it so
! 				// all roles of the referred models are returned
! 				//
! 				// for all reference assocs
  				for ( std::set<ReferenceAssocImpl*>::const_iterator itr = m_setReferenceAssocs.begin() ; itr != m_setReferenceAssocs.end() ; ++itr )
! 				{
! 					// filter with (*it)->getChild()		because we are interested in the targets of this reference only
! 					if ((*itr)->getReference() == (*it)->getChild())
! 					{
! 						// take the reference's target
! 						FCOImpl * referee = (*itr)->getTarget();
! 						// if ( referee gettype == OT_reference - a transitive modelreference
! 						if ( referee->getType() == OT_Model ) // if a modelreference
! 						{
! 							//std::string refereename = referee->getName();//t
! 							
! 							// will contain the roles of the refererred model
! 							std::set<ContainmentImpl*> the_roles_of_referee;
! 							
! 							// for all roles
! 							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 )
! 							{
! 								//std::string name1 = ( ( ContainmentImpl*) (*role_it) )->getChild()->getName();
! 								//if ( name1 == refereename ) // is a role of referee
! 								{
! 									// if a role of referee
! 									if ( ( ( ContainmentImpl*) (*role_it) )->getChild() == referee )
! 									{
! 										the_roles_of_referee.insert( ( ContainmentImpl*) (*role_it) );
! 									}
! 								}
! 							}
! 
! 							// will contain the folder_roles of the referred model
! 							std::set<FolderContainmentImpl *> the_folder_roles_of_referee;
! 							// for all folder_roles
! 							for ( std::set<FolderContainmentImpl*>::const_iterator fold_cont_it = m_setFolderContainments.begin(); fold_cont_it !=  m_setFolderContainments.end(); ++fold_cont_it)
! 							{
! 								//std::string name1 = ( *fold_cont_it )->getChild()->getName();//t
! 								//if ( name1 == refereename ) // a role of referee//t
! 								{
! 									// if a folder_role of referee
! 									if ( ( *fold_cont_it )->getChild() == referee )
! 									{
! 										the_folder_roles_of_referee.insert( *fold_cont_it );
! 									}
! 								}
! 							}
! 
! 						//if ( referee->getType() == OT_Model )
! 						
! 							// copy into setRolesRes
! 							for ( std::set<ContainmentImpl*>::iterator the_it = the_roles_of_referee.begin(); the_it != the_roles_of_referee.end(); ++the_it )
! 								setRolesRes.insert( *the_it );
! 							// copy into setFolderRolesRes
! 							for ( std::set<FolderContainmentImpl*>::iterator the_it2 = the_folder_roles_of_referee.begin(); the_it2 != the_folder_roles_of_referee.end(); ++the_it2 )
! 								setFolderRolesRes.insert( *the_it2 );
! 						}
! 					}
! 				}
  			}
  		}
! 		return;
  	}
  
+ 
  	ProjectImpl::~ProjectImpl()
  	{
***************
*** 1478,1482 ****
  //###############################################################################################################################################
  
! 	ReferenceAssocImpl::ReferenceAssocImpl( ReferenceImpl* pReference, ContainmentImpl* pTarget )
  		: Util::GenRefCounted( false, pReference->getProject() ), m_pReference( pReference ), m_pTarget( pTarget )
  	{
--- 1613,1617 ----
  //###############################################################################################################################################
  
! 	ReferenceAssocImpl::ReferenceAssocImpl( ReferenceImpl* pReference, FCOImpl* pTarget )
  		: Util::GenRefCounted( false, pReference->getProject() ), m_pReference( pReference ), m_pTarget( pTarget )
  	{
***************
*** 1502,1506 ****
  	}
  
! 	ContainmentImpl* ReferenceAssocImpl::getTarget() const
  	{
  		return m_pTarget;
--- 1637,1641 ----
  	}
  
! 	FCOImpl* ReferenceAssocImpl::getTarget() const
  	{
  		return m_pTarget;

Index: MONImpl.h
===================================================================
RCS file: /var/lib/gme/GMESRC/SDK/BON/MONImpl.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** MONImpl.h	3 Feb 2004 10:53:05 -0000	1.4
--- MONImpl.h	29 Apr 2004 18:22:35 -0000	1.5
***************
*** 106,110 ****
  			Type2ObjectsMap							m_mapObjectsByType;
  			std::set<FolderContainmentImpl*>		m_setFolderContainments;
! 			std::set<AttributeAggregationImpl*>	m_setAttributeAggregations;
  			std::set<ReferenceAssocImpl*>			m_setReferenceAssocs;
  			std::set<SetMembershipImpl*>			m_setSetMemberships;
--- 106,110 ----
  			Type2ObjectsMap							m_mapObjectsByType;
  			std::set<FolderContainmentImpl*>		m_setFolderContainments;
! 			std::set<AttributeAggregationImpl*>		m_setAttributeAggregations;
  			std::set<ReferenceAssocImpl*>			m_setReferenceAssocs;
  			std::set<SetMembershipImpl*>			m_setSetMemberships;
***************
*** 164,171 ****
  			AspectImpl*					processAspect( const AspectPtr& spAspect );
  			void							insertObject( ObjectImpl* pObject );
! 			std::set<ContainmentImpl*> ProjectImpl::getRolesResolved( const std::set<ContainmentImpl*>& setIn, bool bResolveReference ) const;
! 			std::set<ContainmentImpl*> ProjectImpl::getRoles( const std::set<ContainmentImpl*>& setIn, const std::string& strDescIn, bool bResolveReference ) const;
! 			std::set<ContainmentImpl*> ProjectImpl::getLocalRoles( FCOImpl* pKind, const std::string& strDescIn ) const;
! 			std::set<ContainmentImpl*> ProjectImpl::getGlobalRoles( const std::string& strDescIn ) const;
  
  		// Prohibited operations
--- 164,171 ----
  			AspectImpl*					processAspect( const AspectPtr& spAspect );
  			void							insertObject( ObjectImpl* pObject );
! 			void						getRolesResolved( const std::set<ContainmentImpl*>& setIn, bool bResolveReference, std::set<ContainmentImpl*>& roles, std::set<FolderContainmentImpl*>& foldroles  ) const;
! 			std::set<ContainmentImpl*>	getRoles( const std::set<ContainmentImpl*>& setIn, const std::string& strDescIn, bool bResolveReference ) const;
! 			std::set<ContainmentImpl*>	getLocalRoles( FCOImpl* pKind, const std::string& strDescIn ) const;
! 			std::set<ContainmentImpl*>	getGlobalRoles( const std::string& strDescIn ) const;
  
  		// Prohibited operations
***************
*** 750,754 ****
  //
  //###############################################################################################################################################
- 
  	class ReferenceAssocImpl
  		: public Util::GenRefCounted
--- 750,753 ----
***************
*** 757,765 ****
  		private :
  			ReferenceImpl*		m_pReference;
! 			ContainmentImpl*		m_pTarget;
  
  		// Construction and Destruction
  		private :
! 			ReferenceAssocImpl( ReferenceImpl* pReference, ContainmentImpl* pTarget );
  		public :
  			~ReferenceAssocImpl();
--- 756,764 ----
  		private :
  			ReferenceImpl*		m_pReference;
! 			FCOImpl*			m_pTarget;
  
  		// Construction and Destruction
  		private :
! 			ReferenceAssocImpl( ReferenceImpl* pReference, FCOImpl* pTarget );
  		public :
  			~ReferenceAssocImpl();
***************
*** 769,774 ****
  		public :
  			ProjectImpl*		getProject() const;
! 			ReferenceImpl*	getReference() const;
! 			ContainmentImpl*	getTarget() const;
  			std::string 		getInfoString( bool bWithIdentifiers = false, bool bWithRef = false ) const;
  
--- 768,773 ----
  		public :
  			ProjectImpl*		getProject() const;
! 			ReferenceImpl*		getReference() const;
! 			FCOImpl*			getTarget() const;
  			std::string 		getInfoString( bool bWithIdentifiers = false, bool bWithRef = false ) const;
  



More information about the GME-commit mailing list