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 2007/02/23 15:25:02 UTC
svn commit: r510951 - in
/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo:
DataFactoryImpl.cpp DataObjectImpl.cpp SDOSAX2Parser.cpp SDOUtils.cpp
SDOXSDWriter.cpp Type.h TypeImpl.cpp TypeImpl.h XSDHelperImpl.cpp
Author: gwinn
Date: Fri Feb 23 06:25:01 2007
New Revision: 510951
URL: http://svn.apache.org/viewvc?view=rev&rev=510951
Log:
TUSCANY-1136
Modified:
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSAX2Parser.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOUtils.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXSDWriter.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Type.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/XSDHelperImpl.cpp
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp?view=diff&rev=510951&r1=510950&r2=510951
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp Fri Feb 23 06:25:01 2007
@@ -175,34 +175,37 @@
// Now add all the properties
- PropertyList props = typeIter->second->getProperties();
- for (unsigned int i=0; i < props.size(); i++)
+ const std::list<PropertyImpl*> props = typeIter->second->getPropertyListReference();
+
+ for (std::list<PropertyImpl*>::const_iterator i = props.begin();
+ i != props.end();
+ i++)
{
// Ensure the properties type is added
- const Type& propType = props[i].getType();
+ const Type& propType = (*i)->getType();
addType(propType.getURI(), propType.getName());
// Now add the property
addPropertyToType((typeIter->second)->getURI(),
(typeIter->second)->getName(),
- props[i].getName(),
+ (*i)->getName(),
propType.getURI(),
propType.getName(),
- props[i].isMany(),
- props[i].isReadOnly(),
- props[i].isContainment());
+ (*i)->isMany(),
+ (*i)->isReadOnly(),
+ (*i)->isContainment());
// copy the aliases if there are any.
- if (props[i].getAliasCount() > 0)
+ if ((*i)->getAliasCount() > 0)
{
PropertyImpl* p = (typeIter2->second)->
- getPropertyImpl(props[i].getName());
+ getPropertyImpl((*i)->getName());
if (p != 0)
{
for (unsigned int j=0;j<p->getAliasCount();j++)
{
- p->setAlias(props[i].getAlias(j));
+ p->setAlias((*i)->getAlias(j));
}
}
@@ -292,11 +295,13 @@
return true;
}
- PropertyList pl = cs->getProperties();
+ const std::list<PropertyImpl*> pl = cs->getPropertyListReference();
- for (unsigned int i=0 ; i < pl.size() ; i++ )
+ for (std::list<PropertyImpl*>::const_iterator j = pl.begin();
+ j != pl.end();
+ j++)
{
- if (recursiveCheck((TypeImpl*)&(pl[i].getType()), t)) return true;
+ if (recursiveCheck((TypeImpl*)&((*j)->getType()), t)) return true;
}
return false;
}
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp?view=diff&rev=510951&r1=510950&r2=510951
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp Fri Feb 23 06:25:01 2007
@@ -803,11 +803,14 @@
unsigned int DataObjectImpl::getPropertyIndex(const Property& p)
{
- PropertyList props = getType().getProperties();
+ const std::list<PropertyImpl*> props = getType().getPropertyListReference();
- for (unsigned int i = 0; i < props.size() ; ++i)
+ unsigned int i = 0;
+ for (std::list<PropertyImpl*>::const_iterator j = props.begin();
+ j != props.end();
+ j++, i++)
{
- if (!strcmp(props[i].getName(),p.getName()) )
+ if (!strcmp((*j)->getName(), p.getName()))
{
return i;
}
@@ -916,6 +919,8 @@
PropertyImpl* DataObjectImpl::getPropertyImpl(unsigned int index)
{
+ // Cannot use getPropertyListReference because we will return a
+ // writeable PropertyImpl.
PropertyList props = getType().getProperties();
if (index < props.size())
{
@@ -1318,11 +1323,13 @@
PropertyList /* Property */ DataObjectImpl::getInstanceProperties()
{
std::vector<PropertyImpl*> theVec;
- PropertyList propList = getType().getProperties();
- for (unsigned int i = 0 ; i < propList.size() ; ++i)
+ const std::list<PropertyImpl*> propList = getType().getPropertyListReference();
+
+ for (std::list<PropertyImpl*>::const_iterator i = propList.begin();
+ i != propList.end();
+ i++)
{
- Property& p = propList[i];
- theVec.insert(theVec.end(),(PropertyImpl*)&p);
+ theVec.insert(theVec.end(), (*i));
}
std::list<PropertyImpl>::iterator j;
for (j = openProperties.begin() ;
@@ -1573,7 +1580,7 @@
void DataObjectImpl::validateIndex(unsigned int index)
{
- PropertyList pl = getType().getProperties();
+ const std::list<PropertyImpl*> pl = getType().getPropertyListReference();
if (index >= pl.size()) {
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSAX2Parser.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSAX2Parser.cpp?view=diff&rev=510951&r1=510950&r2=510951
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSAX2Parser.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSAX2Parser.cpp Fri Feb 23 06:25:01 2007
@@ -1466,10 +1466,15 @@
}
*/
- PropertyList pl = type.getProperties();
- for (unsigned int i = 0; i < pl.size(); i++)
+ const std::list<PropertyImpl*> pl = type.getPropertyListReference();
+
+ for (std::list<PropertyImpl*>::const_iterator i = pl.begin();
+ i != pl.end();
+ i++)
{
- XSDPropertyInfo* pi = (XSDPropertyInfo*)((DASProperty*)&pl[i])->getDASValue("XMLDAS::PropertyInfo");
+ XSDPropertyInfo* pi = (XSDPropertyInfo*)
+ ((DASProperty*) (*i))->getDASValue("XMLDAS::PropertyInfo");
+
if (pi)
{
const PropertyDefinitionImpl& propdef = pi->getPropertyDefinition();
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOUtils.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOUtils.cpp?view=diff&rev=510951&r1=510950&r2=510951
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOUtils.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOUtils.cpp Fri Feb 23 06:25:01 2007
@@ -251,21 +251,32 @@
void SDOUtils::printTypes(std::ostream& out, DataFactoryPtr df)
{
- TypeList tl = df->getTypes();
- for (unsigned int i = 0; i < tl.size(); i++)
- {
- out << "Type: " << tl[i].getURI()<< "#" << tl[i].getName() <<
- " isOpen: " << tl[i].isOpenType()
- << " isSequenced: " << tl[i].isSequencedType() << endl;
- PropertyList pl = tl[i].getProperties();
- for (unsigned int j = 0; j < pl.size(); j++)
- {
- out << "\tProperty: " << pl[j].getName()
- << " type: " <<pl[j].getType().getURI()<<"#"<<pl[j].getType().getName()<<
- " isMany: " << pl[j].isMany() << endl;
-
- }
- }
+ TypeList tl = df->getTypes();
+ for (unsigned int i = 0; i < tl.size(); i++)
+ {
+ out << "Type: " << tl[i].getURI()<< "#" << tl[i].getName() <<
+ " isOpen: " << tl[i].isOpenType()
+ << " isSequenced: " << tl[i].isSequencedType() << endl;
+
+ const std::list<PropertyImpl*> pl = tl[i].getPropertyListReference();
+
+ for (std::list<PropertyImpl*>::const_iterator j = pl.begin();
+ j != pl.end();
+ j++)
+ {
+ const Property* current = (Property*) (*j);
+
+ out << "\tProperty: "
+ << current->getName()
+ << " type: "
+ << current->getType().getURI()
+ << "#"
+ << current->getType().getName()
+ << " isMany: "
+ << current->isMany()
+ << endl;
+ }
+ }
}
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXSDWriter.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXSDWriter.cpp?view=diff&rev=510951&r1=510950&r2=510951
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXSDWriter.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXSDWriter.cpp Fri Feb 23 06:25:01 2007
@@ -411,7 +411,7 @@
// ---------------------------
// Iterate over the properties
// ---------------------------
- PropertyList pl = type.getProperties();
+ const std::list<PropertyImpl*> pl = type.getPropertyListReference();
if (pl.size() != 0)
{
@@ -421,10 +421,11 @@
// Create <element> definitions
// -------------------------------------------------------
- unsigned int j;
- for (j = 0; j < pl.size(); j++)
+ for (std::list<PropertyImpl*>::const_iterator j = pl.begin();
+ j != pl.end();
+ j++)
{
- const Property& prop = pl[j];
+ const Property& prop = *(*j);
const Type& propType = prop.getType();
SDOXMLString propTypeName = resolveName(propType.getURI(),
@@ -562,9 +563,11 @@
// -------------------------------------------------------
// Create <element> definitions
// -------------------------------------------------------
- for (j = 0; j < pl.size(); j++)
+ for (std::list<PropertyImpl*>::const_iterator j = pl.begin();
+ j != pl.end();
+ j++)
{
- const Property& prop = pl[j];
+ const Property& prop = *(*j);
const Type& propType = prop.getType();
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Type.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Type.h?view=diff&rev=510951&r1=510950&r2=510951
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Type.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Type.h Fri Feb 23 06:25:01 2007
@@ -134,6 +134,7 @@
*/
virtual SDO_API PropertyList getProperties() const = 0;
+ virtual SDO_API const std::list<PropertyImpl*>& getPropertyListReference() const = 0;
/** getProperty returns a property for this type
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=510951&r1=510950&r2=510951
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp Fri Feb 23 06:25:01 2007
@@ -469,6 +469,11 @@
return props;
}
+ const std::list<PropertyImpl*>& TypeImpl::getPropertyListReference() const
+ {
+ return props;
+ }
+
unsigned int TypeImpl::getPropertiesSize() const
{
return props.size();
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=510951&r1=510950&r2=510951
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.h Fri Feb 23 06:25:01 2007
@@ -160,6 +160,7 @@
// Returns the list of the properties of this type.
///////////////////////////////////////////////////////////////////////////
PropertyList getProperties() const;
+ const std::list<PropertyImpl*>& getPropertyListReference() const;
///////////////////////////////////////////////////////////////////////////
// add a property to a Type whilst building - this is for DAS
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/XSDHelperImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/XSDHelperImpl.cpp?view=diff&rev=510951&r1=510950&r2=510951
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/XSDHelperImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/XSDHelperImpl.cpp Fri Feb 23 06:25:01 2007
@@ -147,35 +147,36 @@
const char* typeUri = prop.substituteUri.isNull() ?
prop.typeUri : prop.substituteUri;
const Type& rootType = dataFactory->getType(typeUri, entryName);
- PropertyList pl = rootType.getProperties();
- for (unsigned int j = 0; j < pl.size(); j++)
+ const std::list<PropertyImpl*> pl = rootType.getPropertyListReference();
+
+ for (std::list<PropertyImpl*>::const_iterator j = pl.begin();
+ j != pl.end();
+ j++)
{
- if (!pl[j].getType().isDataType()
- && strcmp(pl[j].getType().getURI(),Type::SDOTypeNamespaceURI.c_str()))
+ if (!(*j)->getType().isDataType()
+ && strcmp((*j)->getType().getURI(),Type::SDOTypeNamespaceURI.c_str()))
{
// recurse the tree..
- newSubstitute(pl[j].getType().getName(),
- prop);
+ newSubstitute((*j)->getType().getName(), prop);
- if (!strcmp(pl[j].getName(),prop.substituteName))
+ if (!strcmp((*j)->getName(), prop.substituteName))
{
dataFactory->setPropertySubstitute(rootType.getURI(),
rootType.getName(),
- pl[j].getName(),
+ (*j)->getName(),
prop.name,
typeUri,
prop.typeName);
XSDPropertyInfo* pi = (XSDPropertyInfo*)
- ((DASProperty*)&pl[j])->getDASValue("XMLDAS::PropertyInfo");
+ ((DASProperty*) (*j))->getDASValue("XMLDAS::PropertyInfo");
+
if (pi)
{
PropertyDefinitionImpl& propdef = (PropertyDefinitionImpl&)pi->getPropertyDefinition();
propdef.substituteNames.push_back(prop.name);
propdef.substituteLocalNames.push_back(prop.localname);
}
-
}
-
}
}
}
@@ -194,11 +195,16 @@
DataFactoryImpl* df = (DataFactoryImpl*)(DataFactory*)dataFactory;
const Type* rootType = df->findType(typeUri,"RootType");
if (rootType == 0) return;
- PropertyList pl = rootType->getProperties();
- for (unsigned int j = 0; j < pl.size(); j++)
+
+ const std::list<PropertyImpl*> pl = rootType->getPropertyListReference();
+
+ for (std::list<PropertyImpl*>::const_iterator j = pl.begin();
+ j != pl.end();
+ j++)
{
- XSDPropertyInfo* pi = (XSDPropertyInfo*)
- ((DASProperty*)&pl[j])->getDASValue("XMLDAS::PropertyInfo");
+ XSDPropertyInfo* pi = (XSDPropertyInfo*)
+ ((DASProperty*) (*j))->getDASValue("XMLDAS::PropertyInfo");
+
if (pi)
{
PropertyDefinitionImpl& propdef = (PropertyDefinitionImpl&)pi->getPropertyDefinition();
@@ -209,8 +215,8 @@
dataFactory->setPropertySubstitute(typeUri,ty.name,
prop.name, propdef.name,
- pl[j].getType().getURI(),
- pl[j].getType().getName());
+ (*j)->getType().getURI(),
+ (*j)->getType().getName());
prop.substituteNames.push_back(propdef.name);
prop.substituteLocalNames.push_back(propdef.localname);
}
@@ -397,32 +403,33 @@
{
// Check if this type is already defined to the data factory
- try
- {
- const Type& rootType = dataFactory->getType(prop.typeUri, "RootType");
- PropertyList pl = rootType.getProperties();
-
- for (unsigned int j = 0; j < pl.size(); j++)
- {
+ try
+ {
+ const Type& rootType = dataFactory->getType(prop.typeUri, "RootType");
+
+ const std::list<PropertyImpl*> pl = rootType.getPropertyListReference();
+
+ for (std::list<PropertyImpl*>::const_iterator j = pl.begin();
+ j != pl.end();
+ j++)
+ {
- XSDPropertyInfo* pi = (XSDPropertyInfo*)
- ((DASProperty*)&pl[j])->getDASValue("XMLDAS::PropertyInfo");
+ XSDPropertyInfo* pi = (XSDPropertyInfo*)
+ ((DASProperty*) (*j))->getDASValue("XMLDAS::PropertyInfo");
-
-
- if (prop.typeName.equals(pl[j].getName())
- || (pi && prop.typeName.equals(pi->getPropertyDefinition().localname)))
- {
- prop.typeUri = pl[j].getType().getURI();
- prop.typeName = pl[j].getType().getName();
- refFound = true;
- break;
- }
- }
- }
- catch (const SDORuntimeException&)
- {
- }
+ if (prop.typeName.equals((*j)->getName())
+ || (pi && prop.typeName.equals(pi->getPropertyDefinition().localname)))
+ {
+ prop.typeUri = (*j)->getType().getURI();
+ prop.typeName = (*j)->getType().getName();
+ refFound = true;
+ break;
+ }
+ }
+ }
+ catch (const SDORuntimeException&)
+ {
+ }
}
// If we haven't been able to resolve this reference we should ignore it
if (!refFound)
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org