You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ro...@apache.org on 2006/08/23 10:59:30 UTC
svn commit: r433983 - in
/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model:
Component.cpp Component.h ModelLoader.cpp
Author: robbinspg
Date: Wed Aug 23 01:59:28 2006
New Revision: 433983
URL: http://svn.apache.org/viewvc?rev=433983&view=rev
Log:
Support simple type properties for 0.95 model
Modified:
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Component.cpp
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Component.h
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp
Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Component.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Component.cpp?rev=433983&r1=433982&r2=433983&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Component.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Component.cpp Wed Aug 23 01:59:28 2006
@@ -25,7 +25,8 @@
#include "tuscany/sca/model/Component.h"
using namespace commonj::sdo;
-
+#include <iostream>
+using namespace std;
namespace tuscany
{
namespace sca
@@ -89,7 +90,7 @@
void Component::addProperty(const string& name,
const string& type,
bool many,
- const char* defaultValue)
+ DataObjectPtr defaultValue)
{
// Create a Type in the Properties dataFactory
DataFactoryPtr factory = getPropertyDataFactory();
@@ -234,64 +235,46 @@
return properties;
}
- void Component::addProperties(DataObjectPtr values)
+ void Component::setProperty(const string& name, DataObjectPtr value)
{
- if (!values)
- {
- return;
- }
-
+ //cout << "setting property: " << name.c_str() << " to: " << value <<endl;
DataObjectPtr props = getProperties();
- PropertyList pl = values->getInstanceProperties();
- for (int i=0; i < pl.size(); i++)
+ // Get the property's type
+ try
{
- if (!values->isSet(i))
- {
- continue;
- }
-
- // Add the property value to the component to be resolved later
- string propName = pl[i].getName();
-
- // Get the property's type
- try
+ const Property& propProperty = props->getProperty(name);
+ const Type& propType = propProperty.getType();
+ if (propType.isDataType())
{
- const Property& propProperty = props->getProperty(pl[i].getName());
- const Type& propType = propProperty.getType();
-
- DataObjectList& proplist = values->getList(pl[i]);
- for (int proplistI=0; proplistI<proplist.size(); proplistI++)
+ if (propProperty.isMany())
{
- // Get the property value
- string propValue = proplist.getDataObject(proplistI)->getSequence()->getCStringValue(0);
- if (propType.isDataType())
- {
- if (propProperty.isMany())
- {
- DataObjectList& dol = props->getList(propProperty);
- dol.append(propValue.c_str());
- }
- else
- {
- props->setCString(propProperty, propValue.c_str());
- }
- }
- else
- {
- // Create a new instance of the DO
- // iterate over properties setting each one
- }
+ DataObjectList& dol = props->getList(propProperty);
+ dol.append(value->getCString(""));
+ }
+ else
+ {
+ props->setCString(propProperty, value->getCString(""));
}
}
- catch (SDOPropertyNotFoundException&)
+ else
{
- // Configuration error: property is not defined
- string message = "Undefined property: " + propName;
- throw SystemConfigurationException(message.c_str());
+ // Create a new instance of the DO
+ // iterate over properties setting each one
+
+ // for now:
+ props->setDataObject(propProperty, value);
}
-
}
+ catch (SDOPropertyNotFoundException&)
+ {
+ // Configuration error: property is not defined
+ string message = "Undefined property: " + name;
+ throw SystemConfigurationException(message.c_str());
+ }
+
+ //cout << "properties set: " << props << endl;
+
}
} // End namespace model
Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Component.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Component.h?rev=433983&r1=433982&r2=433983&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Component.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Component.h Wed Aug 23 01:59:28 2006
@@ -32,6 +32,7 @@
#include "commonj/sdo/SDO.h"
using commonj::sdo::DataObjectPtr;
using commonj::sdo::DataFactoryPtr;
+using commonj::sdo::DataObjectList;
namespace tuscany
{
@@ -127,7 +128,7 @@
void addProperty(const string& name,
const string& type,
bool many,
- const char* defaultValue = 0);
+ DataObjectPtr defaultValue);
/**
* Add the property values to the properties defined on this
@@ -135,7 +136,7 @@
* @param properties A data object representing all the values set
* for this component.
*/
- void addProperties(DataObjectPtr properties);
+ void setProperty(const string& name, DataObjectPtr value);
/**
* Returns a data object from which all the properties and their
Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp?rev=433983&r1=433982&r2=433983&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp Wed Aug 23 01:59:28 2006
@@ -382,7 +382,7 @@
XMLDocumentPtr componentTypeFile = getXMLHelper()->loadFile(typeFileName.c_str());
if (componentTypeFile->getRootDataObject() == 0)
{
- LOGERROR_1(0, "ModelLoader::mapComposite: Unable to load file: %s", typeFileName.c_str());
+ LOGERROR_1(0, "ModelLoader::addComponent: Unable to load file: %s", typeFileName.c_str());
}
else
{
@@ -394,7 +394,8 @@
}
} catch (SDORuntimeException& ex)
{
- LOGERROR_1(0, "ModelLoader::mapComposite: Exception caught: %s", ex.getMessageText());
+ LOGERROR_2(0, "ModelLoader::addComponent (%s): Exception caught: %s",
+ typeFileName.c_str(), ex.getMessageText());
throw SystemConfigurationException(ex.getMessageText());
}
@@ -402,10 +403,14 @@
// ----------
// Properties
// ----------
+ DataObjectList& props = componentDO->getList("property");
+ for (int pi=0; pi<props.size(); pi++)
+ {
+ string propName = props[pi]->getCString("name");
+ DataObjectPtr propValue = props[pi]->getDataObject("value");
- //TODO handle new property declaration style
- //DataObjectPtr props = componentDO->getDataObject("properties");
- //component->addProperties(props);
+ component->setProperty(propName, propValue);
+ }
// ----------
// References
@@ -525,9 +530,9 @@
//TODO need to add support for complex properties, need the SDO
// folks to shed some light on how to do this...
- const char* defaultValue = 0;
+ DataObjectPtr defaultValue;
if (props[i]->isSet("value")) {
- defaultValue = props[i]->getCString("value");
+ defaultValue = props[i]->getDataObject("value");
}
component->addProperty(name, type, many, defaultValue);
@@ -813,6 +818,7 @@
}
}
+ //cout << myXSDHelper->getDataFactory();
return myXSDHelper;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org