You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by gw...@apache.org on 2006/12/11 11:31:45 UTC

svn commit: r485591 - in /incubator/tuscany/cpp/sdo/runtime/core: src/commonj/sdo/TypeImpl.cpp src/commonj/sdo/TypeImpl.h test/main.cpp test/sdotest.h test/sdotest2.cpp

Author: gwinn
Date: Mon Dec 11 02:31:41 2006
New Revision: 485591

URL: http://svn.apache.org/viewvc?view=rev&rev=485591
Log:
TUSCANY-562

Modified:
    incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp
    incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.h
    incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp
    incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h
    incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp

Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp?view=diff&rev=485591&r1=485590&r2=485591
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp Mon Dec 11 02:31:41 2006
@@ -233,12 +233,26 @@
           isOpen = set;
     }
 
+    bool TypeImpl::isBaseTypeOf(const Type* type) const
+    { 
+        return type 
+            && (this == type || isBaseTypeOf(type->getBaseType())); 
+    } 
+
     ///////////////////////////////////////////////////////////////////////////
     // Sets a data type as open.
     ///////////////////////////////////////////////////////////////////////////
 
     void TypeImpl::setBaseType(const Type* bt, bool isRestriction) 
     {
+        if (isBaseTypeOf(bt))
+        {
+            SDOString stringBuffer = getName();
+            stringBuffer += "\tis base type of\t";
+            stringBuffer += bt->getName();
+            SDO_THROW_EXCEPTION(setBaseType, SDOIllegalArgumentException, stringBuffer.c_str())
+        }
+
         baseType = (TypeImpl*)bt;
         brestriction = isRestriction;
         

Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.h?view=diff&rev=485591&r1=485590&r2=485591
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.h Mon Dec 11 02:31:41 2006
@@ -284,6 +284,7 @@
     TypeImpl();
     TypeImpl(const TypeImpl& t);
 
+    bool isBaseTypeOf(const Type* type)const;
 
     char* name;
     char* typeURI;

Modified: incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp?view=diff&rev=485591&r1=485590&r2=485591
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp Mon Dec 11 02:31:41 2006
@@ -180,6 +180,7 @@
     TEST (  sdotest::cdatatest() );
 	TEST (  sdotest::cloneopentest() );
 	TEST (  sdotest::tuscany963() );
+	TEST (  sdotest::tuscany562() );
 
     cout << "Total tests:" << totaltests << " Tests passed:" << testspassed << endl;
     return testspassed - totaltests;

Modified: incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h?view=diff&rev=485591&r1=485590&r2=485591
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h Mon Dec 11 02:31:41 2006
@@ -201,5 +201,6 @@
         static int cdatatest();
         static int cloneopentest();
         static int tuscany963();
+        static int tuscany562();
         static int upandatom();
 };

Modified: incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp?view=diff&rev=485591&r1=485590&r2=485591
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp Mon Dec 11 02:31:41 2006
@@ -1517,6 +1517,33 @@
     }
 }
 
+int sdotest::tuscany562()
+{
+    DataFactoryPtr mdg  = DataFactory::getDataFactory();
+    mdg->addType("myspace", "Base");
+    mdg->addType("myspace", "Extended");
+    const Type &base = mdg->getType("myspace", "Base"),
+               &extended = mdg->getType("myspace", "Extended");
+    mdg->setBaseType(extended, base);
+    try
+    {
+        mdg->setBaseType(extended, extended);
+        cout << "Exception should have been thrown in tuscany562 (1)" << endl;
+        return 0;
+    }
+    catch (SDOIllegalArgumentException e)
+    {}
+    try
+    {
+        mdg->setBaseType(base, extended);
+        cout << "Exception should have been thrown in tuscany562 (2)" << endl;
+        return 0;
+    }
+    catch (SDOIllegalArgumentException e)
+    {}
+    return 1;
+}
+
 int sdotest::upandatom()
 {
 



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org