summaryrefslogtreecommitdiff
path: root/cesar/maximus/functioncall/src/FunctionSciMsg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/maximus/functioncall/src/FunctionSciMsg.cpp')
-rw-r--r--cesar/maximus/functioncall/src/FunctionSciMsg.cpp904
1 files changed, 0 insertions, 904 deletions
diff --git a/cesar/maximus/functioncall/src/FunctionSciMsg.cpp b/cesar/maximus/functioncall/src/FunctionSciMsg.cpp
deleted file mode 100644
index 5d70eb9742..0000000000
--- a/cesar/maximus/functioncall/src/FunctionSciMsg.cpp
+++ /dev/null
@@ -1,904 +0,0 @@
-/************************************************************************
- FunctionSciMsg.cpp - Copyright buret
-
-Here you can write a license for your code, some comments or any other
-information you want to have in your generated code. To to this simply
-configure the "headings" directory in uml to point to a directory
-where you have your heading files.
-
-or you can just replace the contents of this file with your own.
-If you want to do this, this file is located at
-
-/usr/share/apps/umbrello/headings/heading.cpp
-
--->Code Generators searches for heading files based on the file extension
- i.e. it will look for a file name ending in ".h" to include in C++ header
- files, and for a file name ending in ".java" to include in all generated
- java code.
- If you name the file "heading.<extension>", Code Generator will always
- choose this file even if there are other files with the same extension in the
- directory. If you name the file something else, it must be the only one with that
- extension in the directory to guarantee that Code Generator will choose it.
-
-you can use variables in your heading files which are replaced at generation
-time. possible variables are : author, date, time, filename and filepath.
-just write %variable_name%
-
-This file was generated on %date% at %time%
-The original location of this file is /home/buret/eclipse/maximus/functioncall/src/FunctionSciMsg.cpp
-**************************************************************************/
-
-#include "FunctionSciMsg.h"
-
-#include "IFunctionCall.h"
-#include "FunctionCallParameter.h"
-
-#include "Error.h"
-#include "Logger.h"
-
-#include <netinet/in.h> // for 'htonl()' and 'htons()'
-#include <cstring> // for 'strcpy()' and 'strcmp()'
-#include <iomanip> // for 'setfill()' and 'setw()'
-#include <iostream> // for 'cout', 'cerr' and 'clog'
-using namespace std;
-
-
-// Constructors/Destructors
-//
-
-
-Function_Call_Msg_Id FunctionSciMsg::mSpecializedSciMsgId = 0;
-
-
-FunctionSciMsg::FunctionSciMsg ( IFunctionCall * p_function_call_manager ):
-mSpecializedSciMsgType(FUNCTION_CALL_TYPE_NONE),
-mSpecializedSciMsgParametersNumber(0),
-mSpecializedSciMsgFlags(FUNCTION_CALL_FLAG_NONE),
-mpFunctionCallManager(NULL)
-{
- logFunction();
-
- if (NULL != p_function_call_manager)
- {
- mpFunctionCallManager = p_function_call_manager;
- }
- else
- {
- errno = EINVAL;
- throw Error(__PRETTY_FUNCTION__, "Function call manager pointer is NULL", errno);
- }
-
- initAttributes ();
-}
-
-
-void FunctionSciMsg::initAttributes ( )
-{
- logFunction();
-
- mSpecializedSciMsgHeader.version = 0x00;
- mSpecializedSciMsgHeader.type = 0x00;
- mSpecializedSciMsgHeader.msg_id = 0x0000;
- mSpecializedSciMsgHeader.param_nb = 0x00;
- mSpecializedSciMsgHeader.flags = 0x00;
- mSpecializedSciMsgHeader.reserved = 0x0000;
-}
-
-
-FunctionSciMsg::FunctionSciMsg ( const FunctionSciMsg & function_sci_msg ) : SciMsg ( )
-{
- logFunction();
-
- setSpecializedSciMsgType (function_sci_msg.getSpecializedSciMsgType());
- setSpecializedSciMsgParametersNumber (function_sci_msg.getSpecializedSciMsgParametersNumber());
- setSpecializedSciMsgHeader (function_sci_msg.getSpecializedSciMsgHeader());
- setFunctionName (function_sci_msg.getFunctionName());
- setListOfParameters (function_sci_msg.getListOfParameters());
- setFunctionCallManager (function_sci_msg.getFunctionCallManager());
-}
-
-
-FunctionSciMsg::~FunctionSciMsg ( )
-{
- logFunction();
-
- if (!mListOfParameters.empty())
- {
- mListOfParameters.clear();
- }
- if (NULL != mpFunctionCallManager)
- {
- mpFunctionCallManager = NULL;
- }
-}
-
-
-//
-// Methods
-//
-
-
-// Other methods
-//
-
-
-// public methods
-//
-
-
-SciMsg * FunctionSciMsg::create ( ) const
-{
- logFunction();
-
- return new FunctionSciMsg(getFunctionCallManager());
-}
-
-
-bool FunctionSciMsg::dispatchMsg ( )
-{
- logFunction();
- bool bDispatch = false;
-
- if (NULL != getFunctionCallManager())
- {
- bDispatch = identifyFunctionName();
- bDispatch &= identifyParameters();
-
- if ( FUNCTION_CALL_TYPE_RSP == getSpecializedSciMsgType() )
- {
- bDispatch &= getFunctionCallManager()->receiveMsg(*this);
- }
- }
- else
- {
- throw Error(__PRETTY_FUNCTION__, "Function call manager pointer is NULL");
- }
-
- return bDispatch;
-}
-
-
-// When receiving a SCI msg, specialized SCI msg header has to be extracted from received SCI msg data
-//
-bool FunctionSciMsg::identifySpecializedSciMsgHeader ( )
-{
- logFunction();
- bool bIdentifyHeader = false;
-
- if (NULL != SciMsg::getSciMsgData())
- {
- // Set specialized SCI msg header size
- //
- SciMsg::setSpecializedSciMsgHeaderSize((unsigned long)sizeof(struct Function_Call_Header));
-
- // Get specialized SCI message header contents
- //
- if (SciMsg::getSciMsgDataLength() >= SciMsg::getSpecializedSciMsgHeaderSize()) // check that there are enough data to get the specialized SCI message header
- {
- mSpecializedSciMsgHeader = *((Function_Call_Header*)SciMsg::getSciMsgData());
- mSpecializedSciMsgHeader.msg_id = ntohs(getSpecializedSciMsgHeader().msg_id);
- mSpecializedSciMsgHeader.reserved = ntohs(getSpecializedSciMsgHeader().reserved);
-
- // Set specialized SCI msg attributes from specialized SCI msg header
- //
- setSpecializedSciMsgType (static_cast<Function_Call_Type>(getSpecializedSciMsgHeader().type));
- setSpecializedSciMsgParametersNumber (static_cast<Function_Call_Parameters_Number>(getSpecializedSciMsgHeader().param_nb));
- setSpecializedSciMsgFlags (static_cast<Function_Call_Flags>(getSpecializedSciMsgHeader().flags));
- displaySpecializedSciMsgHeader();
- bIdentifyHeader = true;
- }
- else
- {
- errno = ENODATA;
- throw Error(__PRETTY_FUNCTION__, "Not enough data to get the specialized SCI message header", errno);
- }
- }
- else
- {
- throw Error(__PRETTY_FUNCTION__, "SCI message data pointer is NULL");
- }
-
- return bIdentifyHeader;
-}
-
-
-// Check specialized SCI msg compatibility (check specialized SCI msg version)
-//
-bool FunctionSciMsg::checkCompatibility ( ) const
-{
- logFunction();
- bool bCheck = false;
-
- if (FUNCTION_CALL_VERSION == getSpecializedSciMsgHeader().version)
- {
- bCheck = SciMsg::checkCompatibility();
- }
-
- return bCheck;
-}
-
-
-// Called by user to configure a message to send
-//
-bool FunctionSciMsg::addParameter ( const FunctionCallParameter & function_argument_to_add )
-{
- logFunction();
- bool bAddParameter = false;
-
- if ( FUNCTION_CALL_PARAM_MAX_SIZE >= function_argument_to_add.getValueLength())
- {
- mListOfParameters.push_back(function_argument_to_add);
- bAddParameter = true;
- }
- else
- {
-#if CONFIG_LOG
- clog << logger(LOG_ERROR) << "add_param: length of parameter value exceeds max size!" << endl;
-#endif
- errno = EMSGSIZE;
- throw Error(__PRETTY_FUNCTION__, "Length of parameter value exceeds max size", errno);
- }
-
- return bAddParameter;
-}
-
-
-// Called by user to configure a message to send
-//
-bool FunctionSciMsg::removeParameter ( const std::string & name )
-{
- logFunction();
- bool bRemoveParameter = false;
-
- for (ParametersList::iterator it = mListOfParameters.begin(); it < mListOfParameters.end(); ++it)
- {
- if ( !it->getName().compare(name) )
- {
- mListOfParameters.erase(it);
- bRemoveParameter = true;
- break;
- }
- }
-
- return bRemoveParameter;
-}
-
-
-// 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, unsigned char * p_data ) const
-{
- logFunction();
- bool bBindParameter = false;
-
- FunctionCallParameter tempParameter;
- for (unsigned int i=0; i<mListOfParameters.size(); ++i)
- {
- tempParameter = mListOfParameters[i];
- if ( !tempParameter.getName().compare(name_of_parameter_to_get) )
- {
- bBindParameter = true;
- if (data_length < tempParameter.getValueLength())
- {
-#if CONFIG_LOG
- clog << logger(LOG_WARNING) << "bind_param: parameter value length too small to get the parameter value" << endl;
- clog << logger(LOG_WARNING) << "\t(given data length = " << data_length << " and needed data length = " << tempParameter.getValueLength() << ")" << endl;
- clog << logger(LOG_WARNING) << "\t=> parameter value will be cut" << endl;
-#endif /* CONFIG_LOG */
- }
- else if (data_length > tempParameter.getValueLength())
- {
-#if CONFIG_LOG
- clog << logger(LOG_WARNING) << "bind_param: parameter value length too large to get the parameter value" << endl;
- clog << logger(LOG_WARNING) << "\t=> update length from " << data_length << " to " << tempParameter.getValueLength() << endl;
-#endif /* CONFIG_LOG */
- data_length = tempParameter.getValueLength();
- }
- if ( (NULL != tempParameter.getValue()) && (NULL != p_data) )
- {
- memcpy(p_data, tempParameter.getValue(), data_length);
-#if CONFIG_LOG
- clog << logger(LOG_COM) << "bind parameter = " << endl;
-#endif /* CONFIG_LOG */
- tempParameter.displayParameter();
- i = mListOfParameters.size()-1;
- }
- }
- }
-
- return bBindParameter;
-}
-
-
-// Called when a function SCI msg is received
-//
-bool FunctionSciMsg::identifyFunctionName ( )
-{
- logFunction();
- bool bName = false;
-
- if (NULL != getSpecializedSciMsgData())
- {
- // Find function name length
- //
- unsigned long functionNameLength = 0;
- while ( (getSpecializedSciMsgDataLength() >= functionNameLength)
- && ('\0' != *(getSpecializedSciMsgData()+functionNameLength)) )
- {
- if (FUNCTION_CALL_ID_MAX_SIZE > functionNameLength) /* max length of a function id */
- {
- functionNameLength++;
- }
- else
- {
-#if CONFIG_LOG
- clog << logger(LOG_ERROR) << "length of function call name exceeds max size!" << endl;
-#endif /* CONFIG_LOG */
- }
- }
-
- // Copy function name from specialized SCI msg data to function name attribute
- //
- mFunctionName.assign((char*)getSpecializedSciMsgData(), functionNameLength);
-
- // Remove function name from specialized SCI msg data
- //
- unsigned long tempDataLength = getSpecializedSciMsgDataLength();
- unsigned char * pTempData = new unsigned char [tempDataLength];
- memcpy(pTempData, getSpecializedSciMsgData(), tempDataLength);
- bName = SciMsg::removeData (functionNameLength+1, tempDataLength, &pTempData);
- if (0 != bName)
- {
- bName &= setSpecializedSciMsgDataLength(tempDataLength);
- bName &= setSpecializedSciMsgData(pTempData);
- }
-
- // Free pointer
- //
- if (NULL != pTempData)
- {
- delete [] pTempData;
- pTempData = NULL;
- }
- }
- else
- {
- if (!getFunctionName().empty()) // function name has already been set
- {
- bName = true;
- }
- }
- displayFunctionName();
-
- return bName;
-}
-
-
-// Called when a function SCI msg is received
-//
-bool FunctionSciMsg::identifyParameters ( )
-{
- logFunction();
- bool bParam = false;
-
- if ( NULL != getSpecializedSciMsgData() )
- {
- // For each parameter
- //
- for (unsigned int n=0; n<getSpecializedSciMsgParametersNumber(); n++)
- {
- // Find parameter name length
- //
- unsigned long parameterNameLength = 0;
- while ( (getSpecializedSciMsgDataLength() >= parameterNameLength)
- && ('\0' != *(getSpecializedSciMsgData()+parameterNameLength)) )
- {
- parameterNameLength++;
- }
-
- // Copy parameter name from specialized SCI msg data to parameter name attribute
- //
- string tempParameterName;
- tempParameterName.assign((char*)getSpecializedSciMsgData(), parameterNameLength);
- FunctionCallParameter parameterToFill;
- parameterToFill.setName(tempParameterName);
-
- // Remove parameter name from specialized SCI msg data
- //
- unsigned long tempDataLength = getSpecializedSciMsgDataLength();
- unsigned char * pTempData = new unsigned char [tempDataLength];
- memcpy(pTempData, getSpecializedSciMsgData(), tempDataLength);
- bParam = SciMsg::removeData (parameterNameLength+1, tempDataLength, &pTempData);
- if (0 != bParam)
- {
- bParam &= setSpecializedSciMsgDataLength(tempDataLength);
- bParam &= setSpecializedSciMsgData(pTempData);
- }
- if (NULL != pTempData)
- {
- delete [] pTempData;
- pTempData = NULL;
- }
-
- // Find parameter value length (coded on 2 bytes)
- //
- uint16_t tempLength = (static_cast<uint8_t>(*(getSpecializedSciMsgData()))<<8) + static_cast<uint8_t>(*(getSpecializedSciMsgData()+1));
- if ( FUNCTION_CALL_PARAM_MAX_SIZE >= tempLength )
- {
- parameterToFill.setValueLength (static_cast<unsigned long>(tempLength));
- }
- else
- {
-#if CONFIG_LOG
- clog << logger(LOG_ERROR) << "length of parameter value exceeds max size!" << endl;
-#endif /* CONFIG_LOG */
- errno = EMSGSIZE;
- throw Error(__PRETTY_FUNCTION__, "Length of parameter value exceeds max size", errno);
- }
-
- // Find parameter value
- //
- unsigned char * pTempParameterValue = new unsigned char [parameterToFill.getValueLength()];
- memcpy(pTempParameterValue, getSpecializedSciMsgData()+2, parameterToFill.getValueLength()); // +2 because parameter value length is coded on 2 bytes
- parameterToFill.setValue(pTempParameterValue);
-
- // Remove parameter value length and parameter value from specialized SCI msg data
- //
- tempDataLength = getSpecializedSciMsgDataLength();
- pTempData = new unsigned char [tempDataLength];
- memcpy(pTempData, getSpecializedSciMsgData(), tempDataLength);
- bParam &= SciMsg::removeData (2+parameterToFill.getValueLength(), tempDataLength, &pTempData); // +2 because parameter value length is coded on 2 bytes
- if (0 != bParam)
- {
- bParam &= setSpecializedSciMsgDataLength(tempDataLength);
- bParam &= setSpecializedSciMsgData(pTempData);
- }
- if (NULL != pTempData)
- {
- delete [] pTempData;
- pTempData = NULL;
- }
- if (NULL != pTempParameterValue)
- {
- delete [] pTempParameterValue;
- pTempParameterValue = NULL;
- }
-
- // Add parameter to the parameters list of the received function SCI msg
- //
- bParam &= addParameter(parameterToFill);
- }
- }
- displayListOfParameters();
-
- return bParam;
-}
-
-
-// Called when a function SCI msg is sent
-// Fill specialized SCI msg attributes
-// Fill specialized SCI msg data length and specialized SCI msg data
-//
-bool FunctionSciMsg::fillSpecializedSciMsgToSend ( )
-{
- logFunction();
- bool bFill = false;
-
- Function_Call_Parameters_Number numberOfParameters = 0;
- unsigned long dataLength = 0;
- unsigned char * pData = NULL;
-
- displayFunctionName();
- displayListOfParameters();
-
- // Function name is sent into the SCI msg data, before parameters
- //
- if (!getFunctionName().empty())
- {
- pData = (unsigned char *)(malloc(getFunctionName().size()+1)); // memory allocation for function name
- getFunctionName().copy ((char*)(pData), getFunctionName().size()); // copy function name into data
- pData[getFunctionName().size()] = '\0';
- dataLength += static_cast<unsigned long>(getFunctionName().size()+1); // update data length
-
- // Parameters are defined as 'FunctionCallParameter'
- // They will be sent into the function SCI msg into specialized SCI msg data
- // 'FunctionCallParameter' fields are sent according to the following format:
- // name\0lengthp_value etc. with length coded on 2 bytes
- // Number of parameters is sent into the 'Function_Call_Header.param_nb' field
- //
- for (unsigned int i=0; i<mListOfParameters.size(); ++i)
- {
- // Dynamic memory allocation for parameter
- //
- pData = (unsigned char *)(realloc(pData, dataLength+((mListOfParameters)[i].getName().length())+1+2+(mListOfParameters)[i].getValueLength()));
-
- // Parameter name
- //
- mListOfParameters[i].getName().copy ((char*)(pData+dataLength), mListOfParameters[i].getName().size()); // copy parameter name into data
- *(pData+dataLength+mListOfParameters[i].getName().size()) = '\0';
- dataLength += static_cast<unsigned long>(mListOfParameters[i].getName().size()+1); // update data length
-
- // Parameter value length
- //
- uint16_t tempLength = static_cast<uint16_t>(mListOfParameters[i].getValueLength());
- uint8_t tempLengthHigh=0, tempLengthLow=0;
- tempLengthHigh = static_cast<uint8_t>(tempLength >> 8);
- tempLengthLow = static_cast<uint8_t>(tempLength);
- *(pData+dataLength) = static_cast<unsigned char>(tempLengthHigh);
- *(pData+dataLength+1) = static_cast<unsigned char>(tempLengthLow);
- dataLength += 2; // update data length
-
- // Parameter value
- //
- if (0 != (mListOfParameters[i].getValueLength()))
- {
- for (unsigned int j=0; j<mListOfParameters[i].getValueLength(); j++)
- {
- *(pData+dataLength+j) = *(mListOfParameters[i].getValue()+j);
- }
- }
- dataLength += mListOfParameters[i].getValueLength(); // update data length
-
- // Increment number of parameters that have been copied into data
- //
- numberOfParameters++;
- }
- }
-
- // Fill specialized SCI msg type,
- // specialized SCI msg number of parameters,
- // specialized SCI msg data length,
- // and specialized SCI msg data
- //
- if (NULL != pData)
- {
- bFill = setSpecializedSciMsgType(FUNCTION_CALL_TYPE_REQ);
- bFill &= setSpecializedSciMsgParametersNumber(numberOfParameters);
- bFill &= setSpecializedSciMsgDataLength(dataLength);
- bFill &= setSpecializedSciMsgData(pData);
-
- // Free temporary allocated memory
- //
- free(pData);
- pData = NULL;
- }
-
- return bFill;
-}
-
-
-void FunctionSciMsg::displaySpecializedSciMsgHeader ( ) const
-{
-#if CONFIG_LOG
- logFunction();
-
- clog << logger(LOG_INFO) << "function SCI msg header = " << endl;
- clog << logger(LOG_INFO) << "\tversion = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(mSpecializedSciMsgHeader.version) << endl;
- displaySpecializedSciMsgType(LOG_INFO);
- clog << logger(LOG_INFO) << "\tmsg id = 0x" << setfill('0') << setw(4) << uppercase << hex << mSpecializedSciMsgHeader.msg_id << endl;
- clog << logger(LOG_INFO) << "\tparam nb = " << dec << static_cast<unsigned short int>(mSpecializedSciMsgHeader.param_nb) \
- << " (0x" << setw(2) << uppercase << hex << static_cast<unsigned short int>(mSpecializedSciMsgHeader.param_nb) << ")" << endl;
- clog << logger(LOG_INFO) << "\tflags = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(mSpecializedSciMsgHeader.flags) << endl;
- clog << logger(LOG_INFO) << "\treserved = 0x" << setfill('0') << setw(4) << uppercase << hex << mSpecializedSciMsgHeader.reserved << dec << endl;
-#endif /* CONFIG_LOG */
-}
-
-
-void FunctionSciMsg::displaySpecializedSciMsgType ( int log_level ) const
-{
-#if CONFIG_LOG
- switch (getSpecializedSciMsgType())
- {
- case 0:
- clog << logger(log_level) << "\ttype = FUNCTION_CALL_TYPE_NONE" << endl;
- break;
- case 1:
- clog << logger(log_level) << "\ttype = FUNCTION_CALL_TYPE_REQ" << endl;
- break;
- case 2:
- clog << logger(log_level) << "\ttype = FUNCTION_CALL_TYPE_RSP" << endl;
- break;
- default:
- clog << logger(log_level) << "\ttype = unknown!" << endl;
- break;
- }
-#endif /* CONFIG_LOG */
-}
-
-
-// private methods
-//
-
-
-void FunctionSciMsg::displayFunctionName ( ) const
-{
-#if CONFIG_LOG
- logFunction();
-
- if (!getFunctionName().empty())
- {
- clog << logger(LOG_COM) << "function name = " << getFunctionName() << endl;
- }
- else
- {
- clog << logger(LOG_ERROR) << "function name = empty!" << endl;
- }
-#endif /* CONFIG_LOG */
-}
-
-
-void FunctionSciMsg::displayParameter ( unsigned int parameter_iterator ) const
-{
-#if CONFIG_LOG
- logFunction();
-
- clog << logger(LOG_INFO) << "parameter " << dec << parameter_iterator+1 << " = " << endl;
- if (parameter_iterator < mListOfParameters.size())
- {
- mListOfParameters[parameter_iterator].displayParameter();
- }
- else
- {
- clog << logger(LOG_INFO) << "\tdoes not exist!" << endl;
- }
-#endif /* CONFIG_LOG */
-}
-
-
-void FunctionSciMsg::displayListOfParameters ( ) const
-{
-#if CONFIG_LOG
- logFunction();
-
- clog << logger(LOG_COM) << "list of parameters = " << endl;
-
- if (!mListOfParameters.empty())
- {
- for (unsigned int i=0; i<mListOfParameters.size(); i++)
- {
- mListOfParameters[i].displayParameter();
- }
- }
- else
- {
- clog << logger(LOG_COM) << "\tempty!" << endl;
- }
-#endif /* CONFIG_LOG */
-}
-
-
-// protected methods
-//
-
-
-// Accessor methods
-//
-
-
-// public attribute accessor methods
-//
-
-
-// private attribute accessor methods
-//
-
-
-Function_Call_Type FunctionSciMsg::getSpecializedSciMsgType ( ) const
-{
- return mSpecializedSciMsgType;
-}
-
-
-bool FunctionSciMsg::setSpecializedSciMsgType ( const Function_Call_Type type )
-{
- mSpecializedSciMsgType = type;
-
- return true;
-}
-
-
-Function_Call_Msg_Id FunctionSciMsg::getMsgId ( ) const
-{
- return getSpecializedSciMsgHeader().msg_id;
-}
-
-
-bool FunctionSciMsg::setMsgId ( const Function_Call_Msg_Id msg_id )
-{
- mSpecializedSciMsgHeader.msg_id = msg_id;
-
- return true;
-}
-
-
-Function_Call_Msg_Id FunctionSciMsg::getSpecializedSciMsgId ( ) const
-{
- return mSpecializedSciMsgId;
-}
-
-
-bool FunctionSciMsg::incrementSpecializedSciMsgId ( )
-{
- mSpecializedSciMsgId++;
-
- return true;
-}
-
-
-Function_Call_Parameters_Number FunctionSciMsg::getSpecializedSciMsgParametersNumber ( ) const
-{
- return mSpecializedSciMsgParametersNumber;
-}
-
-
-bool FunctionSciMsg::setSpecializedSciMsgParametersNumber ( const Function_Call_Parameters_Number number_of_parameters )
-{
- logFunction();
- bool bNb = false;
-
- if ( FUNCTION_CALL_PARAM_MAX_NB >= number_of_parameters ) /* max number of parameter in a function call */
- {
- mSpecializedSciMsgParametersNumber = number_of_parameters;
- bNb = true;
- }
- else
- {
-#if CONFIG_LOG
- clog << logger(LOG_ERROR) << "number of parameters exceeds max number!" << endl;
-#endif /* CONFIG_LOG */
- errno = E2BIG;
- throw Error(__PRETTY_FUNCTION__, "Number of parameters exceeds max number", errno);
- }
-
- return bNb;
-}
-
-
-Function_Call_Flags FunctionSciMsg::getSpecializedSciMsgFlags ( ) const
-{
- return mSpecializedSciMsgFlags;
-}
-
-
-bool FunctionSciMsg::setSpecializedSciMsgFlags ( const Function_Call_Flags flags )
-{
- logFunction();
- bool bFlags = false;
-
- if ( FUNCTION_CALL_FLAG_MAX < flags )
- {
-#if CONFIG_LOG
- clog << logger(LOG_ERROR) << "function SCI message header flags is out-of-range!" << endl;
-#endif /* CONFIG_LOG */
- }
- else if (FUNCTION_CALL_FLAG_FAILED == (flags & FUNCTION_CALL_FLAG_FAILED))
- {
-#if CONFIG_LOG
- clog << logger(LOG_ERROR) << "function SCI message header flags is set to FAILED!" << endl;
-#endif /* CONFIG_LOG */
- mSpecializedSciMsgFlags = flags;
- }
- else
- {
- mSpecializedSciMsgFlags = flags;
- bFlags = true;
- }
-
- return bFlags;
-}
-
-
-bool FunctionSciMsg::setReserved ( const uint16_t reserved )
-{
- mSpecializedSciMsgHeader.reserved = reserved;
-
- return true;
-}
-
-
-void * FunctionSciMsg::returnSpecializedSciMsgHeader ( ) const
-{
- return (void*)&mSpecializedSciMsgHeader;
-}
-
-
-const Function_Call_Header & FunctionSciMsg::getSpecializedSciMsgHeader ( ) const
-{
- return mSpecializedSciMsgHeader;
-}
-
-
-bool FunctionSciMsg::setSpecializedSciMsgHeader ( const Function_Call_Header & specialized_sci_msg_header )
-{
- logFunction();
- bool bSetHeader = false;
-
- mSpecializedSciMsgHeader = specialized_sci_msg_header;
-
- // Set specialized SCI msg attributes from specialized SCI msg header
- //
- bSetHeader = setSpecializedSciMsgType (static_cast<Function_Call_Type>(getSpecializedSciMsgHeader().type));
- bSetHeader &= setSpecializedSciMsgParametersNumber (static_cast<Function_Call_Parameters_Number>(getSpecializedSciMsgHeader().param_nb));
-
- displaySpecializedSciMsgHeader();
-
- return bSetHeader;
-}
-
-
-string FunctionSciMsg::getFunctionName ( ) const
-{
- return mFunctionName;
-}
-
-
-// Called by user to configure a SCI message to send
-//
-bool FunctionSciMsg::setFunctionName ( const string name )
-{
- logFunction();
- bool bName = false;
-
- if ( FUNCTION_CALL_ID_MAX_SIZE > name.size() ) /* max length of a function id */
- {
- mFunctionName = name;
- bName = true;
- }
- else
- {
-#if CONFIG_LOG
- clog << logger(LOG_ERROR) << "function name exceeds max length!" << endl;
-#endif /* CONFIG_LOG */
- }
-
- return bName;
-}
-
-
-const ParametersList & FunctionSciMsg::getListOfParameters ( ) const
-{
- return mListOfParameters;
-}
-
-
-bool FunctionSciMsg::setListOfParameters ( const ParametersList & list_of_parameters )
-{
- if (!mListOfParameters.empty())
- {
- mListOfParameters.clear();
- }
- mListOfParameters = ParametersList(list_of_parameters);
-
- return true;
-}
-
-
-IFunctionCall * FunctionSciMsg::getFunctionCallManager ( ) const
-{
- return mpFunctionCallManager;
-}
-
-
-bool FunctionSciMsg::setFunctionCallManager ( IFunctionCall * p_function_call_manager )
-{
- logFunction();
-
- if (NULL != p_function_call_manager)
- {
- mpFunctionCallManager = p_function_call_manager;
- }
- else
- {
-#if CONFIG_LOG
- clog << logger(LOG_WARNING) << "function call manager pointer is NULL!" << endl;
-#endif /* CONFIG_LOG */
- mpFunctionCallManager = NULL;
- }
-
- return true;
-}
-
-
-// protected attribute accessor methods
-//
-