[GME-commit] GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep Any.cpp,1.15,1.16 Any.h,1.8,1.9 AttributeRep.cpp,1.9,1.10 AttributeRep.h,1.1,1.2 ConstraintFuncRep.cpp,1.2,1.3 ConstraintFuncRep.h,1.1,1.2 ConstraintRep.cpp,1.3,1.4 ConstraintRep.h,1.1,1.2 FCO.cpp,1.14,1.15 FolderRep.cpp,1.12,1.13 Sheet.cpp,1.13,1.14 Sheet.h,1.7,1.8

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Fri Jul 21 20:31:20 CDT 2006


Update of /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep
In directory escher:/tmp/cvs-serv9823/Rep

Modified Files:
	Any.cpp Any.h AttributeRep.cpp AttributeRep.h 
	ConstraintFuncRep.cpp ConstraintFuncRep.h ConstraintRep.cpp 
	ConstraintRep.h FCO.cpp FolderRep.cpp Sheet.cpp Sheet.h 
Log Message:
Namespace related changes.


CVS User: Zoltan Molnar, ISIS (zolmol)

Index: ConstraintFuncRep.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep/ConstraintFuncRep.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ConstraintFuncRep.cpp	30 Jul 2004 00:10:23 -0000	1.2
--- ConstraintFuncRep.cpp	21 Jul 2006 19:31:18 -0000	1.3
***************
*** 43,46 ****
--- 43,55 ----
  	}
  	m_context = contexttype;
+ 	bool modify = true;// if we modify the context that is just for the ConstraintManager's sake (otherwise it would crash)
+ 	if( modify && m_ptr->isInLibrary() && !m_namespace.empty())
+ 	{
+ 		if( m_context.substr(0, 6) == "meta::" && m_context.substr( 6).find( "::") == std::string::npos)
+ 		{ // short kind name used
+ 			m_context.insert( 6, Any::NamespaceDelimiter_str);
+ 			m_context.insert( 6, m_namespace); // thus a context like meta::Target becomes meta::NMSP::Target for library constraints
+ 		}
+ 	}
  
  	std::string returntype = m_ptr->getAttribute( "CFuncReturnType")->getStringValue();
***************
*** 64,69 ****
--- 73,86 ----
  	}
  	m_stereotype = stereotype;
+ 
+ 	//m_defdForNamesp = m_ptr->getAttribute("DefinedForNamespace")->getStringValue();
+ 	m_defdForNamesp = m_namespace;
  }
  
+ /*virtual*/ std::string ConstraintFuncRep::getName() const
+ {
+ 	ASSERT( m_ptr);
+ 	return m_ptr->getName();
+ }
  
  std::string ConstraintFuncRep::doDump()
***************
*** 72,76 ****
  	std::string mmm = "";
  	
! 	mmm += indStr() + "<constraint type=\"function\" name=\"" + getName() + "\">\n";
  	++ind;
  	mmm += indStr() + "<![CDATA[" 
--- 89,98 ----
  	std::string mmm = "";
  	
! 	mmm += indStr() + "<constraint type=\"function\" name=\"" + getName() + "\"";
! 	///z dump either the m_namespace variable /or/ the specific defdForNamesp variable owned by this
! 	///z m_namespace or m_defdForNamesp
! 	///z dump only if the object belongs to main namespace
! 	if( !m_defdForNamesp.empty() && m_ptr && m_ptr->isInLibrary()) mmm+= " defdfornamesp = \"" + m_defdForNamesp + "\"";
! 	mmm += ">\n";
  	++ind;
  	mmm += indStr() + "<![CDATA[" 

Index: ConstraintRep.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep/ConstraintRep.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ConstraintRep.cpp	30 Jul 2004 00:10:23 -0000	1.3
--- ConstraintRep.cpp	21 Jul 2006 19:31:18 -0000	1.4
***************
*** 19,23 ****
  	{
  		fetch();
! 		m_name = Any::getName();
  	}
  }
