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

endre at redhat1.isis.vanderbilt.edu endre at redhat1.isis.vanderbilt.edu
Mon Jul 4 13:25:52 CDT 2011


Author: endre
Date: Mon Jul  4 13:25:52 2011
New Revision: 3775

Log:
Add a toString method to Udm::ObjectImpl and Udm::Object to dump some minimal info about objects during debuging.

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

Modified: UDM/trunk/include/UdmBase.h
==============================================================================
--- UDM/trunk/include/UdmBase.h	Mon Jul  4 13:23:10 2011	(r3774)
+++ UDM/trunk/include/UdmBase.h	Mon Jul  4 13:25:52 2011	(r3775)
@@ -504,6 +504,7 @@
 		virtual vector<ObjectImpl*> getConnectingChain(const ::Uml::AssociationRole &meta, const ObjectImpl* peer) const;
 
 		// utilities
+		virtual string toString() const;
 		// 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;
 	};
@@ -597,6 +598,7 @@
 		virtual ObjectImpl *clone() { return this; }
 		virtual void release() { } 
 		virtual DataNetwork *__getdn() const { throw e; }
+		virtual string toString() const { return "NullObject"; }
 
 		virtual const ::Uml::Class &type() const { throw e; }
 
@@ -3129,6 +3131,8 @@
 		// distance from root; root is at level zero
 		int depth_level() const;
 
+		string toString() const;
+
 		// libraries
 		virtual bool isLibObject() const;
 		virtual bool isLibRoot() const;

Modified: UDM/trunk/src/UdmBase/UdmBase.cpp
==============================================================================
--- UDM/trunk/src/UdmBase/UdmBase.cpp	Mon Jul  4 13:23:10 2011	(r3774)
+++ UDM/trunk/src/UdmBase/UdmBase.cpp	Mon Jul  4 13:25:52 2011	(r3775)
@@ -97,6 +97,7 @@
 #include <string>
 #include <cstdlib>
 #include <cstring>
+#include <sstream>
 
 #ifndef _WIN32
 long long _atoi64(const char *x)  { long long i; sscanf(x,"%lld",&i);return i;};
@@ -238,6 +239,14 @@
 		return Object(lib_root);
 	}
 
+	UDM_DLL string Object::toString() const
+	{
+		if (impl != &Udm::_null)
+			return impl->toString();
+
+		return "NULL impl";
+	}
+
 
 	udm_exception NullObject::e("Object handle is null");
 
@@ -1857,7 +1866,7 @@
 			DataNetwork *dn = __getdn();
 			ObjectImpl *parent = getParent(NULLPARENTROLE);
 
-			if ( (dn && this == dn->GetRootObject().__impl()) || parent == NULL)
+			if ( (dn && this == dn->GetRootObject().__impl()) || parent == &Udm::_null)
 			{
 				if (bNeedRootFolder)
 					return UdmUtil::ExtractName(this, "name");
@@ -1876,6 +1885,30 @@
 			}
 		}
 
+		UDM_DLL string ObjectImpl::toString() const
+		{
+			ostringstream ret;
+
+			// path or name
+			ret << getPath("/");
+
+			// unique Id
+			ret << " [" << uniqueId() << "]";
+
+			if (type().__impl() != &Udm::_null) {
+				ret << " of type " << type().getPath2("::");
+			} else
+				ret << " of unknown type";
+
+			DataNetwork *dn = __getdn();
+			if (dn) {
+				ret << ", in DN " << dn->uniqueId();
+			} else
+				ret << ", not in a DN";
+
+			return ret.str();
+		}
+
 
 		//the map for static metadepository
 		map<string, const UdmDiagram*>* MetaDepository::meta_dep = NULL;


More information about the Mobies-commit mailing list