Author: robbinspg
Date: Mon Apr 10 04:17:28 2006
New Revision: 392919

URL: http://svn.apache.org/viewcvs?rev=392919&view=rev
Log:
TUSCANY-164 encode paramter types

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/core/src/tuscany/sca/core/SCAEntryPoint.cpp
    
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSServiceWrapper.cpp

Modified: 
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp?rev=392919&r1=392918&r2=392919&view=diff
==============================================================================
--- 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 
Mon Apr 10 04:17:28 2006
@@ -32,13 +32,15 @@
         // ===========
         // Constructor
         // ===========
-        Operation::Operation(const char* operationName, unsigned int 
numParameters)
-            : name(operationName), nparms(numParameters)
+        Operation::Operation(const char* operationName)
         {
             LOGENTRY(1,"Operation::constructor");
 
-            parameters = new void*[nparms];
-            
+            if (operationName != 0)
+            {
+                name = operationName;
+            }
+                        
             LOGEXIT(1,"Operation::constructor");
         }
 
@@ -55,25 +57,102 @@
         // ==============================================
         // getParameter: return parameter at position pos
         // ==============================================
-        void* Operation::getParameter(unsigned int pos)
+        void* Operation::getParameterValue(unsigned int pos)
         {
-            if (pos < nparms)
+            if (pos < parameters.size())
             {
-                return parameters[pos];
+                return parameters[pos].getValue();
             }
 
             return 0;
         }
 
-        // ===========================================
-        // setParameter: set parameter at position pos
-        // ===========================================
-        void Operation::setParameter(unsigned int pos, void* parm)
+        // ==============================================
+        // getParameterType: return type of parameter
+        // ==============================================
+        Operation::ParameterType Operation::getParameterType(unsigned int pos)
         {
-            if (pos < nparms)
+            if (pos < parameters.size())
             {
-                parameters[pos] = parm;
+                return parameters[pos].getType();
             }
+
+            return VOID_TYPE;
+        }
+
+        // ===========================================
+        // addParameter: set parameter at position pos
+        // ===========================================
+        void Operation::addParameter(const void *parm)
+        {
+            LOGENTRY(1, "Operation::addParameter(void*)");
+            parameters.insert(parameters.begin(), Parameter((void*)parm, 
VOID_TYPE));
+         }
+
+        void Operation::addParameter(const bool *parm)
+        {
+            LOGENTRY(1, "Operation::addParameter(bool)");
+            parameters.insert(parameters.begin(), Parameter((void*)parm, 
BOOL));
+        }
+
+        void Operation::addParameter(const short *parm)
+        {
+            LOGENTRY(1, "Operation::addParameter(short)");
+            parameters.insert(parameters.begin(), Parameter((void*)parm, 
SHORT));
+        }
+
+        void Operation::addParameter(const long *parm)
+        {
+            LOGENTRY(1, "Operation::addParameter(long)");
+            parameters.insert(parameters.begin(), Parameter((void*)parm, 
LONG));
+        }
+
+        void Operation::addParameter(const unsigned short *parm)
+        {
+            LOGENTRY(1, "Operation::addParameter(unsigned short)");
+            parameters.insert(parameters.begin(), Parameter((void*)parm, 
USHORT));
+        }
+
+        void Operation::addParameter(const unsigned long *parm)
+        {
+            LOGENTRY(1, "Operation::addParameter(unsigned long)");
+            parameters.insert(parameters.begin(), Parameter((void*)parm, 
ULONG));
+        }
+
+       void Operation::addParameter(const float *parm)
+        {
+            LOGENTRY(1, "Operation::addParameter(float)");
+            parameters.insert(parameters.begin(), Parameter((void*)parm, 
FLOAT));
+        }
+
+       void Operation::addParameter(const double *parm)
+        {
+            LOGENTRY(1, "Operation::addParameter(double)");
+            parameters.insert(parameters.begin(), Parameter((void*)parm, 
DOUBLE));
+        }
+
+       void Operation::addParameter(const long double *parm)
+        {
+            LOGENTRY(1, "Operation::addParameter(long double)");
+            parameters.insert(parameters.begin(), Parameter((void*)parm, 
LONGDOUBLE));
+        }
+
+        void Operation::addParameter(const char* *parm)
+        {
+            LOGENTRY(1, "Operation::addParameter(char*)");
+            parameters.insert(parameters.begin(), Parameter((void*)parm, 
CHARS));
+        }
+
+        void Operation::addParameter(const string *parm)
+        {
+            LOGENTRY(1, "Operation::addParameter(string)");
+            parameters.insert(parameters.begin(), Parameter((void*)parm, 
STRING));
+        }
+
+        void Operation::addParameter(const DataObjectPtr *parm)
+        {
+            LOGENTRY(1, "Operation::addParameter(DataObjectPtr)");
+            parameters.insert(parameters.begin(), Parameter((void*)parm, 
DATAOBJECT));
         }
 
         // ====================================
@@ -81,8 +160,13 @@
         // ====================================
         void Operation::setReturnValue(void* val)
         {
-            returnType = val;
+            returnValue = val;
+        }
+
+        Operation::Parameter::Parameter(void* val, Operation::ParameterType 
typ)
+            : value(val), type(type)
+        {
         }
-        
+ 
     } // End namespace sca
 } // End namespace tuscany

Modified: 
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h?rev=392919&r1=392918&r2=392919&view=diff
==============================================================================
--- 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 Mon 
Apr 10 04:17:28 2006
@@ -20,7 +20,8 @@
 #ifndef tuscany_sca_core_operation_h
 #define tuscany_sca_core_operation_h
 #include "osoa/sca/export.h"