--- 19,24 ----
  	{
  		fetch();
! 		//m_name = Any::getName();
! 		m_name = getName();
  	}
  }
***************
*** 50,53 ****
--- 51,58 ----
  	m_depth = m_ptr->getAttribute("Depth")->getStringValue();
  
+ 	//m_defdForNamesp = m_ptr->getAttribute("DefinedForNamespace")->getStringValue();
+ 	//m_defdForNamesp = m_namespace;
+ 
+ 
  	m_eventMask = 0;
  	fetchEventAttribute("CloseEvent",OBJEVENT_CLOSEMODEL);
***************
*** 79,85 ****
--- 84,97 ----
  /*virtual*/ std::string ConstraintRep::getName() const
  {
+ #if(0)
  	// if real object (existing in the BON) the constructor has initialized m_name
  	// if artificial object then the init() did it
  	return m_name;
+ #else
+ 	// if real object we can inquire its name
+ 	// if artificial object then we use the value init() has set
+ 	if( m_ptr) return m_ptr->getName();
+ 	else       return m_name;
+ #endif
  }
  
***************
*** 104,107 ****
--- 116,120 ----
  std::string ConstraintRep::doDump()
  {
+ 	m_defdForNamesp = m_namespace;
  	std::string mmm = "";
  
***************
*** 111,114 ****
--- 124,131 ----
  	mmm += indStr() + "<constraint name=\"" + m_name + "\" eventmask = \"0x" + std::string(mask) + 
  		"\" depth = \"" + m_depth;
+ 	///z dump either the m_namespace variable /or/ the specific defdForNamesp variable owned by this
+ 	///z m_namespace or m_defdForNamesp
+ 	///z dump only if the object belongs to main namespace
+ 	if( !m_defdForNamesp.empty() && m_ptr && m_ptr->isInLibrary()) mmm+= "\" defdfornamesp = \"" + m_defdForNamesp;
  	mmm += "\" priority = \"" + std::string(priority_str) + "\">\n";
  

Index: Any.h
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep/Any.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Any.h	7 Apr 2005 21:26:24 -0000	1.8
--- Any.h	21 Jul 2006 19:31:18 -0000	1.9
***************
*** 23,26 ****
--- 23,27 ----
  {
  public: // constant strings
+ 	static const std::string NamespaceDelimiter_str;//"::"
  	static const std::string InRootFolder_str;//"InRootFolder"
  	static const std::string DisplayedName_str;//"DisplayedName"
***************
*** 68,71 ****
--- 69,74 ----
  public:	
  	virtual void initAttributes();
+ 	void initNamespace();
+ 	void resetNamespace();
  	virtual KIND_TYPE getMyKind() const = 0;
  	std::string getMyKindStr() const;
***************
*** 119,122 ****
--- 122,128 ----
  	ConstraintRepPtrList m_initialConstraintList;
  	ConstraintRepPtrList m_finalConstraintList;
+ 
+ 	// part of this namespace:
+ 	std::string m_namespace;
  
  private: // forbiding copy

Index: Sheet.h
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep/Sheet.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Sheet.h	27 Jun 2005 15:54:02 -0000	1.7
--- Sheet.h	21 Jul 2006 19:31:18 -0000	1.8
***************
*** 57,62 ****
--- 57,65 ----
  	Any* findAny( const BON::FCO& ptr);
  
+ 	std::string getNamespace() { return m_projNamespace; }
+ 
  	static BON::Folder m_BON_Project_Root_Folder;
  	static bool makeValidParadigmName( const std::string& pInName, std::string& result);
+ 	static bool makeValidNamespace( const std::string& pInName, std::string& result);
  
  protected:
***************
*** 115,118 ****
--- 118,122 ----
  	std::string m_projAuthor;
  	std::string m_projComment;
+ 	std::string m_projNamespace;
  
  	RootFolder m_rootFolder;

Index: AttributeRep.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep/AttributeRep.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** AttributeRep.cpp	10 Feb 2006 21:02:43 -0000	1.9
--- AttributeRep.cpp	21 Jul 2006 19:31:18 -0000	1.10
***************
*** 23,26 ****
--- 23,34 ----
  }
  
+ /*virtual*/ std::string AttributeRep::getName() const
+ {
+ 	if ( this->m_ptr)
+ 	{
+ 		return m_ptr->getName();
+ 	}
+ 	return "NullPtrError";
+ }
  
  bool AttributeRep::isGlobal()

Index: Sheet.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep/Sheet.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** Sheet.cpp	28 Jun 2005 17:50:35 -0000	1.13
--- Sheet.cpp	21 Jul 2006 19:31:18 -0000	1.14
***************
*** 19,22 ****
--- 19,23 ----
  	m_projAuthor(),
  	m_projComment(),
+ 	m_projNamespace(),
  	m_rootFolder(),
  	m_fcoRepList(),
***************
*** 154,157 ****
--- 155,162 ----
  	m_projAuthor = project->getAuthor();
  	m_projComment = project->getComment();
+ 	
+ 	BON::RegistryNode rn = project->getRootFolder()->getRegistry()->getChild( "Namespace");
+ 	if( rn) m_projNamespace = rn->getValue();
+ 	else    m_projNamespace = "";
  
  	// check the paradigm's name, containing spaces, other special chars, excluding '.' and '_'
***************
*** 162,165 ****
--- 167,178 ----
  		m_projName = new_name;
  	}
