tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robbin...@apache.org
Subject svn commit: r462618 - in /incubator/tuscany/cpp/sca/runtime: core/src/tuscany/sca/core/ extensions/php/src/tuscany/sca/php/ extensions/python/src/tuscany/sca/python/ extensions/ruby/src/tuscany/sca/ruby/ extensions/ws/reference/axis2c/src/tuscany/sca/w...
Date Tue, 10 Oct 2006 22:39:43 GMT
Author: robbinspg
Date: Tue Oct 10 15:39:42 2006
New Revision: 462618

URL: http://svn.apache.org/viewvc?view=rev&rev=462618
Log:
TUSCANY-816 - revised fix
This fix ensures a DataObjectPtr as a parameter or return value is released in the Operation
destructor.

Modified:
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h
    incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp?view=diff&rev=462618&r1=462617&r2=462618
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp Tue Oct 10 15:39:42
2006
@@ -51,14 +51,91 @@
         Operation::~Operation()
         {
             LOGENTRY(1,"Operation::destructor");
+            clean();
             LOGEXIT(1,"Operation::destructor");
         }
+
+        // ==========
+        // Copy Constructor
+        // ==========
+        Operation::Operation(const Operation& op)
+        {
+            LOGENTRY(1,"Operation::copy contructor");
+          	copy(op);
+            LOGEXIT(1,"Operation::copy contructor");
+        }
+
+        // ==========
+        // operator=
+        // ==========
+        Operation& Operation::operator=(const Operation& op)
+        {
+            LOGENTRY(1,"Operation::operator=");
+            if (&op != this)
+            {
+            	copy(op);
+            }
+            LOGEXIT(1,"Operation::operator=");
+            return *this;
+        }
+    
+        // ==========
+        // Clean 
+        // ==========
+        void Operation::clean()
+        {
+            LOGENTRY(1,"Operation::clean");
+            for (unsigned int i = 0; i < getNParms(); i++)
+            {
+            	const Parameter& parm = getParameter(i);
+            	if (parm.getType() == DATAOBJECT)
+            	{
+            		delete (DataObjectPtr*)parm.getValue();
+            	}
+            }
+            
+            parameters.empty();
+            
+            if (getReturnType() == DATAOBJECT)
+            {
+            	delete (DataObjectPtr*)getReturnValue();
+            }
+          	
+            LOGEXIT(1,"Operation::clean");
+        }
     
+        // ==========
+        // Copy 
+        // ==========
+        void Operation::copy(const Operation& op)
+        {
+            LOGENTRY(1,"Operation::copy");
+            clean();
+            for (unsigned int i = 0; i < op.getNParms(); i++)
+            {
+            	const Parameter& parm = op.getParameter(i);
+            	if (parm.getType() == DATAOBJECT)
+            	{
+            		addParameter((const DataObject*)parm.getValue());
+            	}
+            	else
+            	{
+            		parameters.insert(parameters.end(), parm);
+            	}          	
+            }
+            
+            if (getReturnType() == DATAOBJECT)
+            {
+            	setReturnValue((const DataObjectPtr*)op.getReturnValue());
+            }
+          	
+            LOGEXIT(1,"Operation::copy");
+        }
 
         // ==============================================
         // getParameter: return parameter at position pos
         // ==============================================