-
+#include "commonj/sdo/sdo.h"
+using commonj::sdo::DataObjectPtr;
 #include <string>
 using std::string;
 
@@ -42,7 +43,7 @@
              * @param operationName The method name of the business method to 
be invoked.
              * @param numParameters The number of parameters to be passed.
              */
-            SCA_API Operation(const char* operationName, unsigned int 
numParameters);
+            SCA_API Operation(const char* operationName = 0);
 
             /**
              * Destructor.
@@ -53,14 +54,72 @@
              * Return the operation name.
              * @return The name of the operation.
              */
-            SCA_API const char* getName() {return name;}
+            SCA_API const string& getName() {return name;}
+
+
+            enum ParameterType
+            {
+                VOID_TYPE = 0,
+                BOOL,
+                SHORT,
+                LONG,
+                USHORT,
+                ULONG,
+                FLOAT,
+                DOUBLE,
+                LONGDOUBLE,
+                CHARS,
+                STRING,
+                DATAOBJECT
+            };
+
+            class Parameter
+            {
+                public:
+                    SCA_API Parameter(void* value, ParameterType type);
+                    SCA_API void* getValue() {return value;}
+                    SCA_API ParameterType getType() {return type;}
+
+                private:
+                    void* value;
+                    ParameterType type;
+            };
 
             /**
              * Set a parameter on the operation.
              * @param pos The position of the parameter in the parameter list.
              * @param parm Pointer to the parameter to be passed.
              */
-            SCA_API void setParameter(unsigned int pos, void* parm);
+            SCA_API void addParameter(const void *parm);
+            SCA_API void addParameter(const bool *parm);
+            SCA_API void addParameter(const short *parm);
+            SCA_API void addParameter(const long *parm);
+            SCA_API void addParameter(const unsigned short *parm);
+            SCA_API void addParameter(const unsigned long *parm);
+            SCA_API void addParameter(const float *parm);
+            SCA_API void addParameter(const double *parm);
+            SCA_API void addParameter(const long double *parm);
+            SCA_API void addParameter(const char* *parm);
+            SCA_API void addParameter(const string *parm);
+            SCA_API void addParameter(const DataObjectPtr *parm);
+
+
+            
+            /**
+             * Get a parameter from the operation.
+             * @param pos The position of the parameter in the parameter list.
+             * @return Pointer to the paramter at the given postion. Should be
+             * cast to the appropriate type.
+             */
+            SCA_API Parameter getParameter(unsigned int pos);
+
+            /**
+             * Get a parameter type from the operation.
+             * @param pos The position of the parameter in the parameter list.
+             * @return Pointer to the paramter at the given postion. Should be
+             * cast to the appropriate type.
+             */
+            SCA_API ParameterType getParameterType(unsigned int pos);
 
             /**
              * Get a parameter from the operation.
@@ -68,7 +127,7 @@
              * @return Pointer to the paramter at the given postion. Should be
              * cast to the appropriate type.
              */
-            SCA_API void* getParameter(unsigned int pos);
+            SCA_API void* getParameterValue(unsigned int pos);
 
             /**
              * Get the return value on the operation.
@@ -77,7 +136,7 @@
              * return value pointer and set the return value.
              * @return Pointer to the return type.
              */
-            SCA_API void* getReturnValue() {return returnType;}
+            SCA_API void* getReturnValue() {return returnValue;}
 
             /**
              * Set the return value on the operation.
@@ -92,22 +151,19 @@
             /**
              * Operation name (method name).
              */ 
-            const char* name;
-
-            /**
-             * Number of paramaters passed for this operation.
-             */ 
-            unsigned int nparms;
+            string name;
 
             /**
-             * Pointer to the array of parameters.
+             * Array of parameters.
              */
-            void** parameters;
+            typedef vector<Parameter> PARAMETER_VECTOR;
+            
+            PARAMETER_VECTOR parameters;
 
             /**
              * The return value.
              */ 
-            void* returnType;
+            void* returnValue;
         };
     } // End namespace sca
 } // End namespace tuscany

Modified: 
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.cpp
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.cpp?rev=392919&r1=392918&r2=392919&view=diff
==============================================================================
--- 
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.cpp 
(original)
+++ 
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.cpp 
Mon Apr 10 04:17:28 2006
@@ -161,8 +161,8 @@
             // -------------------
             // Invoke each target
             // -------------------
-            Operation operation(operationName, 1);
-            operation.setParameter(0, &inDataObject);
+            Operation operation(operationName);
+            operation.addParameter(&inDataObject);
             DataObjectPtr ret;
             operation.setReturnValue((void *)&ret);
 

Modified: 
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSServiceWrapper.cpp
URL: 
http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSServiceWrapper.cpp?rev=392919&r1=392918&r2=392919&view=diff
==============================================================================
--- 
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSServiceWrapper.cpp 
(original)
+++ 
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSServiceWrapper.cpp 
Mon Apr 10 04:17:28 2006
@@ -101,7 +101,7 @@
         
     
         // Call the service via the SDOStub
-        *(DataObjectPtr *)operation.getReturnValue() = 
wsStub.invoke(*((DataObjectPtr*)operation.getParameter(0)),
+        *(DataObjectPtr *)operation.getReturnValue() = 
wsStub.invoke(*((DataObjectPtr*)operation.getParameterValue(0)),
             externalService->getContainingModule()->getDataFactory());
 
     }


Reply via email to