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/01/05 11:58:55 UTC
svn commit: r366158 [10/25] - in /incubator/tuscany/cpp/sdo: ./ bin/
dependencies/ include/ include/commonj/ include/commonj/sdo/ lib/ projects/
projects/tuscany_sdo/ projects/tuscany_sdo/sdo_runtime/
projects/tuscany_sdo/sdo_samples/ projects/tuscany_...
Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/EqualityHelper.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/EqualityHelper.cpp?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/EqualityHelper.cpp (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/EqualityHelper.cpp Thu Jan 5 02:55:00 2006
@@ -0,0 +1,370 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+
+#include "commonj/sdo/Property.h"
+#include "commonj/sdo/Type.h"
+#include "commonj/sdo/TypeList.h"
+#include "commonj/sdo/Sequence.h"
+
+#include "commonj/sdo/DataObject.h"
+
+
+
+#include "commonj/sdo/EqualityHelper.h"
+
+namespace commonj{
+namespace sdo{
+
+ bool EqualityHelper::compareitem(DataObjectPtr to, DataObjectPtr from, const Property& p)
+ {
+ switch (p.getTypeEnum())
+ {
+ case Type::BooleanType:
+ return (to->getBoolean(p) == from->getBoolean(p));
+ case Type::ByteType:
+ return (to->getByte(p) == from->getByte(p));
+ case Type::CharacterType:
+ return (to->getCharacter(p) == from->getCharacter(p));
+ case Type::IntegerType:
+ return (to->getInteger(p) == from->getInteger(p));
+ case Type::ShortType:
+ return (to->getShort(p) == from->getShort(p));
+ case Type::DoubleType:
+ return (to->getDouble(p) == from->getDouble(p));
+ case Type::FloatType:
+ return (to->getFloat(p) == from->getFloat(p));
+ case Type::LongType:
+ return (to->getLong(p) == from->getLong(p));
+ case Type::DateType:
+ return (to->getDate(p).getTime() == from->getDate(p).getTime());
+ case Type::BigDecimalType:
+ case Type::BigIntegerType:
+ case Type::UriType:
+ case Type::StringType:
+ {
+ unsigned int siz = from->getLength(p);
+ if (siz != to->getLength(p)) return false;
+
+ if (siz > 0)
+ {
+ wchar_t * buff = new wchar_t[siz];
+ wchar_t * buft = new wchar_t[siz];
+ from->getString(p, buff, siz);
+ to->getString(p, buft, siz);
+ for (int i=0;i< siz; i++)
+ {
+ if (buff[i] != buft[i])
+ {
+ delete buff;
+ delete buft;
+ return false;
+ }
+ }
+ delete buff;
+ delete buft;
+ }
+ return true;
+ }
+ case Type::BytesType:
+ {
+ unsigned int siz = from->getLength(p);
+ if (siz != to->getLength(p)) return false;
+
+ if (siz > 0)
+ {
+ char * buff = new char[siz];
+ char * buft = new char[siz];
+ from->getBytes(p, buff, siz);
+ to->getBytes(p, buft, siz);
+ for (int i=0;i< siz; i++)
+ {
+ if (buff[i] != buft[i])
+ {
+ delete buff;
+ delete buft;
+ return false;
+ }
+ }
+ delete buff;
+ delete buft;
+ }
+ return true;
+ }
+ default:
+ return true;
+ } // switch
+ }
+
+ bool EqualityHelper::comparelist(DataObjectList& to, DataObjectList& from, Type::Types t)
+ {
+ switch (t)
+ {
+ case Type::BooleanType:
+ {
+ for (int i=0;i< from.size(); i++)
+ {
+ if (to.getBoolean(i) != from.getBoolean(i))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ case Type::ByteType:
+ {
+ for (int i=0;i< from.size(); i++)
+ {
+ if (to.getByte(i) != from.getByte(i))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ case Type::CharacterType:
+ {
+ for (int i=0;i< from.size(); i++)
+ {
+ if (to.getCharacter(i) != from.getCharacter(i))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ case Type::IntegerType:
+ {
+ for (int i=0;i< from.size(); i++)
+ {
+ if (to.getInteger(i) != from.getInteger(i))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ case Type::ShortType:
+ {
+ for (int i=0;i< from.size(); i++)
+ {
+ if (to.getShort(i) != from.getShort(i))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ case Type::DoubleType:
+ {
+ for (int i=0;i< from.size(); i++)
+ {
+ if (to.getDouble(i) != from.getDouble(i))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ case Type::FloatType:
+ {
+ for (int i=0;i< from.size(); i++)
+ {
+ if (to.getFloat(i) != from.getFloat(i))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ case Type::LongType:
+ {
+ for (int i=0;i< from.size(); i++)
+ {
+ if (to.getLong(i) != from.getLong(i))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ case Type::DateType:
+ {
+ for (int i=0;i< from.size(); i++)
+ {
+ if (to.getDate(i).getTime() != from.getDate(i).getTime())
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ case Type::BigDecimalType:
+ case Type::BigIntegerType:
+ case Type::UriType:
+ case Type::StringType:
+ {
+ for (int i=0;i< from.size(); i++)
+ {
+ unsigned int siz = from.getLength(i);
+ if (siz != to.getLength(i)) return false;
+
+ if (siz > 0)
+ {
+ wchar_t * buff = new wchar_t[siz];
+ wchar_t * buft = new wchar_t[siz];
+ from.getString(i,buff,siz);
+ to.getString(i,buft,siz);
+ for (int j=0;j<siz;j++)
+ {
+ if (buff[j] != buft[j])
+ {
+ delete buff;
+ delete buft;
+ return false;
+ }
+ }
+ delete buff;
+ delete buft;
+ }
+ }
+ return true;
+ }
+
+ case Type::BytesType:
+ {
+ for (int i=0;i< from.size(); i++)
+ {
+ unsigned int siz = from.getLength(i);
+ if (siz != to.getLength(i)) return false;
+
+ if (siz > 0)
+ {
+ char * buff = new char[siz];
+ char * buft = new char[siz];
+ from.getBytes(i,buff,siz);
+ to.getBytes(i,buft,siz);
+ for (int j=0;j<siz;j++)
+ {
+ if (buff[j] != buft[j])
+ {
+ delete buff;
+ delete buft;
+ return false;
+ }
+ }
+ delete buff;
+ delete buft;
+ }
+ }
+ return true;
+ }
+
+ default:
+ return true;
+
+ } // case
+ } // method
+
+ bool EqualityHelper::equalShallow(DataObjectPtr dataObject1, DataObjectPtr dataObject2)
+ {
+ return internalEqual(dataObject1, dataObject2, false);
+
+ }
+
+ bool EqualityHelper::equal(DataObjectPtr dataObject1, DataObjectPtr dataObject2)
+ {
+ return internalEqual(dataObject1, dataObject2, true);
+ }
+
+
+ bool EqualityHelper::internalEqual(DataObjectPtr dataObject1,
+ DataObjectPtr dataObject2,
+ bool fullEqual)
+ {
+
+
+ PropertyList pl = dataObject1->getInstanceProperties();
+ for (int i=0;i < pl.size(); i++)
+ {
+ // data objects are only compared the deep equality case
+ if (pl[i].getType().isDataObjectType())
+ {
+ if (!fullEqual)
+ {
+ continue;
+ }
+ else
+ {
+ if (pl[i].isMany())
+ {
+ DataObjectList& dolold = dataObject1->getList(pl[i]);
+ DataObjectList& dolnew = dataObject2->getList(pl[i]);
+ if (dolnew.size() != dolold.size()) return false;
+
+ for (int i=0;i< dolold.size(); i++)
+ {
+ if (!internalEqual(dolold[i], dolnew[i], true))
+ {
+ return false;
+ }
+ }
+ }
+ else
+ {
+ if (!internalEqual(
+ dataObject1->getDataObject(pl[i]),
+ dataObject2->getDataObject(pl[i]), true))
+ {
+ return false;
+ }
+ }
+ }
+ }
+ else
+ {
+ if (pl[i].isMany())
+ {
+ DataObjectList& dolold = dataObject1->getList(pl[i]);
+ DataObjectList& dolnew = dataObject2->getList(pl[i]);
+ if (dolold.size() != dolnew.size()) return false;
+ if (!comparelist(dolold, dolnew, pl[i].getTypeEnum())) return false;
+ }
+ else
+ {
+ if (!compareitem(dataObject1,dataObject2, pl[i]))
+ {
+ return false;
+ }
+ } // else
+ }
+ }
+ return true;
+ }
+
+}
+};
+
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/EqualityHelper.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/EqualityHelper.cpp
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/EqualityHelper.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/EqualityHelper.h?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/EqualityHelper.h (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/EqualityHelper.h Thu Jan 5 02:55:00 2006
@@ -0,0 +1,97 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+
+#ifndef _EQUALITYHELPER_H_
+#define _EQUALITYHELPER_H_
+
+#include "commonj/sdo/RefCountingPointer.h"
+
+
+
+namespace commonj{
+namespace sdo{
+
+/**
+ * EqualityHelper provides static helper methods for equals.
+ * equalsShallow compares the DataType properties of the
+ * two data objects.
+ * equals performs a check on all the memebers and verifies that
+ * the same data objects are children.
+ */
+
+ class EqualityHelper
+{
+ public:
+
+ /**
+ * Shallow compare of DataObjects
+ *
+ * Compares two DataObjects for each property where
+ * property.getType().isDataObjectType() is false.
+ * Compares dataObject1.get(property).equals(dataObject2.get(property))
+ * Properties where property.getType().isDataObjectType() is true
+ * are not compared.
+ * DataObjects must have the same type
+ * dataObject1.getType() == dataObject2.getType()
+ * Returns true if all values of all compared properties are equal.
+ * @param dataObject1 DataObject to be compared
+ * @param dataObject2 DataObject to be compared
+ * @return true if equal
+ */
+ static SDO_API bool equalShallow(DataObjectPtr dataObject1, DataObjectPtr dataObject2);
+
+ /**
+ * Deep compare of DataObjects
+ * Compares dataObject1 and dataObject2 and all their contained
+ * DataObjects (property.isContainment() is true) recursively.
+ * Values of properties are comapred as in isEqualShallow,
+ * and values of properties where
+ * property.getType().isDataObjectType() is true
+ * are compared where each value copied must be a corresponding
+ * DataObject contained by the source dataObject.
+ * The dataObject trees must be closed.
+ * If any DataObject referenced in either tree is not part of the
+ * containment trees an IllegalArgumentException is thrown.
+ * If a ChangeSummary is part of the tree they must contain an
+ * identical summary for their respective trees.
+ *
+ * @param dataObject1 DataObject to be compared
+ * @param dataObject2 DataObject to be compared
+ * @return true if all compared aspects of all compared objects are equal
+ * @throws IllegalArgumentException if any referenced DataObject
+ * is not part of the containment trees.
+ */
+ static SDO_API bool equal(DataObjectPtr dataObject1, DataObjectPtr dataObject2);
+
+ private:
+
+ static bool internalEqual(DataObjectPtr dataObject1,
+ DataObjectPtr dataObject2,
+ bool fullEqual);
+
+ static bool comparelist(DataObjectList& to, DataObjectList& from, Type::Types t);
+
+ static bool compareitem(DataObjectPtr to, DataObjectPtr from, const Property& p);
+
+
+
+};
+};
+};
+#endif //_EQUALITYHELPER_H_
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/EqualityHelper.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/EqualityHelper.h
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/HelperProvider.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/HelperProvider.cpp?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/HelperProvider.cpp (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/HelperProvider.cpp Thu Jan 5 02:55:00 2006
@@ -0,0 +1,47 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+
+#include "commonj/sdo/HelperProvider.h"
+#include "commonj/sdo/XSDHelperImpl.h"
+#include "commonj/sdo/XMLHelperImpl.h"
+#include "commonj/sdo/export.h"
+#include "commonj/sdo/DataFactory.h"
+
+namespace commonj
+{
+ namespace sdo
+ {
+
+ //////////////////////////////////////////////////////////////////////
+ // Create an XSDHelper
+ //////////////////////////////////////////////////////////////////////
+ XSDHelperPtr HelperProvider::getXSDHelper(DataFactoryPtr dataFactory)
+ {
+ return new XSDHelperImpl(dataFactory);
+ }
+ //////////////////////////////////////////////////////////////////////
+ // Create an XMLHelper
+ //////////////////////////////////////////////////////////////////////
+ XMLHelperPtr HelperProvider::getXMLHelper(DataFactoryPtr dataFactory)
+ {
+ return new XMLHelperImpl(dataFactory);
+ }
+
+ } // End - namespace sdo
+} // End - namespace commonj
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/HelperProvider.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/HelperProvider.cpp
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/HelperProvider.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/HelperProvider.h?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/HelperProvider.h (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/HelperProvider.h Thu Jan 5 02:55:00 2006
@@ -0,0 +1,65 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+
+#ifndef _HELPERPROVIDER_H_
+#define _HELPERPROVIDER_H_
+
+
+#include "commonj/sdo/XSDHelper.h"
+#include "commonj/sdo/XMLHelper.h"
+#include "commonj/sdo/DataFactory.h"
+#include "commonj/sdo/export.h"
+
+
+namespace commonj
+{
+ namespace sdo
+ {
+
+
+/**
+ * HelperProvider gives access to helpers (static methods).
+ *
+ * The helper provider gives back an XSD or XML helper associated
+ * with the given data factory
+ */
+ class HelperProvider
+ {
+ public:
+
+/**
+ *
+ * The helper provider gives back an XSD helper associated
+ * with the given data factory
+ */
+ SDO_API static XSDHelperPtr getXSDHelper(DataFactoryPtr dataFactory=0);
+
+/**
+ *
+ * The helper provider gives back an XML helper associated
+ * with the given data factory
+ */
+ SDO_API static XMLHelperPtr getXMLHelper(DataFactoryPtr dataFactory=0);
+
+ };
+
+ } // End - namespace sdo
+} // End - namespace commonj
+
+#endif // _HELPERPROVIDER_H_
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/HelperProvider.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/HelperProvider.h
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/LogWriter.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/LogWriter.cpp?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/LogWriter.cpp (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/LogWriter.cpp Thu Jan 5 02:55:00 2006
@@ -0,0 +1,32 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+
+#include "commonj/sdo/LogWriter.h"
+
+namespace commonj
+{
+ namespace sdo
+ {
+ LogWriter::~LogWriter()
+ {
+ }
+
+ } // End namespace sdo
+} // End namespace commonj
+
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/LogWriter.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/LogWriter.cpp
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/LogWriter.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/LogWriter.h?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/LogWriter.h (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/LogWriter.h Thu Jan 5 02:55:00 2006
@@ -0,0 +1,44 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+
+#ifndef SDO_LOGWriter_H
+#define SDO_LOGWriter_H
+
+#include "commonj/sdo/export.h"
+
+namespace commonj
+{
+ namespace sdo
+ {
+
+/**
+ * LogWriter is an abstract class for implementers to inherit from.
+ * see DefaultLogWriter.
+ */
+ class LogWriter
+ {
+ public:
+ virtual ~LogWriter();
+
+ SDO_API virtual void log(int indent, int level, const char* msg) = 0;
+ };
+
+ } // End namespace sdo
+} // End namespace commonj
+#endif // SDO_LOGWriter_H
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/LogWriter.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/LogWriter.h
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Logger.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Logger.cpp?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Logger.cpp (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Logger.cpp Thu Jan 5 02:55:00 2006
@@ -0,0 +1,99 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+
+#include "commonj/sdo/Logger.h"
+#include <iostream>
+#include <stdarg.h>
+#include "commonj/sdo/DefaultLogWriter.h"
+
+using namespace std;
+
+namespace commonj
+{
+ namespace sdo
+ {
+ LogWriter* Logger::logWriter = getLogWriter();
+
+ LogWriter* Logger::getLogWriter()
+ {
+ if (logWriter == 0)
+ {
+ setLogWriter(0);
+ }
+ return logWriter;
+ }
+
+ void Logger::setLogWriter(LogWriter* writer)
+ {
+ if (logWriter != writer)
+ {
+ delete logWriter;
+ }
+
+ if (writer == 0)
+ {
+ logWriter = new DefaultLogWriter;
+ }
+ else
+ {
+ logWriter = writer;
+ }
+ }
+
+ int Logger::loggingLevel = setLogging();
+
+ int Logger::setLogging()
+ {
+ char* loggingVar = 0;
+ loggingVar = getenv("SDO4CPP_LOGGING");
+ if (loggingVar == 0)
+ return 0;
+ else
+ return atoi(loggingVar);
+ }
+
+ void Logger::setLogging(int level)
+ {
+ loggingLevel = level;
+ }
+
+ void Logger::log(int indent, int level, const char* msg)
+ {
+ if (level <= loggingLevel)
+ {
+ logWriter->log(indent, level, msg);
+ }
+ }
+
+ void Logger::logArgs(int indent, int level, const char* msg, ...)
+ {
+ if (level <= loggingLevel)
+ {
+ va_list variableArguments;
+ va_start(variableArguments, msg);
+ char messageBuffer[1024];
+ vsprintf(messageBuffer, msg, variableArguments);
+ logWriter->log(indent, level, messageBuffer);
+ va_end(variableArguments);
+ }
+ }
+
+ } // End namespace sdo
+} // End namespace commonj
+
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Logger.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Logger.cpp
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Logger.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Logger.h?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Logger.h (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Logger.h Thu Jan 5 02:55:00 2006
@@ -0,0 +1,69 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+
+#ifndef SDO_LOGGER_H
+#define SDO_LOGGER_H
+
+
+
+#include "commonj/sdo/export.h"
+#include "commonj/sdo/LogWriter.h"
+namespace commonj
+{
+ namespace sdo
+ {
+
+/**
+ * Logger is used for debug style logging such as method trace.
+ * The logger can log at different levels, and can log entry, exit
+ * and events. The log entries can take arguments or be just
+ * strings.
+ */
+ class Logger {
+
+ public:
+/**
+ * attach a log writer.
+ */
+ SDO_API static void setLogWriter(LogWriter* writer);
+/**
+ * switch logging to a level.
+ */
+ SDO_API static void setLogging(int level);
+
+/**
+ * log a message.
+ */
+ SDO_API static void log(int indent, int level, const char* msg);
+/**
+ * log a message with parameters.
+ */
+ SDO_API static void logArgs(int indent, int level, const char* msg, ...);
+
+ static int loggingLevel;
+
+ private:
+ static LogWriter* logWriter;
+ static LogWriter* getLogWriter();
+ static int setLogging();
+ };
+
+ } // End namespace sdo
+} // End namespace commonj
+#endif // SDO_LOGGER_H
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Logger.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Logger.h
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Logging.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Logging.h?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Logging.h (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Logging.h Thu Jan 5 02:55:00 2006
@@ -0,0 +1,170 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+
+#include "commonj/sdo/Logger.h"
+#include "commonj/sdo/SDORuntimeException.h"
+
+#
+#ifndef SDO_LOGGING_H
+#define SDO_LOGGING_H
+
+/**
+ * logging level for stuff you rarely want to see, like
+ * memory allocations.
+ */
+
+#define HIGHVOLUME 40
+/**
+ * logging level for normal path information
+ */
+#define INFO 30
+
+ /**
+ * logging level for something which is unusual.
+ */
+
+#define WARNING 20
+/**
+ * logging level for a major problem
+ */
+
+#define ERROR 10
+
+#define INDENT 1
+#define OUTDENT -1
+#define NODENT 0
+
+
+/**
+ * Macro for simplifying addition of trace points
+ */
+
+#ifdef _DEBUG
+#define LOGENTRY(level, methodName) \
+if (Logger::loggingLevel >= level) \
+Logger::logArgs(INDENT, level, "Entering: %s", methodName);
+
+/**
+ * Macro for simplifying addition of trace points
+ */
+#define LOGEXIT(level, methodName) \
+if (Logger::loggingLevel >= level) \
+Logger::logArgs(OUTDENT, level, "Exiting: %s" ,methodName);
+
+/**
+ * Macro for simplifying addition of trace points
+ */
+#define LOGINFO(level, message) \
+if (Logger::loggingLevel >= level) \
+Logger::log(NODENT, level, message);
+
+/**
+ * Macro for simplifying addition of trace points
+ */
+#define LOGINFO_1(level, message, arg1) \
+if (Logger::loggingLevel >= level) \
+Logger::logArgs(NODENT,level, message, arg1);
+
+/**
+ * Macro for simplifying addition of trace points
+ */
+#define LOGINFO_2(level, message, arg1, arg2) \
+if (Logger::loggingLevel >= level) \
+Logger::logArgs(NODENT,level, message, arg1, arg2);
+
+/**
+ * Macro for simplifying addition of trace points
+ */
+#define LOGERROR(level, message) \
+if (Logger::loggingLevel >= level) \
+Logger::log(NODENT,level, message);
+
+/**
+ * Macro for simplifying addition of trace points
+ */
+#define LOGERROR_1(level, message, arg1) \
+if (Logger::loggingLevel >= level) \
+Logger::logArgs(NODENT,level, message, arg1);
+
+/**
+ * Macro for simplifying addition of trace points
+ */
+#define LOGERROR_2(level, message, arg1, arg2) \
+if (Logger::loggingLevel >= level) \
+Logger::logArgs(NODENT,level, message, arg1, arg2);
+
+/**
+ * Macro for simplifying addition of trace points
+ */
+#define LOGSDOEXCEPTION(level, message, arg1) \
+if (Logger::loggingLevel >= level) \
+Logger::log(NODENT,level, message);\
+Logger::logArgs(NODENT,level, "%s:%s\nIn %s\nAt %s line %ld\n",\
+ ((SDORuntimeException)arg1).getEClassName(),\
+ ((SDORuntimeException)arg1).getMessageText(),\
+ ((SDORuntimeException)arg1).getFunctionName(),\
+ ((SDORuntimeException)arg1).getFileName(),\
+ ((SDORuntimeException)arg1).getLineNumber());
+
+#else // Not DEBUG
+
+/**
+ * Macro for simplifying addition of trace points
+ */
+#define LOGSDOEXCEPTION(level, message, arg1)
+
+/**
+ * Macro for simplifying addition of trace points
+ */
+#define LOGENTRY(level, methodName)
+
+/**
+ * Macro for simplifying addition of trace points
+ */
+#define LOGEXIT(level, methodName)
+
+/**
+ * Macro for simplifying addition of trace points
+ */
+#define LOGINFO(level, message)
+
+/**
+ * Macro for simplifying addition of trace points
+ */
+#define LOGINFO_1(level, message, arg1)
+
+/**
+ * Macro for simplifying addition of trace points
+ */
+#define LOGINFO_2(level, message, arg1, arg2)
+/**
+ * Macro for simplifying addition of trace points
+ */
+#define LOGERROR(level, message)
+/**
+ * Macro for simplifying addition of trace points
+ */
+#define LOGERROR_1(level, message, arg1)
+/**
+ * Macro for simplifying addition of trace points
+ */
+#define LOGERROR_2(level, message, arg1, arg2)
+
+#endif
+#endif // SDO_LOGGING_H
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Logging.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Logging.h
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/ParserErrorSetter.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/ParserErrorSetter.cpp?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/ParserErrorSetter.cpp (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/ParserErrorSetter.cpp Thu Jan 5 02:55:00 2006
@@ -0,0 +1,38 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+
+// ParserErrorSetter.cpp: class allowing parser to push errors back.
+//
+//////////////////////////////////////////////////////////////////////
+#include "commonj/sdo/ParserErrorSetter.h"
+namespace commonj
+{
+ namespace sdo
+ {
+ //////////////////////////////////////////////////////////////////////
+ // Construction/Destruction
+ //////////////////////////////////////////////////////////////////////
+ ParserErrorSetter::~ParserErrorSetter()
+ {
+ }
+
+ } // End - namespace sdo
+} // End - namespace commonj
+
+
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/ParserErrorSetter.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/ParserErrorSetter.cpp
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/ParserErrorSetter.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/ParserErrorSetter.h?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/ParserErrorSetter.h (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/ParserErrorSetter.h Thu Jan 5 02:55:00 2006
@@ -0,0 +1,48 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+
+#ifndef _PARSER_ERROR_SETTER_H_
+#define _PARSER_ERROR_SETTER_H_
+
+#include "commonj/sdo/export.h"
+
+#include "commonj/sdo/disable_warn.h"
+
+#include <vector>
+using namespace std;
+
+namespace commonj{
+namespace sdo{
+
+/**
+ * The ParserErrorSetter builds a list of all the errors which
+ * occurred during a parse, so they can be displayed for the
+ * user of an XSDHelper or XMLHelper
+ */
+
+class ParserErrorSetter
+{
+public:
+ virtual ~ParserErrorSetter();
+ virtual void setError(const char* message) = 0;
+};
+};
+};
+
+#endif
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/ParserErrorSetter.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/ParserErrorSetter.h
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Property.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Property.cpp?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Property.cpp (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Property.cpp Thu Jan 5 02:55:00 2006
@@ -0,0 +1,42 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+
+#include <iostream>
+using namespace std;
+
+
+#ifndef SDO_EXPORTS
+#define SDO_EXPORTS
+#endif
+#include "commonj/sdo/export.h"
+
+#include "commonj/sdo/Sequence.h"
+#include "commonj/sdo/DataObject.h"
+#include "commonj/sdo/TypeList.h"
+
+#include "commonj/sdo/Type.h"
+#include "commonj/sdo/Property.h"
+namespace commonj{
+namespace sdo{
+
+ // All delegated to the impl.
+
+};
+};
+
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Property.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Property.cpp
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Property.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Property.h?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Property.h (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Property.h Thu Jan 5 02:55:00 2006
@@ -0,0 +1,193 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+
+#ifndef _PROPERTY_H_
+#define _PROPERTY_H_
+
+
+#include "commonj/sdo/export.h"
+
+#include "commonj/sdo/Type.h"
+#include "commonj/sdo/SDODate.h"
+
+namespace commonj{
+namespace sdo{
+
+class Type;
+class TypeImpl;
+class DataObject;
+
+/**
+ *
+ * A representation of a property in the type of a data object.
+ */
+
+class Property
+{
+ public:
+
+ /** getName gets the name of the property
+ *
+ * Returns the name of the property.
+ */
+
+ virtual const SDO_API char* getName() const = 0;
+
+ /** getAlias returns the n'th alias
+ *
+ * This method returns a const char* corresponding to the
+ * alias at index n of the list of aliases. Use getAliasCount to
+ * discover the size of the list.
+ */
+
+ virtual SDO_API const char* getAlias(unsigned int index = 0) const = 0;
+
+ /** getAliasCount returns the number of aliases
+ *
+ * This method returns the number of aliases for this type
+ */
+
+ virtual SDO_API unsigned int getAliasCount() const = 0;
+
+ /** getType returns the type of this property
+ *
+ * This method returns the type, which may be a DataType or a
+ * DataObjectType
+ */
+
+ virtual SDO_API const Type& getType() const = 0;
+
+ /** getTypeEnum gets the enum for this type.
+ *
+ * Each DataType has a defined value in the list of Types.
+ */
+
+ virtual SDO_API const Type::Types getTypeEnum() const = 0;
+
+ /** isMany is true if the property is a list
+ *
+ * IsMany returns true if this property represents a list of
+ * values, and should be accessed via the getList DataObjectAPI.
+ */
+
+ virtual bool SDO_API isMany() const = 0;
+
+ /** isContainment is true if the property value is contained
+ *
+ * IsContainment returns true if this property represents a DataObjectType,
+ * and that DataObjectType is contained. I.E the property value is not a pointer
+ * to a DataObject somewhere else in the graph, it is an actual value.
+ */
+
+ virtual bool SDO_API isContainment() const = 0;
+
+ /** isReference is true if the property value is not contained
+ *
+ * IsReference returns true if this property represents a DataObjectType,
+ * and that DataObjectType is not contained. I.E the property value is a pointer
+ * to a DataObject somewhere else in the graph not an actual value.
+ */
+
+ virtual bool SDO_API isReference() const = 0;
+
+ /** getContainingType give the type which holds this property.
+ *
+ * Although many types may have a property of the same name, any given
+ * instance of a property belongs to only one type.
+ * This method returns the type which holds this proeprty.
+ */
+
+ virtual SDO_API const Type& getContainingType() const = 0;
+
+
+
+ /** isReadOnly returns true if the property is unmodifiable.
+ *
+ * NOT IMPLEMENTED
+ * Returns true if values for this Property cannot be modified using the SDO APIs.
+ * When true, DataObject.set(Property property, Object value) throws an exception.
+ * Values may change due to other factors, such as services operating on DataObjects.
+ */
+
+ virtual bool SDO_API isReadOnly() const = 0;
+
+ /** getOpposite returns the opposite property or zero.
+ *
+ * NOT IMPLEMENTED
+ */
+
+ virtual SDO_API const Property* getOpposite() const = 0;
+
+ /** isDefaulted is true if a default has been set.
+ *
+ * A property value may be set or unset. If unset, requests to the
+ * data object for the value will return a default if there is one.
+ * If the property is not defaulted, an un specified value will be
+ * returned. (Thism value will probably be zero).
+ */
+
+ virtual SDO_API bool isDefaulted() const = 0 ;
+
+ /** setDefault sets the right sort of default.
+ *
+ * The many overrides of this method allow the setting
+ * of a default value for any DataType property.
+ */
+
+ virtual SDO_API void setDefault(bool b ) = 0;
+ virtual SDO_API void setDefault(char c) = 0;
+ virtual SDO_API void setDefault(wchar_t c) = 0;
+ virtual SDO_API void setDefault(char* c) = 0;
+ virtual SDO_API void setDefault(short s) = 0;
+ virtual SDO_API void setDefault(long l) = 0;
+ virtual SDO_API void setDefault(int64_t i) = 0;
+ virtual SDO_API void setDefault(float f) = 0;
+ virtual SDO_API void setDefault(long double d) = 0;
+ virtual SDO_API void setDefault(const SDODate d) = 0;
+ virtual SDO_API void setDefault(const wchar_t* c, unsigned int len) = 0;
+ virtual SDO_API void setDefault(const char* c, unsigned int len) = 0;
+
+ /** getDefault gets the right sort of default.
+ *
+ * The many overrides of this method allow the getting
+ * of a default value for any DataType property.
+ */
+
+ virtual SDO_API unsigned int getStringDefault(wchar_t* val, unsigned int max) const = 0;
+ virtual SDO_API unsigned int getBytesDefault(char* val, unsigned int max) const = 0;
+ virtual SDO_API bool getBooleanDefault() const = 0;
+ virtual SDO_API char getByteDefault() const = 0;
+ virtual SDO_API wchar_t getCharacterDefault() const = 0;
+ virtual SDO_API short getShortDefault() const = 0;
+ virtual SDO_API long getIntegerDefault() const = 0;
+ virtual SDO_API int64_t getLongDefault() const = 0;
+ virtual SDO_API float getFloatDefault() const = 0;
+ virtual SDO_API long double getDoubleDefault() const = 0;
+ virtual SDO_API const SDODate getDateDefault() const = 0;
+ virtual SDO_API const char* getCStringDefault() const = 0;
+ virtual SDO_API unsigned int getDefaultLength() const = 0;
+
+
+};
+
+
+};
+};
+
+#endif //_PROPERTY_H_
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Property.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Property.h
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyDefinition.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyDefinition.cpp?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyDefinition.cpp (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyDefinition.cpp Thu Jan 5 02:55:00 2006
@@ -0,0 +1,44 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+
+#include "commonj/sdo/PropertyDefinition.h"
+namespace commonj
+{
+ namespace sdo
+ {
+ PropertyDefinition::PropertyDefinition()
+ : isMany(false),
+ isContainment(true),
+ isReadOnly(false),
+ isElement(false),
+ isReference(false),
+ isQName(false),
+ isID(false),
+ isIDREF(false),
+ isSubstitute(false)
+
+ {
+ }
+
+ PropertyDefinition::~PropertyDefinition()
+ {
+ }
+
+ } // End - namespace sdo
+} // End - namespace commonj
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyDefinition.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyDefinition.cpp
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyDefinition.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyDefinition.h?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyDefinition.h (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyDefinition.h Thu Jan 5 02:55:00 2006
@@ -0,0 +1,88 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+
+#ifndef _PROPERTYDEFINITION_H_
+#define _PROPERTYDEFINITION_H_
+
+#include "commonj/sdo/disable_warn.h"
+
+#include "commonj/sdo/SDOXMLString.h"
+#include <vector>
+using namespace std;
+
+
+
+namespace commonj
+{
+ namespace sdo
+ {
+
+
+/**
+ * PropertyDefinition holds a property as defined by an XSD.
+ * The XSD holds more information than does the SDO Property.
+ * This class holds the extra information found as the XSD is
+ * parsed.
+ */
+ class PropertyDefinition
+ {
+
+ public:
+ PropertyDefinition();
+ virtual ~PropertyDefinition();
+
+ // where this property is to be substituted for another
+ SDOXMLString substituteName;
+ SDOXMLString substituteUri;
+
+ // where there are substitute names for this property.
+ std::vector<SDOXMLString> substituteNames;
+ std::vector<SDOXMLString> substituteLocalNames;
+
+ SDOXMLString aliases;
+
+ SDOXMLString name;
+ SDOXMLString localname;
+
+ SDOXMLString typeUri;
+ SDOXMLString typeName;
+ SDOXMLString fullTypeName;
+
+ SDOXMLString fullLocalTypeName;
+
+ SDOXMLString defaultValue;
+
+ bool isMany;
+ bool isContainment;
+ bool isReadOnly;
+
+ bool isID;
+ bool isIDREF;
+ bool isReference;
+ bool isElement;
+
+ bool isQName;
+
+ bool isSubstitute;
+ };
+ } // End - namespace sdo
+} // End - namespace commonj
+
+
+#endif //_PROPERTYDEFINITION_H_
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyDefinition.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyDefinition.h
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.cpp?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.cpp (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.cpp Thu Jan 5 02:55:00 2006
@@ -0,0 +1,536 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+
+#include <iostream>
+using namespace std;
+
+#ifndef SDO_EXPORTS
+#define SDO_EXPORTS
+#endif
+#include "commonj/sdo/export.h"
+
+
+#include "commonj/sdo/Sequence.h"
+#include "commonj/sdo/DataObject.h"
+#include "commonj/sdo/TypeList.h"
+
+#include "commonj/sdo/Type.h"
+#include "commonj/sdo/TypeImpl.h"
+#include "commonj/sdo/Property.h"
+#include "commonj/sdo/PropertyImpl.h"
+#include "commonj/sdo/DataFactoryImpl.h"
+#include "commonj/sdo/SDORuntimeException.h"
+
+namespace commonj{
+namespace sdo{
+
+
+ Substitution::Substitution()
+ {
+ name = 0;
+ type = 0;
+ }
+
+ Substitution::Substitution(DataFactoryPtr mdg, const char* inname,
+ const Type& intype)
+ {
+ DataFactory* f = (DataFactory*)mdg;
+
+
+ if (inname != 0)
+ {
+ name = new char[strlen(inname) + 1];
+ strcpy(name,inname);
+ }
+ else
+ {
+ name = 0;
+ }
+
+ type = ((DataFactoryImpl*)f)->findType(intype.getURI(),intype.getName());
+ }
+
+ Substitution::Substitution(const Substitution& s)
+ {
+ type = s.type;
+ if (s.name != 0)
+ {
+ name = new char[strlen(s.name)+1];
+ strcpy(name,s.name);
+ }
+ else
+ {
+ name = 0;
+ }
+ }
+
+ Substitution::~Substitution()
+ {
+ if (name != 0) delete (char*)name;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // construction by DAS
+ ///////////////////////////////////////////////////////////////////////////
+
+ PropertyImpl::PropertyImpl( const Type& cont,
+ const char* inname,
+ const TypeImpl& intype,
+ bool many ,
+ bool ro ,
+ bool contain) : containertype(cont), type (intype)
+ {
+ name = new char[strlen(inname)+1];
+ strcpy(name,inname);
+ defvalue = 0;
+ defvaluelength = 0;
+ opposite = 0;
+ stringdef = 0;
+ bisMany = many;
+ bisReadOnly = ro;
+ bisContainer = contain;
+ bDefaulted=false;
+ if (contain == false && intype.isDataObjectType())
+ {
+ bisReference = true;
+ }
+ else
+ {
+ bisReference = false;
+ }
+ }
+
+
+ PropertyImpl::PropertyImpl(const PropertyImpl& p) :
+ type((*(p.getTypeImpl()))),
+ containertype (p.getContainingType())
+
+
+ {
+ name = new char[strlen(p.getName())+1];
+ strcpy(name,p.getName());
+ defvalue = 0;
+ defvaluelength = 0;
+ stringdef = 0;
+ opposite = 0;
+ bisMany = p.bisMany;
+ bisReadOnly = p.bisReadOnly;
+ bisContainer = p.bisContainer;
+ bDefaulted=false;
+ if (bisContainer == false && type.isDataObjectType())
+ {
+ bisReference = true;
+ }
+ else
+ {
+ bisReference = false;
+ }
+ }
+
+
+ PropertyImpl::~PropertyImpl()
+ {
+ if (name != 0) delete name;
+ if (defvalue != 0) delete defvalue;
+ if (stringdef != 0) delete stringdef;
+ for (int i = 0; i < aliases.size();i++)
+ {
+ delete ((char*)aliases[i]);
+ }
+
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Setting of attributes by DAS
+ ///////////////////////////////////////////////////////////////////////////
+
+ void PropertyImpl::setMany(bool many)
+ {
+ bisMany = many;
+ }
+
+ void PropertyImpl::setReadOnly(bool readonly)
+ {
+ bisReadOnly = readonly;
+ }
+
+ void PropertyImpl::setContainment(bool contains)
+ {
+ if (contains == true && type.isDataType())
+ {
+ return;
+ }
+ bisContainer = contains;
+ if (bisContainer == false && type.isDataObjectType())
+ {
+ bisReference = true;
+ }
+ else
+ {
+ bisReference = false;
+ }
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Setting of defaults by DAS
+ ///////////////////////////////////////////////////////////////////////////
+
+ void PropertyImpl::setDefault(bool b )
+ {
+ setDefaultBoolean(b);
+ }
+
+ void PropertyImpl::setDefault(char c )
+ {
+ setDefaultByte(c);
+ }
+
+ void PropertyImpl::setDefault(wchar_t c )
+ {
+ setDefaultCharacter(c);
+ }
+ void PropertyImpl::setDefault(char* c )
+ {
+ setDefaultCString(c);
+ }
+ void PropertyImpl::setDefault(short s )
+ {
+ setDefaultShort(s);
+ }
+ void PropertyImpl::setDefault(long i )
+ {
+ setDefaultInteger(i);
+ }
+ void PropertyImpl::setDefault(int64_t i )
+ {
+ setDefaultLong(i);
+ }
+ void PropertyImpl::setDefault(float f )
+ {
+ setDefaultFloat(f);
+ }
+ void PropertyImpl::setDefault(long double d )
+ {
+ setDefaultDouble(d);
+ }
+ void PropertyImpl::setDefault(const SDODate d )
+ {
+ setDefaultDate(d);
+ }
+ void PropertyImpl::setDefault(const char* c , unsigned int len)
+ {
+ setDefaultBytes(c, len);
+ }
+
+ void PropertyImpl::setDefault(const wchar_t* c, unsigned int len )
+ {
+ setDefaultString(c, len);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Substitution groups.
+ ///////////////////////////////////////////////////////////////////////////
+ const Type* PropertyImpl::getSubstitutionType(const char* inname) const
+ {
+ for (int i=0;i<substitutions.size();i++)
+ {
+ if (!strcmp(inname, substitutions[i].name))
+ {
+ return substitutions[i].type;
+ }
+ }
+ return 0;
+ }
+
+ const char * PropertyImpl::getSubstitutionName(unsigned int index) const
+ {
+ if (index < getSubstitutionCount())
+ {
+ return (substitutions[index].name);
+ }
+ SDO_THROW_EXCEPTION("getSubstitutionName", SDOIndexOutOfRangeException,
+ "index out of range");
+ }
+
+ unsigned int PropertyImpl::getSubstitutionCount(void) const
+ {
+ return substitutions.size();
+ }
+
+ const Type* PropertyImpl::getSubstitutionType(unsigned int index) const
+ {
+ if (index < getSubstitutionCount())
+ {
+ return (substitutions[index].type);
+ }
+ return 0;
+ }
+
+ void PropertyImpl::setSubstitution(DataFactoryPtr mdg, const char* alias,
+ const Type& substype)
+ {
+ substitutions.push_back(Substitution(mdg,alias,substype));
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Returns the name of the property.
+ ///////////////////////////////////////////////////////////////////////////
+ const char* PropertyImpl::getName() const
+ {
+ return name;
+ }
+
+ void PropertyImpl::setAlias(const char* alias)
+ {
+ char* tmp = new char[strlen(alias)+1];
+ strcpy(tmp,alias);
+ aliases.push_back(tmp);
+ }
+
+ const char* PropertyImpl::getAlias(unsigned int index) const
+ {
+ if (index < aliases.size())
+ {
+ return aliases[index];
+ }
+ return name;
+ }
+
+ unsigned int PropertyImpl::getAliasCount() const
+ {
+ return aliases.size();
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Returns the type of the property.
+ ///////////////////////////////////////////////////////////////////////////
+ const Type& PropertyImpl::getType() const
+ {
+ return (Type&)type;
+ }
+
+ const Type::Types PropertyImpl::getTypeEnum() const
+ {
+ return type.getTypeEnum();
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Returns the type of the property.
+ ///////////////////////////////////////////////////////////////////////////
+ const TypeImpl* PropertyImpl::getTypeImpl() const
+ {
+ return &type;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Returns whether the property is many-valued.
+ ///////////////////////////////////////////////////////////////////////////
+ bool PropertyImpl::isMany() const
+ {
+ return bisMany;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Returns whether the property is containment.
+ ///////////////////////////////////////////////////////////////////////////
+ bool PropertyImpl::isContainment() const
+ {
+ return bisContainer;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Returns whether the property is containment.
+ ///////////////////////////////////////////////////////////////////////////
+ bool PropertyImpl::isReference() const
+ {
+ return bisReference;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Returns the containing type of this property.
+ ///////////////////////////////////////////////////////////////////////////
+ const Type& PropertyImpl::getContainingType() const
+ {
+ return containertype;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Returns the opposite.
+ ///////////////////////////////////////////////////////////////////////////
+ const Property* PropertyImpl::getOpposite() const
+ {
+ return opposite;
+ }
+
+ void PropertyImpl::setOpposite(const Property* opp)
+ {
+ opposite = opp;
+ }
+ ///////////////////////////////////////////////////////////////////////////
+ // Returns the default value this property will have in a
+ // data object where the property hasn't been set.
+ ///////////////////////////////////////////////////////////////////////////
+
+ // check whether the property has a default first
+ bool PropertyImpl::isDefaulted() const
+ {
+ return bDefaulted;
+ }
+
+ const char* PropertyImpl::getCStringDefault() const
+ {
+ PropertyImpl* p = (PropertyImpl*)this;
+ return getTypeImpl()->convertToCString(defvalue, &(p->stringdef), defvaluelength);
+ }
+ bool PropertyImpl::getBooleanDefault() const
+ {
+ return getTypeImpl()->convertToBoolean(defvalue,defvaluelength);
+ }
+ char PropertyImpl::getByteDefault() const
+ {
+ return getTypeImpl()->convertToByte(defvalue,defvaluelength);
+ }
+ wchar_t PropertyImpl::getCharacterDefault() const
+ {
+ return getTypeImpl()->convertToCharacter(defvalue,defvaluelength);
+ }
+ short PropertyImpl::getShortDefault() const
+ {
+ return getTypeImpl()->convertToShort(defvalue,defvaluelength);
+ }
+ long PropertyImpl::getIntegerDefault() const
+ {
+ return getTypeImpl()->convertToInteger(defvalue,defvaluelength);
+ }
+ int64_t PropertyImpl::getLongDefault() const
+ {
+ return getTypeImpl()->convertToLong(defvalue,defvaluelength);
+ }
+ float PropertyImpl::getFloatDefault() const
+ {
+ return getTypeImpl()->convertToFloat(defvalue,defvaluelength);
+ }
+ long double PropertyImpl::getDoubleDefault() const
+ {
+ return getTypeImpl()->convertToDouble(defvalue,defvaluelength);
+ }
+ const SDODate PropertyImpl::getDateDefault() const
+ {
+ return getTypeImpl()->convertToDate(defvalue,defvaluelength);
+ }
+ unsigned int PropertyImpl::getStringDefault(wchar_t* val, unsigned int max) const
+ {
+ if (val == 0 || max == 0) return defvaluelength;
+ return getTypeImpl()->convertToString(defvalue, val, defvaluelength, max);
+
+ }
+ unsigned int PropertyImpl::getBytesDefault(char* val, unsigned int max) const
+ {
+ if (val == 0 || max == 0) return defvaluelength;
+ return getTypeImpl()->convertToBytes(defvalue, val, defvaluelength, max);
+ }
+
+ unsigned int PropertyImpl::getDefaultLength() const
+ {
+ return defvaluelength;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // sets the default value by type
+ ///////////////////////////////////////////////////////////////////////////
+
+ void PropertyImpl::setDefaultCString(const char* s)
+ {
+ bDefaulted=true;
+ defvaluelength = getTypeImpl()->convert(&defvalue,s);
+ }
+ void PropertyImpl::setDefaultString( const wchar_t* c , unsigned int len )
+ {
+ bDefaulted=true;
+ defvaluelength = getTypeImpl()->convert(&defvalue,c, len);
+ }
+ void PropertyImpl::setDefaultBytes( const char* c , unsigned int len )
+ {
+ bDefaulted=true;
+ defvaluelength = getTypeImpl()->convert(&defvalue,c, len);
+ }
+ void PropertyImpl::setDefaultBoolean( const bool b )
+ {
+ bDefaulted=true;
+ defvaluelength = getTypeImpl()->convert(&defvalue,b);
+ }
+ void PropertyImpl::setDefaultByte( const char c )
+ {
+ bDefaulted=true;
+ defvaluelength = getTypeImpl()->convert(&defvalue,c);
+ }
+ void PropertyImpl::setDefaultCharacter( const wchar_t c)
+ {
+ bDefaulted=true;
+ defvaluelength = getTypeImpl()->convert(&defvalue,c);
+ }
+ void PropertyImpl::setDefaultShort( const short s )
+ {
+ bDefaulted=true;
+ defvaluelength = getTypeImpl()->convert(&defvalue,s);
+ }
+ void PropertyImpl::setDefaultInteger( const long i )
+ {
+ bDefaulted=true;
+ defvaluelength = getTypeImpl()->convert(&defvalue,i);
+ }
+ void PropertyImpl::setDefaultLong(const int64_t l)
+ {
+ bDefaulted=true;
+ defvaluelength = getTypeImpl()->convert(&defvalue,l);
+ }
+ void PropertyImpl::setDefaultFloat( const float f )
+ {
+ bDefaulted=true;
+ defvaluelength = getTypeImpl()->convert(&defvalue,f);
+ }
+ void PropertyImpl::setDefaultDouble( const long double d )
+ {
+ bDefaulted=true;
+ defvaluelength = getTypeImpl()->convert(&defvalue,d);
+ }
+ void PropertyImpl::setDefaultDate( const SDODate d )
+ {
+ bDefaulted=true;
+ defvaluelength = getTypeImpl()->convertDate(&defvalue,d);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Returns true if values for this Property cannot be modified using the SDO APIs.
+ // When true, DataObject.set(Property property, Object value) throws an exception.
+ // Values may change due to other factors, such as services operating on DataObjects.
+ ///////////////////////////////////////////////////////////////////////////
+ bool PropertyImpl::isReadOnly() const
+ {
+ return bisReadOnly;
+ }
+
+};
+};
+
+
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.cpp
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.h?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.h (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.h Thu Jan 5 02:55:00 2006
@@ -0,0 +1,277 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+
+#ifndef _PROPERTYIMPL_H_
+#define _PROPERTYIMPL_H_
+
+#include "commonj/sdo/disable_warn.h"
+
+#include <string>
+using namespace std;
+
+#include "commonj/sdo/DASProperty.h"
+#include "commonj/sdo/SDODate.h"
+#include "commonj/sdo/DataFactory.h"
+
+namespace commonj{
+namespace sdo{
+
+class Type;
+class TypeImpl;
+class DataObject;
+
+/**
+ * A substitution is a class which permits a property to be a substitute for
+ * another one.
+ * A substitution is a definition of a type which is allowed to be placed in the
+ * data object in place of a property of another type.
+ */
+
+
+class Substitution
+{
+public:
+ Substitution();
+ Substitution(DataFactoryPtr mdg, const char* inname,
+ const Type& intype);
+ Substitution(const Substitution& s);
+ virtual ~Substitution();
+ const Type* type;
+ char* name;
+};
+
+/** PropertyImpl implements the abstract class Property.
+ *
+ * A representation of a property in the type of a data object.
+ */
+
+class PropertyImpl :public DASProperty
+{
+ public:
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Construction for the DAS
+ ///////////////////////////////////////////////////////////////////////////
+
+ SDO_API PropertyImpl(
+ const Type& cont,
+ const char* name,
+ const TypeImpl& type,
+ bool many = false,
+ bool ro = false,
+ bool contain = false);
+
+
+
+ virtual SDO_API ~PropertyImpl();
+
+ /**
+ * A Data access service may set the features of this property instead of
+ * passing them as construction parameters.
+ */
+
+ virtual SDO_API void setMany(bool many );
+
+ /**
+ * A Data access service may set the features of this property instead of
+ * passing them as construction parameters.
+ */
+ virtual SDO_API void setReadOnly(bool rdonly);
+
+ /**
+ * A Data access service may set the features of this property instead of
+ * passing them as construction parameters.
+ */
+ virtual SDO_API void setContainment(bool contains);
+
+ /**
+ * A Data access service may set the features of this property instead of
+ * passing them as construction parameters.
+ */
+
+ virtual SDO_API bool isDefaulted() const;
+
+ /**
+ * A Data access service sets the default value.
+ */
+
+ virtual SDO_API void setDefault(bool b );
+ virtual SDO_API void setDefault(char c);
+ virtual SDO_API void setDefault(wchar_t c);
+ virtual SDO_API void setDefault(char* c);
+ virtual SDO_API void setDefault(short s);
+ virtual SDO_API void setDefault(long l);
+ virtual SDO_API void setDefault(int64_t i);
+ virtual SDO_API void setDefault(float f);
+ virtual SDO_API void setDefault(long double d);
+ virtual SDO_API void setDefault(const SDODate d);
+ virtual SDO_API void setDefault(const wchar_t* c, unsigned int len);
+ virtual SDO_API void setDefault(const char* c, unsigned int len);
+
+
+
+
+
+ /**
+ * Returns the name of the property.
+ */
+
+ virtual const SDO_API char* getName() const;
+
+ /** getAlias returns the n'th alias
+ *
+ * This method returns a const char* corresponding to the
+ * alias at index n of the list of aliases. Use getAliasCount to
+ * discover the size of the list.
+ */
+
+ virtual const char* getAlias(unsigned int index = 0) const ;
+ virtual unsigned int getAliasCount() const ;
+ virtual void setAlias(const char* alias) ;
+
+ /**
+ *
+ * SubstitutionGroup support.
+ */
+
+ virtual const Type* getSubstitutionType(const char* name) const ;
+ virtual unsigned int getSubstitutionCount(void) const ;
+ virtual const Type* getSubstitutionType(unsigned int index) const ;
+ virtual const char* getSubstitutionName(unsigned int index) const ;
+ virtual void setSubstitution(DataFactoryPtr mdg, const char* alias,
+ const Type& substype) ;
+
+
+ /** getType returns the type of this property
+ *
+ * This method returns the type, which may be a DataType or a
+ * DataObjectType
+ */
+
+ virtual SDO_API const Type& getType() const;
+
+ virtual SDO_API const Type::Types getTypeEnum() const;
+
+ virtual SDO_API const TypeImpl* getTypeImpl() const;
+
+ /**
+ * Returns whether the property is many-valued.
+ */
+ virtual bool SDO_API isMany() const;
+
+ /**
+ * Returns whether the property is containment.
+ */
+ virtual bool SDO_API isContainment() const;
+
+ /**
+ * Returns whether the property is a reference.
+ */
+ virtual bool SDO_API isReference() const;
+
+ /**
+ * Returns the containing type of this property.
+ */
+ virtual SDO_API const Type& getContainingType() const;
+
+ /**
+ * returns the opposite property, or zero if there is none
+ */
+ virtual SDO_API const Property* getOpposite() const;
+
+ virtual void setOpposite(const Property* opp);
+
+
+ /**
+ * setters for type primitive types and 'an object'
+ */
+
+ SDO_API void setDefaultCString( const char* s);
+ SDO_API void setDefaultString( const wchar_t* c , unsigned int len );
+ SDO_API void setDefaultBytes( const char* c , unsigned int len );
+ SDO_API void setDefaultBoolean( const bool b );
+ SDO_API void setDefaultByte( const char c );
+ SDO_API void setDefaultCharacter( const wchar_t c);
+ SDO_API void setDefaultShort( const short s );
+ SDO_API void setDefaultInteger( const long i );
+ SDO_API void setDefaultLong(const int64_t l);
+ SDO_API void setDefaultFloat( const float f );
+ SDO_API void setDefaultDouble( const long double d );
+ SDO_API void setDefaultDate( const SDODate d );
+
+ SDO_API const char* getCStringDefault() const;
+ SDO_API unsigned int getStringDefault(wchar_t* val, unsigned int max) const;
+ SDO_API unsigned int getBytesDefault(char* val, unsigned int max) const;
+ SDO_API bool getBooleanDefault() const;
+ SDO_API char getByteDefault() const;
+ SDO_API wchar_t getCharacterDefault() const;
+ SDO_API short getShortDefault() const;
+ SDO_API long getIntegerDefault() const;
+ SDO_API int64_t getLongDefault() const;
+ SDO_API float getFloatDefault() const;
+ SDO_API long double getDoubleDefault() const;
+ SDO_API const SDODate getDateDefault() const;
+ SDO_API unsigned int getDefaultLength() const;
+
+ /**
+ * Returns true if values for this Property cannot be modified using the SDO APIs.
+ * When true, DataObject.set(Property property, Object value) throws an exception.
+ * Values may change due to other factors, such as services operating on DataObjects.
+ */
+ virtual bool SDO_API isReadOnly() const;
+
+ SDO_API PropertyImpl(const PropertyImpl& p);
+
+ private:
+
+ // clear the default value
+ void deleteValue();
+
+ bool bisReadOnly;
+ bool bisContainer;
+ bool bisReference;
+ bool bisMany;
+
+ bool bDefaulted;
+
+ const TypeImpl& type;
+ const Type& containertype;
+ const Property* opposite;
+ char* name;
+ char* stringdef;
+
+ void* defvalue;
+ // in the event of a bytes and string, this holds the length
+ unsigned int defvaluelength;
+
+ // alias support
+ std::vector<char*> aliases;
+
+ std::vector<Substitution> substitutions;
+
+ typedef std::list<PropertyImpl*> REFEREE_LIST;
+ REFEREE_LIST references;
+
+
+};
+};
+};
+
+#endif //_PROPERTYIMPL_H_
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.h
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyList.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyList.cpp?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyList.cpp (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyList.cpp Thu Jan 5 02:55:00 2006
@@ -0,0 +1,93 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+
+#ifndef SDO_EXPORTS
+ #define SDO_EXPORTS
+#endif
+
+#include "commonj/sdo/export.h"
+#include <iostream>
+#include "commonj/sdo/Property.h"
+#include "commonj/sdo/PropertyImpl.h"
+#include "commonj/sdo/Type.h"
+#include "commonj/sdo/PropertyList.h"
+
+#include "commonj/sdo/Logger.h"
+
+namespace commonj{
+namespace sdo {
+
+class Property;
+
+SDO_API PropertyList::PropertyList(PROPERTY_LIST p)
+{
+ PROPERTY_LIST::iterator i;
+ for (i = p.begin(); i != p.end(); ++i)
+ {
+ plist.insert(plist.end(),(PropertyImpl*)(*i));
+ }
+}
+
+SDO_API PropertyList::PropertyList(PROPERTY_VECTOR p)
+{
+ plist = PROPERTY_VECTOR(p);
+}
+
+SDO_API PropertyList::PropertyList(const PropertyList &pin)
+{
+ plist = PROPERTY_VECTOR(pin.getVec());
+}
+
+SDO_API PropertyList::PropertyList()
+{
+}
+
+SDO_API PropertyList::~PropertyList()
+{
+}
+
+SDO_API Property& PropertyList::operator[] (int pos)
+{
+ return *(plist[pos]);
+}
+
+SDO_API const Property& PropertyList::operator[] (int pos) const
+{
+ return *(plist[pos]);
+}
+
+SDO_API int PropertyList::size ()
+{
+ return plist.size();
+}
+
+SDO_API void PropertyList::insert(const Property& p)
+{
+ PropertyImpl* pi = (PropertyImpl*)&p;
+ plist.insert(plist.end(),new PropertyImpl(*pi));
+}
+
+PROPERTY_VECTOR PropertyList::getVec() const
+{
+ return plist;
+}
+
+};
+};
+
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyList.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyList.cpp
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyList.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyList.h?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyList.h (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyList.h Thu Jan 5 02:55:00 2006
@@ -0,0 +1,87 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 16:54:15 $ */
+
+#ifndef _PROPERTYLIST_H_
+#define _PROPERTYLIST_H_
+
+
+#include "commonj/sdo/export.h"
+
+#include <vector>
+#include <list>
+
+
+
+
+namespace commonj{
+namespace sdo{
+
+ class PropertyImpl;
+ class Property;
+ typedef std::vector<PropertyImpl*> PROPERTY_VECTOR;
+#ifndef PROPERTY_LIST
+ typedef std::list<PropertyImpl*> PROPERTY_LIST;
+#endif
+
+/**
+ * This class provides for iteration over a collection of Properties
+ */
+
+class PropertyList
+{
+private:
+ PROPERTY_VECTOR plist;
+ PROPERTY_VECTOR getVec() const;
+public:
+ SDO_API PropertyList(PROPERTY_VECTOR p);
+ SDO_API PropertyList(PROPERTY_LIST p);
+ SDO_API PropertyList(const PropertyList &pin);
+ SDO_API PropertyList();
+ virtual SDO_API ~PropertyList();
+
+ /** []
+ *
+ * Operator to allow reference to an element of the list.
+ * There are separate versions for const and variable lists
+ */
+
+ SDO_API Property& operator[] (int pos);
+ SDO_API const Property& operator[] (int pos) const;
+
+ /** size gives the number of elements.
+ *
+ * size() returns the number of elements in the list.
+ */
+
+ SDO_API int size ();
+
+ /** insert adds an element to the list
+ *
+ * insert appends an item to the list. This is not
+ * of any use to a client application, as these lists
+ * are always supplied by the library, and are const.
+ */
+
+ SDO_API void insert (const Property& p);
+};
+};
+};
+
+
+#endif
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyList.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyList.h
------------------------------------------------------------------------------
svn:keywords = Rev,Date