+ 
+ 	// check the namespace specified (can be empty)
+ 	new_name = "";
+ 	if( !Sheet::makeValidNamespace( m_projNamespace, new_name))
+ 	{
+ 		global_vars.err << MSG_ERROR << "Error: Incorrect namespace specified: \"" << m_projNamespace << "\". Use only alphanumerics and '_'. Using modified name: \"" << new_name << "\".\n";
+ 		m_projNamespace = new_name;
+ 	}
  }
  
***************
*** 185,188 ****
--- 198,202 ----
  	for( ; it0 != m_fcoRepList.end(); ++it0 )
  	{
+ 		(*it0)->initNamespace();
  		(*it0)->initAttributes();
  		if ( isInRootFolder( *it0)) m_rootFolder.addRootElement( *it0);
***************
*** 192,195 ****
--- 206,210 ----
  	for( ; it1 != m_atomList.end(); ++it1 )
  	{
+ 		(*it1)->initNamespace();
  		(*it1)->initAttributes();
  		if ( isInRootFolder( *it1)) m_rootFolder.addRootElement( *it1);
***************
*** 199,202 ****
--- 214,218 ----
  	for( ; it2 != m_modelList.end(); ++it2 )
  	{
+ 		(*it2)->initNamespace();
  		(*it2)->initAttributes();
  		if ( isInRootFolder( *it2)) m_rootFolder.addRootElement( *it2);
***************
*** 206,209 ****
--- 222,226 ----
  	for( ; it3 != m_connList.end(); ++it3 )
  	{
+ 		(*it3)->initNamespace();
  		(*it3)->initAttributes();
  		if ( isInRootFolder( *it3)) m_rootFolder.addRootElement( *it3);
***************
*** 213,216 ****
--- 230,234 ----
  	for( ; it4 != m_setList.end(); ++it4 )
  	{
+ 		(*it4)->initNamespace();
  		(*it4)->initAttributes();
  		if ( isInRootFolder( *it4)) m_rootFolder.addRootElement( *it4);
***************
*** 220,223 ****
--- 238,242 ----
  	for( ; it5 != m_refList.end(); ++it5 )
  	{
+ 		(*it5)->initNamespace();
  		(*it5)->initAttributes();
  		if ( isInRootFolder( *it5)) m_rootFolder.addRootElement( *it5);
***************
*** 227,233 ****
--- 246,271 ----
  	for( ; it6 != m_folderList.end(); ++it6 )
  	{
+ 		(*it6)->initNamespace();
  		(*it6)->initAttributes();
  		if ( isInRootFolder( *it6)) m_rootFolder.addSubFolder( *it6);
  	}}
+ 
+ 	{AttributeRep_Iterator it7 = m_attributeList.begin();
+ 	for( ; it7 != m_attributeList.end(); ++it7 )
+ 	{
+ 		(*it7)->initNamespace();
+ 	}}
+ 
+ 	{ConstraintFuncRep_Iterator it8 = m_constraintFuncList.begin();
+ 	for( ; it8 != m_constraintFuncList.end(); ++it8 )
+ 	{
+ 		(*it8)->initNamespace();
+ 	}}
+ 
+ 	{ConstraintRep_Iterator it9 = m_constraintList.begin();
+ 	for( ; it9 != m_constraintList.end(); ++it9 )
+ 	{
+ 		(*it9)->initNamespace();
+ 	}}
  }
  
***************
*** 751,752 ****
--- 789,810 ----
  	return !inv;
  }
+ 
+ /*static*/ bool Sheet::makeValidNamespace( const std::string& pInName, std::string& res)
+ {
+ 	res = pInName;
+ 	bool inv = false;
+ 	for( unsigned int i = 0; i < res.length(); ++i)
+ 	{
+ 		bool v = res[i] >= 'a' && res[i] <= 'z'
+ 			||   res[i] >= 'A' && res[i] <= 'Z'
+ 			||   res[i] >= '0' && res[i] <= '9' && i >= 1 // first char can't be a digit
+ 			||   res[i] == '_';
+ 
+ 		if( !v)
+ 		{
+ 			res[i] = '_';
+ 			inv = true;
+ 		}
+ 	}
+ 	return !inv;
+ }
\ No newline at end of file

Index: Any.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep/Any.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** Any.cpp	6 Jan 2006 21:49:03 -0000	1.15
--- Any.cpp	21 Jul 2006 19:31:18 -0000	1.16
***************
*** 23,26 ****
--- 23,27 ----
  }
  
+ /*static*/ const std::string Any::NamespaceDelimiter_str = "::";
  /*static*/ const std::string Any::InRootFolder_str = "InRootFolder";
  /*static*/ const std::string Any::DisplayedName_str = "DisplayedName";
***************
*** 61,64 ****
--- 62,109 ----
  }
  
+ void Any::initNamespace()
+ {
+ 	// decide which namespace the object belongs to:
+ 	if( m_ptr->isInLibrary())
+ 	{
+ 		bool all_equivs_in_lib = true;
+ 		for ( std::set< BON::FCO >::const_iterator it = m_equivs.begin()
+ 			; all_equivs_in_lib && it != m_equivs.end()
+ 			; ++it)
+ 		{
+ 			if ( *it == m_ptr) continue;
+ 			all_equivs_in_lib = (*it)->isInLibrary();
+ 		}
+ 
+ 		if( !all_equivs_in_lib) // it has equivs in the host project
+ 			resetNamespace();   // so needs to be in the main namespace
+ 		else
+ 		{
+ 			// if object is from a library its m_parentFolder variable holds the librootfolder (a readwriteable object)
+ 			ASSERT(0);
+ 			ASSERT( !m_parentFolder->isInLibrary());
+ 			BON::Folder parent( m_parentFolder);
+ 			while( parent && parent->isInLibrary()) {
+ 				parent = parent->getParentFolder();
+ 			} // the first parent which is not in the library is the LibRootFolder
+ 
+ 			BON::RegistryNode rn;
+ 			if( parent)	rn = parent->getRegistry()->getChild( "Namespace");
+ 
+ 			if( rn)	m_namespace = rn->getValue();
+ 			else    m_namespace = "";
+ 			//m_respPointer could be in another library then m_ptr, so the namespace could be different
+ 		}
+ 	}
+ 	else // regular object, init its namespace value from the project's value
+ 	{
+ 		resetNamespace();
+ 	}
+ }
+ 
+ void Any::resetNamespace()
+ {
+ 	m_namespace = Dumper::getInstance()->getNamespace();
+ }
  
  // applicable for folders only
***************
*** 103,107 ****
  	if ( this->m_ptr)
  	{
! 		return m_ptr->getName();
  	}
  	return "NullPtrError";
--- 148,152 ----
  	if ( this->m_ptr)
  	{
! 		return m_namespace + (m_namespace.empty()?"":Any::NamespaceDelimiter_str) + m_ptr->getName();
  	}
  	return "NullPtrError";

Index: ConstraintFuncRep.h
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep/ConstraintFuncRep.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ConstraintFuncRep.h	4 Dec 2003 16:45:27 -0000	1.1
--- ConstraintFuncRep.h	21 Jul 2006 19:31:18 -0000	1.2
***************
*** 10,13 ****
--- 10,14 ----
  	ConstraintFuncRep( BON::FCO& ptr);
  	std::string doDump();
+ 	/*virtual*/ std::string getName() const;
  	Any::KIND_TYPE getMyKind() const { return Any::CONSTRAINTFUNC; }
  
***************
*** 19,22 ****
--- 20,24 ----
  	std::string m_definition;
  	std::string m_parameterlist;
+ 	std::string m_defdForNamesp;
  
  private: // forbiding copy

Index: FCO.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep/FCO.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** FCO.cpp	21 Jun 2005 17:16:46 -0000	1.14
--- FCO.cpp	21 Jul 2006 19:31:18 -0000	1.15
***************
*** 76,84 ****
  	if( m_respPointer)
  	{
! 		return m_respPointer->getName();
  	}
  	else
  	{
! 		return m_ptr->getName();
  	}
  }
