summaryrefslogtreecommitdiff
path: root/maximus/functioncall
diff options
context:
space:
mode:
authorburet2007-06-19 11:10:30 +0000
committerburet2007-06-19 11:10:30 +0000
commit84dc06c8a1e9ffde49840aa0d74028c0b8515949 (patch)
tree2884e3969ddd8c88cae960888d00d900d0d641db /maximus/functioncall
parent27d67755dd79e35c522649d15887f73d9f03cd0c (diff)
Function SCI msg bind parameter
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@324 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'maximus/functioncall')
-rw-r--r--maximus/functioncall/inc/FunctionSciMsg.h2
-rw-r--r--maximus/functioncall/src/FunctionSciMsg.cpp18
-rw-r--r--maximus/functioncall/src/FunctionSciMsgTest.cpp15
3 files changed, 15 insertions, 20 deletions
diff --git a/maximus/functioncall/inc/FunctionSciMsg.h b/maximus/functioncall/inc/FunctionSciMsg.h
index da27e9504c..926d26686e 100644
--- a/maximus/functioncall/inc/FunctionSciMsg.h
+++ b/maximus/functioncall/inc/FunctionSciMsg.h
@@ -145,7 +145,7 @@ public:
* @param name_of_parameter_to_get
* @param p_data
*/
- bool bindParameter ( const std::string name_of_parameter_to_get, unsigned long & data_length, void * & p_data ) const;
+ bool bindParameter ( const std::string name_of_parameter_to_get, unsigned long & data_length, unsigned char * & p_data ) const;
/**
* @return bool
diff --git a/maximus/functioncall/src/FunctionSciMsg.cpp b/maximus/functioncall/src/FunctionSciMsg.cpp
index d92f68a249..51d21df4f2 100644
--- a/maximus/functioncall/src/FunctionSciMsg.cpp
+++ b/maximus/functioncall/src/FunctionSciMsg.cpp
@@ -297,7 +297,7 @@ bool FunctionSciMsg::addParameter ( const FunctionCallParameter & function_argum
// Called by user when a message is received to retrieve function parameters
//
-bool FunctionSciMsg::bindParameter ( const string name_of_parameter_to_get, unsigned long & data_length, void * & p_data ) const
+bool FunctionSciMsg::bindParameter ( const string name_of_parameter_to_get, unsigned long & data_length, unsigned char * & p_data ) const
{
clog << "FunctionSciMsg::bindParameter" << endl;
bool bBindParameter = false;
@@ -311,26 +311,20 @@ bool FunctionSciMsg::bindParameter ( const string name_of_parameter_to_get, unsi
if ( !tempParameter.getName().compare(name_of_parameter_to_get) )
{
data_length = tempParameter.getValueLength();
- if (NULL != p_data)
+ p_data = new unsigned char [data_length+1]; // to be deleted by user
+ if ( (NULL != tempParameter.getValue()) && (NULL != p_data) )
{
- if (NULL != tempParameter.getValue())
+ for (unsigned int j=0; j<data_length; j++)
{
- p_data = tempParameter.getValue();
- }
- else
- {
- p_data = NULL;
+ *(p_data+j) = *(tempParameter.getValue()+j);
}
+ p_data[data_length] = '\0';
clog << "\tbind parameter = ";
tempParameter.displayParameter();
clog << endl;
i = mListOfParameters.size()-1;
bBindParameter = true;
}
- else
- {
- throw Error("FunctionSciMsg::bindParameter", "Allocated data pointer is NULL");
- }
}
}
diff --git a/maximus/functioncall/src/FunctionSciMsgTest.cpp b/maximus/functioncall/src/FunctionSciMsgTest.cpp
index b119ff3cd8..68ceb480d2 100644
--- a/maximus/functioncall/src/FunctionSciMsgTest.cpp
+++ b/maximus/functioncall/src/FunctionSciMsgTest.cpp
@@ -117,23 +117,24 @@ void FunctionSciMsgTest::bindParameterTest (void)
const string name = "parameter1";
unsigned long dataLength = 0;
- char * pData = NULL;
- void * pVoidData = (void *)pVoidData;
+ unsigned char * pData = NULL;
clog << "\tFunctionSciMsgTest -> FunctionSciMsg::bindParameter" << endl;
CPPUNIT_ASSERT_MESSAGE ( CPPUNIT_NS::Message("bindParameter failed"),
- mpFunctionSciMsg->bindParameter(name, dataLength, pVoidData) );
- pData = static_cast<char*>(pVoidData);
+ mpFunctionSciMsg->bindParameter(name, dataLength, pData) );
// Check results
//
CPPUNIT_ASSERT_MESSAGE ( CPPUNIT_NS::Message("bindParameterTest failed: wrong data length"), (3 == dataLength) );
CPPUNIT_ASSERT_MESSAGE ( CPPUNIT_NS::Message("bindParameterTest failed: data pointer is NULL"), (NULL != pData) );
+ CPPUNIT_ASSERT_MESSAGE ( CPPUNIT_NS::Message("bindParameterTest failed: wrong data"), (!strcmp("123", (char*)pData)) );
// Free memory allocated into 'FunctionSciMsg::bindParameter'
//
- pVoidData = NULL;
- pData = NULL;
-
+ if (NULL != pData)
+ {
+ delete [] pData;
+ pData = NULL;
+ }
}
else
{