You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ed...@apache.org on 2006/03/08 10:23:38 UTC
svn commit: r384165 -
/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/
Author: edslattery
Date: Wed Mar 8 01:23:35 2006
New Revision: 384165
URL: http://svn.apache.org/viewcvs?rev=384165&view=rev
Log:
Addition of fixes for PHP and initial proposal for code-gen support for typesafe interface.
Modified:
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DASType.h
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactory.h
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.h
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.h
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeDefinition.h
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/src/commonj/sdo/TypeList.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/XSDHelperImpl.cpp
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DASType.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DASType.h?rev=384165&r1=384164&r2=384165&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DASType.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DASType.h Wed Mar 8 01:23:35 2006
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Rev$ $Date: 2005/12/22 16:54:14 $ */
+/* $Rev$ $Date: 2006/03/01 08:52:41 $ */
#ifndef _DASTYPE_H_
#define _DASTYPE_H_
@@ -43,7 +43,7 @@
virtual void setOpen(bool set) = 0;
virtual void setSequenced( bool set) = 0;
- virtual void setBaseType( const Type* type) = 0;
+ virtual void setBaseType( const Type* type, bool isRestriction=false) = 0;
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactory.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactory.h?rev=384165&r1=384164&r2=384165&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactory.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactory.h Wed Mar 8 01:23:35 2006
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Rev$ $Date: 2005/12/22 16:54:14 $ */
+/* $Rev$ $Date: 2006/03/07 11:05:20 $ */
#ifndef _DATAFACTORY_H_
#define _DATAFACTORY_H_
@@ -142,13 +142,25 @@
virtual SDO_API void setBaseType(
const Type& type,
- const Type& base) = 0;
+ const Type& base,
+ bool isRestriction = false) = 0;
virtual SDO_API void setBaseType(
const char* typeuri,
const char* typenam,
const char* baseuri,
- const char* basename) = 0;
+ const char* basename,
+ bool isRestriction = false) = 0;
+
+
+ /**
+ * Generate a typesafe interface for a given data factory
+ * test code.
+ */
+
+ virtual SDO_API bool generateInterface(const char* fileroot,
+ const char *factoryname) = 0;
+
/**
* DataFactory::setAlias sets an alternative name
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp?rev=384165&r1=384164&r2=384165&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp Wed Mar 8 01:23:35 2006
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Rev$ $Date: 2006/02/08 14:43:56 $ */
+/* $Rev$ $Date: 2006/03/07 11:05:20 $ */
//////////////////////////////////////////////////////////////////////
// DataFactoryImpl.cpp: implementation of the DataFactory class.
@@ -608,9 +608,10 @@
// ===================================================================
void DataFactoryImpl::setBaseType( const Type& type,
- const Type& base)
+ const Type& base, bool isRestriction)
{
- setBaseType(type.getURI(),type.getName(),base.getURI(), base.getName());
+ setBaseType(type.getURI(),type.getName(),base.getURI(), base.getName(),
+ isRestriction);
}
// ===================================================================
@@ -620,7 +621,8 @@
void DataFactoryImpl::setBaseType( const char* typeuri,
const char* typenam,
const char* baseuri,
- const char* basename)
+ const char* basename,
+ bool isRestriction )
{
const TypeImpl* base = findTypeImpl(baseuri, basename);
if (base == 0)
@@ -649,7 +651,7 @@
SDOTypeNotFoundException, msg.c_str());
}
- (typeIter->second)->setBaseType(base);
+ (typeIter->second)->setBaseType(base, isRestriction);
}
@@ -1229,6 +1231,529 @@
}
return NULL;
+}
+
+
+bool DataFactoryImpl::compareTypes(const TypeImpl* t1, const Type& t2)
+{
+ PropertyList pl = t2.getProperties();
+ for (int i=0;i<pl.size();i++)
+ {
+ PropertyImpl* p = t1->getPropertyImpl(i);
+ if (p == 0) return false;
+ if (p->isMany() != pl[i].isMany()) return false;
+ if (p->isContainment() != pl[i].isContainment()) return false;
+ if (strcmp( p->getType().getURI(),
+ pl[i].getType().getURI())) return false;
+ if (strcmp( p->getType().getName(),
+ pl[i].getType().getName())) return false;
+ }
+ return true;
+
+}
+bool DataFactoryImpl::checkType(const Type& t)
+{
+ const TypeImpl* t2 = findTypeImpl(t.getURI(),
+ t.getName());
+
+ if (t2 == 0) return false;
+
+ if (!compareTypes(t2,t)) return false;
+
+ PropertyList pl = t.getProperties();
+ for (int i=0;i<pl.size();i++)
+ {
+ if (pl[i].getType().isDataObjectType())
+ {
+ if (!checkType(pl[i].getType())) return false;
+ }
+ }
+ return true;
+}
+
+
+// only checks the tree dirctly descended from this object if the
+// object is specified, otherwise validates the whole factory
+
+bool DataFactoryImpl::isCompatible(DataFactory* df, DataObject* d)
+{
+ if (d == 0)
+ {
+ TypeList tl = df->getTypes();
+ for (int j=0;j<tl.size();j++)
+ {
+ const TypeImpl* t = findTypeImpl(tl[j].getURI(),
+ tl[j].getName());
+
+ if (t == 0) return false;
+ if (!compareTypes(t,tl[j]))return false;
+ }
+ return true;
+ }
+ else
+ {
+ return checkType(d->getType());
+ }
+}
+
+bool DataFactoryImpl::generateInterface(const char* fileroot, const char* factoryname)
+{
+
+ FILE* header;
+ FILE* body;
+
+ if ((fileroot == 0) || (strlen(fileroot) == 0)) return false;
+
+ if (factoryname == 0 || (strlen(factoryname) == 0)) return false;
+
+
+ char *headername = new char[strlen(fileroot) + 5];
+ char *bodyname = new char[strlen(fileroot) + 5];
+ strcpy(headername,fileroot);
+ strcpy(bodyname,fileroot);
+ strcat(headername,".h");
+ strcat(bodyname,".cpp");
+
+ // here we should check the files - and if they are present with
+ // contents we should read them, and merge the new generated code
+ // I think the way to do that is to allow sections in between comment
+ // pairs in three locations:
+ // a) outside any method in the CPP file.
+ // b) in the header file anywhere.
+ // c) inside method definitions in cpp, either before, or after the
+ // entire generated contents.
+ //
+ //
+
+ header = fopen(headername,"w+");
+ if (header == 0) return false;
+
+ body = fopen(bodyname,"w+");
+ if (body == 0) return false;
+
+
+ fprintf(header,"/*******************************************\n");
+ fprintf(header," * Generated Typesafe Interface Header *\n");
+ fprintf(header," *******************************************/\n\n\n");
+ fprintf(header,"#include \"commonj/sdo/SDO.h\"\n");
+ fprintf(header,"using namespace commonj::sdo;\n\n\n");
+
+ fprintf(body,"/*******************************************\n");
+ fprintf(body," * Generated Typesafe Interface Body *\n");
+ fprintf(body," *******************************************/\n\n\n");
+ fprintf(body,"#include \"%s\"\n",headername);
+ fprintf(body,"using namespace commonj::sdo;\n\n\n");
+
+ delete headername;
+ delete bodyname;
+
+ try {
+
+ int nscount;
+
+ TypeList& tl = getTypes();
+
+ // forward declarations and smart pointers
+
+ fprintf(header,"/*******************************************\n");
+ fprintf(header," * Forward declarations and smart pointers *\n");
+ fprintf(header," *******************************************/\n\n\n");
+
+ for (int i=0;i<tl.size();i++)
+ {
+ nscount = 0;
+
+ if (!strcmp(tl[i].getURI(),"commonj.sdo")) continue;
+
+ const char *uri = tl[i].getURI();
+ char *c = strchr(uri,'.');
+
+ if (c == 0)
+ {
+ fprintf(header,"namespace %s{\n",uri);
+ nscount = 1;
+ }
+ else
+ {
+ char* buf = new char[strlen(uri) + 1];
+ strcpy(buf, uri);
+ c = buf;
+ char* c1;
+ do {
+ c1 = strchr(c,'.');
+ if (c1) *c1 = 0;
+ fprintf(header,"namespace %s{\n", c);
+ nscount++;
+ if (c1) c = c1+1;
+ } while (c1 != 0);
+ delete buf;
+ }
+
+ const char* name = tl[i].getName();
+
+ fprintf(header," class %s;\n",name);
+ fprintf(header," typedef RefCountingPointer<%s> %sPtr;\n",
+ name, name);
+
+ for (int i=0;i<nscount;i++)
+ {
+ fprintf(header,"}\n");
+ }
+ }
+ fprintf(header,"\n\n");
+ fprintf(header,"/*******************************************\n");
+ fprintf(header," * The Data factory *\n");
+ fprintf(header," *******************************************/\n\n\n");
+
+ fprintf(header,"class %sDataFactory {\n", factoryname);
+ fprintf(header," public:\n");
+ fprintf(header," static %sDataFactory* get%sDataFactory();\n",
+ factoryname, factoryname);
+
+ for (i=0;i<tl.size();i++)
+ {
+
+ if (!strcmp(tl[i].getURI(),"commonj.sdo")) continue;
+
+ const char *uri = tl[i].getURI();
+ const char *name = tl[i].getName();
+ char* the_uri = strchr(uri,'.');
+
+ if (the_uri == 0)
+ {
+ the_uri = new char[strlen(uri) + 1];
+ strcpy(the_uri,uri);
+ }
+ else
+ {
+ the_uri = new char[2 * strlen(uri) + 1];
+ int jj=0;
+ for (int ii=0;ii<strlen(uri);ii++)
+ {
+ if (uri[ii] == '.')
+ {
+ the_uri[jj++]=':';
+ the_uri[jj++]=':';
+ }
+ else
+ {
+ the_uri[jj++] = uri[ii];
+ }
+ }
+ the_uri[jj] = 0;
+ }
+
+ fprintf(header," %s::%sPtr create%s();\n", the_uri, name, name);
+
+ fprintf(body,"%s::%sPtr %sDataFactory::create%s()\n",the_uri, name, factoryname, name);
+ fprintf(body,"{\n");
+ fprintf(body," DataObjectPtr dob = the_factory->create(\"%s\",\"%s\");\n",
+ tl[i].getURI(),name);
+ fprintf(body," %s::%s* the_ob = new %s::%s(dob);\n",the_uri,name,the_uri,name);
+ fprintf(body," return the_ob;\n");
+ fprintf(body,"}\n\n");
+
+ delete the_uri;
+
+ }
+
+ fprintf(header," DataFactory* getDataFactory()\n");
+ fprintf(header," {\n");
+ fprintf(header," return (DataFactory*)the_factory;\n");
+ fprintf(header," }\n");
+ fprintf(header," private:\n");
+ fprintf(header," DataFactoryPtr the_factory;\n");
+ fprintf(header,"};\n");
+
+ fprintf(header,"\n\n");
+
+ fprintf(body,"%sDataFactory* %sDataFactory::get%sDataFactory()\n",
+ factoryname,factoryname,factoryname);
+ fprintf(body,"{\n");
+ fprintf(body," %sDataFactory* t = new %sDataFactory();\n",
+ factoryname, factoryname);
+ fprintf(body," t->the_factory = DataFactory::getDataFactory();\n");
+ fprintf(body," return t;\n");
+ fprintf(body,"}\n\n");
+
+
+ fprintf(header,"/*******************************************\n");
+ fprintf(header," * DataObject Type definitions *\n");
+ fprintf(header," *******************************************/\n\n\n");
+
+
+ for (i=0;i<tl.size();i++)
+ {
+ nscount = 0;
+
+ if (!strcmp(tl[i].getURI(),"commonj.sdo")) continue;
+ const char *uri = tl[i].getURI();
+ char *c = strchr(uri,'.');
+
+ if (c == 0)
+ {
+ fprintf(header,"namespace %s{\n",uri);
+ fprintf(body, "namespace %s{\n",uri);
+ nscount = 1;
+ }
+ else
+ {
+ char* buf = new char[strlen(uri) + 1];
+ strcpy(buf, uri);
+ c = buf;
+ char* c1;
+ do {
+ c1 = strchr(c,'.');
+ if (c1) *c1 = 0;
+ fprintf(header,"namespace %s{\n", c);
+ fprintf(body, "namespace %s{\n", c);
+ nscount++;
+ if (c1) c = c1+1;
+ } while (c1 != 0);
+ delete buf;
+ }
+
+
+ const char* name = tl[i].getName();
+
+ fprintf(header," class %s :public RefCountingObject {\n", name);
+ fprintf(header," public:\n");
+ fprintf(header," %s(DataObject* d);",name);
+
+ // construction from a data object
+
+ fprintf(body,"%s::%s(DataObject* d)\n",name,name);
+ fprintf(body,"{\n");
+ fprintf(body," the_object = d;\n");
+ fprintf(body," the_object->setUserData((void*)this);\n");
+ fprintf(body,"}\n\n\n");
+
+
+
+ PropertyList& pl = tl[i].getProperties();
+ for (int j=0;j<pl.size();j++)
+ {
+ const char* pname = pl[j].getName();
+
+ if (pl[j].isMany())
+ {
+ fprintf(header," DataObjectList& get%s();\n",pname);
+ fprintf(body, "DataObjectList& %s::get%s\n{\n",name,pname);
+ fprintf(body, " return the_object->getList(\"%s\");\n",pname);
+ fprintf(body, "}\n\n");
+ }
+ else
+ {
+ if (pl[j].getType().isDataType())
+ {
+ switch (pl[j].getTypeEnum())
+ {
+ case Type::BooleanType:
+ fprintf(header," bool get%s();\n",pname);
+ fprintf(body, "bool %s::get%s\n(){\n",name, pname);
+ fprintf(body, " return the_object->getBoolean(\"%s\");\n",pname);
+ fprintf(body, "}\n\n");
+ fprintf(header," void set%s(bool b);\n",pname);
+ fprintf(body, "void %s::set%s(bool b)\n{\n",name, pname);
+ fprintf(body, " the_object->setBoolean(\"%s\",b);\nreturn;\n",pname);
+ fprintf(body, "}\n\n");
+
+ break;
+
+ case Type::ByteType:
+
+ fprintf(header," char get%s();\n",pname);
+ fprintf(body, "char %s::get%s\n{\n",name, pname);
+ fprintf(body, " return the_object->getByte(\"%s\");\n",pname);
+ fprintf(body, "}\n\n");
+ fprintf(header," void set%s(char c);\n",pname);
+ fprintf(body, "void %s::set%s(char c)\n{\n",name, pname);
+ fprintf(body, " the_object->setByte(\"%s\",c);\nreturn;\n",pname);
+ fprintf(body, "}\n\n");
+
+ break;
+
+ case Type::BytesType:
+
+ fprintf(header," unsigned int get%s(char *buf, unsigned int len);\n",pname);
+ fprintf(body, "unsigned int %s::get%s(char *buf, unsigned int len)\n{\n",name,
+ pname);
+ fprintf(body, " return the_object->getBytes(\"%s\", buf,len);\n",pname);
+ fprintf(body, "}\n\n");
+ fprintf(header," void set%s(char *buf,unsigned int len);\n",pname);
+ fprintf(body, "void %s::set%s(char *buf, unsigned int len)\n{\n",name,
+ pname);
+ fprintf(body, " the_object->setBytes(\"%s\", buf,len);\nreturn;\n",pname);
+ fprintf(body, "}\n\n");
+
+ break;
+
+ case Type::CharacterType:
+
+ fprintf(header," wchar_t get%s();\n",pname);
+ fprintf(body, "wchar_t %s::get%s\n{\n",name, pname);
+ fprintf(body, " return the_object->getCharacter(\"%s\");\n",pname);
+ fprintf(body, "}\n\n");
+ fprintf(header," void set%s(wchar_t c);\n",pname);
+ fprintf(body, "void %s::set%s(wchar_t c)\n{\n",name, pname);
+ fprintf(body, " the_object->setCharacter(\"%s\",c);\nreturn;\n",pname);
+ fprintf(body, "}\n\n");
+
+ break;
+
+ case Type::DateType:
+
+ fprintf(header," SDODate get%s();\n",pname);
+ fprintf(body, "SDODate %s::get%s\n{\n",name, pname);
+ fprintf(body, " return the_object->getDate(\"%s\");\n",pname);
+ fprintf(body, "}\n\n");
+ fprintf(header," void set%s(const SDODate c);\n",pname);
+ fprintf(body, "void %s::set%s(const SDODate c)\n{\n",name, pname);
+ fprintf(body, " the_object->setDate(\"%s\",c);\nreturn;\n",pname);
+ fprintf(body, "}\n\n");
+
+ break;
+
+ case Type::DoubleType:
+
+ fprintf(header," long double get%s();\n",pname);
+ fprintf(body, "long double %s::get%s\n{\n",name, pname);
+ fprintf(body, " return the_object->getDouble(\"%s\");\n",pname);
+ fprintf(body, "}\n\n");
+ fprintf(header," void set%s(long double c);\n",pname);
+ fprintf(body, "void %s::set%s(long double c)\n{\n",name, pname);
+ fprintf(body, " the_object->setDouble(\"%s\",c);\nreturn;\n",pname);
+ fprintf(body, "}\n\n");
+
+ break;
+
+ case Type::FloatType:
+
+ fprintf(header," float get%s();\n",pname);
+ fprintf(body, "float %s::get%s\n{\n",name, pname);
+ fprintf(body, " return the_object->getFloat(\"%s\");\n",pname);
+ fprintf(body, "}\n\n");
+ fprintf(header," void set%s(float c);\n",pname);
+ fprintf(body, "void %s::set%s(float c)\n{\n",name, pname);
+ fprintf(body, " the_object->setFloat(\"%s\",c);\nreturn;\n",pname);
+ fprintf(body, "}\n\n");
+
+ break;
+
+ case Type::IntegerType:
+
+ fprintf(header," long get%s();\n",pname);
+ fprintf(body, "long %s::get%s\n{\n",name, pname);
+ fprintf(body, " return the_object->getInteger(\"%s\");\n",pname);
+ fprintf(body, "}\n\n");
+ fprintf(header," void set%s(long c);\n",pname);
+ fprintf(body, "void %s::set%s(long c)\n{\n",name, pname);
+ fprintf(body, " the_object->setInteger(\"%s\",c);\nreturn;\n",pname);
+ fprintf(body, "}\n\n");
+
+ break;
+
+ case Type::LongType:
+
+ fprintf(header," int64_t get%s();\n",pname);
+ fprintf(body, "int64_t %s::get%s\n{\n",name, pname);
+ fprintf(body, " return the_object->getLong(\"%s\");\n",pname);
+ fprintf(body, "}\n\n");
+ fprintf(header," void set%s(int64_t c);\n",pname);
+ fprintf(body, "void %s::set%s(int64_t c)\n{\n",name, pname);
+ fprintf(body, " the_object->setLong(\"%s\",c);\nreturn;\n",pname);
+ fprintf(body, "}\n\n");
+
+ break;
+
+ case Type::ShortType:
+
+ fprintf(header," short get%s();\n",pname);
+ fprintf(body, "short %s::get%s\n{\n",name, pname);
+ fprintf(body, " return the_object->getShort(\"%s\");\n",pname);
+ fprintf(body, "}\n\n");
+ fprintf(header," void set%s(short c);\n",pname);
+ fprintf(body, "void %s::set%s(short c)\n{\n",name, pname);
+ fprintf(body, " the_object->setShort(\"%s\",c);\nreturn;\n",pname);
+ fprintf(body, "}\n\n");
+
+ break;
+
+ case Type::StringType:
+ case Type::UriType:
+
+ fprintf(header," unsigned int get%s(wchar_t *buf, unsigned int len);\n",pname);
+ fprintf(body, "unsigned int %s::get%s(wchar_t *buf, unsigned int len)\n{\n",name,
+ pname);
+ fprintf(body, " return the_object->getString(\"%s\", buf,len);\n",pname);
+ fprintf(body, "}\n\n");
+ fprintf(header," void set%s(wchar_t *buf,unsigned int len);\n",pname);
+ fprintf(body, "void %s::set%s(wchar_t *buf, unsigned int len)\n{\n",name,
+ pname);
+ fprintf(body, " the_object->setString(\"%s\", buf,len);\nreturn;\n",pname);
+ fprintf(body, "}\n\n");
+
+ break;
+
+ default:
+ fprintf(header,"/* unknown primitive:%s */\n",pname);
+ break;
+ }
+ }
+ else
+
+ {
+ const char* ttname = pl[j].getType().getName();
+
+ fprintf(header," %sPtr get%s();\n",ttname, pname);
+
+ fprintf(body, "%sPtr %s::get%s()\n{\n",
+ ttname,
+ name,
+ pname);
+ fprintf(body, "DataObjectPtr dob = the_object->getDataObject(\"%s\");\n",pname);
+ fprintf(body, "DataObject* d = (DataObject*)dob;\n");
+ fprintf(body,"%s* value = (%s*)(d->getUserData());\n",ttname, ttname);
+ fprintf(body, " return (%s*)value;\n", ttname);
+ fprintf(body, "}\n\n");
+ fprintf(header," void set%s(%sPtr dob);\n",pname, ttname);
+ fprintf(body, "void %s::set%s(%sPtr dob)\n{\n",
+ name,pname,ttname);
+ fprintf(body,"%s* ptr = dob;\n", ttname);
+ fprintf(body,"DataObject* the_obj = ptr->getDataObject();\n");
+ fprintf(body,"the_object->setDataObject(\"%s\", the_obj);\nreturn;\n",
+ pname);
+ fprintf(body, "}\n\n");
+
+ }
+ }
+ } // for
+
+ // now print the contained data object
+
+ fprintf(header," DataObject* getDataObject()\n");
+ fprintf(header," {\n");
+ fprintf(header," return (DataObject*)the_object;\n");
+ fprintf(header," }\n");
+ fprintf(header," private:\n");
+ fprintf(header," DataObjectPtr the_object;\n");
+
+ fprintf(header,"};\n");
+ for (int i=0;i<nscount;i++)
+ {
+ fprintf(header,"}\n");
+ fprintf(body,"}\n");
+ }
+ }
+ fclose (header);
+ fclose (body);
+ }
+ catch (SDORuntimeException e)
+ {
+ cout << "Exception in code Generation" << endl;
+ cout << e << endl;
+ }
+ return true;
}
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.h?rev=384165&r1=384164&r2=384165&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.h Wed Mar 8 01:23:35 2006
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Rev$ $Date: 2005/12/22 16:54:14 $ */
+/* $Rev$ $Date: 2006/03/07 11:05:20 $ */
#ifndef _DataFactoryIMPL_H_
#define _DataFactoryIMPL_H_
@@ -120,12 +120,14 @@
virtual void setBaseType( const Type& type,
- const Type& base);
+ const Type& base,
+ bool isRestriction = false);
virtual void setBaseType( const char* typeuri,
const char* typenam,
const char* baseuri,
- const char* basename);
+ const char* basename,
+ bool isRestriction = false);
virtual const Type& getType(const char* uri, const char* inTypeName) const;
@@ -357,11 +359,17 @@
virtual const TypeImpl& getTypeImpl(const char* uri, const char* inTypeName) const;
virtual const char* getRootElementName() const;
virtual void setRootElementName(const char* ren);
+ virtual bool checkType(const Type& t);
+ virtual bool isCompatible(DataFactory* df, DataObject* d);
+ virtual bool compareTypes(const TypeImpl* t1, const Type& t2);
+ virtual bool generateInterface(const char* fileroot, const char* factoryname);
private:
typedef map<string, TypeImpl*> TYPES_MAP;
TYPES_MAP types;
+
+ std::vector<DataFactory*> compatibleFactories;
char * rootElementName;
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp?rev=384165&r1=384164&r2=384165&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp Wed Mar 8 01:23:35 2006
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Rev$ $Date: 2006/02/02 16:41:30 $ */
+/* $Rev$ $Date: 2006/03/03 14:34:26 $ */
#include "commonj/sdo/disable_warn.h"
#include "commonj/sdo/DataObjectImpl.h"
@@ -2078,19 +2078,96 @@
}
}
- void DataObjectImpl::checkFactory(DataObjectPtr dob)
+ void DataObjectImpl::transferChildren(DataObject* d, DataFactory* f)
+ {
+ PropertyList pl = d->getInstanceProperties();
+ for (int i=0;i<pl.size();i++)
+ {
+ if (pl[i].getType().isDataType())
+ {
+ continue;
+ }
+ if (!d->isSet(pl[i]) || d->isNull(pl[i]))
+ {
+ continue;
+ }
+ if (pl[i].isMany())
+ {
+ DataObjectList& dl = d->getList(pl[i]);
+ for (int j=0;j<dl.size();j++)
+ {
+
+ DataObject* d2 = dl[j];
+ if (d2) {
+ ((DataObjectImpl*)d2)->setDataFactory(f);
+ transferChildren(d2,f);
+ }
+ }
+ }
+ else
+ {
+ DataObject* d3 = d->getDataObject(pl[i]);
+ if (d3)
+ {
+ ((DataObjectImpl*)d3)->setDataFactory(f);
+ transferChildren(d3,f);
+ }
+ }
+ }
+ }
+
+
+
+ void DataObjectImpl::checkFactory(DataObjectPtr dob,
+ unsigned int propertyIndex)
{
DataObjectImpl* d = (DataObjectImpl*)(DataObject*)dob;
if (d->getDataFactory() == getDataFactory()) return;
+
+ // Temporary alteration to test the feasibility and
+ // problems associated with allowing data object 'migration'
+ // lets move this one and all its children to the factory of the
+ // new parent if the factories are compatible.
+
+ DataFactoryImpl* f = (DataFactoryImpl*)getDataFactory();
+
+ if (d->getContainer() != 0)
+ {
+ string msg("Insertion of object from another factory is only allowed if the parent is null: ");
+ const Type& t = d->getType();
+ msg += t.getURI();
+ msg += "#";
+ msg += t.getName();
+ msg += " into property ";
+ msg += getProperty(propertyIndex).getName();
+ msg += " of ";
+ msg += getType().getURI();
+ msg += "#";
+ msg += getType().getName();
+ SDO_THROW_EXCEPTION("checkFactory", SDOInvalidConversionException,
+ msg.c_str());
+ }
+
+ if (f->isCompatible(d->getDataFactory(),d))
+ {
+ d->setDataFactory(getDataFactory());
+ transferChildren(d,getDataFactory());
+ return;
+ }
+
+
+ // This is the default position....
string msg("Insertion from incompatible factory ");
const Type& t = d->getType();
msg += t.getURI();
msg += "#";
msg += t.getName();
- msg += " into data object ";
+ msg += " into property ";
+ msg += getProperty(propertyIndex).getName();
+ msg += " of ";
msg += getType().getURI();
msg += "#";
msg += getType().getName();
@@ -2157,7 +2234,7 @@
if (value != 0)
{
- checkFactory(value);
+ checkFactory(value, propertyIndex);
checkType(prop,value->getType());
}
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h?rev=384165&r1=384164&r2=384165&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h Wed Mar 8 01:23:35 2006
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Rev$ $Date: 2006/02/02 16:41:30 $ */
+/* $Rev$ $Date: 2006/03/07 11:05:20 $ */
#ifndef _DATAOBJECTIMPL_H_
#define _DATAOBJECTIMPL_H_
@@ -546,12 +546,14 @@
virtual const PropertyImpl* defineList(const char* propname);
virtual void undefineProperty(unsigned int index);
virtual const TypeImpl& getTypeImpl();
+ virtual void transferChildren(DataObject* d, DataFactory* f);
+ virtual void setDataFactory(DataFactory *df);
private:
- void validateIndex(unsigned int index);
- virtual void checkFactory(DataObjectPtr dob);
- virtual void checkType( const Property& prop,
+ virtual void validateIndex(unsigned int index);
+ virtual void checkFactory(DataObjectPtr dob, unsigned int propertyIndex);
+ virtual void checkType( const Property& prop,
const Type& objectType);
virtual bool remove(DataObjectImpl* indol);
@@ -601,8 +603,7 @@
// The data object holds a counted reference to the data factory.
DataFactoryPtr factory;
- void setDataFactory(DataFactory *df);
-
+
// Support for open types
int openBase;
std::list<PropertyImpl> openProperties;
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp?rev=384165&r1=384164&r2=384165&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp Wed Mar 8 01:23:35 2006
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Rev$ $Date: 2006/02/02 16:41:30 $ */
+/* $Rev$ $Date: 2006/03/03 14:34:26 $ */
#include "commonj/sdo/DataObjectListImpl.h"
@@ -269,24 +269,64 @@
}
+
+
void DataObjectListImpl::checkFactory(DataObjectPtr dob)
{
DataObjectImpl* d = (DataObjectImpl*)(DataObject*)dob;
if (d->getDataFactory() == theFactory) return;
+
+ // temporary experiment with allowing data objects
+ // to move from factory to factory if the type is
+ // nominally present, and the type systems match
+
+ DataFactoryImpl* f = (DataFactoryImpl*)theFactory;
+
+
+ if (d->getContainer() != 0)
+ {
+ string msg("Insertion of object into list from another factory is only allowed if the parent is null: ");
+
+ const Type& t = d->getType();
+ msg += t.getURI();
+ msg += "#";
+ msg += t.getName();
+ msg += " into property ";
+ msg += container->getProperty(pindex).getName();
+ msg += " of type ";
+ msg += typeURI;
+ msg += "#";
+ msg += typeName;
+ SDO_THROW_EXCEPTION("checkFactory", SDOInvalidConversionException,
+ msg.c_str());
+ }
+
+ if (f->isCompatible(d->getDataFactory(),d))
+ {
+ d->setDataFactory(theFactory);
+ // we will also need to transfer any children - assuming they
+ // are ok in the new factory!!
+ d->transferChildren(d,theFactory);
+ return;
+ }
+
+ string msg("Insertion into list fromm incompatible factory:");
- string msg("Insertion from incompatible factory ");
const Type& t = d->getType();
msg += t.getURI();
msg += "#";
msg += t.getName();
- msg += " into list ";
+ msg += " into property ";
+ msg += container->getProperty(pindex).getName();
+ msg += " of type ";
msg += typeURI;
msg += "#";
msg += typeName;
SDO_THROW_EXCEPTION("checkFactory", SDOInvalidConversionException,
msg.c_str());
+
}
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.cpp?rev=384165&r1=384164&r2=384165&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.cpp Wed Mar 8 01:23:35 2006
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Rev$ $Date: 2006/02/08 15:53:52 $ */
+/* $Rev$ $Date: 2006/03/01 08:52:41 $ */
#include "commonj/sdo/SDOSchemaSAX2Parser.h"
#include "commonj/sdo/XSDPropertyInfo.h"
@@ -35,6 +35,8 @@
: schemaInfo(schemaInf) ,SAX2Parser(insetter)
{
bInSchema = false;
+ bInvalidElement = false;
+ bInInvalidContent = false;
}
SDOSchemaSAX2Parser::~SDOSchemaSAX2Parser()
@@ -111,17 +113,17 @@
///////////////////////////////////////////////////////////////////////
else if (localname.equalsIgnoreCase("element"))
{
- startElement(localname, prefix, URI, namespaces, attributes);
+ if (!bInInvalidContent) startElement(localname, prefix, URI, namespaces, attributes);
}
else if (localname.equalsIgnoreCase("attribute"))
{
- startAttribute(localname, prefix, URI, namespaces, attributes);
+ if (!bInInvalidContent) startAttribute(localname, prefix, URI, namespaces, attributes);
}
else if (localname.equalsIgnoreCase("any")
|| localname.equalsIgnoreCase("anyAttribute"))
{
// the type containing this is to be created as open
- currentType.isOpen = true;
+ if (!bInInvalidContent) currentType.isOpen = true;
}
@@ -131,14 +133,14 @@
///////////////////////////////////////////////////////////////////////
else if (localname.equalsIgnoreCase("complexType"))
{
- startComplexType(localname, prefix, URI, namespaces, attributes);
+ if (!bInInvalidContent) startComplexType(localname, prefix, URI, namespaces, attributes);
} // end complexType handling
else if (localname.equalsIgnoreCase("choice")
|| localname.equalsIgnoreCase("sequence")
|| localname.equalsIgnoreCase("all"))
{
- startGroup(localname, prefix, URI, namespaces, attributes);
+ if (!bInInvalidContent) startGroup(localname, prefix, URI, namespaces, attributes);
} // end Group handling
else if (localname.equalsIgnoreCase("group")
@@ -146,26 +148,47 @@
{
if (setter)
{
- setter->setError("Schema contains group or attributeGroup which are not yet implemented");
+ setter->setError("Schema contains a group or attributeGroup which are not yet implemented");
+
}
}
- ///////////////////////////////////////////////////////////////////////
+ else if (localname.equalsIgnoreCase("list")
+ )
+ {
+ if (setter)
+ {
+ setter->setError("Schema contains a list which is not yet implemented");
+
+ }
+ }
+
+ ///////////////////////////////////////////////////////////////////////
// Handle simpleType
// These become new types
///////////////////////////////////////////////////////////////////////
else if (localname.equalsIgnoreCase("simpleType"))
{
- startSimpleType(localname, prefix, URI, namespaces, attributes);
+ if (!bInInvalidContent) startSimpleType(localname, prefix, URI, namespaces, attributes);
} // end complexType handling
else if (localname.equalsIgnoreCase("restriction"))
{
- startRestriction(localname, prefix, URI, namespaces, attributes);
+ if (!bInInvalidContent) startRestriction(localname, prefix, URI, namespaces, attributes);
}
else if (localname.equalsIgnoreCase("extension"))
{
- startExtension(localname, prefix, URI, namespaces, attributes);
+ if (!bInInvalidContent) startExtension(localname, prefix, URI, namespaces, attributes);
+ }
+ // Handle <import> of other schema
+ else if (localname.equalsIgnoreCase("union"))
+ {
+ // TODO - unions not yet supported
+ bInInvalidContent = true;
+ if (setter)
+ {
+ setter->setError("Schema contains a union which is not yet implemented");
+ }
}
}
else // not in schema - check for any extra namespaces
@@ -197,34 +220,49 @@
// Handle complexType
// Pop the Type off our stack
///////////////////////////////////////////////////////////////////////
- if (localname.equalsIgnoreCase("complexType"))
- {
- defineType();
- } // end complexType handling
- else if (localname.equalsIgnoreCase("simpleType"))
+
+ // We do not support unions, so all inside a union, plus the containing
+ // element are invalid for now.
+ //
+ if (!bInInvalidContent)
{
- defineType();
- }
+ if (localname.equalsIgnoreCase("complexType"))
+ {
+ if (!bInvalidElement) defineType();
+ } // end complexType handling
+ else if (localname.equalsIgnoreCase("simpleType"))
+ {
+ if (!bInvalidElement) defineType();
+ }
- else if (localname.equalsIgnoreCase("schema"))
- {
- defineType();
- } // end complexType handling
+ else if (localname.equalsIgnoreCase("schema"))
+ {
+ if (!bInvalidElement) defineType();
+ } // end complexType handling
- else if (localname.equalsIgnoreCase("element")
- || localname.equalsIgnoreCase("attribute"))
- {
- // PropertyDefinition should now be complete
- defineProperty();
- }
- else if (localname.equalsIgnoreCase("choice")
- || localname.equalsIgnoreCase("sequence")
- || localname.equalsIgnoreCase("all"))
- {
- currentType.isMany = false;
+ else if (localname.equalsIgnoreCase("element")
+ || localname.equalsIgnoreCase("attribute"))
+ {
+ // PropertyDefinition should now be complete
+ if (!bInvalidElement) defineProperty();
+ }
+ else if (localname.equalsIgnoreCase("choice")
+ || localname.equalsIgnoreCase("sequence")
+ || localname.equalsIgnoreCase("all"))
+ {
+ if (!bInvalidElement) currentType.isMany = false;
+ }
+ bInvalidElement = false;
+
+ } // bInUnsupportedContent
+ if (localname.equalsIgnoreCase("union"))
+ {
+ bInInvalidContent = false;
+ // the enclosing element is not useful
+ bInvalidElement = true;
}
-
- }
+ }
+
}
@@ -558,6 +596,8 @@
currentType.parentTypeUri,
currentType.parentTypeName);
+ currentType.isRestriction=true;
+
if(qname.getLocalName().equals("QName"))
{
@@ -595,6 +635,7 @@
// If extending a simple type (an SDO DataType) we create a
// Property named "value" of this type rather than set the
// simple type as a base
+ currentType.isRestriction=false;
// ?? Does this only apply within a <simpleContent> tag??
if (typeUri.equalsIgnoreCase(Type::SDOTypeNamespaceURI))
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.h?rev=384165&r1=384164&r2=384165&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.h Wed Mar 8 01:23:35 2006
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+/* $Rev$ $Date: 2006/02/27 12:26:31 $ */
#ifndef _SDOSCHEMASAX2PARSER_H_
#define _SDOSCHEMASAX2PARSER_H_
@@ -75,6 +75,8 @@
const char* currentFile;
bool bInSchema; // only parse when within a schema
+ bool bInvalidElement; // where element content is not valid
+ bool bInInvalidContent; // actually inside invalid content.
virtual void startInclude(
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp?rev=384165&r1=384164&r2=384165&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp Wed Mar 8 01:23:35 2006
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Rev$ $Date: 2006/02/17 16:01:05 $ */
+/* $Rev$ $Date: 2006/03/07 15:35:56 $ */
#include "commonj/sdo/SDOXMLWriter.h"
#include "commonj/sdo/SDOXMLString.h"
@@ -465,13 +465,18 @@
int rc;
ChangedDataObjectList& changedDOs = cs->getChangedDataObjects();
- if (changedDOs.size() > 0)
+ rc = xmlTextWriterStartElementNS(writer,
+ SDOXMLString("sdo"), SDOXMLString("changeSummary"), SDOXMLString(Type::SDOTypeNamespaceURI));
+ if (rc != 0) return;
+ if (cs->isLogging())
{
- rc = xmlTextWriterStartElementNS(writer,
- SDOXMLString("sdo"), SDOXMLString("changeSummary"), SDOXMLString(Type::SDOTypeNamespaceURI));
+ rc = xmlTextWriterWriteAttribute(writer,
+ SDOXMLString("logging"),
+ SDOXMLString("true"));
+ }
- // Fall at the first hurdle - dont write anything.
- if (rc != 0) return;
+ if (changedDOs.size() > 0)
+ {
// write the creates/deletes in the order they
// happened, as elements.
@@ -511,13 +516,6 @@
}
}
- if (cs->isLogging())
- {
- rc = xmlTextWriterWriteAttribute(writer,
- SDOXMLString("logging"),
- SDOXMLString("true"));
- }
-
for (i=0;i< changedDOs.size();i++)
{
@@ -526,10 +524,9 @@
handleSummaryChange(elementName, cs, changedDOs[i]);
}
}
-
- rc = xmlTextWriterEndElement(writer);
- }
+ }
+ rc = xmlTextWriterEndElement(writer);
}
//////////////////////////////////////////////////////////////////////////
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeDefinition.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeDefinition.h?rev=384165&r1=384164&r2=384165&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeDefinition.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeDefinition.h Wed Mar 8 01:23:35 2006
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+/* $Rev$ $Date: 2006/03/01 08:52:41 $ */
#ifndef _TYPEDEFINITION_H_
#define _TYPEDEFINITION_H_
@@ -53,6 +53,7 @@
SDOXMLString parentTypeUri;
SDOXMLString parentTypeName;
+ bool isRestriction;
SDOXMLString IDPropertyName;
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp?rev=384165&r1=384164&r2=384165&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp Wed Mar 8 01:23:35 2006
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Rev$ $Date: 2006/01/25 15:51:00 $ */
+/* $Rev$ $Date: 2006/03/01 08:52:41 $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -94,6 +94,7 @@
{
isResolving = false;
isResolved = false;
+ brestriction = false;
}
TypeImpl::TypeImpl(const Type* base, const char* uri,
@@ -101,10 +102,12 @@
bool isSeq,
bool isOp,
bool isAbs,
- bool isData)
+ bool isData,
+ bool isRestriction)
{
init(uri,inname,isSeq,isOp, isAbs, isData);
baseType = (TypeImpl*)base;
+ brestriction = isRestriction;
}
TypeImpl::TypeImpl(const char* uri, const char* inname,
@@ -116,6 +119,7 @@
{
init(uri,inname,isSeq,isOp,isAbs, isData);
baseType = 0;
+ brestriction = false;
}
void TypeImpl::init(const char* uri, const char* inname,
@@ -218,9 +222,10 @@
// Sets a data type as open.
///////////////////////////////////////////////////////////////////////////
- void TypeImpl::setBaseType(const Type* bt)
+ void TypeImpl::setBaseType(const Type* bt, bool isRestriction)
{
baseType = (TypeImpl*)bt;
+ brestriction = isRestriction;
// DataType and Sequenced must be the same as the base Type
isPrimitive = baseType->isPrimitive;
@@ -370,8 +375,35 @@
{
baseType->initCompoundProperties();
PROPERTY_LIST pl = baseType->getCompoundProperties();
- localPropsSize = props.size();
+ localPropsSize = props.size();
+
+ // spec says the properties which are common are taken from
+ // the superclass. I imagine this will change , and only the
+ // ones taken from the subclass will be used.
+
+ if (brestriction)
+ {
+ // restrict the properties to only those which
+ // appear in the parent
+ std::list<PropertyImpl*>::iterator p1,p;
+ for (p=pl.begin();p!=pl.end();++p)
+ {
+ for (p1=props.begin();p1!=props.end();++p1)
+ {
+ if (!strcmp((*p1)->getName(),
+ (*p)->getName()))
+ {
+ props.erase(p1);
+ localPropsSize = props.size();
+ break;
+ }
+ }
+ }
+
+ }
+
props.insert(props.begin(),pl.begin(), pl.end());
+
isPrimitive = !(baseType->isDataObjectType());
}
if (isPrimitive && (props.size() > 0))
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.h?rev=384165&r1=384164&r2=384165&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.h Wed Mar 8 01:23:35 2006
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+/* $Rev$ $Date: 2006/03/01 08:52:41 $ */
#ifndef _TYPEIMPL_H_
#define _TYPEIMPL_H_
@@ -197,7 +197,7 @@
///////////////////////////////////////////////////////////////////////////
// Set the base type for inherited types
///////////////////////////////////////////////////////////////////////////
- void setBaseType(const Type* tb);
+ void setBaseType(const Type* tb, bool isRestriction = false);
const Type* getBaseType() const;
@@ -254,7 +254,8 @@
bool isSeq = false,
bool isOp = false,
bool isAbs = false,
- bool isData = false);
+ bool isData = false,
+ bool isRest = false);
void init(const char* uri, const char* inname,
bool isSeq,
@@ -296,6 +297,8 @@
// type inheritance
TypeImpl* baseType;
+ bool brestriction; /* if this is a restriction of the base type
+ rather than an extension.*/
// says how many of the props are really in this data object type.
unsigned int localPropsSize;
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeList.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeList.cpp?rev=384165&r1=384164&r2=384165&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeList.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeList.cpp Wed Mar 8 01:23:35 2006
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+/* $Rev$ $Date: 2006/01/16 15:41:28 $ */
#ifndef SDO_EXPORTS
#define SDO_EXPORTS
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/XSDHelperImpl.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/XSDHelperImpl.cpp?rev=384165&r1=384164&r2=384165&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/XSDHelperImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/XSDHelperImpl.cpp Wed Mar 8 01:23:35 2006
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Rev$ $Date: 2006/02/01 16:24:13 $ */
+/* $Rev$ $Date: 2006/03/01 08:52:41 $ */
#include "commonj/sdo/SDOXMLFileWriter.h" // Include first to avoid libxml compile problems!
#include "commonj/sdo/SDOXMLStreamWriter.h" // Include first to avoid libxml compile problems!
@@ -298,7 +298,8 @@
ty.uri,
ty.name,
ty.parentTypeUri,
- ty.parentTypeName);
+ ty.parentTypeName,
+ ty.isRestriction);
}
catch (SDORuntimeException& e)
{