--- 76,84 ----
  	if( m_respPointer)
  	{
! 		return m_namespace + (m_namespace.empty()?"":Any::NamespaceDelimiter_str) + m_respPointer->getName();
  	}
  	else
  	{
! 		return m_namespace + (m_namespace.empty()?"":Any::NamespaceDelimiter_str) + m_ptr->getName();
  	}
  }

Index: AttributeRep.h
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep/AttributeRep.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** AttributeRep.h	4 Dec 2003 16:45:27 -0000	1.1
--- AttributeRep.h	21 Jul 2006 19:31:18 -0000	1.2
***************
*** 18,21 ****
--- 18,22 ----
  	virtual ~AttributeRep();
  	/*virtual*/ inline Any::KIND_TYPE  getMyKind() const { return Any::ATTRIBUTE; }
+ 	/*virtual*/ std::string getName() const;
  	/*virtual*/ std::string doDump() { return ""; }
  

Index: ConstraintRep.h
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep/ConstraintRep.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ConstraintRep.h	4 Dec 2003 16:45:27 -0000	1.1
--- ConstraintRep.h	21 Jul 2006 19:31:18 -0000	1.2
***************
*** 35,38 ****
--- 35,39 ----
  	//int m_depth;
  	std::string m_depth;
+ 	std::string m_defdForNamesp;
  	int m_eventMask;
  

Index: FolderRep.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Rep/FolderRep.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** FolderRep.cpp	21 Jun 2005 17:16:46 -0000	1.12
--- FolderRep.cpp	21 Jul 2006 19:31:18 -0000	1.13
***************
*** 45,53 ****
  	if( m_respPointer)
  	{
! 		return m_respPointer->getName();
  	}
  	else
  	{
! 		return m_ptr->getName();
  	}
  #endif
--- 45,53 ----
  	if( m_respPointer)
  	{
! 		return m_namespace + (m_namespace.empty()?"":Any::NamespaceDelimiter_str) + m_respPointer->getName();
  	}
  	else
  	{
! 		return m_namespace + (m_namespace.empty()?"":Any::NamespaceDelimiter_str) + m_ptr->getName();
  	}
  #endif



More information about the GME-commit mailing list