-        void* Operation::getParameterValue(unsigned int pos)
+        void* Operation::getParameterValue(unsigned int pos) const
         {
             if (pos < parameters.size())
             {
@@ -71,7 +148,7 @@
         // ==============================================
         // getParameter: return of parameter
         // ==============================================
-        Operation::Parameter& Operation::getParameter(unsigned int pos)
+        const Operation::Parameter& Operation::getParameter(unsigned int pos) const
         {
             if (pos < parameters.size())
             {
@@ -85,7 +162,7 @@
         // ==============================================
         // getParameterType: return type of parameter
         // ==============================================
-        Operation::ParameterType Operation::getParameterType(unsigned int pos)
+        Operation::ParameterType Operation::getParameterType(unsigned int pos) const
         {
             if (pos < parameters.size())
             {
@@ -185,7 +262,7 @@
         void Operation::addParameter(const DataObjectPtr *parm)
         {
             LOGINFO(4, "Operation::addParameter(DataObjectPtr)");
-            parameters.insert(parameters.end(), Parameter((void*)parm, DATAOBJECT));
+            parameters.insert(parameters.end(), Parameter((void*)new DataObjectPtr(*parm),
DATAOBJECT));
         }
 
         Operation::Parameter::Parameter(void* val, Operation::ParameterType typ)
@@ -283,7 +360,7 @@
         void Operation::setReturnValue(const DataObjectPtr *parm)
         {
             LOGINFO(4, "Operation::setReturnValue(DataObjectPtr*)");
-            returnValue = Parameter((void*)parm, DATAOBJECT);
+            returnValue = Parameter((void*)new DataObjectPtr(*parm), DATAOBJECT);
         }
 
  

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h?view=diff&rev=462618&r1=462617&r2=462618
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h Tue Oct 10 15:39:42
2006
@@ -55,10 +55,20 @@
             SCA_API virtual    ~Operation();
 
             /**
+             * Copy constructor.
+             */
+            SCA_API Operation(const Operation& op);
+
+            /**
+             * Assignment operator.
+             */
+            SCA_API Operation& operator=(const Operation& op);
+
+            /**
              * Return the operation name.
              * @return The name of the operation.
              */
-            SCA_API const string& getName() {return name;}
+            SCA_API const string& getName() const {return name;}
 
 
             enum ParameterType
@@ -85,8 +95,8 @@
             {
                 public:
                     SCA_API Parameter(void* value = NULL, ParameterType type = VOID_TYPE);
-                    SCA_API void* getValue() {return value;}
-                    SCA_API ParameterType getType() {return type;}
+                    SCA_API void* getValue() const {return value;}
+                    SCA_API ParameterType getType() const {return type;}
 
                 private:
                     void* value;
@@ -134,7 +144,7 @@
             SCA_API void addParameter(const string *parm);
             SCA_API void addParameter(const DataObjectPtr *parm);
             
-            SCA_API unsigned int getNParms() {return parameters.size();}
+            SCA_API unsigned int getNParms() const {return parameters.size();}
 
             /**
              * Get a parameter from the operation.
@@ -142,7 +152,7 @@
              * @return Pointer to the paramter at the given postion. Should be
              * cast to the appropriate type.
              */
-            SCA_API Parameter& getParameter(unsigned int pos);
+            SCA_API const Parameter& getParameter(unsigned int pos) const;
 
             /**
              * Get a parameter type from the operation.
@@ -150,7 +160,7 @@
              * @return Pointer to the paramter at the given postion. Should be
              * cast to the appropriate type.
              */
-            SCA_API ParameterType getParameterType(unsigned int pos);
+            SCA_API ParameterType getParameterType(unsigned int pos) const;
 
             /**
              * Get a parameter from the operation.
@@ -158,10 +168,10 @@
              * @return Pointer to the paramter at the given postion. Should be
              * cast to the appropriate type.
              */
-            SCA_API void* getParameterValue(unsigned int pos);
+            SCA_API void* getParameterValue(unsigned int pos) const;
 
-            SCA_API ParameterType getReturnType() {return returnValue.getType();}
-            SCA_API void* getReturnValue() {return returnValue.getValue();}
+            SCA_API ParameterType getReturnType() const {return returnValue.getType();}
+            SCA_API void* getReturnValue() const {return returnValue.getValue();}
 
         private:
             /**
@@ -177,6 +187,9 @@
             PARAMETER_VECTOR parameters;
 
             Parameter returnValue;
+            
+            void clean();
+            void copy(const Operation& op);
 
         };
     } // End namespace sca

Modified: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp?view=diff&rev=462618&r1=462617&r2=462618
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp
(original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp
Tue Oct 10 15:39:42 2006
@@ -179,7 +179,7 @@
                     // add the parameters to the call
                     for(unsigned int i = 0; i < operation.getNParms(); i++) 
 					{
-                        Operation::Parameter& parm = operation.getParameter(i);
+                        const Operation::Parameter& parm = operation.getParameter(i);
     		            switch(parm.getType())
     		            {
     			            case Operation::BOOL: 

Modified: incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp?view=diff&rev=462618&r1=462617&r2=462618
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp
(original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp
Tue Oct 10 15:39:42 2006
@@ -304,7 +304,7 @@
 
                         for(unsigned int i = 0; i < operation.getNParms(); i++) 
                         {
-                            Operation::Parameter& parm = operation.getParameter(i);
+                            const Operation::Parameter& parm = operation.getParameter(i);
     		                switch(parm.getType())
     		                {
     			                case Operation::BOOL: 

Modified: incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.cpp?view=diff&rev=462618&r1=462617&r2=462618
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.cpp
(original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.cpp
Tue Oct 10 15:39:42 2006
@@ -227,14 +227,14 @@
                                 commonj::sdo::XMLHelper* xmlHelper = composite->getXMLHelper();
                                 commonj::sdo::XMLDocumentPtr xmlDoc = xmlHelper->load(str.c_str());
                                 
-                                DataObjectPtr* dob = new DataObjectPtr;
+                                DataObjectPtr dob;
                                 if (xmlDoc != NULL)
                                 {
-                                    *dob = xmlDoc->getRootDataObject();
+                                    dob = xmlDoc->getRootDataObject();
                                 }
-                                if (*dob != NULL)
+                                if (dob != NULL)
                                 {
-                                    operation.addParameter(dob);
+                                    operation.addParameter(&dob);
                                 }
                                 else
                                 {

Modified: incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp?view=diff&rev=462618&r1=462617&r2=462618
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp
(original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp
Tue Oct 10 15:39:42 2006
@@ -146,7 +146,7 @@
                         {
                             VALUE value;
                             
-                            Operation::Parameter& parm = operation.getParameter(i);
+                            const Operation::Parameter& parm = operation.getParameter(i);
                             Operation::ParameterType parmType = parm.getType();
                             switch(parmType)
                             {
@@ -678,15 +678,15 @@
                                 Composite* composite = component->getComposite();    
                              
                                 commonj::sdo::XMLHelper* xmlHelper = composite->getXMLHelper();
                                 commonj::sdo::XMLDocumentPtr xmlDoc = xmlHelper->load(str.c_str());
-                                
-                                DataObjectPtr* dob = new DataObjectPtr;
+                               
+                                DataObjectPtr dob;
                                 if (xmlDoc != NULL)
                                 {
-                                    *dob = xmlDoc->getRootDataObject();
+                                    dob = xmlDoc->getRootDataObject();
                                 }
-                                if (*dob != NULL)
+                                if (dob != NULL)
                                 {
-                                    operation.setReturnValue(dob);
+                                    operation.setReturnValue(&dob);
                                 }
                                 else
                                 {

Modified: incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp?view=diff&rev=462618&r1=462617&r2=462618
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp
(original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp
Tue Oct 10 15:39:42 2006
@@ -308,7 +308,7 @@
                                 pname << "param" << (i+1);
                                 DataObjectList& l = inputDataObject->getList(pname.str());
                                 
-                                Operation::Parameter& parm = operation.getParameter(i);
+                                const Operation::Parameter& parm = operation.getParameter(i);
                                 switch(parm.getType())
                                 {
                                 case Operation::BOOL: 
@@ -386,7 +386,7 @@
                         // Each parameter in the operation should be a property on the request
dataobject
                         for (int i=0; i<operation.getNParms(); i++)
                         {
-                            Operation::Parameter& parm = operation.getParameter(i);
+                            const Operation::Parameter& parm = operation.getParameter(i);
                             switch(parm.getType())
                             {
                             case Operation::BOOL: 
@@ -614,13 +614,12 @@
                         break;
                     case Type::DataObjectType:
                         {
-                            DataObjectPtr* dataObjectData = new DataObjectPtr;
-                            *dataObjectData = outputDataObject->getDataObject(pl[i]);
+                            DataObjectPtr dataObjectData = outputDataObject->getDataObject(pl[i]);
                             if(!dataObjectData)
                             {
                                 LOGINFO(4, "SDO DataObject return value was null");
                             }
-                            operation.setReturnValue(dataObjectData);
+                            operation.setReturnValue(&dataObjectData);
                         }
                         break;
                     case Type::OpenDataObjectType:
@@ -636,9 +635,7 @@
                                 DataObjectPtr dataObjectData = dataObjectList[j];
                                 if(!dataObjectData)
                                 {
-                                    DataObjectPtr* dob = new DataObjectPtr;
-                                    *dob = NULL;
-                                    operation.setReturnValue(dob);
+                                    operation.setReturnValue(&dataObjectData);
                                     LOGINFO(4, "SDO OpenDataObject return value was null");
                                 }
                                 else 
@@ -656,13 +653,12 @@
                                         else
                                         {
                                             // Return a DataObject representing a complex
element
-                                            DataObjectPtr* dob = new DataObjectPtr;
-                                            *dob = sequence->getDataObjectValue(0);
-                                            if(!*dob)
+                                            DataObjectPtr dob = sequence->getDataObjectValue(0);
+                                            if(!dob)
                                             {
                                                 LOGINFO(4, "SDO DataObject return value was
null");
                                             }
-                                            operation.setReturnValue(dob);
+                                            operation.setReturnValue(&dob);
                                         }
                                     }
                                     else

Modified: incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp?view=diff&rev=462618&r1=462617&r2=462618
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp
(original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp
Tue Oct 10 15:39:42 2006
@@ -233,14 +233,12 @@
                                 break;
                             case Type::DataObjectType:
                                 {
-                                    DataObjectPtr* dataObjectData = new DataObjectPtr;
-                                    *dataObjectData = inputDataObject->getDataObject(pl[i]);
-                    
+                                    DataObjectPtr dataObjectData = inputDataObject->getDataObject(pl[i]);
                                     if(!dataObjectData)
                                     {
                                         LOGINFO_1(4, "SDO DataObject parameter named %s was
null", name);
                                     }
-                                    operation.addParameter(dataObjectData);
+                                    operation.addParameter(&dataObjectData);
                                 }
                                 break;
                             case Type::OpenDataObjectType:
@@ -261,9 +259,7 @@
                                             
                                             // Add a null DataObject ptr
                                             LOGINFO_2(4, "SDO OpenDataObject parameter named
%s[%d] was null", name, j);
-                                            DataObjectPtr* dob = new DataObjectPtr;
-                                            *dob = NULL;
-                                            operation.addParameter(dob);
+                                            operation.addParameter(&dataObjectData);
                                         }
                                         else
                                         {
@@ -280,13 +276,12 @@
                                                 else
                                                 {
                                                     // Add a complex element DataObject
-                                                    DataObjectPtr* dob = new DataObjectPtr;
-                                                    *dob = sequence->getDataObjectValue(0);
-                                                    if(!*dob)
+                                                    DataObjectPtr dob = sequence->getDataObjectValue(0);
+                                                    if(!dob)
                                                     {
                                                         LOGINFO_1(4, "SDO DataObject parameter
named %s was null", name);
                                                     }
-                                                    operation.addParameter(dob);
+                                                    operation.addParameter(&dob);
                                                 }
                                             }
                                             else



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message