tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edslatt...@apache.org
Subject svn commit: r366158 [9/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_s...
Date Thu, 05 Jan 2006 10:58:55 GMT
Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h Thu Jan  5 02:55:00 2006
@@ -0,0 +1,662 @@
+/*
+ *
+ *  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 _DATAOBJECTIMPL_H_
+#define _DATAOBJECTIMPL_H_
+#include "commonj/sdo/DataObject.h"
+
+#include "commonj/sdo/disable_warn.h"
+
+#include <ctime>
+#include <list>
+#include <map>
+
+#include <string>
+
+
+#include "commonj/sdo/Property.h"
+#include "commonj/sdo/TypeImpl.h"
+#include "commonj/sdo/DataFactory.h"
+#include "commonj/sdo/SequenceImpl.h"
+#include "commonj/sdo/DataObjectListImpl.h"
+#include "commonj/sdo/PropertyList.h"
+
+#include "commonj/sdo/RefCountingPointer.h"
+#include "commonj/sdo/ChangeSummaryImpl.h"
+#include "commonj/sdo/SDODate.h"
+
+namespace commonj{
+namespace sdo{
+    
+class DataGraph;
+class DataObjectImpl; 
+class DataObjectListImpl;
+class DataFactory;
+
+
+#define DataObjectImplPtr RefCountingPointer<DataObjectImpl>
+#define ChangeSummaryImplPtr RefCountingPointer<ChangeSummaryImpl>
+
+/**
+ * rdo is an internal class holding a property value in a data object.
+ */
+
+class rdo {
+public:
+    unsigned int first;
+    DataObjectImplPtr second;
+    rdo(unsigned int infirst, DataObjectImpl* insecond);
+    rdo();
+    rdo (const rdo& inrdo);
+    virtual ~rdo();
+};
+
+typedef std::list< rdo > PropertyValueMap;
+
+
+ /**  
+  *  DataObjectImpl implements the abstract class DataObject.
+  *
+  * A data object is a representation of some structured data. 
+  * it is the fundamental component in the SDO (Service Data Objects) package.
+  * Data objects support reflection, path-based accesss, convenience creation 
+  * and deletion methods,and the ability to be part of a data graph.
+  * Each data object holds its data as a series of properties. 
+  * Properties can be accessed by name, property index, or using the property 
+  * meta object itself. 
+  * A data object can also contain references to other data objects, through 
+  * reference-type properties.
+  * A data object has a series of convenience accessors for its properties. 
+  * These methods either use a path (String), a property index, 
+  * or the property's meta object itself, to identify the property.
+  * Some examples of the path-based accessors are as follows:
+  * DataObjectPtr company = ...;
+  * company->getString("name");                   
+  * company->setString("name", "acme");
+  * company->getString("department.0/name")       
+  *                                        .n  indexes from 0.
+  * company->getString("department[1]/name")      [] indexes from 1.
+  * company->getDataObject("department[number=123]")  returns the department where number=123
+  * company->getDataObject("..")                      returns the containing data object
+  * company->getDataObject("/")                       returns the root containing data object
+  * There are specific accessors for the primitive types and commonly used 
+  * data types like String.
+  */
+
+class DataObjectImpl : public DataObject
+{
+     public:
+
+    DataObjectImpl();
+    DataObjectImpl(const TypeImpl& t);
+    DataObjectImpl(DataFactory* dataFactory, const Type& t);
+
+    // This one only needs the values, and the type/prop info. The rest
+    // is not copied and would be unsafe to do so. This is used to
+    // store the cloned info in a change summary.
+
+    DataObjectImpl(DataObjectImplPtr indo);
+
+    virtual ~DataObjectImpl();
+
+    /////////////////////////////////////////////////////////////////////////
+    //    Introspection
+    /////////////////////////////////////////////////////////////////////////
+
+
+    void handlePropertyNotSet(const char* name);
+
+    /**  getPropertyIndex gets the unique index of a property
+     *
+     * A property of a data object has a unique index associated with it. 
+     * This method gets a property index for this object from the property, 
+     * or throw SDOPropertyNotFoundException if the property is not part 
+     * of this data object.
+     */
+
+    virtual unsigned int getPropertyIndex(const Property& p);
+    
+    /**
+     * These are just like getType().getProperty(), but may return
+     * values other than the property list for open types.
+     */
+
+    virtual const Property& getProperty(unsigned int index);
+    
+    virtual const Property& getProperty(const char* prop);
+    
+    virtual PropertyImpl* getPropertyImpl(const char* prop);
+    
+    virtual PropertyImpl* getPropertyImpl(unsigned int index);
+
+   /**  getInstanceProperties gets the props of the current object.
+     *
+     * Returns a read-only List of the Properties currently used in this DataObject.
+     * This list will contain all of the properties in getType().getProperties()
+     * and any properties where isSet(property) is true.
+     * For example, properties resulting from the use of
+     * open or mixed XML content are present if allowed by the Type.
+     * The list does not contain duplicates. 
+     * The order of the properties in the list begins with getType().getProperties()
+     * and the order of the remaining properties is determined by the implementation.
+     * The same list will be returned unless the DataObject is updated so that 
+     * the contents of the list change
+     * Returns the list of Properties currently used in this DataObject.
+     */
+    
+    virtual PropertyList getInstanceProperties();
+
+     /**  getContainer get the containing object
+     *
+     * Returns the containing data object
+     * or 0 if there is no container.
+     */
+
+    virtual DataObjectPtr getContainer();
+
+    /**  getContainmentProperty returns the property containing this object
+     *
+     *  Return the Property of the data object containing this data object
+     *  or throw an SDOPropertyNotFoundException if there is no container.
+     */
+
+    virtual const Property& getContainmentProperty();
+    
+    /**  getType  returns the data object's type.
+     *
+     * getType returns the data object's type.
+     * The type defines the properties available for reflective access.
+     */
+    
+    virtual const Type& getType();
+    
+    virtual const Type::Types getTypeEnum();
+
+
+
+    ///////////////////////////////////////////////////////////////////////////
+    // get/set
+    ///////////////////////////////////////////////////////////////////////////
+    
+    
+    /**  getDataObject returns a data object by path, index or property
+     *
+     * Returns the value of a property of either this object or an object 
+     * reachable from it, as identified by the specified path.
+     */
+
+    virtual DataObjectPtr getDataObject(const char* path); 
+    virtual DataObjectPtr getDataObject(unsigned int propertyIndex); 
+    virtual DataObjectPtr getDataObject(const Property& property); 
+
+    /**  setDataObject sets a value by path, index or property
+     *
+     * Sets a property of either this object or an object reachable from it,
+     * as identified by the specified path,
+     * to the specified value.
+     */
+    
+    virtual void setDataObject(const char* path, DataObjectPtr value); 
+    virtual void setDataObject(unsigned int propertyIndex, DataObjectPtr value); 
+    virtual void setDataObject(const Property& property, DataObjectPtr value); 
+
+    /**  getBoolean returns a boolean by path, index or property
+     *
+     * Returns the value of a property of either this object or an object 
+     * reachable from it, as identified by the specified path.
+     */
+
+    virtual bool getBoolean(const char* path);
+    virtual bool getBoolean(unsigned int propindex);
+    virtual bool getBoolean(const Property& p);
+    
+    virtual void setBoolean(const char* path, bool b);
+    virtual void setBoolean(unsigned int propindex, bool b);
+    virtual void setBoolean(const Property& p, bool b);
+
+    virtual char getByte(const char* path);
+    virtual char getByte(unsigned int propindex);
+    virtual char getByte(const Property& p);
+    
+    virtual void setByte(const char* path, char c);
+    virtual void setByte(unsigned int propindex, char c);
+    virtual void setByte(const Property& p, char c);
+
+    virtual wchar_t getCharacter(const char* path);
+    virtual wchar_t getCharacter(unsigned int propindex);
+    virtual wchar_t getCharacter(const Property& p);
+    
+    virtual void setCharacter(const char* path, wchar_t c);
+    virtual void setCharacter(unsigned int propindex, wchar_t c);
+    virtual void setCharacter(const Property& p, wchar_t c);
+
+    virtual unsigned int getLength(const char* path) ;
+    virtual unsigned int getLength(unsigned int propindex) ;
+    virtual unsigned int getLength(const Property& p) ;
+    virtual unsigned int getLength() ;
+
+    virtual unsigned int getBytes(const char* path, char* buf, unsigned int max) ;
+    virtual unsigned int getBytes(unsigned int propindex, char* buf, unsigned int max) ;
+    virtual unsigned int getBytes(const Property& p, char* buf, unsigned int max) ;
+    
+    virtual void setBytes(const char* path, const char* c, unsigned int len) ;
+    virtual void setBytes(unsigned int propindex, const char* c,unsigned int len) ;
+    virtual void setBytes(const Property& p, const char* c,unsigned int len) ;
+
+    virtual unsigned int getString(const char* path, wchar_t* buf, unsigned int max) ;
+    virtual unsigned int getString(unsigned int propindex,wchar_t* buf, unsigned int max) ;
+    virtual unsigned int getString(const Property& p,wchar_t* buf, unsigned int max) ;
+    
+    virtual void setString(const char* path, const wchar_t* c,unsigned int len) ;
+    virtual void setString(unsigned int propindex, const wchar_t* c,unsigned int len) ;
+    virtual void setString(const Property& p, const wchar_t* c,unsigned int len) ;
+
+    virtual const SDODate getDate(const char* path);
+    virtual const SDODate getDate(unsigned int propindex);
+    virtual const SDODate getDate(const Property& p);
+    
+    virtual void setDate(const char* path, const SDODate d);
+    virtual void setDate(unsigned int propindex, const SDODate d);
+    virtual void setDate(const Property& p, const SDODate d);
+
+    virtual long double getDouble(const char* path);
+    virtual long double getDouble(unsigned int propindex);
+    virtual long double getDouble(const Property& p);
+    
+    virtual void setDouble(const char* path, long double d);
+    virtual void setDouble(unsigned int propindex, long double d);
+    virtual void setDouble(const Property& p, long double d);
+
+    virtual float getFloat(const char* path);
+    virtual float getFloat(unsigned int propindex);
+    virtual float getFloat(const Property& p);
+    
+    virtual void setFloat(const char* path, float f);
+    virtual void setFloat(unsigned int propindex, float f);
+    virtual void setFloat(const Property& p, float f);
+
+    virtual long getInteger(const char* path);
+    virtual long getInteger(unsigned int propindex);
+    virtual long getInteger(const Property& p);
+    
+    virtual void setInteger(const char* path, long i);
+    virtual void setInteger(unsigned int propindex, long i);
+    virtual void setInteger(const Property& p, long i);
+
+    virtual /*long long*/ int64_t getLong(const char* path);
+    virtual /*long long*/ int64_t getLong(unsigned int propindex);
+    virtual /*long long*/ int64_t getLong(const Property& p);
+    
+    virtual void setLong(const char* path, /*long long*/ int64_t l);
+    virtual void setLong(unsigned int propindex, /*long long*/ int64_t l);
+    virtual void setLong(const Property& p, /*long long*/ int64_t l);
+
+    virtual short getShort(const char* path);
+    virtual short getShort(unsigned int propindex);
+    virtual short getShort(const Property& p);
+    
+    virtual void setShort(const char* path, short s);
+    virtual void setShort(unsigned int propindex, short s);
+    virtual void setShort(const Property& p, short s);
+
+     virtual const char* getCString(const char* path);
+    virtual const char* getCString(unsigned int propertyIndex);
+    virtual const char* getCString(const Property& prop);
+    
+    virtual void setCString(const char* path, const char* value);
+    virtual void setCString(unsigned int propertyIndex, const char* value);
+    virtual void setCString (const Property& prop, const char* value);
+    
+    /**  setNull sets a data object value to null.
+     *
+     * A DataObjectType or DataType value may be set or unset. If it is set, then
+     * it may have a value, or it may be set to null. A distinction is drawn between
+     * being unset, having the default value, being set and being null.
+     * When the value of an integer (for example) is returned as zero, it could have
+     * been set to zero, or it could be null. Use isNull() to verify.
+        */
+
+    virtual void setNull(const char* path);
+    virtual void setNull(unsigned int propertyIndex);
+    virtual void setNull(const Property& prop);
+    
+    virtual bool isNull(const char* path);
+    virtual bool isNull(unsigned int propertyIndex);
+    virtual bool isNull(const Property& prop);
+    
+    virtual bool isSet(const char* path);
+    virtual bool isSet(unsigned int propertyIndex);
+    virtual bool isSet(const Property& property);
+
+    virtual bool isValid(const char* path);
+    virtual bool isValid(unsigned int propertyIndex);
+    virtual bool isValid(const Property& property);
+
+    virtual void unset(const char* path);
+    virtual void unset(unsigned int propertyIndex);
+    virtual void unset(const Property& property);
+
+
+    ///////////////////////////////////////////////////////////////////////////
+    // Sequences
+    ///////////////////////////////////////////////////////////////////////////
+
+    /**  getSequence returns the sequence for a data object
+     *
+     * Returns the value of a Sequence property identified by 
+     * the specified path. See Sequence.
+     */
+
+    virtual SequenceImpl* getSequenceImpl();
+    virtual SequencePtr getSequence();
+    virtual SequencePtr getSequence(const char* path);
+    virtual SequencePtr getSequence(unsigned int propertyIndex);
+    virtual SequencePtr getSequence(const Property& property);
+
+
+    ///////////////////////////////////////////////////////////////////////////    
+    // Creation of dataobjects 
+    ///////////////////////////////////////////////////////////////////////////
+
+    /**  createDataObject creates a data object value
+     *
+     * Returns a new data object contained by this object using the 
+     * specified property,which must be a containment property.
+     * The type of the created object is the declared type
+     * of the specified property.
+     * If the property is many valued, this method adds an element to the
+     * list, otherwise it sets the value, removing any old value.
+     */
+    
+    virtual DataObjectPtr createDataObject(const char* propertyName);
+    virtual DataObjectPtr createDataObject(unsigned int propertyIndex);
+    virtual DataObjectPtr createDataObject(const Property& property);
+
+
+
+
+    virtual void detach();
+
+    virtual void clear();
+
+
+    ///////////////////////////////////////////////////////////////////////////
+    // Lists
+    ///////////////////////////////////////////////////////////////////////////
+
+   /**  getList gets the value of a many-valued property
+     *
+     * Many valued properties are returned as lists of DataObjects.
+     * These lists may contain primitives or data objects, but they behave
+     * like data objects.
+     * Getting a many valued integer consists of getting the list, then
+     * using the DataObjectList API to getInteger() for each list element.
+     */
+
+    virtual DataObjectList& getList(const char* path);
+    virtual DataObjectList& getList(unsigned int propIndex);
+    virtual DataObjectList& getList(const Property& p);
+    virtual DataObjectList& getList();
+    virtual DataObjectListImpl* getListImpl();
+
+    void setList( DataObjectList* theList);
+
+    ///////////////////////////////////////////////////////////////////////////
+    // Change Summary
+    ///////////////////////////////////////////////////////////////////////////
+    
+    /**  getChangeSummary get the applicable change summary
+     *
+     * This method gets the applicable change summary for a data object.
+     * The summary is not necessarily attached to the data object, it may be
+     * the summary for a parent data object. No object with a summary attached
+     * may be a child of another object with a summary attached. 
+     * See the ChangeSummary API for details of using the change sumamry.
+     */
+
+    virtual SDO_API ChangeSummaryPtr getChangeSummary(const char* path);
+    virtual SDO_API ChangeSummaryPtr getChangeSummary(unsigned int propIndex);
+    virtual SDO_API ChangeSummaryPtr getChangeSummary(const Property& prop);
+      virtual SDO_API ChangeSummaryPtr getChangeSummary();
+
+
+    virtual bool getBoolean();
+    virtual void setBoolean(bool b);
+    virtual char getByte();
+    virtual void setByte(char c);
+    virtual wchar_t getCharacter();
+    virtual void setCharacter(wchar_t c);
+    virtual unsigned int getString(wchar_t* buf, unsigned int max);
+    virtual unsigned int getBytes(char* buf, unsigned int max);
+    virtual void setString(const wchar_t* buf, unsigned int len);
+    virtual void setBytes(const char* c, unsigned int len);
+    virtual short getShort();
+    virtual void setShort(short s);
+    virtual long getInteger();
+    virtual void setInteger(long s);
+    virtual /* long long*/ int64_t getLong();
+    virtual void setLong(/* long long */ int64_t i);
+    virtual float getFloat();
+    virtual void setFloat(float b);
+    virtual long double getDouble();
+    virtual void setDouble(long double d);
+    virtual const SDODate getDate();
+    virtual void setDate(const SDODate d);
+    virtual const char*  getCString();
+    virtual void setCString(const char* s);
+    virtual DataObjectImpl* getDataObject();
+    virtual void setDataObject(DataObject* d);
+
+    // null support
+    virtual bool isNull();
+    virtual void setNull();
+    virtual void unsetNull();
+
+    // change logging is used by the dataobjectlistimpl
+    virtual void logChange(const Property& prop);
+    virtual void logChange(unsigned int propIndex);
+    virtual void logDeletion();
+    virtual void logCreation(DataObjectImpl* dol,
+        DataObjectImpl* cont, const Property& prop);
+
+    // reference support
+    virtual void setReference(DataObject* dob, const Property& prop);
+    virtual void unsetReference(DataObject* dob, const Property& prop);
+    virtual void clearReferences();
+    
+    // user data support
+    virtual void setUserData(const char* path,void* value);
+    virtual void setUserData(unsigned int propertyIndex, void* value);
+    virtual void setUserData(const Property& property, void* value);
+    virtual void setUserData(void* value);
+    virtual void* getUserData(const char* path);
+    virtual void* getUserData(unsigned int propertyIndex);
+    virtual void* getUserData(const Property& property);
+    virtual void* getUserData();
+
+    virtual void setContainer(DataObjectImpl* d);
+    DataObjectImpl* getContainerImpl();
+
+    // builds a temporary XPath for this object.
+    const char* objectToXPath();
+
+    // The data factory can be used to create new data objects within
+    // the Type system of this data object
+    // 
+      
+    SDO_API DataFactory* getDataFactory();
+
+
+    // cache a copy of the change summary in this data object, if there
+    // is one in the tree.
+
+    virtual void setApplicableChangeSummary();
+
+
+    // open type support
+    virtual void   setInstancePropertyType(unsigned int index,
+                                            const Type* t);
+
+    /** 
+     * defineProperty is used by open type support.
+     * This method and its siblings define a new property on an
+     * open type when a setting is requested.
+     */
+
+    virtual const PropertyImpl* defineProperty(const char* propname, 
+                 const Type& t);
+
+    virtual const PropertyImpl* defineBoolean(const char* propname);
+    virtual const PropertyImpl* defineByte(const char* propname);
+    virtual const PropertyImpl* defineCharacter(const char* propname);
+    virtual const PropertyImpl* defineString(const char* propname);
+    virtual const PropertyImpl* defineBytes(const char* propname);
+    virtual const PropertyImpl* defineShort(const char* propname);
+    virtual const PropertyImpl* defineInteger(const char* propname);
+    virtual const PropertyImpl* defineLong(const char* propname);
+    virtual const PropertyImpl* defineFloat(const char* propname);
+    virtual const PropertyImpl* defineDouble(const char* propname);
+    virtual const PropertyImpl* defineDate(const char* propname);
+    virtual const PropertyImpl* defineCString(const char* propname);
+    virtual const PropertyImpl* defineDataObject(const char* propname,
+        const Type&t );
+    virtual const PropertyImpl* defineDataObject(const char* propname,
+        const char* typeURI, const char* typeName );
+    virtual const PropertyImpl* defineList(const char* propname);
+    virtual void  undefineProperty(unsigned int index);
+
+private:
+
+    void validateIndex(unsigned int index);
+     void checkType(    const Property& prop,
+                    const Type& objectType);
+     
+    virtual bool remove(DataObjectImpl* indol);
+    virtual bool isSet(const Property& prop, unsigned int propertyIndex);
+
+    virtual const TypeImpl& getTypeImpl();
+
+    virtual DataObjectImpl* getDataObjectImpl(const char* path); 
+    virtual DataObjectImpl* getDataObjectImpl(unsigned int propertyIndex); 
+    virtual DataObjectImpl* getDataObjectImpl(const Property& property); 
+
+    virtual DataObjectPtr
+        createDataObject(const Property& property, 
+        const char* namespaceURI,
+        const char* typeName);
+
+    DataObjectImpl* findDataObject(char* token, long* index);
+     const Property*   findInProperties(DataObject* ob);
+    char* findPropertyContainer(const char* path, DataObjectImpl** din);
+     char* stripPath(const char* path);
+
+
+    // Does not keep a reference counted pointer to the container.
+    DataObjectImpl* container;
+ 
+    // remove the value from the data object.
+    void deleteValue();
+
+
+    PropertyValueMap PropertyValues;
+    
+    const TypeImpl& ObjectType;
+
+    DataObjectListImpl* listValue;
+    
+    // Holds the value , reallocated as necessary for strings
+    void* value;  
+
+    // In the case of a bytes/string - this holds the length;
+    unsigned int valuelength;
+                         
+    // holds the value as a string - if requested.
+    char* asStringBuffer; 
+
+    // holds the Xpath to this object if requested.
+    std::string asXPathBuffer;
+
+    // The data object holds a counted reference to the data factory.
+    DataFactoryPtr factory;
+
+    void setDataFactory(DataFactory *df);
+
+    // Support for open types
+    int openBase;
+    std::list<PropertyImpl> openProperties;
+
+    static const char* emptyString;
+    static const char* templateString;
+
+    // Data may be set to null in any data object
+    bool isnull;
+
+    // user supplied 32 bit value.
+    void* userdata;
+
+    //
+    // The sequence, if this is a sequenced type - not
+    // reference counted by the data object
+    //
+    SequenceImpl* sequence;
+
+    //
+    // The change summary if this is a summarised type
+    // not reference counted by the data object - only by
+    // clients
+    //
+
+    ChangeSummaryImpl* getChangeSummaryImpl();
+    ChangeSummaryImpl* getSummary();
+    ChangeSummaryImpl* localCS;
+    DataObjectImpl* changesummaryobject;
+
+
+    // reference type support
+
+    class Reference
+    {
+    public:
+        DataObject* getDataObject()
+        {
+            return referer;
+        }
+        const Property& getProperty()
+        {
+            return refprop;
+        }
+        Reference(DataObject* d, const Property& p) : refprop(p), referer(d)
+        {
+        }
+    private:
+        DataObject* referer;
+        const Property& refprop;
+    };
+
+    typedef std::vector<Reference*> REFERENCE_LIST;
+
+    REFERENCE_LIST refs;
+
+
+  
+};
+};
+};
+ 
+#endif //_DATAOBJECTIMPL_H_

Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectInstance.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectInstance.cpp?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectInstance.cpp (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectInstance.cpp 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 $ */
+
+#include "commonj/sdo/DataObjectInstance.h"
+using commonj::sdo::CopyHelper;
+
+
+
+namespace commonj
+{
+    namespace sdo
+    {        
+        // ============
+        // Constructors
+        // ============    
+        DataObjectInstance::DataObjectInstance()
+        {
+        }
+
+        DataObjectInstance::DataObjectInstance(const DataObjectPtr& theDO)
+        {
+            dataObject = CopyHelper::copy(theDO);
+        }
+        
+        // ==========
+        // Destructor
+        // ==========
+        DataObjectInstance::~DataObjectInstance()
+        {
+        }
+
+        // ===================================
+        // Copy constructor: deep copy the DO
+        // ===================================
+        DataObjectInstance::DataObjectInstance(const DataObjectInstance& doi)
+        {
+            dataObject = CopyHelper::copy(doi.dataObject);
+        }
+        
+        // =============================
+        // operator= : deep copy the DO
+        // =============================
+        DataObjectInstance& DataObjectInstance::operator=(const DataObjectInstance& doi)
+        {
+            if (this != &doi)
+            {
+                dataObject = CopyHelper::copy(doi.dataObject);
+            }
+            return *this;
+        }
+
+    } // End namespace sca
+} // End namespace osoa

Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectInstance.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectInstance.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectInstance.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectInstance.h?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectInstance.h (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectInstance.h Thu Jan  5 02:55:00 2006
@@ -0,0 +1,62 @@
+/*
+ *
+ *  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 commonj_sdo_DataObjectInstance_h
+#define commonj_sdo_DataObjectInstance_h
+
+
+#include "commonj/sdo/export.h"
+#include "commonj/sdo/SDO.h"
+using commonj::sdo::DataObjectPtr;
+using commonj::sdo::DataObject;
+
+
+namespace commonj
+{
+    namespace sdo
+    {
+/**
+ * DataObjectInstance is a class which allows DataObjects to be considered
+ * as instances rather than data object pointers.
+ */
+        class DataObjectInstance  
+        {
+        
+        public:
+            SDO_API DataObjectInstance();
+            SDO_API virtual ~DataObjectInstance();
+
+            SDO_API DataObjectInstance(const DataObjectPtr& theDO);
+            SDO_API DataObjectInstance(const DataObjectInstance&);
+
+            SDO_API DataObjectInstance& operator=(const DataObjectInstance&);
+            SDO_API bool operator!() {return (!dataObject);}
+            SDO_API operator bool() {return !!dataObject;}
+
+            SDO_API DataObject* operator->() {return dataObject;}
+
+            SDO_API DataObjectPtr getDataObject() {return dataObject;}
+            SDO_API operator DataObjectPtr() {return dataObject;}
+        private:
+            DataObjectPtr dataObject;
+        };
+    } // End namespace sdo
+} // End namespace commonj
+
+#endif // commonj_sdo_DataObjectInstance_h

Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectInstance.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectInstance.h
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectList.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectList.cpp?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectList.cpp (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectList.cpp Thu Jan  5 02:55:00 2006
@@ -0,0 +1,41 @@
+/*
+ *
+ *  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/DataObjectList.h"
+
+namespace commonj{
+namespace sdo {
+
+/** 
+ * 
+ * List for retrieving many valued property values.
+ *
+ * DataObjectList provides an API for getting and setting values in
+ * many valued properties. The list deals with both DataType and 
+ * DataObjectType properties.
+ */
+
+DataObjectList::~DataObjectList()
+{
+
+}
+
+};
+};
+

Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectList.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectList.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectList.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectList.h?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectList.h (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectList.h Thu Jan  5 02:55:00 2006
@@ -0,0 +1,173 @@
+/*
+ *
+ *  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 _DATAOBJECTLIST_H_
+#define _DATAOBJECTLIST_H_
+
+
+#include "commonj/sdo/export.h"
+#include "commonj/sdo/RefCountingPointer.h"
+#include "commonj/sdo/DataObject.h"
+#include "commonj/sdo/SDODate.h"
+#include <wchar.h>
+
+
+namespace commonj{
+namespace sdo{
+
+/** 
+ * 
+ * List for retrieving many valued property values, DataType or DataObjectType.
+ *
+ * DataObjectList provides an API for getting and setting values in
+ * many valued properties. The list deals with both DataType and 
+ * DataObjectType properties.
+ */
+
+class DataObjectList
+{
+public:
+    virtual  ~DataObjectList();
+
+    /**  [] is a index operator, and returns a dataobject.
+     *
+     * The index operator returns a data object, even if the 
+     * list is of a DataType. The data object can yield its true value using
+     * getInteger() etc. Alternatively, list elements can be accessed
+     * with their correct type using the list getInteger(index) api.
+     */
+
+    virtual SDO_API DataObjectPtr operator[] (int pos) = 0;
+    virtual SDO_API const DataObjectPtr operator[] (int pos) const = 0;
+
+    /**  size returns the number of elements.
+     *
+     * The size method returns the number of elements in the list
+     */
+
+    virtual SDO_API int size () const = 0;
+
+    /**  getBoolean returns a boolean at an index
+     *
+     * Each of the DataTypes has a corresponding getter and setter
+     * overload. getBoolean returns a bool, getByte returns a char
+     * etc
+     */
+
+    virtual SDO_API bool getBoolean(unsigned int index) const = 0;
+    virtual SDO_API char getByte(unsigned int index) const = 0;
+    virtual SDO_API wchar_t getCharacter(unsigned int index) const = 0;
+    virtual SDO_API unsigned int getString(unsigned int index, wchar_t* value,
+        unsigned int max) const = 0;
+    virtual SDO_API unsigned int getBytes(unsigned int index, char* value,
+        unsigned int max) const = 0;
+    virtual SDO_API short getShort(unsigned int index) const = 0;
+    virtual SDO_API long getInteger(unsigned int index) const = 0;
+    virtual SDO_API int64_t getLong(unsigned int index) const = 0;
+    virtual SDO_API float getFloat(unsigned int index) const = 0;
+    virtual SDO_API long double getDouble(unsigned int index) const = 0;
+    virtual SDO_API const SDODate  getDate(unsigned int index) const = 0;
+    virtual SDO_API const char*  getCString(unsigned int index) const = 0;
+    virtual SDO_API DataObjectPtr  getDataObject(unsigned int index) const = 0;
+
+    virtual SDO_API void setBoolean(unsigned int index, bool d)  = 0;
+    virtual SDO_API void setByte(unsigned int index, char d)  = 0;
+    virtual SDO_API void setCharacter(unsigned int index, wchar_t d)  = 0;
+    virtual SDO_API void setString(unsigned int index, const wchar_t* d, unsigned int len)  = 0;
+    virtual SDO_API void setBytes(unsigned int index, const char* d, unsigned int len)  = 0;
+    virtual SDO_API void setShort(unsigned int index, short d)  = 0;
+    virtual SDO_API void setInteger(unsigned int index, long d)  = 0;
+    virtual SDO_API void setLong(unsigned int index, int64_t d)  = 0;
+    virtual SDO_API void setFloat(unsigned int index, float d)  = 0;
+    virtual SDO_API void setDouble(unsigned int index, long double d)  = 0;
+    virtual SDO_API void setDate(unsigned int index, const SDODate d)  = 0;
+    virtual SDO_API void setCString(unsigned int index, char* d)  = 0;
+    virtual SDO_API void setDataObject(unsigned int index, DataObjectPtr dob)  = 0;
+
+    /**  getLength returns the length of a string element
+     *
+     * getLength behaves like DataObject::getlength. It returns the length
+     * of a bytes or string buffer such that space can be allocated for the
+     * values from getBytes() and getString()
+     */
+
+    virtual SDO_API unsigned int getLength(unsigned int index) const = 0;
+
+    /**  insert and append put items into the list
+     *
+     * insert and append have overrides for each of the DataTypes, and 
+     * for DataObject. Insert inserts before the element number given. If the insertion 
+     * point is off the end of the list, then an append is performed.
+     * Append puts the element on the end of the list.
+     */
+
+
+    virtual SDO_API void insert (unsigned int index, DataObjectPtr d) = 0;
+    virtual SDO_API void append (DataObjectPtr d) = 0;
+    
+    virtual SDO_API void insert (unsigned int index, bool d) = 0;
+    virtual SDO_API void append (bool d) = 0;
+
+    virtual SDO_API void insert (unsigned int index, char d) = 0;
+    virtual SDO_API void append (char d) = 0;
+
+    virtual SDO_API void insert (unsigned int index, wchar_t d) = 0;
+    virtual SDO_API void append (wchar_t d) = 0;
+
+    virtual SDO_API void insert (unsigned int index, const wchar_t* d, unsigned int len) = 0;
+    virtual SDO_API void append (const wchar_t* d, unsigned int len) = 0;
+
+    virtual SDO_API void insert (unsigned int index, const char* d, unsigned int len) = 0;
+    virtual SDO_API void append (const char* d, unsigned int len) = 0;
+
+    virtual SDO_API void insert (unsigned int index, const char* d) = 0;
+    virtual SDO_API void append (const char* d) = 0;
+
+    virtual SDO_API void insert (unsigned int index, short d) = 0;
+    virtual SDO_API void append (short d) = 0;
+
+    virtual SDO_API void insert (unsigned int index, const SDODate d) = 0;
+    virtual SDO_API void append (const SDODate d) = 0;
+
+    virtual SDO_API void insert (unsigned int index, long d) = 0;
+    virtual SDO_API void append (long d) = 0;
+
+    virtual SDO_API void insert (unsigned int index, int64_t d) = 0;
+    virtual SDO_API void append (int64_t d) = 0;
+    
+    virtual SDO_API void insert (unsigned int index, float d) = 0;
+    virtual SDO_API void append (float d) = 0;
+
+
+    virtual SDO_API void insert (unsigned int index, long double d) = 0;
+    virtual SDO_API void append (long double d) = 0;
+
+    /**  remove removes an element from the list.
+     * 
+     * Remove removes the element from the list, and passes out a 
+     * DataObjectPtr to the old value. This can be attached to the list
+     * somewhere else, or discarded.
+     */
+
+    virtual SDO_API DataObjectPtr  remove (unsigned int index) = 0;
+};
+};
+};
+
+#endif

Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectList.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectList.h
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp Thu Jan  5 02:55:00 2006
@@ -0,0 +1,959 @@
+/*
+ *
+ *  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/DataObjectListImpl.h"
+
+
+#include <iostream>
+#include "commonj/sdo/Property.h"
+#include "commonj/sdo/Type.h"
+#include "commonj/sdo/DataObject.h"
+#include "commonj/sdo/Logger.h"
+#include "commonj/sdo/SDORuntimeException.h"
+#include "commonj/sdo/DataFactory.h"
+#include "commonj/sdo/DataObjectImpl.h"
+#include "commonj/sdo/DataFactoryImpl.h"
+
+namespace commonj{
+namespace sdo {
+
+/** 
+ * DataObjectListImpl implements DataObjectList.
+ * List for retrieving many valued property values.
+ *
+ * DataObjectList provides an API for getting and setting values in
+ * many valued properties. The list deals with both DataType and 
+ * DataObjectType properties.
+ */
+DataObjectListImpl::DataObjectListImpl(DATAOBJECT_VECTOR p) : plist (p)
+{
+    theFactory = 0;
+    container  = 0;
+    pindex     = 0;
+    isReference = false;
+}
+
+DataObjectListImpl::DataObjectListImpl(const DataObjectListImpl &pin)
+{
+    plist = std::vector<RefCountingPointer<DataObjectImpl> >(pin.getVec());
+    theFactory = pin.theFactory;
+    container = pin.container;
+    pindex = pin.pindex;
+    typeUnset = pin.typeUnset;
+    isReference = pin.isReference;
+    if (pin.typeURI != 0) {
+        typeURI = new char[strlen(pin.typeURI) +1];
+        strcpy(typeURI, pin.typeURI);
+    }
+    if (pin.typeName != 0) {
+        typeName = new char[strlen(pin.typeName) +1];
+        strcpy(typeName, pin.typeName);
+    }
+}
+
+DataObjectListImpl::DataObjectListImpl()
+{
+    theFactory = 0;
+    typeURI    = 0;
+    typeName   = 0;
+    theFactory = 0;
+    container  = 0;
+    pindex     = 0;
+    typeUnset  = false;
+    isReference = false;
+}
+
+DataObjectListImpl::DataObjectListImpl(DataFactory* df, 
+                                       DataObjectImpl* cont,
+                                       unsigned int inpindex,
+                                       const char* intypeURI,
+                                       const char* intypeName)
+{
+    container = cont;
+    pindex = inpindex;
+    theFactory = df;
+
+
+    isReference = false;
+    if (container->getProperty(pindex).isReference())
+    {
+        isReference = true;
+    }
+    typeUnset = false;
+
+    if (container->getType().isOpenType())
+    {
+        if (!strcmp(intypeURI,Type::SDOTypeNamespaceURI) &&
+            !strcmp(intypeName,"DataObject"))
+        {
+            typeUnset = true;
+        }
+    }
+
+
+    if (intypeURI != 0) {
+        typeURI = new char[strlen(intypeURI) +1];
+        strcpy(typeURI, intypeURI);
+    }
+    else {
+        typeURI = 0;
+    }
+    if (intypeName != 0) {
+        typeName = new char[strlen(intypeName) +1];
+        strcpy(typeName, intypeName);
+    }
+    else {
+        typeName = 0;
+        theFactory = 0;
+    }
+}
+
+DataObjectListImpl::~DataObjectListImpl()
+{
+    if (typeURI != 0) {
+        delete typeURI;
+        typeURI = 0;
+    }
+    if (typeName != 0) {
+        delete typeName;
+        typeName = 0;
+    }
+}
+
+RefCountingPointer<DataObject> DataObjectListImpl::operator[] (int pos)
+{
+    validateIndex(pos);
+    return plist[pos];
+}
+
+const RefCountingPointer<DataObject> DataObjectListImpl::operator[] (int pos) const
+{
+    validateIndex(pos);
+    RefCountingPointer<DataObjectImpl> d = plist[pos];
+    DataObjectImpl* dob = d;
+    return  RefCountingPointer<DataObject>((DataObject*)dob);
+}
+
+
+int DataObjectListImpl::size () const
+{
+    return plist.size();
+}
+
+DATAOBJECT_VECTOR DataObjectListImpl::getVec() const
+{
+    return plist;
+}
+
+
+void DataObjectListImpl::insert (unsigned int index, DataObjectPtr d)
+{
+    if (typeUnset)setType(d->getType().getURI(),d->getType().getName());
+
+    if (container != 0)
+    {
+        container->logChange(pindex);
+    }
+    for (int i=0;i < plist.size(); i++)
+    {
+        if (plist[i] == d)
+        {
+        string msg("Insertion of object which already exists in the list:");
+        msg += typeURI;
+        msg += " ";
+        msg += typeName;
+        SDO_THROW_EXCEPTION("List insert", SDOUnsupportedOperationException,
+            msg.c_str());
+        }
+    }
+    if (strcmp(typeURI,d->getType().getURI()) 
+        || 
+        strcmp(typeName,d->getType().getName()))
+    {
+        string msg("Insertion of object of the wrong type to a list:");
+        msg += typeURI;
+        msg += " ";
+        msg += typeName;
+        msg += " not compatible with ";
+        msg += d->getType().getURI();
+        msg += " ";
+        msg += d->getType().getName();
+        SDO_THROW_EXCEPTION("List append", SDOInvalidConversionException,
+            msg.c_str());
+    }
+
+    DataObject* dob = d; // unwrap the data object ready for a downcasting hack.
+    DataObjectImpl* con  = ((DataObjectImpl*)dob)->getContainerImpl();  
+    if (!isReference)
+    {
+        if (con != 0)
+        {
+            if (con != container)
+            {
+                /* this data object is already contained somewhere else */
+                string msg("Insertion of object to list, object is already contained:");
+                msg += d->getType().getURI();
+                msg += " ";
+                msg += d->getType().getName();
+                SDO_THROW_EXCEPTION("List append", SDOInvalidConversionException,
+                    msg.c_str());
+            }
+        }
+        else 
+        {
+            ((DataObjectImpl*)dob)->setContainer(container);
+            ((DataObjectImpl*)dob)->setApplicableChangeSummary();
+            ((DataObjectImpl*)dob)->logCreation((DataObjectImpl*)dob,
+                (DataObjectImpl*)container,
+                container->getProperty(pindex));
+        }
+    }
+
+    plist.insert(plist.begin()+index, RefCountingPointer<DataObjectImpl>((DataObjectImpl*)dob));
+
+    if (container != 0) 
+    {
+        if (container->getType().isSequencedType())
+        {
+            SequenceImpl* sq = container->getSequenceImpl();
+            if (sq)sq->push(container->getProperty(pindex),index);
+        }
+    }
+
+}
+
+void DataObjectListImpl::checkType(const Type& listType, const Type& objectType)
+    {
+        if (listType.equals(objectType)) return;
+
+        const TypeImpl* ti = ((DataFactoryImpl*)theFactory)->findTypeImpl
+            (objectType.getURI(),objectType.getName());
+        
+        do  
+        {
+            ti  = (const TypeImpl*)ti->getBaseType();
+            if (ti == 0) break;
+            if (listType.equals(*ti)) return;
+        } while (ti != 0);
+
+        // allow types of any substitutes
+        if (container != 0)
+        {
+            PropertyImpl* pi = 
+                container->getPropertyImpl(pindex);
+            if (pi != 0)
+            {
+                unsigned int subcount = pi->getSubstitutionCount();
+                for (int i=0;i<subcount;i++)
+                {
+                    const Type* tsub = pi->getSubstitutionType(i);
+                    if (tsub != 0 && tsub->equals(objectType)) return;
+                }
+            }
+        }
+
+        // no match..
+        string msg("Insertion of object of incompatible type ");
+        msg += objectType.getName();
+        msg += " into property of type ";
+        msg += listType.getName();
+        SDO_THROW_EXCEPTION("TypeCheck", SDOInvalidConversionException,
+            msg.c_str());
+    }
+
+
+void DataObjectListImpl::setType(const char* uri, const char* name)    
+{
+    // need to check for an opentype list which has not been set up yet
+    if (name == 0) return;
+
+    const TypeImpl* t = ((DataFactoryImpl*)theFactory)->findTypeImpl(uri,name);
+    if (t == 0) return; // cannot set to a type which is not avilable
+
+    // need to modify the instance property of the container
+    container->setInstancePropertyType(pindex,t);
+
+    delete typeName;
+    typeName = new char[strlen(name)+1];
+    strcpy(typeName, name);
+    delete typeURI;
+    if (uri == 0) 
+    {
+        typeURI = new char[1];
+        typeURI[0] = 0;
+    }
+    else 
+    {
+        typeURI = new char[strlen(uri)+1];
+        strcpy(typeURI, uri);
+    }
+    typeUnset = false;
+}
+
+
+void DataObjectListImpl::append (DataObjectPtr d)
+{
+
+    if (typeUnset)setType(d->getType().getURI(),d->getType().getName());
+
+    if (container != 0)
+    {
+        container->logChange(pindex);
+    }
+
+    for (int i=0;i < plist.size(); i++)
+    {
+        if (plist[i] == d)
+        {
+        string msg("Append of object which already exists in the list:");
+        msg += typeURI;
+        msg += " ";
+        msg += typeName;
+        SDO_THROW_EXCEPTION("List append", SDOUnsupportedOperationException,
+            msg.c_str());
+        }
+    }
+
+
+    checkType(theFactory->getType(typeURI,typeName),
+                d->getType());
+
+    DataObject* dob = d; // unwrap the data object ready for a downcasting hack.
+    DataObjectImpl* con  = ((DataObjectImpl*)dob)->getContainerImpl();  
+    
+    if (!isReference)
+    {
+        if (con != 0)
+        {
+            if (con != container)
+            {
+                /* this data object is already contained somewhere else */
+                string msg("Append of object to list, object is already contained:");
+                msg += d->getType().getURI();
+                msg += " ";
+                msg += d->getType().getName();
+                SDO_THROW_EXCEPTION("List append", SDOInvalidConversionException,
+                    msg.c_str());
+            }
+        }
+        else 
+        {
+            ((DataObjectImpl*)dob)->setContainer(container);
+            ((DataObjectImpl*)dob)->setApplicableChangeSummary();
+            if (!container->getProperty(pindex).getType().isDataType())
+            {
+                ((DataObjectImpl*)dob)->logCreation((DataObjectImpl*)dob,
+                    container,container->getProperty(pindex));
+            }
+
+        }
+    }
+    plist.insert(plist.end(),RefCountingPointer<DataObjectImpl>((DataObjectImpl*)dob));
+
+    if (container != 0) {
+        if (container->getType().isSequencedType())
+        {
+            SequenceImpl* sq = container->getSequenceImpl();
+            if (sq)sq->push(container->getProperty(pindex),plist.size()-1);
+        }
+    }
+}
+
+void DataObjectListImpl::insert (unsigned int index, bool d)
+{
+    if (theFactory == 0) return;
+    
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Boolean");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setBoolean(d);
+    insert(index, dol);
+}
+
+void DataObjectListImpl::append (bool d) 
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Boolean");
+    
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setBoolean(d);
+    append( dol);
+}
+
+void DataObjectListImpl::insert (unsigned int index, char d)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Byte");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setByte(d);
+    insert(index, dol);
+}
+
+void DataObjectListImpl::append (char d)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Byte");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setByte(d);
+    append( dol);
+}
+
+void DataObjectListImpl::insert (unsigned int index, wchar_t d)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Character");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setCharacter(d);
+    insert(index, dol);
+}
+
+void DataObjectListImpl::append (wchar_t d)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Character");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setCharacter(d);
+    append( dol);
+}
+
+void DataObjectListImpl::insert (unsigned int index, const wchar_t* d, unsigned int length)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "String");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setString(d, length);
+    insert(index, dol);
+}
+
+void DataObjectListImpl::append (const wchar_t* d, unsigned int length)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "String");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setString(d, length);
+    append( dol);
+}
+void DataObjectListImpl::insert (unsigned int index, const char* d, unsigned int length)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Bytes");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setBytes(d, length);
+    insert(index, dol);
+}
+
+void DataObjectListImpl::append (const char* d, unsigned int length)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Bytes");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setBytes(d, length);
+    append( dol);
+}
+void DataObjectListImpl::insert (unsigned int index, const char* d)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Bytes");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setCString(d);
+    insert(index, dol);
+}
+
+void DataObjectListImpl::append (const char* d)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Bytes");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setCString(d);
+    append( dol);
+}
+
+void DataObjectListImpl::insert (unsigned int index, short d)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Short");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setShort(d);
+    insert(index, dol);
+}
+
+void DataObjectListImpl::append (short d)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Short");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setShort(d);
+    append( dol);
+}
+
+void DataObjectListImpl::insert (unsigned int index, long d)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Integer");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setInteger(d);
+    insert(index, dol);
+}
+
+void DataObjectListImpl::append (long d)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Integer");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setInteger(d);
+    append( dol);
+}
+
+
+void DataObjectListImpl::insert (unsigned int index, const SDODate d)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Date");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setDate(d);
+    insert(index, dol);
+}
+
+void DataObjectListImpl::append (const SDODate d)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Date");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setDate(d);
+    append( dol);
+}
+
+void DataObjectListImpl::insert (unsigned int index, int64_t d)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Long");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setLong(d);
+    insert(index, dol);
+}
+
+void DataObjectListImpl::append (int64_t d)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Long");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setLong(d);
+    append( dol);
+}
+
+void DataObjectListImpl::insert (unsigned int index, float d)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Float");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setFloat(d);
+    insert(index, dol);
+}
+
+void DataObjectListImpl::append (float d)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Float");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setFloat(d);
+    append( dol);
+}
+
+void DataObjectListImpl::insert (unsigned int index, long double d)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Double");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setDouble(d);
+    insert(index, dol);
+}
+
+void DataObjectListImpl::append (long double d)
+{
+    if (theFactory == 0) return;
+
+    if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Double");
+
+    RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
+    DataObject* dob = dol;
+    ((DataObjectImpl*)dob)->setDouble(d);
+    append( dol);
+}
+
+
+void DataObjectListImpl::decrementPindex()
+{
+    pindex--;
+}
+
+
+RefCountingPointer<DataObject> DataObjectListImpl::remove(unsigned int index)
+{
+    validateIndex(index);
+    if (container != 0)
+    {
+        container->logChange(pindex);
+    }
+    RefCountingPointer<DataObject> d = (*this)[index];
+    
+    // log deletion only if the list is of data objects.
+    if (theFactory != 0) 
+    {
+        const Type& t = theFactory->getType(typeURI,typeName);
+        const Property& p = container->getProperty(pindex);
+        if (!t.isDataType() && !p.isReference())
+        {
+            (getVec()[index])->logDeletion();
+        }
+    }
+    plist.erase(plist.begin()+index);
+    DataObject* dob = d;
+    ((DataObjectImpl*)dob)->setContainer(0);
+    return d;
+}
+
+void DataObjectListImpl::validateIndex(int index) const
+{
+    if ((index < 0) || (index >= size()))
+    {
+        char val[32];
+        string msg("Index out of range:");
+        sprintf(val,"%d",index);
+        msg += val;
+        SDO_THROW_EXCEPTION("validateIndex", SDOIndexOutOfRangeException,
+            msg.c_str());
+
+    }
+
+}
+
+bool        DataObjectListImpl::getBoolean(unsigned int index) const
+{
+    validateIndex(index);
+    RefCountingPointer<DataObject> d = ((*this)[index]);
+    DataObject* dob = d;
+    return ((DataObjectImpl*)dob)->getBoolean();
+}
+char        DataObjectListImpl::getByte(unsigned int index) const
+{
+    validateIndex(index);
+    RefCountingPointer<DataObject> d = ((*this)[index]);
+    DataObject* dob = d;
+    return ((DataObjectImpl*)dob)->getByte();
+}
+wchar_t     DataObjectListImpl::getCharacter(unsigned int index) const
+{
+    validateIndex(index);
+    RefCountingPointer<DataObject> d = ((*this)[index]);
+    DataObject* dob = d;
+    return ((DataObjectImpl*)dob)->getCharacter();
+}
+unsigned int  DataObjectListImpl::getBytes(unsigned int index, char* value, unsigned int max) const
+{
+    validateIndex(index);
+    RefCountingPointer<DataObject> d = ((*this)[index]);
+    DataObject* dob = d;
+    return ((DataObjectImpl*)dob)->getBytes(value, max);
+}
+unsigned int  DataObjectListImpl::getString(unsigned int index, wchar_t* value, unsigned int max) const
+{
+    validateIndex(index);
+    RefCountingPointer<DataObject> d = ((*this)[index]);
+    DataObject* dob = d;
+    return ((DataObjectImpl*)dob)->getString(value, max);
+}
+short       DataObjectListImpl::getShort(unsigned int index) const
+{
+    validateIndex(index);
+    RefCountingPointer<DataObject> d = ((*this)[index]);
+    DataObject* dob = d;
+    return ((DataObjectImpl*)dob)->getShort();
+}
+long         DataObjectListImpl::getInteger(unsigned int index) const
+{
+    validateIndex(index);
+    RefCountingPointer<DataObject> d = ((*this)[index]);
+    DataObject* dob = d;
+    return ((DataObjectImpl*)dob)->getInteger();
+}
+int64_t     DataObjectListImpl::getLong(unsigned int index) const
+{
+    validateIndex(index);
+    RefCountingPointer<DataObject> d = ((*this)[index]);
+    DataObject* dob = d;
+    return ((DataObjectImpl*)dob)->getLong();
+}
+float       DataObjectListImpl::getFloat(unsigned int index) const 
+{
+    validateIndex(index);
+    RefCountingPointer<DataObject> d = ((*this)[index]); 
+    DataObject* dob = d;
+    return ((DataObjectImpl*)dob)->getFloat();
+}
+long double DataObjectListImpl::getDouble(unsigned int index) const 
+{
+    validateIndex(index);
+    RefCountingPointer<DataObject> d = ((*this)[index]);
+    DataObject* dob = d;
+    return ((DataObjectImpl*)dob)->getDouble();
+}
+const SDODate      DataObjectListImpl::getDate(unsigned int index) const
+{
+    validateIndex(index);
+    RefCountingPointer<DataObject> d = ((*this)[index]);
+    DataObject* dob = d;
+    return ((DataObjectImpl*)dob)->getDate();
+}
+const char* DataObjectListImpl::getCString(unsigned int index) const
+{
+    validateIndex(index);
+    RefCountingPointer<DataObject> d = ((*this)[index]);
+    DataObject* dob = d;
+    return ((DataObjectImpl*)dob)->getCString();
+}
+
+DataObjectPtr DataObjectListImpl::getDataObject(unsigned int index) const
+{
+    validateIndex(index);
+    return (*this)[index];
+}
+
+void DataObjectListImpl::setBoolean(unsigned int index, bool d) 
+{
+    validateIndex(index);
+    if (container != 0)
+    {
+        container->logChange(pindex);
+    }
+    RefCountingPointer<DataObject> dd = ((*this)[index]);
+    DataObject* dob = dd;
+    ((DataObjectImpl*)dob)->setBoolean(d);
+}
+void DataObjectListImpl::setByte(unsigned int index, char d) 
+{
+    validateIndex(index);
+    if (container != 0)
+    {
+        container->logChange(pindex);
+    }
+    RefCountingPointer<DataObject> dd = ((*this)[index]);
+    DataObject* dob = dd;
+    ((DataObjectImpl*)dob)->setByte(d);
+}
+void DataObjectListImpl::setCharacter(unsigned int index, wchar_t d) 
+{
+    validateIndex(index);
+    if (container != 0)
+    {
+        container->logChange(pindex);
+    }
+    RefCountingPointer<DataObject> dd = ((*this)[index]);
+    DataObject* dob = dd;
+    ((DataObjectImpl*)dob)->setCharacter(d);
+}
+
+void DataObjectListImpl::setString(unsigned int index, const wchar_t* d, unsigned int len) 
+{
+    validateIndex(index);
+    if (container != 0)
+    {
+        container->logChange(pindex);
+    }
+    RefCountingPointer<DataObject> dd = ((*this)[index]);
+    DataObject* dob = dd;
+    ((DataObjectImpl*)dob)->setString(d, len);
+}
+void DataObjectListImpl::setBytes(unsigned int index, const char* d, unsigned int len) 
+{
+    validateIndex(index);
+    if (container != 0)
+    {
+        container->logChange(pindex);
+    }
+    RefCountingPointer<DataObject> dd = ((*this)[index]);
+    DataObject* dob = dd;
+    ((DataObjectImpl*)dob)->setBytes(d, len);
+}
+
+void DataObjectListImpl::setShort(unsigned int index, short d) 
+{
+    validateIndex(index);
+    if (container != 0)
+    {
+        container->logChange(pindex);
+    }
+    RefCountingPointer<DataObject> dd = ((*this)[index]);
+    DataObject* dob = dd;
+    ((DataObjectImpl*)dob)->setShort(d);
+}
+void DataObjectListImpl::setInteger(unsigned int index, long d) 
+{
+    validateIndex(index);
+    if (container != 0)
+    {
+        container->logChange(pindex);
+    }
+    RefCountingPointer<DataObject> dd = ((*this)[index]);
+    DataObject* dob = dd;
+    ((DataObjectImpl*)dob)->setInteger(d);
+}
+void DataObjectListImpl::setLong(unsigned int index, int64_t d) 
+{
+    validateIndex(index);
+    if (container != 0)
+    {
+        container->logChange(pindex);
+    }
+    RefCountingPointer<DataObject> dd = ((*this)[index]);
+    DataObject* dob = dd;
+    ((DataObjectImpl*)dob)->setLong(d);
+}
+void DataObjectListImpl::setFloat(unsigned int index, float d) 
+{
+    validateIndex(index);
+    if (container != 0)
+    {
+        container->logChange(pindex);
+    }
+    RefCountingPointer<DataObject> dd = ((*this)[index]);
+    DataObject* dob = dd;
+    ((DataObjectImpl*)dob)->setFloat(d);
+}
+void DataObjectListImpl::setDouble(unsigned int index, long double d) 
+{
+    validateIndex(index);
+    if (container != 0)
+    {
+        container->logChange(pindex);
+    }
+    RefCountingPointer<DataObject> dd = ((*this)[index]);
+    DataObject* dob = dd;
+    ((DataObjectImpl*)dob)->setDouble(d);
+}
+void DataObjectListImpl::setDate(unsigned int index, const SDODate d) 
+{
+    validateIndex(index);
+    if (container != 0)
+    {
+        container->logChange(pindex);
+    }
+    RefCountingPointer<DataObject> dd = ((*this)[index]);
+    DataObject* dob = dd;
+    ((DataObjectImpl*)dob)->setDate(d);
+}
+void DataObjectListImpl::setCString(unsigned int index, char* d) 
+{
+    validateIndex(index);
+    if (container != 0)
+    {
+        container->logChange(pindex);
+    }
+    RefCountingPointer<DataObject> dd = ((*this)[index]);
+    DataObject* dob = dd;
+    ((DataObjectImpl*)dob)->setCString(d);
+}
+
+void DataObjectListImpl::setDataObject(unsigned int index, DataObjectPtr dob) 
+{
+    validateIndex(index);
+    if (container != 0)
+    {
+        container->logChange(pindex);
+    }
+
+    remove(index);
+    insert(index,dob);
+}
+
+unsigned int DataObjectListImpl::getLength(unsigned int index) const
+{
+    validateIndex(index);
+    RefCountingPointer<DataObject> dd = ((*this)[index]);
+    DataObject* dob = dd;
+    return dob->getLength();
+}
+
+};
+};

Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.h?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.h (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.h Thu Jan  5 02:55:00 2006
@@ -0,0 +1,173 @@
+/*
+ *
+ *  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 _DATAOBJECTLISTIMPL_H_
+#define _DATAOBJECTLISTIMPL_H_
+
+#include "commonj/sdo/DataObjectList.h"
+#include "commonj/sdo/SDODate.h"
+
+#include "commonj/sdo/disable_warn.h"
+
+#include <vector>
+
+
+namespace commonj{
+namespace sdo{
+
+class DataObjectImpl;
+class DataFactory;
+
+typedef std::vector< RefCountingPointer<DataObjectImpl> > DATAOBJECT_VECTOR;
+
+/** 
+ * DataObjectListImpl implements the abstract class DataObjectList.
+ * List for retrieving many valued property values.
+ *
+ * DataObjectList provides an API for getting and setting values in
+ * many valued properties. The list deals with both DataType and 
+ * DataObjectType properties.
+ */
+
+class DataObjectListImpl : public DataObjectList
+{
+
+public:
+    DataObjectListImpl(DATAOBJECT_VECTOR p);
+    DataObjectListImpl(const DataObjectListImpl &pin);
+    DataObjectListImpl();
+    DataObjectListImpl(DataFactory* df, DataObjectImpl* cont, unsigned int inpindex, 
+                       const char* tURI, const char* tName);
+
+    virtual ~DataObjectListImpl();
+
+    // open type support
+    virtual void decrementPindex();
+
+    virtual DataObjectPtr operator[] (int pos);
+    virtual const DataObjectPtr operator[] (int pos) const;
+
+    // set/get primitive values 
+    virtual bool getBoolean(unsigned int index) const;
+    virtual char getByte(unsigned int index) const;
+    virtual wchar_t getCharacter(unsigned int index) const;
+    virtual unsigned int getString(unsigned int index, wchar_t* buf,
+        unsigned int max) const;
+    virtual unsigned int getBytes(unsigned int index, char* buf, 
+        unsigned int max) const;
+    virtual short getShort(unsigned int index) const;
+    virtual long getInteger(unsigned int index) const;
+    virtual int64_t getLong(unsigned int index) const;
+    virtual float getFloat(unsigned int index) const;
+    virtual long double getDouble(unsigned int index) const;
+    virtual const SDODate  getDate(unsigned int index) const;
+    virtual const char*  getCString(unsigned int index) const;
+    virtual DataObjectPtr getDataObject(unsigned int index) const;
+
+    virtual void setBoolean(unsigned int index, bool d);
+    virtual void setByte(unsigned int index, char d);
+    virtual void setCharacter(unsigned int index, wchar_t d);
+    virtual void setString(unsigned int index, const wchar_t* d, unsigned int len);
+    virtual void setBytes(unsigned int index, const char* d, unsigned int len);
+    virtual void setShort(unsigned int index, short d);
+    virtual void setInteger(unsigned int index, long d);
+    virtual void setLong(unsigned int index, int64_t d);
+    virtual void setFloat(unsigned int index, float d);
+    virtual void setDouble(unsigned int index, long double d);
+    virtual void setDate(unsigned int index, const SDODate d);
+    virtual void setCString(unsigned int index, char* d);
+    virtual void setDataObject(unsigned int index, DataObjectPtr dob);
+
+    virtual unsigned int getLength(unsigned int index) const;
+
+    virtual int size () const;
+
+    virtual void insert (unsigned int index, DataObjectPtr d);
+    virtual void append (DataObjectPtr d);
+
+    virtual  void insert (unsigned int index, bool d) ;
+    virtual  void append (bool d) ;
+
+    virtual  void insert (unsigned int index, char d) ;
+    virtual  void append (char d) ;
+
+    virtual  void insert (unsigned int index, wchar_t d) ;
+    virtual  void append (wchar_t d) ;
+
+    virtual  void insert (unsigned int index, const wchar_t* d, unsigned int len) ;
+    virtual  void append (const wchar_t* d, unsigned int len) ;
+
+    virtual  void insert (unsigned int index, const char* d, unsigned int len) ;
+    virtual  void append (const char* d, unsigned int len) ;
+
+    virtual  void insert (unsigned int index, const char* d) ;
+    virtual  void append (const char* d) ;
+
+    virtual  void insert (unsigned int index, short d) ;
+    virtual  void append (short d) ;
+
+    virtual  void insert (unsigned int index, const SDODate d) ;
+    virtual  void append (const SDODate d) ;
+
+    virtual  void insert (unsigned int index, long d) ;
+    virtual  void append (long d) ;
+
+    virtual  void insert (unsigned int index, int64_t d) ;
+    virtual  void append (int64_t d) ;
+    
+    virtual  void insert (unsigned int index, float d) ;
+    virtual  void append (float d) ;
+
+    virtual  void insert (unsigned int index, long double d) ;
+    virtual  void append (long double d) ;
+    
+    
+    virtual DataObjectPtr  remove (unsigned int index);
+
+    virtual void checkType(const Type& listType, const Type& objectType);
+    virtual void setType(const char* uri, const char* name);    
+
+
+
+private: 
+    DATAOBJECT_VECTOR plist;
+    DATAOBJECT_VECTOR getVec() const;
+
+    // For creation of items via the insert/append api.
+    char* typeURI;
+    char* typeName;
+
+    // for open types, the list may not have a type until the
+    // first item is entered
+
+    bool typeUnset;
+
+    // No reference count held on the factory
+    DataFactory* theFactory;
+
+    // For logging a change in the change summary when appending
+    DataObjectImpl* container;
+    unsigned int pindex;
+    bool isReference;
+
+    void validateIndex(int index) const;
+};
+};
+};
+#endif

Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.h
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DefaultLogWriter.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DefaultLogWriter.cpp?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DefaultLogWriter.cpp (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DefaultLogWriter.cpp Thu Jan  5 02:55:00 2006
@@ -0,0 +1,53 @@
+/*
+ *
+ *  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/disable_warn.h"
+#include "commonj/sdo/DefaultLogWriter.h"
+
+#include <iostream>
+using namespace std;
+
+namespace commonj
+{
+    namespace sdo
+    {
+
+        DefaultLogWriter::DefaultLogWriter()
+        {
+            formatindent = 0;
+        }
+
+        DefaultLogWriter::~DefaultLogWriter()
+        {
+        }
+
+        void DefaultLogWriter::log(int indent, int level, const char* msg)
+        {
+            if (indent < 0) formatindent += indent;
+            for (int i=0; i < formatindent; i++)
+            {
+                cout << "  ";
+            }
+            cout << msg <<endl;
+            if (indent > 0) formatindent += indent;
+        }
+
+    } // End namespace sca
+} // End namespace commonj
+

Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DefaultLogWriter.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DefaultLogWriter.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DefaultLogWriter.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DefaultLogWriter.h?rev=366158&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DefaultLogWriter.h (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DefaultLogWriter.h Thu Jan  5 02:55:00 2006
@@ -0,0 +1,52 @@
+/*
+ *
+ *  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_DefaultLOGWriter_H
+#define SDO_DefaultLOGWriter_H
+
+#include "commonj/sdo/LogWriter.h"
+
+
+
+namespace commonj
+{
+    namespace sdo
+    {
+        
+/** 
+ * DefaultLogWriter is a basic log writer, part of the logger.
+ * The logging API holds a log writer , and uses it to send
+ * output whereever it is needed. The application writer would
+ * hook their own LogWriter in place of this simple one.
+ */
+        class DefaultLogWriter : public LogWriter
+        {
+        public:
+
+            DefaultLogWriter();
+            virtual ~DefaultLogWriter();
+
+            virtual void log(int indent, int level, const char* msg);
+        private:
+            int formatindent;
+        };
+        
+    } // End namespace sca
+} // End namespace commonj
+#endif // SDO_DefaultLOGWriter_H

Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DefaultLogWriter.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DefaultLogWriter.h
------------------------------------------------------------------------------
    svn:keywords = Rev,Date



Mime
View raw message