[Mobies-commit] [commit] r3774 - in UDM/trunk: include src/UdmBase src/UdmUtil

endre at redhat1.isis.vanderbilt.edu endre at redhat1.isis.vanderbilt.edu
Mon Jul 4 13:23:10 CDT 2011


Author: endre
Date: Mon Jul  4 13:23:10 2011
New Revision: 3774

Log:
Implement getPath method for ObjectImpl.

Modified:
   UDM/trunk/include/UdmBase.h
   UDM/trunk/src/UdmBase/UdmBase.cpp
   UDM/trunk/src/UdmUtil/UdmUtil.cpp

Modified: UDM/trunk/include/UdmBase.h
==============================================================================
--- UDM/trunk/include/UdmBase.h	Mon Jul  4 13:18:21 2011	(r3773)
+++ UDM/trunk/include/UdmBase.h	Mon Jul  4 13:23:10 2011	(r3774)
@@ -503,6 +503,9 @@
 		virtual void disconnectFrom(const ::Uml::AssociationRole &meta, ObjectImpl* peer);
 		virtual vector<ObjectImpl*> getConnectingChain(const ::Uml::AssociationRole &meta, const ObjectImpl* peer) const;
 
+		// utilities
+		// root folder is added by default, no reverse order suport, delimiter is never added to the front
+		virtual string getPath( const string &strDelimiter = "/", bool bNeedRootFolder = true ) const;
 	};
 
 

Modified: UDM/trunk/src/UdmBase/UdmBase.cpp
==============================================================================
--- UDM/trunk/src/UdmBase/UdmBase.cpp	Mon Jul  4 13:18:21 2011	(r3773)
+++ UDM/trunk/src/UdmBase/UdmBase.cpp	Mon Jul  4 13:23:10 2011	(r3774)
@@ -1852,6 +1852,30 @@
 			return ret;
 		}
 
+		UDM_DLL string ObjectImpl::getPath(const string &strDelimiter, bool bNeedRootFolder) const
+		{
+			DataNetwork *dn = __getdn();
+			ObjectImpl *parent = getParent(NULLPARENTROLE);
+
+			if ( (dn && this == dn->GetRootObject().__impl()) || parent == NULL)
+			{
+				if (bNeedRootFolder)
+					return UdmUtil::ExtractName(this, "name");
+				else
+					return "";
+			}
+			else
+			{
+				string path = parent->getPath(strDelimiter, bNeedRootFolder);
+				if (path.length())
+					path += strDelimiter;	// parent could be the root folder, if bNeedRootFolder is
+								// false then path to parent is empty and delimiter must not be added
+
+				path += UdmUtil::ExtractName(this, "name");
+				return path;
+			}
+		}
+
 
 		//the map for static metadepository
 		map<string, const UdmDiagram*>* MetaDepository::meta_dep = NULL;

Modified: UDM/trunk/src/UdmUtil/UdmUtil.cpp
==============================================================================
--- UDM/trunk/src/UdmUtil/UdmUtil.cpp	Mon Jul  4 13:18:21 2011	(r3773)
+++ UDM/trunk/src/UdmUtil/UdmUtil.cpp	Mon Jul  4 13:23:10 2011	(r3774)
@@ -23,7 +23,6 @@
 #include <sstream>
 
 
-
 using namespace Uml;
 using namespace Udm;
 
@@ -95,6 +94,9 @@
 
 	UDM_DLL string ExtractName(const Udm::ObjectImpl *impl,  const string &att_name )
 	{
+		if (impl->type().__impl() == NULL)
+			return string("<not discoverable>");
+
 		::Uml::Class cls = impl->type();
 		set< ::Uml::Attribute> attrs=cls.attributes();		
 		
@@ -843,8 +845,7 @@
 	}
 
 
-
-	#if defined(HAVE_EXECINFO_H)
+#if defined(HAVE_EXECINFO_H)
 
 	string demangled_symbol(const char *str)
 	{
@@ -941,7 +942,7 @@
 
 #endif // if defined(HAVE_DLFCN_H)
 
-	#else // if defined(HAVE_EXECINFO_H)
+#else // if defined(HAVE_EXECINFO_H)
 
 	vector<string> get_symbols()
 	{
@@ -1002,7 +1003,7 @@
 		return res;
 	}
 
-	#endif // if defined(HAVE_EXECINFO_H)
+#endif // if defined(HAVE_EXECINFO_H)
 
 	UDM_DLL string stacktrace()
 	{
@@ -1024,5 +1025,5 @@
 			trace += "    " + v[i] + "\n";
 
 		return trace;
-	};
-};
\ No newline at end of file
+	}
+};


More information about the Mobies-commit mailing list