[OSADL-svn-commits] r86 - fapia-trunk/FAPIAIPCParameter/source
OSADL repository commits
osadl-svn-commits at lists.osadl.org
Tue Oct 2 11:46:44 CEST 2007
Author: tb10rts
Date: Thu Jul 19 07:15:27 2007
New Revision: 86
Log:
Added a folder remotely
Added:
fapia-trunk/FAPIAIPCParameter/source/
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterCommunication.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterError.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterImplementation.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterInfo.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterInit.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMarshalling.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMarshalling.h
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequest.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestFinish.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestFinish.h
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestInfoRequest.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestInfoResponse.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestReadRequest.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestReadResponse.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestWriteRequest.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestWriteResponse.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterParameter.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverAcceptor.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverAcceptor.h
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverService.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverService.h
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverTask.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverTask.h
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterSenderService.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterSenderService.h
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterSocket.h
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterStreaming.cpp
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterStreaming.h
fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterValue.cpp
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterCommunication.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterCommunication.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,105 @@
+// $Id$
+
+
+#include "FAPIAIPCParameterCommunication.h"
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+/*---------------------------------------------------------------------------*/
+
+ Communication::Communication (void)
+ {
+ open ();
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ Communication::Communication ( \
+ const Communication& communication)
+ {
+ open ();
+ copy (communication);
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ const Communication& Communication::operator= (
+ const Communication& communication)
+ {
+ if (this != &communication)
+ {
+ copy (communication);
+ }
+
+ return *this;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ Communication::~Communication (void)
+ {
+ close ();
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ bool Communication::operator!= (const Communication& comm)
+ const
+ {
+ return ((this->send_reply_ != comm.send_reply_) ||
+ (this->transaction_id_ != comm.transaction_id_) ||
+ (this->logical_object_name_.compare (
+ comm.logical_object_name_) != 0) ||
+ (this->source_physical_object_name_.compare (
+ comm.source_physical_object_name_) != 0) ||
+ (this->communication_error_ !=
+ comm.communication_error_)
+ );
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ void Communication::open (void)
+ {
+ this->transaction_id_ = 0;
+ this->logical_object_name_ = ACE_CString ();
+ this->source_physical_object_name_ = ACE_CString();
+ this->send_reply_ = false;
+ this->communication_error_ = Error ();
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ void Communication::copy (const Communication& communication)
+ {
+ this->transaction_id_ = communication.transaction_id_;
+ this->logical_object_name_ =
+ communication.logical_object_name_;
+ this->source_physical_object_name_ =
+ communication.source_physical_object_name_;
+ this->send_reply_ = communication.send_reply_;
+ this->communication_error_ =
+ communication.communication_error_;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ void Communication::close (void)
+ {
+ this->transaction_id_ = 0;
+ this->send_reply_ = false;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterError.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterError.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,86 @@
+// $Id$
+
+
+#include "FAPIAIPCParameterError.h"
+#include /**/ <ace/Vector_T.h>
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+/*---------------------------------------------------------------------------*/
+
+ Error::Error (void)
+ {
+ open ();
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ Error::Error (const Error& error)
+ {
+ open ();
+ copy (error);
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ const Error& Error::operator= (const Error& error)
+ {
+ if (this != &error)
+ {
+ copy (error);
+ }
+
+ return *this;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ Error::~Error (void)
+ {
+ close ();
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ bool Error::operator!= (const Error& error) const
+ {
+ return ((this->error_code_ != error.error_code_) ||
+ (this->reason_.compare (error.reason_) != 0));
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ void Error::open (void)
+ {
+ this->error_code_ = FAPIA_ERROR_OK;
+ this->reason_ = ACE_CString();
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ void Error::copy (const Error& error)
+ {
+ this->error_code_ = error.error_code_;
+ this->reason_ = error.reason_;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ void Error::close (void)
+ {
+ this->error_code_ = FAPIA_ERROR_OK;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterImplementation.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterImplementation.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,177 @@
+// $Id$
+
+
+#include "FAPIAIPCParameterImplementation.h"
+
+#include "FAPIAIPCParameterReceiverTask.h"
+#include "FAPIAIPCParameterSenderService.h"
+#include "FAPIATrace.h"
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+/*---------------------------------------------------------------------------*/
+
+ ParameterImplementation::ParameterImplementation ()
+ : recv_task_ (NULL), send_task_ (NULL)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ ParameterImplementation::~ParameterImplementation ()
+ {
+ if (recv_task_ != NULL)
+ {
+ delete recv_task_;
+ recv_task_ = NULL;
+ }
+
+ if (send_task_ != NULL)
+ {
+ delete send_task_;
+ send_task_ = NULL;
+ }
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ int ParameterImplementation::init ( \
+ const FAPI::Acyclic::IPC::Parameter::Init& init,
+ ACE_CString& physical_object_address,
+ FAPI::Acyclic::IPC::Parameter::Error& error)
+ {
+ FAPIA_TRACE;
+
+ // check if queues are set
+ if ((init.receive_queue_ == NULL) ||
+ (init.send_queue_ == NULL))
+ {
+ error.error_code_ = FAPIA_ERROR_COMMUNICATION;
+ error.reason_ =
+ "init function lacks necessary parameters.";
+ FAPIA_DEBUG (LM_ERROR, error.reason_.c_str ());
+ return -1;
+ }
+
+ // create ReceiverService and check for errors
+ recv_task_ = new ReceiverTask (init.receive_queue_);
+ if (recv_task_ == NULL)
+ {
+ error.error_code_ = FAPIA_ERROR_COMMUNICATION;
+ error.reason_ = "could not initialize receiver.";
+ FAPIA_DEBUG (LM_ALERT, error.reason_.c_str ());
+ return -1;
+ }
+
+ // start receiver thread
+ if (recv_task_->activate () != 0)
+ {
+ error.error_code_ = FAPIA_ERROR_COMMUNICATION;
+ error.reason_ = "could not execute receiver thread.";
+ FAPIA_DEBUG (LM_ERROR, error.reason_.c_str ());
+ return -1;
+ }
+
+ // retrieve socket address and synchronize with acceptor
+ physical_object_address = recv_task_->listen_addr ();
+
+ // create SenderService
+ send_task_ = new SenderService ();
+ if (send_task_ == NULL)
+ {
+ error.error_code_ = FAPIA_ERROR_COMMUNICATION;
+ error.reason_ = "could not initialize sender.";
+ FAPIA_DEBUG (LM_ALERT, error.reason_.c_str ());
+
+ FAPIA_DEBUG (LM_NOTICE,
+ "shutting down receiver thread");
+ recv_task_->shutdown ();
+ recv_task_->wait ();
+
+ return -1;
+ }
+
+ // pass queues to the task
+ send_task_->receive_queue (init.receive_queue_);
+ send_task_->send_queue (init.send_queue_);
+
+ // start sender service thread
+ if (send_task_->activate () != 0)
+ {
+ error.error_code_ = FAPIA_ERROR_COMMUNICATION;
+ error.reason_ = "could not execute sender thread.";
+ FAPIA_DEBUG (LM_ERROR, error.reason_.c_str ());
+
+ FAPIA_DEBUG (LM_NOTICE,
+ "shutting down receiver thread");
+ recv_task_->shutdown ();
+ recv_task_->wait ();
+
+ return -1;
+ }
+
+ return 0;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ int ParameterImplementation::deinit (void)
+ {
+ FAPIA_TRACE;
+
+ // check if queues are set
+ if ((send_task_ == NULL) ||
+ (recv_task_ == NULL))
+ {
+ FAPIA_DEBUG (LM_ERROR,
+ "deinit() called without calling init() before.");
+ return -1;
+ }
+
+ // stop sender task
+ FAPIA_DEBUG (LM_NOTICE, "shutting down sender service.");
+
+ send_task_->shutdown ();
+// send_task_->close ();
+
+ delete send_task_;
+ send_task_ = NULL;
+
+ // stop receiver task
+ FAPIA_DEBUG (LM_NOTICE, "shutting down receiver service.");
+
+ recv_task_->shutdown ();
+
+ delete recv_task_;
+ recv_task_ = NULL;
+
+ return 0;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ ParameterImplementation::ParameterImplementation ( \
+ const ParameterImplementation&)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+ const ParameterImplementation& ParameterImplementation:: \
+ operator= (const ParameterImplementation&)
+ {
+ return *this;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterInfo.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterInfo.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,204 @@
+// $Id$
+
+
+#include "FAPIAIPCParameterInfo.h"
+#include "FAPIATrace.h"
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+/*---------------------------------------------------------------------------*/
+
+ Info::Info (void)
+ {
+ open ();
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ Info::Info (const Info& info)
+ {
+ open ();
+ copy (info);
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ const Info& Info::operator= (const Info& info)
+ {
+ if (this != &info)
+ {
+ close ();
+ copy (info);
+ }
+
+ return *this;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ Info::~Info (void)
+ {
+ close ();
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ bool Info::operator!= (const Info& info) const
+ {
+
+ if (this->min_value_)
+ {
+ if (info.min_value_ == 0)
+ {
+ return false;
+ }
+
+ if (ACE_OS::memcmp (
+ this->min_value_,
+ info.min_value_,
+ info.data_len_) == 0)
+ {
+ return false;
+ }
+ }
+ else if (info.min_value_)
+ {
+ return false;
+ }
+
+ if (this->max_value_)
+ {
+ if (info.max_value_ == 0)
+ {
+ return false;
+ }
+
+ if (ACE_OS::memcmp (
+ this->max_value_,
+ info.max_value_,
+ info.data_len_) == 0)
+ {
+ return false;
+ }
+ }
+ else if (info.max_value_)
+ {
+ return false;
+ }
+
+ return ((this->data_type_ != info.data_type_) ||
+ (this->data_len_ != info.data_len_) ||
+ (this->access_rights_ != info.access_rights_) ||
+ (this->unit_.compare (info.unit_) != 0) ||
+ (this->exponent_ != info.exponent_) ||
+ (this->factor_ != info.factor_) ||
+ (this->description_.compare (info.description_) != 0)
+ );
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ void Info::open (void)
+ {
+ this->data_type_ = FAPIA_DATA_TYPE_UNS08;
+ this->data_len_ = 0;
+ this->min_value_ = 0;
+ this->max_value_ = 0;
+ this->access_rights_ = FAPIA_ACCESS_RIGHTS_READWRITE;
+ this->unit_ = ACE_CString ();
+ this->exponent_ = 0;
+ this->factor_ = 1;
+ this->description_ = ACE_CString ();
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ void Info::copy (const Info& info)
+ {
+ this->data_len_ = info.data_len_;
+ this->data_type_ = info.data_type_;
+
+ if (info.min_value_)
+ {
+ // allocate memory for the min_value.
+ ACE_NEW_NORETURN (this->min_value_, char[info.data_len_]);
+ if (this->min_value_ == NULL)
+ {
+ FAPIA_DEBUG (LM_CRITICAL,
+ "insufficient memory for heap allocation");
+ return;
+ }
+
+ // copy content
+ ACE_OS::memcpy (this->min_value_,
+ info.min_value_,
+ info.data_len_);
+ }
+ else
+ {
+ this->min_value_ = 0;
+ }
+
+ if (info.max_value_)
+ {
+ // allocate memory for the max_value.
+ ACE_NEW_NORETURN (this->max_value_, char[info.data_len_]);
+ if (this->max_value_ == NULL)
+ {
+ FAPIA_DEBUG (LM_CRITICAL,
+ "insufficient memory for heap allocation");
+ return;
+ }
+
+ // copy content
+ ACE_OS::memcpy (this->max_value_,
+ info.max_value_,
+ info.data_len_);
+ }
+ else
+ {
+ this->max_value_ = 0;
+ }
+
+ this->access_rights_ = info.access_rights_;
+ this->unit_ = info.unit_;
+ this->exponent_ = info.exponent_;
+ this->factor_ = info.factor_;
+ this->description_ = info.description_;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ void Info::close (void)
+ {
+ this->data_type_ = FAPIA_DATA_TYPE_UNS08;
+ this->data_len_ = 0;
+
+ if (this->min_value_)
+ {
+ delete [] (char*) this->min_value_;
+ this->min_value_ = 0;
+ }
+ if (this->max_value_)
+ {
+ delete [] (char*) this->max_value_;
+ this->max_value_ = 0;
+ }
+ this->access_rights_ = FAPIA_ACCESS_RIGHTS_READWRITE;
+ this->exponent_ = 0;
+ this->factor_ = 1;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterInit.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterInit.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,80 @@
+// $Id$
+
+
+#include "FAPIAIPCParameterInit.h"
+
+#include <ace/Activation_Queue.h>
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+/*---------------------------------------------------------------------------*/
+
+ Init::Init (void)
+ {
+ open ();
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ Init::Init (const Init& init)
+ {
+ open ();
+ copy (init);
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ const Init& Init::operator= (const Init& init)
+ {
+ if (this != &init)
+ {
+ copy (init);
+ }
+
+ return *this;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ Init::~Init (void)
+ {
+ close ();
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ void Init::open (void)
+ {
+ this->send_queue_ = NULL;
+ this->receive_queue_ = NULL;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ void Init::copy (const Init& init)
+ {
+ this->send_queue_ = init.send_queue_;
+ this->receive_queue_ = init.receive_queue_;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ void Init::close (void)
+ {
+ this->send_queue_ = NULL;
+ this->receive_queue_ = NULL;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMarshalling.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMarshalling.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,879 @@
+// $Id$
+
+#include "FAPIAIPCParameterMarshalling.h"
+
+#include <ace/CDR_Stream.h>
+
+/*---------------------------------------------------------------------------*/
+
+unsigned long operator+= (unsigned long& ul,
+ const FAPI::Acyclic::IPC::Parameter::Parameter &p)
+ {
+ return ul += ACE_CDR::LONG_SIZE + p.parameter_name_.length () + 1;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+int operator<< (ACE_OutputCDR &cdr,
+ const FAPI::Acyclic::IPC::Parameter::Parameter ¶meter)
+{
+ // insert the <parameter> fields into the output CDR stream
+ return cdr.write_string (parameter.parameter_name_);
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator>> (ACE_InputCDR &cdr,
+ FAPI::Acyclic::IPC::Parameter::Parameter ¶meter)
+{
+ // extract all fields from the input CDR stream into <parameter>.
+ return cdr.read_string (parameter.parameter_name_);
+}
+
+/*---------------------------------------------------------------------------*/
+
+unsigned long operator+= (unsigned long& ul,
+ const FAPI::Acyclic::IPC::Parameter::Parameters &p)
+{
+ ul += ACE_CDR::LONG_SIZE;
+
+ for (size_t i = 0; i < p.size (); i++)
+ {
+ ul += p[i];
+ }
+
+ return ul += ACE_CDR::MAX_ALIGNMENT;
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator<< (ACE_OutputCDR &cdr,
+ const FAPI::Acyclic::IPC::Parameter::Parameters ¶meters)
+{
+ ACE_CDR::ULong parameter_count = parameters.size ();
+
+ // insert all elements of the parameter vector into the output CDR stream
+ cdr << parameter_count;
+
+ for (size_t parameter_index = 0;
+ parameter_index < parameter_count;
+ parameter_index++)
+ {
+ cdr << parameters[parameter_index];
+ }
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator>> (ACE_InputCDR &cdr,
+ FAPI::Acyclic::IPC::Parameter::Parameters ¶meters)
+{
+ ACE_CDR::ULong parameter_count;
+
+ // extract all elements from the input CDR stream to the parameter vector
+ if (cdr >> parameter_count)
+ {
+ FAPI::Acyclic::IPC::Parameter::Parameter parameter;
+ for (size_t parameter_index = 0;
+ parameter_index < parameter_count;
+ parameter_index++)
+ {
+ if (cdr >> parameter)
+ {
+ parameters.push_back (parameter);
+ }
+ else break;
+ }
+ }
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+unsigned long operator+= (unsigned long &ul,
+ const FAPI::Acyclic::IPC::Parameter::Communication &c)
+{
+ // transaction id + boolean + strlen field
+ ul += c.communication_error_;
+ return ul += ACE_CDR::LONG_SIZE * 4 +
+ c.logical_object_name_.length () + 1 + //+ string
+ c.source_physical_object_name_.length () + 1 + //+ string
+ ACE_CDR::MAX_ALIGNMENT;
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator<< (ACE_OutputCDR &cdr,
+ const FAPI::Acyclic::IPC::Parameter::Communication &comm)
+{
+ // insert the <comm> fields into the output CDR stream
+
+ cdr << ACE_CDR::ULong (comm.transaction_id_);
+
+ ACE_OutputCDR::from_boolean send_reply_fb(comm.send_reply_);
+ cdr << send_reply_fb;
+
+ cdr.write_string (comm.logical_object_name_);
+ cdr.write_string (comm.source_physical_object_name_);
+
+ cdr << comm.communication_error_;
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator>> (ACE_InputCDR &cdr,
+ FAPI::Acyclic::IPC::Parameter::Communication &comm)
+{
+ // extract all fields from the input CDR stream into <comm>.
+
+ ACE_CDR::ULong transaction_id;
+ ACE_CDR::Boolean send_reply;
+ ACE_InputCDR::to_boolean send_reply_tb(send_reply);
+
+ if ((cdr >> transaction_id) && (cdr >> send_reply_tb) &&
+ (cdr.read_string (comm.logical_object_name_)) &&
+ (cdr.read_string (comm.source_physical_object_name_)) &&
+ (cdr >> comm.communication_error_))
+ {
+ comm.transaction_id_ = transaction_id;
+ comm.send_reply_ = (send_reply ? true : false);
+ }
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+unsigned long operator+= (unsigned long &ul,
+ const FAPI::Acyclic::IPC::Parameter::Value &v)
+{
+ return ul += ACE_CDR::LONG_SIZE * 2 +
+ v.data_len () + 1 +
+ ACE_CDR::OCTET_ALIGN;
+}
+
+/*---------------------------------------------------------------------------*/
+
+
+int operator<< (ACE_OutputCDR &cdr,
+ const FAPI::Acyclic::IPC::Parameter::Value &value)
+{
+ size_t data_len = value.data_len ();
+
+ // insert the <value> fields into the output CDR stream
+ cdr << ACE_CDR::ULong (value.data_type_);
+ cdr << ACE_CDR::ULong (data_len);
+
+ cdr.write_octet_array (ACE_static_cast (const ACE_CDR::Octet*,
+ value.data_value () ),
+ data_len);
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator>> (ACE_InputCDR &cdr,
+ FAPI::Acyclic::IPC::Parameter::Value &value)
+{
+ ACE_CDR::ULong data_type;
+ ACE_CDR::ULong data_len;
+ ACE_CDR::Octet* data_value;
+
+ // extract all fields from the input CDR stream into <value>.
+ if ((cdr >> data_type) &&
+ (cdr >> data_len) )
+ {
+ ACE_NEW_RETURN (data_value, ACE_CDR::Octet[data_len], 0);
+
+ if (cdr.read_octet_array (data_value, data_len))
+ {
+ value.data_type_ = ACE_static_cast (FAPIADataType, data_type);
+ value.data_value (data_value, data_len);
+ }
+
+ delete[] data_value;
+ }
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+unsigned long operator+= (unsigned long &ul,
+ const FAPI::Acyclic::IPC::Parameter::Values &v)
+{
+ ul += ACE_CDR::LONG_SIZE;
+
+ for (size_t i = 0; i < v.size (); i++)
+ {
+ ul += v[i];
+ }
+
+ return ul += ACE_CDR::MAX_ALIGNMENT;
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator<< (ACE_OutputCDR &cdr,
+ const FAPI::Acyclic::IPC::Parameter::Values &values)
+{
+ ACE_CDR::ULong value_count = values.size ();
+
+ // insert all elements of the value vector into the output CDR stream
+ cdr << value_count;
+
+ for (size_t value_index = 0;
+ value_index < value_count;
+ value_index++)
+ {
+ cdr << values[value_index];
+ }
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator>> (ACE_InputCDR &cdr,
+ FAPI::Acyclic::IPC::Parameter::Values &values)
+{
+ ACE_CDR::ULong value_count;
+
+ // extract all elements from the input CDR stream to the value vector
+ if (cdr >> value_count)
+ {
+ FAPI::Acyclic::IPC::Parameter::Value value;
+ for (size_t value_index = 0;
+ value_index < value_count;
+ value_index++)
+ {
+ if (cdr >> value)
+ {
+ values.push_back (value);
+ }
+ else break;
+ }
+ }
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+unsigned long operator+= (unsigned long &ul,
+ const FAPI::Acyclic::IPC::Parameter::Info &v)
+{
+ return ul += ACE_CDR::LONG_SIZE +
+ ACE_CDR::LONG_SIZE +
+ v.data_len_ + 1 + ACE_CDR::OCTET_ALIGN +
+ v.data_len_ + 1 + ACE_CDR::OCTET_ALIGN +
+ ACE_CDR::LONG_SIZE +
+ ACE_CDR::LONG_SIZE + v.unit_.length () + 1 +
+ ACE_CDR::LONG_SIZE +
+ ACE_CDR::LONG_SIZE +
+ ACE_CDR::LONG_SIZE + v.description_.length () + 1 +
+ ACE_CDR::MAX_ALIGNMENT;
+}
+
+/*---------------------------------------------------------------------------*/
+
+
+int operator<< (ACE_OutputCDR &cdr,
+ const FAPI::Acyclic::IPC::Parameter::Info &info)
+{
+ // insert the <info> fields into the output CDR stream
+ cdr << ACE_CDR::ULong (info.data_type_);
+ cdr << ACE_CDR::ULong (info.data_len_);
+ if (info.min_value_)
+ {
+ cdr << ACE_CDR::ULong (info.data_len_);
+ cdr.write_octet_array (ACE_static_cast (const ACE_CDR::Octet*,
+ info.min_value_),
+ info.data_len_);
+ }
+ else
+ {
+ cdr << ACE_CDR::ULong (0);
+ }
+ if (info.max_value_)
+ {
+ cdr << ACE_CDR::ULong (info.data_len_);
+ cdr.write_octet_array (ACE_static_cast (const ACE_CDR::Octet*,
+ info.max_value_),
+ info.data_len_);
+ }
+ else
+ {
+ cdr << ACE_CDR::ULong (0);
+ }
+ cdr << ACE_CDR::ULong (info.access_rights_);
+ cdr.write_string (info.unit_);
+ cdr << ACE_CDR::Long (info.exponent_);
+ cdr << ACE_CDR::Long (info.factor_);
+ cdr.write_string (info.description_);
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator>> (ACE_InputCDR &cdr,
+ FAPI::Acyclic::IPC::Parameter::Info &info)
+{
+ ACE_CDR::ULong data_type;
+ ACE_CDR::ULong data_len;
+ ACE_CDR::ULong min_value_len;
+ ACE_CDR::ULong max_value_len;
+ ACE_CDR::Octet* min_value = 0;
+ ACE_CDR::Octet* max_value = 0;
+ ACE_CDR::ULong access_rights;
+ ACE_CDR::Long exponent;
+ ACE_CDR::Long factor;
+
+ bool data_read = true;
+
+ // extract all fields from the input CDR stream into <info>.
+ cdr >> data_type;
+ cdr >> data_len;
+ cdr >> min_value_len;
+ if (min_value_len > 0)
+ {
+ ACE_NEW_RETURN (min_value, ACE_CDR::Octet[min_value_len], 0);
+
+ if (!cdr.read_octet_array (min_value, min_value_len))
+ {
+ data_read = false;
+ }
+ if (min_value_len != data_len)
+ {
+ data_read = false;
+ }
+
+ ACE_NEW_RETURN (info.min_value_, char [min_value_len], 0);
+ ACE_OS::memcpy (info.min_value_, min_value, min_value_len);
+
+ delete[] min_value;
+ min_value = 0;
+ }
+ else
+ {
+ info.min_value_ = 0;
+ }
+ cdr >> max_value_len;
+ if (max_value_len > 0)
+ {
+ ACE_NEW_RETURN (max_value, ACE_CDR::Octet[max_value_len], 0);
+
+ if (!cdr.read_octet_array (max_value, max_value_len))
+ {
+ data_read = false;
+ }
+ if (max_value_len != data_len)
+ {
+ data_read = false;
+ }
+
+ ACE_NEW_RETURN (info.max_value_, char [max_value_len], 0);
+ ACE_OS::memcpy (info.max_value_, max_value, max_value_len);
+
+ delete[] max_value;
+ max_value = 0;
+ }
+ else
+ {
+ info.max_value_ = 0;
+ }
+ cdr >> access_rights;
+ cdr.read_string (info.unit_);
+ cdr >> exponent;
+ cdr >> factor;
+ cdr.read_string (info.description_);
+
+ if (!data_read)
+ {
+ return 0;
+ }
+
+ info.data_type_ = ACE_static_cast (FAPIADataType, data_type);
+ info.data_len_ = data_len;
+ info.access_rights_ = ACE_static_cast (FAPIAAccessRights, access_rights);
+ info.exponent_ = exponent;
+ info.factor_ = factor;
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+unsigned long operator+= (unsigned long &ul,
+ const FAPI::Acyclic::IPC::Parameter::Infos &v)
+{
+ ul += ACE_CDR::LONG_SIZE;
+
+ for (size_t i = 0; i < v.size (); i++)
+ {
+ ul += v[i];
+ }
+
+ return ul += ACE_CDR::MAX_ALIGNMENT;
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator<< (ACE_OutputCDR &cdr,
+ const FAPI::Acyclic::IPC::Parameter::Infos &infos)
+{
+ ACE_CDR::ULong info_count = infos.size ();
+
+ // insert all elements of the info vector into the output CDR stream
+ cdr << info_count;
+
+ for (size_t info_index = 0;
+ info_index < info_count;
+ info_index++)
+ {
+ cdr << infos[info_index];
+ }
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator>> (ACE_InputCDR &cdr,
+ FAPI::Acyclic::IPC::Parameter::Infos &infos)
+{
+ ACE_CDR::ULong info_count;
+
+ // extract all elements from the input CDR stream to the info vector
+ if (cdr >> info_count)
+ {
+ FAPI::Acyclic::IPC::Parameter::Info info;
+ for (size_t info_index = 0;
+ info_index < info_count;
+ info_index++)
+ {
+ if (cdr >> info)
+ {
+ infos.push_back (info);
+ }
+ else break;
+ }
+ }
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+unsigned long operator+= (unsigned long &ul,
+ const FAPI::Acyclic::IPC::Parameter::Error &e)
+{
+ return ul += ACE_CDR::LONG_SIZE +
+ ACE_CDR::LONG_SIZE + e.reason_.length () +1;
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator<< (ACE_OutputCDR &cdr,
+ const FAPI::Acyclic::IPC::Parameter::Error &error)
+{
+ // insert the <value> fields into the output CDR stream
+
+ cdr << ACE_CDR::ULong (error.error_code_);
+ cdr.write_string (error.reason_);
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator>> (ACE_InputCDR &cdr,
+ FAPI::Acyclic::IPC::Parameter::Error &error)
+{
+ ACE_CDR::ULong error_code;
+
+ // extract all fields from the input CDR stream into <error>.
+ if ((cdr >> error_code) && (cdr.read_string (error.reason_)))
+ {
+ error.error_code_ = ACE_static_cast (FAPIAErrorCode, error_code);
+ }
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+unsigned long operator+= (unsigned long &ul,
+ const FAPI::Acyclic::IPC::Parameter::Errors &e)
+{
+ ul += ACE_CDR::LONG_SIZE;
+
+ for (size_t i = 0; i < e.size (); i++)
+ {
+ ul += e[i];
+ }
+
+ return ul += ACE_CDR::MAX_ALIGNMENT;
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator<< (ACE_OutputCDR &cdr,
+ const FAPI::Acyclic::IPC::Parameter::Errors &errors)
+{
+ ACE_CDR::ULong error_count = errors.size ();
+
+ // insert all elements of the error vector into the output CDR stream
+ cdr << error_count;
+
+ for (size_t error_index = 0;
+ error_index < error_count;
+ error_index++)
+ {
+ cdr << errors[error_index];
+ }
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator>> (ACE_InputCDR &cdr,
+ FAPI::Acyclic::IPC::Parameter::Errors &errors)
+{
+ ACE_CDR::ULong error_count;
+
+ // extract all elements from the input CDR stream to the error vector
+ if (cdr >> error_count)
+ {
+ FAPI::Acyclic::IPC::Parameter::Error error;
+ for (size_t error_index = 0;
+ error_index < error_count;
+ error_index++)
+ {
+ if (cdr >> error)
+ {
+ errors.push_back (error);
+ }
+ else break;
+ }
+ }
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+unsigned long operator+= (unsigned long &ul,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestReadRequest &rr)
+{
+ ul += rr.parameters_;
+ ul += rr.communication_;
+ return ul += ACE_CDR::LONG_SIZE +
+ ACE_CDR::LONG_SIZE + rr.destination_physical_object_address_.length ()
+ +1;
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator<< (ACE_OutputCDR &cdr,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestReadRequest &read_request)
+{
+ // insert the <read_request> fields into the output CDR stream
+
+ cdr.write_string (read_request.destination_physical_object_address_);
+ cdr << ACE_CDR::ULong (read_request.priority ());
+ cdr << read_request.communication_;
+ cdr << read_request.parameters_;
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator>> (ACE_InputCDR &cdr,
+ FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestReadRequest &read_request)
+{
+ ACE_CDR::ULong priority;
+
+ // extract all fields from the input CDR stream into <error>.
+ if ((cdr.read_string (read_request.destination_physical_object_address_)) &&
+ (cdr >> priority) && (cdr >> read_request.communication_) &&
+ (cdr >> read_request.parameters_))
+ {
+ read_request.priority (priority);
+ }
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+unsigned long operator+= (unsigned long &ul,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestReadResponse &rr)
+{
+ ul += rr.communication_;
+ ul += rr.parameters_;
+ ul += rr.values_;
+ ul += rr.errors_;
+ return ul += ACE_CDR::LONG_SIZE +
+ ACE_CDR::LONG_SIZE + rr.destination_physical_object_address_.length () + 1;
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator<< (ACE_OutputCDR &cdr,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestReadResponse &read_response)
+{
+ // insert the <read_response> fields into the output CDR stream
+
+ cdr.write_string (read_response.destination_physical_object_address_);
+ cdr << ACE_CDR::ULong (read_response.priority ());
+ cdr << read_response.communication_;
+ cdr << read_response.parameters_;
+ cdr << read_response.values_;
+ cdr << read_response.errors_;
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator>> (ACE_InputCDR &cdr,
+ FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestReadResponse &read_response)
+{
+ ACE_CDR::ULong priority;
+
+ // extract all fields from the input CDR stream into <read_response>.
+ if ((cdr.read_string (read_response.destination_physical_object_address_)) &&
+ (cdr >> priority) && (cdr >> read_response.communication_) &&
+ (cdr >> read_response.parameters_) &&
+ (cdr >> read_response.values_) &&
+ (cdr >> read_response.errors_))
+ {
+ read_response.priority (priority);
+ }
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+unsigned long operator+= (unsigned long &ul,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestWriteRequest &wr)
+{
+ ul += wr.communication_;
+ ul += wr.parameters_;
+ ul += wr.values_;
+ return ul += ACE_CDR::LONG_SIZE +
+ ACE_CDR::LONG_SIZE +
+ wr.destination_physical_object_address_.length () + 1;
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator<< (ACE_OutputCDR &cdr,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestWriteRequest &write_request)
+{
+ // insert the <write_request> fields into the output CDR stream
+
+ cdr.write_string (write_request.destination_physical_object_address_);
+ cdr << ACE_CDR::ULong (write_request.priority ());
+ cdr << write_request.communication_;
+ cdr << write_request.parameters_;
+ cdr << write_request.values_;
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator>> (ACE_InputCDR &cdr,
+ FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestWriteRequest &write_request)
+{
+ ACE_CDR::ULong priority;
+
+ // extract all fields from the input CDR stream into <write_request>.
+ if ((cdr.read_string (write_request.destination_physical_object_address_)) &&
+ (cdr >> priority) && (cdr >> write_request.communication_) &&
+ (cdr >> write_request.parameters_) &&
+ (cdr >> write_request.values_))
+ {
+ write_request.priority (priority);
+ }
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+unsigned long operator+= (unsigned long& ul,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestWriteResponse &wr)
+{
+ ul += wr.communication_;
+ ul += wr.parameters_;
+ ul += wr.errors_;
+ return ul += ACE_CDR::LONG_SIZE +
+ ACE_CDR::LONG_SIZE +
+ wr.destination_physical_object_address_.length () + 1;
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator<< (ACE_OutputCDR &cdr,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestWriteResponse &write_response)
+{
+ // insert the <write_response> fields into the output CDR stream
+
+ cdr.write_string (write_response.destination_physical_object_address_);
+ cdr << ACE_CDR::ULong (write_response.priority ());
+ cdr << write_response.communication_;
+ cdr << write_response.parameters_;
+ cdr << write_response.errors_;
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator>> (ACE_InputCDR &cdr,
+ FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestWriteResponse &write_response)
+{
+ ACE_CDR::ULong priority;
+
+ // extract all fields from the input CDR stream into <write_response>.
+ if ((cdr.read_string (write_response.destination_physical_object_address_))
+ && (cdr >> priority) &&
+ (cdr >> write_response.communication_) &&
+ (cdr >> write_response.parameters_) &&
+ (cdr >> write_response.errors_))
+ {
+ write_response.priority (priority);
+ }
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+unsigned long operator+= (unsigned long &ul,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestInfoRequest &wr)
+{
+ ul += wr.communication_;
+ ul += wr.parameters_;
+ return ul += ACE_CDR::LONG_SIZE +
+ ACE_CDR::LONG_SIZE +
+ wr.destination_physical_object_address_.length () + 1;
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator<< (ACE_OutputCDR &cdr,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestInfoRequest &info_request)
+{
+ // insert the <info_request> fields into the output CDR stream
+
+ cdr.write_string (info_request.destination_physical_object_address_);
+ cdr << ACE_CDR::ULong (info_request.priority ());
+ cdr << info_request.communication_;
+ cdr << info_request.parameters_;
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator>> (ACE_InputCDR &cdr,
+ FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestInfoRequest &info_request)
+{
+ ACE_CDR::ULong priority;
+
+ // extract all fields from the input CDR stream into <info_request>.
+ if ((cdr.read_string (info_request.destination_physical_object_address_)) &&
+ (cdr >> priority) && (cdr >> info_request.communication_) &&
+ (cdr >> info_request.parameters_))
+ {
+ info_request.priority (priority);
+ }
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+unsigned long operator+= (unsigned long& ul,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestInfoResponse &wr)
+{
+ ul += wr.communication_;
+ ul += wr.parameters_;
+ ul += wr.infos_;
+ ul += wr.errors_;
+ return ul += ACE_CDR::LONG_SIZE +
+ ACE_CDR::LONG_SIZE +
+ wr.destination_physical_object_address_.length () + 1;
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator<< (ACE_OutputCDR &cdr,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestInfoResponse &info_response)
+{
+ // insert the <info_response> fields into the output CDR stream
+
+ cdr.write_string (info_response.destination_physical_object_address_);
+ cdr << ACE_CDR::ULong (info_response.priority ());
+ cdr << info_response.communication_;
+ cdr << info_response.parameters_;
+ cdr << info_response.infos_;
+ cdr << info_response.errors_;
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
+
+int operator>> (ACE_InputCDR &cdr,
+ FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestInfoResponse &info_response)
+{
+ ACE_CDR::ULong priority;
+
+ // extract all fields from the input CDR stream into <info_response>.
+ if ((cdr.read_string (info_response.destination_physical_object_address_))
+ && (cdr >> priority) &&
+ (cdr >> info_response.communication_) &&
+ (cdr >> info_response.parameters_) &&
+ (cdr >> info_response.infos_) &&
+ (cdr >> info_response.errors_))
+ {
+ info_response.priority (priority);
+ }
+
+ return cdr.good_bit ();
+}
+
+/*---------------------------------------------------------------------------*/
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMarshalling.h
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMarshalling.h Thu Jul 19 07:15:27 2007
@@ -0,0 +1,376 @@
+/* -*- C -*- */
+
+//=============================================================================
+/**
+ * @file FAPIAMarshalling.h
+ *
+ * $Id$
+ *
+ * @author Friedhelm Wolf <friedhelm.wolf at homag.de>
+ */
+//=============================================================================
+
+
+#ifndef _FAPI_ACYCLIC_PARAMETER_MARSHALLING_H_
+#define _FAPI_ACYCLIC_PARAMETER_MARSHALLING_H_
+
+
+#include <FAPIAIPCParameter/interface/FAPIAIPCParameterParameter.h>
+#include <FAPIAIPCParameter/interface/FAPIAIPCParameterCommunication.h>
+#include <FAPIAIPCParameter/interface/FAPIAIPCParameterInfo.h>
+#include <FAPIAIPCParameter/interface/FAPIAIPCParameterValue.h>
+#include <FAPIAIPCParameter/interface/FAPIAIPCParameterError.h>
+
+#include \
+ <FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestReadRequest.h>
+#include \
+ <FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestReadResponse.h>
+#include \
+ <FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestWriteRequest.h>
+#include \
+ <FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestWriteResponse.h>
+
+#include \
+ <FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestInfoRequest.h>
+#include \
+ <FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestInfoResponse.h>
+
+// forward declarations
+
+class ACE_OutputCDR;
+class ACE_InputCDR;
+
+// size of an internal FAPIA socket data header
+#define FAPIA_HEADER_SIZE 12
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+ /**
+ * @brief existing types of method requests
+ */
+ enum MethodRequestType
+ {
+ FAPIA_UNKNOWN_REQUEST =0,
+ FAPIA_READ_REQUEST = 1,
+ FAPIA_READ_RESPONSE = 2,
+ FAPIA_WRITE_REQUEST = 3,
+ FAPIA_WRITE_RESPONSE = 4,
+ FAPIA_INFO_REQUEST = 5,
+ FAPIA_INFO_RESPONSE = 6
+ };
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
+
+/**
+ * @brief evaluates the size of the content of a Parameter class
+ */
+unsigned long operator+= (unsigned long&,
+ const FAPI::Acyclic::IPC::Parameter::Parameter &);
+
+/**
+ * @brief ACE CDR extraction operator for the Parameter class
+ */
+int operator<< (ACE_OutputCDR &,
+ const FAPI::Acyclic::IPC::Parameter::Parameter &);
+
+/**
+ * @brief ACE CDR insertion operator for the Parameter class
+ */
+int operator>> (ACE_InputCDR &,
+ FAPI::Acyclic::IPC::Parameter::Parameter &);
+
+
+/**
+ * @brief evaluates the size of the content of a Parameters vector
+ */
+unsigned long operator+= (unsigned long&,
+ const FAPI::Acyclic::IPC::Parameter::Parameters &);
+
+/**
+ * @brief ACE CDR extraction operator for the Parameters vector
+ */
+int operator<< (ACE_OutputCDR &,
+ const FAPI::Acyclic::IPC::Parameter::Parameters &);
+
+/**
+ * @brief ACE CDR insertion operator for the Parameters vector
+ */
+int operator>> (ACE_InputCDR &,
+ FAPI::Acyclic::IPC::Parameter::Parameters &);
+
+
+/**
+ * @brief evaluates the size of the content of a Communication class
+ */
+unsigned long operator+= (unsigned long&,
+ const FAPI::Acyclic::IPC::Parameter::Communication &);
+
+/**
+ * @brief ACE CDR extraction operator for the Communication class
+ */
+int operator<< (ACE_OutputCDR &,
+ const FAPI::Acyclic::IPC::Parameter::Communication &);
+
+/**
+ * @brief ACE CDR insertion operator for the Communication class
+ */
+int operator>> (ACE_InputCDR &,
+ FAPI::Acyclic::IPC::Parameter::Communication &);
+
+
+/**
+ * @brief evaluates the size of the content of a Value class
+ */
+unsigned long operator+= (unsigned long&,
+ const FAPI::Acyclic::IPC::Parameter::Value &);
+
+/**
+ * @brief ACE CDR extraction operator for the Value class
+ */
+int operator<< (ACE_OutputCDR &,
+ const FAPI::Acyclic::IPC::Parameter::Value &);
+
+/**
+ * @brief ACE CDR insertion operator for the Value class
+ */
+int operator>> (ACE_InputCDR &,
+ FAPI::Acyclic::IPC::Parameter::Value &);
+
+
+/**
+ * @brief evaluates the size of the content of a Values vector
+ */
+unsigned long operator+= (unsigned long&,
+ const FAPI::Acyclic::IPC::Parameter::Values &);
+
+/**
+ * @brief ACE CDR extraction operator for the Value class
+ */
+int operator<< (ACE_OutputCDR &,
+ const FAPI::Acyclic::IPC::Parameter::Values &);
+
+/**
+ * @brief ACE CDR insertion operator for the Value class
+ */
+int operator>> (ACE_InputCDR &,
+ FAPI::Acyclic::IPC::Parameter::Values &);
+
+
+/**
+ * @brief evaluates the size of the content of a Info class
+ */
+unsigned long operator+= (unsigned long&,
+ const FAPI::Acyclic::IPC::Parameter::Info &);
+
+/**
+ * @brief ACE CDR extraction operator for the Info class
+ */
+int operator<< (ACE_OutputCDR &,
+ const FAPI::Acyclic::IPC::Parameter::Info &);
+
+/**
+ * @brief ACE CDR insertion operator for the Info class
+ */
+int operator>> (ACE_InputCDR &,
+ FAPI::Acyclic::IPC::Parameter::Info &);
+
+
+/**
+ * @brief evaluates the size of the content of a Infos vector
+ */
+unsigned long operator+= (unsigned long&,
+ const FAPI::Acyclic::IPC::Parameter::Infos &);
+
+/**
+ * @brief ACE CDR extraction operator for the Info class
+ */
+int operator<< (ACE_OutputCDR &,
+ const FAPI::Acyclic::IPC::Parameter::Infos &);
+
+/**
+ * @brief ACE CDR insertion operator for the Info class
+ */
+int operator>> (ACE_InputCDR &,
+ FAPI::Acyclic::IPC::Parameter::Infos &);
+
+
+/**
+ * @brief evaluates the size of the content of a Error class
+ */
+unsigned long operator+= (unsigned long&,
+ const FAPI::Acyclic::IPC::Parameter::Error &);
+
+/**
+ * @brief ACE CDR extraction operator for the Error class
+ */
+int operator<< (ACE_OutputCDR &,
+ const FAPI::Acyclic::IPC::Parameter::Error &);
+
+/**
+ * @brief ACE CDR insertion operator for the Error class
+ */
+int operator>> (ACE_InputCDR &,
+ FAPI::Acyclic::IPC::Parameter::Error &);
+
+
+/**
+ * @brief evaluates the size of the content of a Errors vector
+ */
+unsigned long operator+= (unsigned long&,
+ const FAPI::Acyclic::IPC::Parameter::Errors &);
+
+/**
+ * @brief ACE CDR extraction operator for the Error class
+ */
+int operator<< (ACE_OutputCDR &,
+ const FAPI::Acyclic::IPC::Parameter::Errors &);
+
+/**
+ * @brief ACE CDR insertion operator for the Error class
+ */
+int operator>> (ACE_InputCDR &,
+ FAPI::Acyclic::IPC::Parameter::Errors &);
+
+
+/**
+ * @brief evaluates the size of the content of a MethodRequestReadRequest
+ * class
+ */
+unsigned long operator+= (unsigned long&,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestReadRequest &);
+
+/**
+ * @brief ACE CDR extraction operator for the MethodRequestReadRequest class
+ */
+int operator<< (ACE_OutputCDR &,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestReadRequest &);
+
+/**
+ * @brief ACE CDR insertion operator for the MethodRequestReadRequest class
+ */
+int operator>> (ACE_InputCDR &,
+ FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestReadRequest &);
+
+
+/**
+ * @brief evaluates the size of the content of a MethodRequestReadResponse
+ * class
+ */
+unsigned long operator+= (unsigned long&,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestReadResponse &);
+
+/**
+ * @brief ACE CDR extraction operator for the MethodRequestReadResponse class
+ */
+int operator<< (ACE_OutputCDR &,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestReadResponse &);
+
+/**
+ * @brief ACE CDR insertion operator for the MethodRequestReadResponse class
+ */
+int operator>> (ACE_InputCDR &,
+ FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestReadResponse &);
+
+
+/**
+ * @brief evaluates the size of the content of a MethodRequestWriteRequest
+ * class
+ */
+unsigned long operator+= (unsigned long&,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestWriteRequest &);
+
+/**
+ * @brief ACE CDR extraction operator for the MethodRequestWriteRequest class
+ */
+int operator<< (ACE_OutputCDR &,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestWriteRequest &);
+
+/**
+ * @brief ACE CDR insertion operator for the MethodRequestWriteRequest class
+ */
+int operator>> (ACE_InputCDR &,
+ FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestWriteRequest &);
+
+/**
+ * @brief evaluates the size of the content of a MethodRequestWriteResponse
+ * class
+ */
+unsigned long operator+= (unsigned long&,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestWriteResponse &);
+
+/**
+ * @brief ACE CDR extraction operator for the MethodRequestWriteResponse class.
+ */
+int operator<< (ACE_OutputCDR &,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestWriteResponse &);
+
+/**
+ * @brief ACE CDR insertion operator for the MethodRequestWriteResponse class.
+ */
+int operator>> (ACE_InputCDR &,
+ FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestWriteResponse &);
+
+/**
+ * @brief evaluates the size of the content of a MethodRequestInfoRequest
+ * class
+ */
+unsigned long operator+= (unsigned long&,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestInfoRequest &);
+
+/**
+ * @brief ACE CDR extraction operator for the MethodRequestInfoRequest class
+ */
+int operator<< (ACE_OutputCDR &,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestInfoRequest &);
+
+/**
+ * @brief ACE CDR insertion operator for the MethodRequestInfoRequest class
+ */
+int operator>> (ACE_InputCDR &,
+ FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestInfoRequest &);
+
+/**
+ * @brief evaluates the size of the content of a MethodRequestInfoResponse
+ * class
+ */
+unsigned long operator+= (unsigned long&,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestInfoResponse &);
+
+/**
+ * @brief ACE CDR extraction operator for the MethodRequestInfoResponse class.
+ */
+int operator<< (ACE_OutputCDR &,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestInfoResponse &);
+
+/**
+ * @brief ACE CDR insertion operator for the MethodRequestInfoResponse class.
+ */
+int operator>> (ACE_InputCDR &,
+ FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestInfoResponse &);
+#endif /* _FAPI_ACYCLIC_PARAMETER_MARSHALLING_H_ */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequest.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequest.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,33 @@
+// $Id$
+
+
+#include "FAPIAIPCParameterMethodRequest.h"
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequest::MethodRequest (unsigned long priority)
+ : ACE_Method_Request (priority)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequest::~MethodRequest (void)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestFinish.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestFinish.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,56 @@
+// $Id$
+
+
+#include "FAPIAIPCParameterMethodRequestFinish.h"
+
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestFinish::MethodRequestFinish (void)
+ : MethodRequest (FAPIA_COMMUNICATION_PRIORITY_MAX)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestFinish::~MethodRequestFinish (void)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ int MethodRequestFinish::call (void)
+ {
+ return -1;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestFinish::MethodRequestFinish ( \
+ const MethodRequestFinish&)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ const MethodRequestFinish& MethodRequestFinish \
+ ::operator= (const MethodRequestFinish&)
+ {
+ return *this;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestFinish.h
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestFinish.h Thu Jul 19 07:15:27 2007
@@ -0,0 +1,86 @@
+/* -*- C++ -*- */
+
+//=============================================================================
+/**
+ * @file FAPIAIPCParameterMethodRequestFinish.h
+ *
+ * $Id$
+ *
+ * @author Thomas Rothfuss <thomas.rothfuss at homag.de>
+ */
+//=============================================================================
+
+#ifndef _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_FINISH_H_
+#define _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_FINISH_H_
+
+#include "FAPIAIPCParameterMethodRequest.h"
+
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+ /**
+ * @class MethodRequestFinish
+ *
+ * @brief The MethodRequestFinish is the class for a read
+ * operation request.
+ *
+ */
+ class MethodRequestFinish :
+ public FAPI::Acyclic::IPC::Parameter::MethodRequest
+ {
+
+ public:
+ /**
+ * @brief Constructor of MethodRequestFinish.
+ *
+ */
+ MethodRequestFinish (void);
+
+ /**
+ * @brief Destructor of MethodRequestFinish.
+ *
+ */
+ virtual ~MethodRequestFinish (void);
+
+ /**
+ * @brief Invoked when the MethodRequestFinish is
+ * scheduled to run.
+ *
+ * If it returns -1 the receiving thread of this message
+ * must shut down.
+ *
+ */
+ virtual int call (void);
+
+ protected:
+
+ private:
+ /**
+ * @brief Copy Constructor is private, so this object
+ * cannot be copied.
+ *
+ */
+ MethodRequestFinish (const MethodRequestFinish&);
+
+ /**
+ * @brief Assignment operator is private, so this object
+ * cannot be copied.
+ *
+ */
+ const MethodRequestFinish& operator= ( \
+ const MethodRequestFinish&);
+
+ }; /* class MethodRequestFinish */
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
+
+#endif /* _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_FINISH_H_ */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestInfoRequest.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestInfoRequest.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,69 @@
+// $Id$
+
+
+#include "FAPIAIPCParameterMethodRequestInfoRequest.h"
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestInfoRequest::MethodRequestInfoRequest (void)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestInfoRequest::~MethodRequestInfoRequest (void)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ bool MethodRequestInfoRequest::operator!= (
+ const MethodRequestInfoRequest& request) const
+ {
+ return ((this->priority_ != request.priority_) ||
+ (this->communication_ != request.communication_) ||
+ (this->parameters_ != request.parameters_) ||
+ (this->destination_physical_object_address_. \
+ compare (
+ request.destination_physical_object_address_
+ ) != 0)
+ );
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ int MethodRequestInfoRequest::call (void)
+ {
+ return 0;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestInfoRequest::MethodRequestInfoRequest ( \
+ const MethodRequestInfoRequest&)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ const MethodRequestInfoRequest& MethodRequestInfoRequest \
+ ::operator= (const MethodRequestInfoRequest&)
+ {
+ return *this;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestInfoResponse.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestInfoResponse.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,71 @@
+// $Id$
+
+
+#include "FAPIAIPCParameterMethodRequestInfoResponse.h"
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestInfoResponse::MethodRequestInfoResponse (void)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestInfoResponse::~MethodRequestInfoResponse (void)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ bool MethodRequestInfoResponse::operator!= (
+ const MethodRequestInfoResponse& resp) const
+ {
+ return ((this->priority_ != resp.priority_) ||
+ (this->communication_ != resp.communication_) ||
+ (this->parameters_ != resp.parameters_) ||
+ (this->infos_ != resp.infos_) ||
+ (this->errors_ != resp.errors_) ||
+ (this->destination_physical_object_address_. \
+ compare (
+ resp.destination_physical_object_address_
+ ) != 0)
+ );
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ int MethodRequestInfoResponse::call (void)
+ {
+ return 0;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestInfoResponse::MethodRequestInfoResponse ( \
+ const MethodRequestInfoResponse&)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ const MethodRequestInfoResponse& MethodRequestInfoResponse \
+ ::operator= (const MethodRequestInfoResponse&)
+ {
+ return *this;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestReadRequest.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestReadRequest.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,69 @@
+// $Id$
+
+
+#include "FAPIAIPCParameterMethodRequestReadRequest.h"
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestReadRequest::MethodRequestReadRequest (void)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestReadRequest::~MethodRequestReadRequest (void)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ bool MethodRequestReadRequest::operator!= (
+ const MethodRequestReadRequest& request) const
+ {
+ return ((this->priority_ != request.priority_) ||
+ (this->communication_ != request.communication_) ||
+ (this->parameters_ != request.parameters_) ||
+ (this->destination_physical_object_address_. \
+ compare (
+ request.destination_physical_object_address_
+ ) != 0)
+ );
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ int MethodRequestReadRequest::call (void)
+ {
+ return 0;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestReadRequest::MethodRequestReadRequest ( \
+ const MethodRequestReadRequest&)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ const MethodRequestReadRequest& MethodRequestReadRequest \
+ ::operator= (const MethodRequestReadRequest&)
+ {
+ return *this;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestReadResponse.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestReadResponse.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,71 @@
+// $Id$
+
+
+#include "FAPIAIPCParameterMethodRequestReadResponse.h"
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestReadResponse::MethodRequestReadResponse (void)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestReadResponse::~MethodRequestReadResponse (void)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ bool MethodRequestReadResponse::operator!= (
+ const MethodRequestReadResponse& resp) const
+ {
+ return ((this->priority_ != resp.priority_) ||
+ (this->communication_ != resp.communication_) ||
+ (this->parameters_ != resp.parameters_) ||
+ (this->values_ != resp.values_) ||
+ (this->errors_ != resp.errors_) ||
+ (this->destination_physical_object_address_. \
+ compare (
+ resp.destination_physical_object_address_
+ ) != 0)
+ );
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ int MethodRequestReadResponse::call (void)
+ {
+ return 0;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestReadResponse::MethodRequestReadResponse ( \
+ const MethodRequestReadResponse&)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ const MethodRequestReadResponse& MethodRequestReadResponse \
+ ::operator= (const MethodRequestReadResponse&)
+ {
+ return *this;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestWriteRequest.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestWriteRequest.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,70 @@
+// $Id$
+
+
+#include "FAPIAIPCParameterMethodRequestWriteRequest.h"
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestWriteRequest::MethodRequestWriteRequest (void)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestWriteRequest::~MethodRequestWriteRequest (void)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ bool MethodRequestWriteRequest::operator!= (
+ const MethodRequestWriteRequest& request) const
+ {
+ return ((this->priority_ != request.priority_) ||
+ (this->communication_ != request.communication_) ||
+ (this->parameters_ != request.parameters_) ||
+ (this->values_ != request.values_) ||
+ (this->destination_physical_object_address_. \
+ compare (
+ request.destination_physical_object_address_
+ ) != 0)
+ );
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ int MethodRequestWriteRequest::call (void)
+ {
+ return 0;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestWriteRequest::MethodRequestWriteRequest ( \
+ const MethodRequestWriteRequest&)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ const MethodRequestWriteRequest& MethodRequestWriteRequest \
+ ::operator= (const MethodRequestWriteRequest&)
+ {
+ return *this;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestWriteResponse.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestWriteResponse.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,70 @@
+// $Id$
+
+
+#include "FAPIAIPCParameterMethodRequestWriteResponse.h"
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestWriteResponse::MethodRequestWriteResponse (void)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestWriteResponse::~MethodRequestWriteResponse (void)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ bool MethodRequestWriteResponse::operator!= (
+ const MethodRequestWriteResponse& resp) const
+ {
+ return ((this->priority_ != resp.priority_) ||
+ (this->communication_ != resp.communication_) ||
+ (this->parameters_ != resp.parameters_) ||
+ (this->errors_ != resp.errors_) ||
+ (this->destination_physical_object_address_. \
+ compare (
+ resp.destination_physical_object_address_
+ ) != 0)
+ );
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ int MethodRequestWriteResponse::call (void)
+ {
+ return 0;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ MethodRequestWriteResponse::MethodRequestWriteResponse ( \
+ const MethodRequestWriteResponse&)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ const MethodRequestWriteResponse& MethodRequestWriteResponse \
+ ::operator= (const MethodRequestWriteResponse&)
+ {
+ return *this;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterParameter.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterParameter.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,83 @@
+// $Id$
+
+
+#include "FAPIAIPCParameterParameter.h"
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+/*---------------------------------------------------------------------------*/
+
+ Parameter::Parameter (void)
+ {
+ open ();
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ Parameter::Parameter (const Parameter& parameter)
+ {
+ open ();
+ copy (parameter);
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ const Parameter& Parameter::operator= (const Parameter& parameter)
+ {
+ if (this != ¶meter)
+ {
+ copy (parameter);
+ }
+
+ return *this;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ Parameter::~Parameter (void)
+ {
+ close ();
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ bool Parameter::operator!= (const Parameter& parameter) const
+ {
+ return ((this->parameter_name_.compare (
+ parameter.parameter_name_) != 0)
+ );
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ void Parameter::open (void)
+ {
+ this->parameter_name_ = ACE_CString ();
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ void Parameter::copy (const Parameter& parameter)
+ {
+ this->parameter_name_ = parameter.parameter_name_;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ void Parameter::close (void)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverAcceptor.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverAcceptor.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,76 @@
+// $Id$
+
+
+#include "FAPIAIPCParameterReceiverAcceptor.h"
+
+#include /**/ <ace/Activation_Queue.h>
+#include /**/ <ace/Vector_T.h>
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+/*---------------------------------------------------------------------------*/
+
+ ReceiverAcceptor::ReceiverAcceptor (ACE_Activation_Queue* q)
+ : queue_ (q)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ ReceiverAcceptor::~ReceiverAcceptor (void)
+ {
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ int ReceiverAcceptor::close (void)
+ {
+ // close all open connections
+ for (size_t i = 0; i < this->receivers_.size (); i++)
+ {
+ this->receivers_[i]->close ();
+ }
+ return this->handle_close ();
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ int ReceiverAcceptor::accept_svc_handler (ReceiverService* h)
+ {
+ h->queue (this->queue_);
+
+ int reset_new_handle =
+ this->reactor ()->uses_event_associations ();
+
+ if (this->acceptor ().accept (h->peer (), // stream
+ 0, // remote address
+ 0, // timeout
+ 1, // restart
+ reset_new_handle // reset
+ ) == -1)
+ {
+ // Close down handler to avoid memory leaks.
+ h->close (0);
+
+ return -1;
+ }
+ else
+ {
+ this->receivers_.push_back (h);
+ return 0;
+ }
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverAcceptor.h
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverAcceptor.h Thu Jul 19 07:15:27 2007
@@ -0,0 +1,88 @@
+/* -*- C++ -*- */
+
+//=============================================================================
+/**
+ * @file FAPIAIPCParameterReceiverAcceptor.h
+ *
+ * $Id$
+ *
+ * @author Friedhelm Wolf <friedhelm.wolf at homag.de>
+ */
+//=============================================================================
+
+#ifndef _FAPIA_IPC_PARAMETER_RECEIVER_ACCEPTOR_H_
+#define _FAPIA_IPC_PARAMETER_RECEIVER_ACCEPTOR_H_
+
+#include "FAPIAIPCParameterReceiverService.h"
+#include /**/ <ace/Acceptor.h>
+#include /**/ <ace/Bound_Ptr.h>
+#include /**/ <ace/Vector_T.h>
+
+#include "FAPIAIPCParameterSocket.h"
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+ typedef ACE_Strong_Bound_Ptr <ReceiverService,
+ ACE_Null_Mutex>
+ ReceiverService_Ptr;
+
+ typedef ACE_Vector <ReceiverService*> Receiver_Vector;
+
+ /**
+ * @class ReceiverAcceptor
+ *
+ * @brief Acceptor class which delegates socket communication
+ * to the ReceiverService.
+ * @sa ReceiverService
+ */
+ class ReceiverAcceptor :
+ public ACE_Acceptor<ReceiverService, FAPIA_ACCEPTOR>
+ {
+ public:
+
+ /**
+ * @brief constructor
+ * @param queue to which the ReceiverService will
+ * pass the received MethodRequests
+ */
+ ReceiverAcceptor (ACE_Activation_Queue*);
+
+ /**
+ * @brief standard destructor
+ */
+ virtual ~ReceiverAcceptor ();
+
+ /**
+ * @brief closes all open connections
+ */
+ virtual int close (void);
+
+ /**
+ * @brief implementation of the ACE_Acceptor template
+ * method for activating the service handler.
+ * It will pass the queue to the ReceiverService
+ * besides the standard behaviour
+ */
+ virtual int accept_svc_handler (ReceiverService*);
+
+ private:
+ /// input queue which will be passed to the ReceiverService
+ ACE_Activation_Queue* queue_;
+
+ Receiver_Vector receivers_;
+ };
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
+
+
+#endif /* _FAPIA_IPC_PARAMETER_RECEIVER_ACCEPTOR_H_ */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverService.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverService.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,355 @@
+// $Id$
+
+
+#include "FAPIAIPCParameterReceiverService.h"
+
+#include "FAPIATrace.h"
+#include "FAPIAIPCParameterMarshalling.h"
+#include "FAPIAIPCParameterStreaming.h"
+
+#include /**/ <ace/Activation_Queue.h>
+#include /**/ <ace/Bound_Ptr.h>
+#include /**/ <ace/CDR_Stream.h>
+
+#include <sstream>
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+/*---------------------------------------------------------------------------*/
+
+ReceiverService::ReceiverService (void)
+: queue_ (NULL)
+{
+}
+
+/*---------------------------------------------------------------------------*/
+
+ReceiverService::~ReceiverService (void)
+{
+ FAPIA_TRACE;
+}
+
+/*---------------------------------------------------------------------------*/
+
+void ReceiverService::queue (ACE_Activation_Queue* q)
+{
+ this->queue_ = q;
+}
+
+/*---------------------------------------------------------------------------*/
+
+int ReceiverService::open (void *)
+{
+ FAPIA_TRACE;
+
+ if (this->queue_ == NULL)
+ {
+ FAPIA_DEBUG (LM_ERROR, "queue not initialized.");
+ return -1;
+ }
+
+ if (this->reactor ()->register_handler (this,
+ ACE_Svc_Handler<FAPIA_STREAM, ACE_NULL_SYNCH>::READ_MASK) == 1)
+ {
+ FAPIA_DEBUG (LM_ERROR, "could not register receiver handler");
+ return -1;
+ }
+
+ return 0;
+}
+
+/*---------------------------------------------------------------------------*/
+
+int ReceiverService::handle_input (ACE_HANDLE)
+{
+ FAPIA_TRACE;
+
+ // allocate memory for the fixed size header containing the necessary
+ // data to demarshal the following method request
+ ACE_Strong_Bound_Ptr<ACE_Message_Block, ACE_Null_Mutex> header_data (
+ new ACE_Message_Block (ACE_DEFAULT_CDR_BUFSIZE));
+ ACE_CDR::mb_align (header_data.get ());
+
+ // read the data and check for correct header size
+ if (this->peer ().recv_n (header_data->wr_ptr (), FAPIA_HEADER_SIZE) ==
+ FAPIA_HEADER_SIZE)
+ {
+ // set write pointer according to read in length
+ header_data->wr_ptr (FAPIA_HEADER_SIZE);
+
+ // create a ACE CDR object to demarshall data
+ ACE_InputCDR header_cdr (header_data.get ());
+
+ // find out byte order
+ ACE_CDR::Boolean byte_order;
+ header_cdr >> ACE_InputCDR::to_boolean (byte_order);
+ header_cdr.reset_byte_order (byte_order);
+
+ // find out the length of the following data block
+ ACE_CDR::ULong data_length;
+ header_cdr >> data_length;
+
+ // find out exact type of the received method request
+ ACE_CDR::ULong method_request_val;
+ header_cdr >> method_request_val;
+ FAPI::Acyclic::IPC::Parameter::MethodRequestType method_request_type =
+ ACE_static_cast (FAPI::Acyclic::IPC::Parameter::MethodRequestType,
+ method_request_val);
+
+ // allocate data for the data part of the received telegramm
+ ACE_Strong_Bound_Ptr <ACE_Message_Block, ACE_Null_Mutex> request_data (
+ new ACE_Message_Block (data_length));
+ ACE_CDR::mb_align (request_data.get ());
+
+ // read the socket buffer
+ if (this->peer ().recv_n (request_data->wr_ptr (), data_length) ==
+ (long)data_length)
+ {
+ // prepare demarshalling
+ request_data->wr_ptr (data_length);
+ ACE_InputCDR request_cdr (request_data.get ());
+
+ // ditinguish between the different kinds of method requests
+ switch (method_request_type)
+ {
+ case FAPIA_READ_REQUEST:
+ {
+ // allocate new object to be filled with the data
+ FAPI::Acyclic::IPC::Parameter::MethodRequestReadRequest*
+ read_request = new FAPI::Acyclic::IPC::Parameter::
+ MethodRequestReadRequest;
+
+ // demarshall request
+ if (request_cdr >> *read_request)
+ {
+ std::stringstream ss;
+ if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) &
+ LM_DEBUG)
+ {
+ ss << *read_request;
+ }
+ // enqueue request into Activation_Queue
+ if (queue_->enqueue (read_request) != -1)
+ {
+ FAPIA_DEBUG (LM_DEBUG, "enqueued %s", ss.str ().c_str ());
+ }
+ else // error when enqueuing
+ {
+ FAPIA_DEBUG (LM_ERROR, "error when enqueueing ReadRequest");
+ return -1;
+ }
+ }
+ else // error of demarshalling
+ {
+ FAPIA_DEBUG (LM_ERROR, "ReadRequest was not received correctly");
+ return -1;
+ }
+
+ break;
+ } // end case FAPIA_READ_REQUEST
+ case FAPIA_READ_RESPONSE:
+ {
+ // allocate new object to be filled with the data
+ FAPI::Acyclic::IPC::Parameter::MethodRequestReadResponse*
+ read_response = new FAPI::Acyclic::IPC::Parameter::
+ MethodRequestReadResponse;
+
+ // demarshall request
+ if (request_cdr >> *read_response)
+ {
+ std::stringstream ss;
+ if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) &
+ LM_DEBUG)
+ {
+ ss << *read_response;
+ }
+ // enqueue request into Activation_Queue
+ if (queue_->enqueue (read_response) != -1)
+ {
+ FAPIA_DEBUG (LM_DEBUG, "enqueued %s", ss.str ().c_str ());
+ }
+ else // error when enqueuing
+ {
+ FAPIA_DEBUG (LM_ERROR, "error when enqueueing ReadResponse");
+ return -1;
+ }
+ }
+ else // error of demarshalling
+ {
+ FAPIA_DEBUG (LM_ERROR, "ReadResponse was not received correctly");
+ return -1;
+ }
+
+ break;
+ } // end case FAPIA_READ_RESPONSE
+ case FAPIA_WRITE_REQUEST:
+ {
+ // allocate new object to be filled with the data
+ FAPI::Acyclic::IPC::Parameter::MethodRequestWriteRequest*
+ write_request = new FAPI::Acyclic::IPC::Parameter::
+ MethodRequestWriteRequest;
+
+ // demarshall request
+ if (request_cdr >> *write_request)
+ {
+ std::stringstream ss;
+ if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) &
+ LM_DEBUG)
+ {
+ ss << *write_request;
+ }
+ // enqueue request into Activation_Queue
+ if (queue_->enqueue (write_request) != -1)
+ {
+ FAPIA_DEBUG (LM_DEBUG, "enqueued %s", ss.str ().c_str ());
+ }
+ else // error when enqueuing
+ {
+ FAPIA_DEBUG (LM_ERROR, "error when enqueueing WriteRequest");
+ return -1;
+ }
+ }
+ else // error of demarshalling
+ {
+ FAPIA_DEBUG (LM_ERROR, "WriteRequest was not received correctly");
+ return -1;
+ }
+
+ break;
+ } // end case FAPIA_WRITE_REQUEST
+ case FAPIA_WRITE_RESPONSE:
+ {
+ // allocate new object to be filled with the data
+ FAPI::Acyclic::IPC::Parameter::MethodRequestWriteResponse*
+ write_response = new FAPI::Acyclic::IPC::Parameter::
+ MethodRequestWriteResponse;
+
+ // demarshall request
+ if (request_cdr >> *write_response)
+ {
+ std::stringstream ss;
+ if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) &
+ LM_DEBUG)
+ {
+ ss << *write_response;
+ }
+ // enqueue request into Activation_Queue
+ if (queue_->enqueue (write_response) != -1)
+ {
+ FAPIA_DEBUG (LM_DEBUG, "enqueued %s", ss.str ().c_str ());
+ }
+ else // error when enqueuing
+ {
+ FAPIA_DEBUG (LM_ERROR, "error when enqueueing WriteResponse");
+ return -1;
+ }
+ }
+ else // error of demarshalling
+ {
+ FAPIA_DEBUG (LM_ERROR, "WriteResponse was not received correctly");
+ return -1;
+ }
+ } // end case FAPIA_WRITE_RESPONSE
+
+ break;
+ case FAPIA_INFO_REQUEST:
+ {
+ // allocate new object to be filled with the data
+ FAPI::Acyclic::IPC::Parameter::MethodRequestInfoRequest*
+ info_request = new FAPI::Acyclic::IPC::Parameter::
+ MethodRequestInfoRequest;
+
+ // demarshall request
+ if (request_cdr >> *info_request)
+ {
+ std::stringstream ss;
+ if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) &
+ LM_DEBUG)
+ {
+ ss << *info_request;
+ }
+ // enqueue request into Activation_Queue
+ if (queue_->enqueue (info_request) != -1)
+ {
+ FAPIA_DEBUG (LM_DEBUG, "enqueued %s", ss.str ().c_str ());
+ }
+ else // error when enqueuing
+ {
+ FAPIA_DEBUG (LM_ERROR, "error when enqueueing InfoRequest");
+ return -1;
+ }
+ }
+ else // error of demarshalling
+ {
+ FAPIA_DEBUG (LM_ERROR, "InfoRequest was not received correctly");
+ return -1;
+ }
+
+ break;
+ } // end case FAPIA_INFO_REQUEST
+ case FAPIA_INFO_RESPONSE:
+ {
+ // allocate new object to be filled with the data
+ FAPI::Acyclic::IPC::Parameter::MethodRequestInfoResponse*
+ info_response = new FAPI::Acyclic::IPC::Parameter::
+ MethodRequestInfoResponse;
+
+ // demarshall request
+ if (request_cdr >> *info_response)
+ {
+ std::stringstream ss;
+ if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) &
+ LM_DEBUG)
+ {
+ ss << *info_response;
+ }
+ // enqueue request into Activation_Queue
+ if (queue_->enqueue (info_response) != -1)
+ {
+ FAPIA_DEBUG (LM_DEBUG, "enqueued %s", ss.str ().c_str ());
+ }
+ else // error when enqueuing
+ {
+ FAPIA_DEBUG (LM_ERROR, "error when enqueueing InfoResponse");
+ return -1;
+ }
+ }
+ else // error of demarshalling
+ {
+ FAPIA_DEBUG (LM_ERROR, "InfoResponse was not received correctly");
+ return -1;
+ }
+
+ break;
+ } // end case FAPIA_INFO_RESPONSE
+ default:
+ {
+ // could not recognize method request, so just return and print a
+ // warning
+ FAPIA_DEBUG (LM_WARNING, "unkown method request type revieved.");
+ return 0;
+ }
+ } // end swith (method_request_type)
+
+ // if everything went well, return number of received bytes
+ return 0; //data_length + FAPIA_HEADER_SIZE;
+ }
+ } // end if header was received correctly
+
+ // do nothing, if no correct header was sent
+ return 0;
+}
+
+/*---------------------------------------------------------------------------*/
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverService.h
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverService.h Thu Jul 19 07:15:27 2007
@@ -0,0 +1,95 @@
+/* -*- C++ -*- */
+
+//=============================================================================
+/**
+ * @file FAPIAIPCParameterReceiverService.h
+ *
+ * $Id$
+ *
+ * @author Friedhelm Wolf <friedhelm.wolf at homag.de>
+ */
+//=============================================================================
+
+#ifndef _FAPIA_IPC_PARAMETER_RECEIVER_SERVICE_H_
+#define _FAPIA_IPC_PARAMETER_RECEIVER_SERVICE_H_
+
+#include <ace/Svc_Handler.h>
+
+#include "FAPIAIPCParameterSocket.h"
+
+// forward declaration
+class ACE_Activation_Queue;
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+ /**
+ * @class ReceiverService
+ *
+ * @brief A service using the ACE_Svc_Handler technique
+ * to implement the receiver part of FAPIA socket
+ * communication. It receives MethodRequests from
+ * a socket connection and enqueues them into an
+ * ACE_Activation_Queue for further processing by
+ * the Controller.
+ */
+ class ReceiverService :
+ public ACE_Svc_Handler<FAPIA_STREAM, ACE_NULL_SYNCH>
+ {
+ public:
+
+ /**
+ * @brief standard constructor
+ */
+ ReceiverService (void);
+
+ /**
+ * @brief standard destructor
+ */
+ virtual ~ReceiverService (void);
+
+ /**
+ * @brief initialization method to set the queue
+ * from which the requests are read
+ */
+ void queue (ACE_Activation_Queue*);
+
+ /**
+ * @brief implementation of the ACE_Svc_Handler open
+ * method, which is responsible for service
+ * initialization. In this case especially the
+ * registration of the socket connection within
+ * the reactor framework
+ * @return 0 if successful, -1 otherwise
+ * @sa ACE_Svc_Handler
+ */
+ virtual int open (void *);
+
+ /**
+ * @brief implementation of the event handler method
+ * of the ACE_Svc_Handler, which is responsible
+ * for socket events
+ * @sa ACE_Svc_Handler
+ */
+ virtual int handle_input (ACE_HANDLE);
+
+ private:
+
+ /// input queue into which requests will be enqueued
+ ACE_Activation_Queue* queue_;
+
+ };
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
+
+
+#endif /* _FAPIA_IPC_PARAMETER_RECEIVER_SERVICE_H_ */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverTask.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverTask.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,136 @@
+// $Id$
+
+
+#include "FAPIAIPCParameterReceiverTask.h"
+#include "FAPIAIPCParameterReceiverAcceptor.h"
+#include "FAPIATrace.h"
+
+#include /**/ <ace/Activation_Queue.h>
+
+using namespace FAPI::Acyclic::IPC::Parameter;
+
+/*---------------------------------------------------------------------------*/
+
+ReceiverTask::ReceiverTask (ACE_Activation_Queue *q)
+: queue_ (q), connection_semaphore_ (0)
+{
+ receiver_acceptor_ = new ReceiverAcceptor(q);
+}
+
+/*---------------------------------------------------------------------------*/
+
+ReceiverTask::~ReceiverTask (void)
+{
+ delete receiver_acceptor_;
+}
+
+/*---------------------------------------------------------------------------*/
+
+ACE_CString ReceiverTask::listen_addr ()
+{
+
+ // wait until semaphore is released
+ connection_semaphore_.acquire ();
+ connection_semaphore_.release ();
+
+ return listen_addr_;
+}
+
+/*---------------------------------------------------------------------------*/
+
+int ReceiverTask::shutdown (void)
+{
+ FAPIA_TRACE;
+
+ receiver_acceptor_->close ();
+ if (ACE_Reactor::instance()->end_reactor_event_loop() == 0)
+ {
+ return this->wait ();
+ }
+
+ return -1;
+}
+
+/*---------------------------------------------------------------------------*/
+
+int ReceiverTask::svc (void)
+{
+ FAPIA_TRACE;
+/*
+ // Create an adapter to end the event loop.
+ ACE_Sig_Adapter sa ((ACE_Sig_Handler_Ex) ACE_Reactor::end_event_loop);
+
+ ACE_Sig_Set sig_set;
+ sig_set.sig_add (SIGINT);
+ sig_set.sig_add (SIGQUIT);
+
+ // Register ourselves to receive SIGINT and SIGQUIT so we can shut
+ // down gracefully via signals.
+ if (ACE_Reactor::instance ()->register_handler (sig_set,
+ &sa) == -1)
+ {
+ FAPIA_DEBUG (LM_ERROR, "could not register signal handler.\n");
+ return -1;
+ }
+*/
+ FAPIA_Addr addr;
+
+#ifdef FAPIA_HAS_NETWORK_SOCKETS
+ addr.set (ACE_sap_any_cast (const FAPIA_Addr &));
+#else
+ ACE_CString rendevous_point = "/tmp/fapia.cp.";
+ char pid[10];
+ sprintf (pid, "%d", ACE_OS::getpid ());
+ rendevous_point += pid;
+ ACE_OS::unlink (rendevous_point.c_str ());
+ addr.set (rendevous_point.c_str ());
+#endif
+
+ if (receiver_acceptor_->open (addr,
+ ACE_Reactor::instance ()) == -1)
+ {
+ if (errno == EADDRINUSE)
+ {
+ FAPIA_DEBUG (LM_ERROR, "address already in use\n");
+ }
+
+ receiver_acceptor_->acceptor ().get_local_addr (addr);
+ ACE_TCHAR str_addr[255];
+ addr.addr_to_string (str_addr, 255);
+ FAPIA_DEBUG (LM_ERROR, "could not open new port %s for listening\n", str_addr);
+ return -1;
+ }
+
+ // store address
+ receiver_acceptor_->acceptor ().get_local_addr (addr);
+
+ // if we have TCP/IP sockets we have to enter the hostname as well
+#ifdef FAPIA_HAS_NETWORK_SOCKETS
+ char hostname[255];
+ addr.set (addr.get_port_number (),
+ ACE_OS::hostname (hostname, 255) ? "localhost" : hostname);
+#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */
+
+ ACE_TCHAR str_addr[255];
+ addr.addr_to_string (str_addr, 255);
+ listen_addr_ = str_addr;
+
+ // make address information accessible via this::listen_addr ()
+ connection_semaphore_.release ();
+
+ FAPIA_DEBUG (LM_NOTICE, "waiting for requests on %s ...", listen_addr_.c_str ());
+
+ // we need these settings to be able to rerun the event loop
+ // after a deinit, init sequence
+ ACE_Reactor::instance()->owner (ACE_OS::thr_self ());
+ ACE_Reactor::instance()->reset_event_loop ();
+
+ // run the Reactor to wait for socket connections
+ int result = ACE_Reactor::instance()->run_reactor_event_loop();
+
+ FAPIA_DEBUG (LM_NOTICE, "receiver task is shutting down (%d) ...", result);
+
+ return result;
+}
+
+/*---------------------------------------------------------------------------*/
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverTask.h
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverTask.h Thu Jul 19 07:15:27 2007
@@ -0,0 +1,102 @@
+/* -*- C++ -*- */
+
+//=============================================================================
+/**
+ * @file FAPIAIPCParameterReceiverTask.h
+ *
+ * $Id$
+ *
+ * @author Friedhelm Wolf <friedhelm.wolf at homag.de>
+ */
+//=============================================================================
+
+#ifndef _FAPIA_IPC_PARAMETER_RECEIVER_TASK_H_
+#define _FAPIA_IPC_PARAMETER_RECEIVER_TASK_H_
+
+#include <ace/Task.h>
+#include <ace/SString.h>
+
+// forward declaration
+class ACE_Activation_Queue;
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+ // forward declaration
+ class ReceiverAcceptor;
+
+ /**
+ * @brief this class encapsulates initialisation of
+ * a socket acceptor, receiving method requests
+ * and runs the reactor event loop in it's svc
+ * routine.
+ */
+ class ReceiverTask : public ACE_Task <ACE_MT_SYNCH>
+ {
+ public:
+
+ /**
+ * @brief constructor
+ * @param queue to which received request should be
+ * passed
+ */
+ ReceiverTask (ACE_Activation_Queue*);
+
+ /**
+ * @brief default destructor
+ */
+ virtual ~ReceiverTask (void);
+
+ /**
+ * @brief terminates the thread.and performs
+ * a blocking wait on thread cancellation
+ * @return 0 if successful, -1 otherwise
+ */
+ int shutdown (void);
+
+ /**
+ * @brief operation which will block until the
+ * socket is initialized to listen for incoming
+ * requests. Therefore it can also be used as a
+ * synchronization point during initialization.
+ * @result stringified socket listen address of the form
+ * <hostname>:<port>
+ */
+ ACE_CString listen_addr ();
+
+ protected:
+
+ /**
+ * @break thread execution routine
+ * @return 0 on success, negative value otherwise
+ */
+ virtual int svc (void);
+
+ private:
+
+ /// this queue is passed to the internal ReceiverService
+ ACE_Activation_Queue* queue_;
+
+ /// acceptor used to establish connections
+ ReceiverAcceptor* receiver_acceptor_;
+
+ /// will block until connection is initialized.
+ ACE_Semaphore connection_semaphore_;
+
+ /// socket address on which to wait for connections
+ ACE_CString listen_addr_;
+ };
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
+
+
+#endif /* _FAPIA_IPC_PARAMETER_RECEIVER_TASK_H_ */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterSenderService.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterSenderService.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,565 @@
+// $Id$
+
+
+#include "FAPIAIPCParameterSenderService.h"
+
+#include "FAPIAIPCParameterMethodRequestFinish.h"
+#include "FAPIAIPCParameterMarshalling.h"
+#include "FAPIAIPCParameterStreaming.h"
+#include "FAPIATrace.h"
+
+#include /**/ <ace/Activation_Queue.h>
+#include /**/ <ace/CDR_Stream.h>
+
+#include <sstream>
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+/*---------------------------------------------------------------------------*/
+
+SenderService::SenderService (void)
+: send_queue_ (NULL), receive_queue_ (NULL)
+{
+}
+
+/*---------------------------------------------------------------------------*/
+
+SenderService::~SenderService (void)
+{
+}
+
+/*---------------------------------------------------------------------------*/
+
+int SenderService::close (u_long flags)
+{
+ FAPIA_TRACE;
+
+ ACE_UNUSED_ARG (flags);
+ int result = 0;
+
+ // close all connections
+ for (StreamMap::iterator stream = connections_.begin ();
+ stream != connections_.end ();
+ stream++)
+ {
+ result += (*stream).int_id_->close ();
+ }
+/*
+ result +=
+ ACE_Svc_Handler <FAPIA_STREAM, ACE_MT_SYNCH>::close (flags);
+*/
+ return result;
+}
+
+/*---------------------------------------------------------------------------*/
+
+void SenderService::send_queue (ACE_Activation_Queue* q)
+{
+ this->send_queue_ = q;
+}
+
+/*---------------------------------------------------------------------------*/
+
+void SenderService::receive_queue (ACE_Activation_Queue* q)
+{
+ this->receive_queue_ = q;
+}
+
+/*---------------------------------------------------------------------------*/
+
+int SenderService::svc (void)
+{
+ //FAPIA_TRACE;
+
+ bool shutdown_flag = false;
+
+ // check if queue is available
+ if (send_queue_ == NULL)
+ {
+ FAPIA_DEBUG (LM_ERROR, "SenderService queue was not initialized");
+ return -1;
+ }
+
+ FAPI::Acyclic::IPC::Parameter::MethodRequestType request_type =
+ FAPIA_UNKNOWN_REQUEST;
+
+ do
+ {
+ // dequeue method request from the queue
+ ACE_Strong_Bound_Ptr<MethodRequest, ACE_Null_Mutex>
+ request(ACE_dynamic_cast (MethodRequest*,
+ this->send_queue_->dequeue ())
+ );
+
+ // check for abort request
+ if ((!request.null ()) && (request->call () == 0))
+ {
+ // find out the type of the call
+ MethodRequestReadRequest* rreq= NULL;
+ MethodRequestReadResponse* rres = NULL;
+ MethodRequestWriteRequest* wreq = NULL;
+ MethodRequestWriteResponse* wres = NULL;
+ MethodRequestInfoRequest* ireq = NULL;
+ MethodRequestInfoResponse* ires = NULL;
+
+ // is the request a read request?
+ rreq = ACE_dynamic_cast (MethodRequestReadRequest*,
+ request.get ());
+ if (rreq == NULL)
+ {
+ // is the request a read response?
+ rres = ACE_dynamic_cast (MethodRequestReadResponse*,
+ request.get ());
+ if (rres == NULL)
+ {
+ // is the request a write request?
+ wreq = ACE_dynamic_cast (MethodRequestWriteRequest*,
+ request.get ());
+ if (wreq == NULL)
+ {
+ // is the request a write response?
+ wres = ACE_dynamic_cast (MethodRequestWriteResponse*,
+ request.get ());
+ if (wres == NULL)
+ {
+ // is the request an info request?
+ ireq = ACE_dynamic_cast (MethodRequestInfoRequest*,
+ request.get ());
+ if (ireq == NULL)
+ {
+ // is the request an info response?
+ ires = ACE_dynamic_cast (MethodRequestInfoResponse*,
+ request.get ());
+ if (ires == NULL)
+ {
+ // Type of request is unknown.
+ request_type = FAPIA_UNKNOWN_REQUEST;
+ }
+ else
+ {
+ request_type = FAPIA_INFO_RESPONSE;
+ } // is the request an info response?
+ }
+ else
+ {
+ request_type = FAPIA_INFO_REQUEST;
+ } // is the request an info request?
+ }
+ else
+ {
+ request_type = FAPIA_WRITE_RESPONSE;
+ } // end if is the request a write response?
+ }
+ else
+ {
+ request_type = FAPIA_WRITE_REQUEST;
+ } // end if is the request a write request?
+ }
+ else
+ {
+ request_type = FAPIA_READ_RESPONSE;
+ } // end if is the request a read response?
+ }
+ else
+ {
+ request_type = FAPIA_READ_REQUEST;
+ } // end if is the request a read request?
+
+ //prepare data structures for marshalling
+ ACE_OutputCDR header_cdr (ACE_CDR::MAX_ALIGNMENT +
+ FAPIA_HEADER_SIZE);
+ header_cdr << ACE_OutputCDR::from_boolean (ACE_CDR_BYTE_ORDER);
+
+ ACE_Strong_Bound_Ptr <ACE_OutputCDR, ACE_Null_Mutex> request_cdr;
+
+ // process request
+ switch (request_type)
+ {
+ case FAPIA_READ_REQUEST:
+ {
+ std::stringstream ss;
+ if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) &
+ LM_DEBUG)
+ {
+ ss << *rreq;
+ }
+ FAPIA_DEBUG (LM_DEBUG, "sending %s", ss.str ().c_str ());
+
+ // calculate data block size
+ unsigned long request_size = 0;
+ request_size += *rreq;
+ request_cdr.reset (new ACE_OutputCDR (request_size));
+
+ // linearize data
+ *request_cdr << *rreq;
+
+ // add length and type information to the header
+ header_cdr << ACE_CDR::ULong (request_cdr->total_length ());
+ header_cdr << ACE_CDR::ULong (request_type);
+
+ break;
+ } // end case FAPIA_READ_REQUEST
+ case FAPIA_READ_RESPONSE:
+ {
+ std::stringstream ss;
+ if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) & LM_DEBUG)
+ {
+ ss << *rres;
+ }
+ FAPIA_DEBUG (LM_DEBUG, "sending %s", ss.str ().c_str ());
+
+ // calculate data block size
+ unsigned long request_size = 0;
+ request_size += *rres;
+ request_cdr.reset (new ACE_OutputCDR (request_size));
+
+ // linearize data
+ *request_cdr << *rres;
+
+ // add length and type information to the header
+ header_cdr << ACE_CDR::ULong (request_cdr->total_length ());
+ header_cdr << ACE_CDR::ULong (request_type);
+
+ break;
+ } // end case FAPIA_READ_RESPONSE
+ case FAPIA_WRITE_REQUEST:
+ {
+ std::stringstream ss;
+ if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) &
+ LM_DEBUG)
+ {
+ ss << *wreq;
+ }
+ FAPIA_DEBUG (LM_DEBUG, "sending %s", ss.str ().c_str ());
+
+ // calculate data block size
+ unsigned long request_size = 0;
+ request_size += *wreq;
+ request_cdr.reset (new ACE_OutputCDR (request_size));
+
+ // linearize data
+ *request_cdr << *wreq;
+
+ // add length and type information to the header
+ header_cdr << ACE_CDR::ULong (request_cdr->total_length ());
+ header_cdr << ACE_CDR::ULong (request_type);
+
+ break;
+ } // end case FAPIA_WRITE_REQUEST
+ case FAPIA_WRITE_RESPONSE:
+ {
+ std::stringstream ss;
+ if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) &
+ LM_DEBUG)
+ {
+ ss << *wres;
+ }
+ FAPIA_DEBUG (LM_DEBUG, "sending %s", ss.str ().c_str ());
+
+ // calculate data block size
+ unsigned long request_size = 0;
+ request_size += *wres;
+ request_cdr.reset (new ACE_OutputCDR (request_size));
+
+ // linearize data
+ *request_cdr << *wres;
+
+ // add length and type information to the header
+ header_cdr << ACE_CDR::ULong (request_cdr->total_length ());
+ header_cdr << ACE_CDR::ULong (request_type);
+
+ break;
+ } // end case FAPIA_WRITE_RESPONSE
+ case FAPIA_INFO_REQUEST:
+ {
+ std::stringstream ss;
+ if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) &
+ LM_DEBUG)
+ {
+ ss << *ireq;
+ }
+ FAPIA_DEBUG (LM_DEBUG, "sending %s", ss.str ().c_str ());
+
+ // calculate data block size
+ unsigned long request_size = 0;
+ request_size += *ireq;
+ request_cdr.reset (new ACE_OutputCDR (request_size));
+
+ // linearize data
+ *request_cdr << *ireq;
+
+ // add length and type information to the header
+ header_cdr << ACE_CDR::ULong (request_cdr->total_length ());
+ header_cdr << ACE_CDR::ULong (request_type);
+
+ break;
+ } // end case FAPIA_INFO_REQUEST
+ case FAPIA_INFO_RESPONSE:
+ {
+ std::stringstream ss;
+ if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) &
+ LM_DEBUG)
+ {
+ ss << *ires;
+ }
+ FAPIA_DEBUG (LM_DEBUG, "sending %s", ss.str ().c_str ());
+
+ // calculate data block size
+ unsigned long request_size = 0;
+ request_size += *ires;
+ request_cdr.reset (new ACE_OutputCDR (request_size));
+
+ // linearize data
+ *request_cdr << *ires;
+
+ // add length and type information to the header
+ header_cdr << ACE_CDR::ULong (request_cdr->total_length ());
+ header_cdr << ACE_CDR::ULong (request_type);
+
+ break;
+ } // end case FAPIA_INFO_RESPONSE
+ case FAPIA_UNKNOWN_REQUEST:
+ default:
+ {
+ FAPIA_DEBUG (LM_WARNING, "unkown request received.");
+ continue;
+ } // end of default case
+ } // end switch (request_type)
+
+ // Determine amount of message blocks.
+ unsigned long i = 0;
+ const ACE_Message_Block *mb = request_cdr->begin ();
+ while (mb != request_cdr->end ())
+ {
+ mb = mb->cont();
+ ++i;
+ }
+
+ // fill buffers for a scatter
+ iovec* iov = 0;
+ ACE_NEW_NORETURN (iov, iovec[1 + i]);
+ if (iov == 0)
+ {
+ FAPIA_DEBUG (LM_EMERGENCY, "Error allocating memory.");
+ continue;
+ }
+
+ iov[0].iov_base = header_cdr.begin ()->rd_ptr ();
+ iov[0].iov_len = FAPIA_HEADER_SIZE;
+
+ mb = request_cdr->begin ();
+ i = 1;
+ while (mb != request_cdr->end ())
+ {
+ iov[i].iov_base = mb->rd_ptr ();
+ iov[i].iov_len = mb->length ();
+ mb = mb->cont();
+ ++i;
+ }
+
+ ACE_Hash_Map_Entry <ACE_CString, StreamPtr>* map_entry;
+
+ // find out, if connection to destination needs to be established
+ if (connections_.find (request->destination_physical_object_address_,
+ map_entry) != 0)
+ {
+ // make new connection
+
+ ACE_Strong_Bound_Ptr <FAPIA_Stream, ACE_RW_Mutex> stream (
+ new FAPIA_Stream ());
+
+ FAPIA_Addr addr (
+ request->destination_physical_object_address_.c_str ());
+
+ if (connector_.connect (*stream, addr) == 0)
+ {
+ // save stream into the connection map if connection was
+ // succesfully established
+ // and fill map entry with the correct value
+ if ( (connections_.bind (
+ request->destination_physical_object_address_,
+ stream) != 0)
+ || (connections_.find (
+ request->destination_physical_object_address_,
+ map_entry) != 0))
+ {
+ FAPIA_DEBUG (LM_ERROR,
+ "could not add connection to map.");
+ delete [] iov;
+ iov = 0;
+ return -1;
+ }
+ }
+ else
+ {
+ ACE_TCHAR buffer[255];
+ addr.addr_to_string (buffer, 255);
+ FAPIA_DEBUG (LM_WARNING,
+ "could not connect to address %s. I'll try to enqueue an error.",
+ buffer);
+
+ if (request_type == FAPIA_READ_REQUEST)
+ {
+ if (queue_read_error (rreq->communication_,
+ buffer) != 0)
+ FAPIA_DEBUG (LM_WARNING,
+ "could not enqueue read response error");
+ }
+ else if (request_type == FAPIA_WRITE_REQUEST)
+ {
+ if (queue_write_error (wreq->communication_,
+ buffer) != 0)
+ FAPIA_DEBUG (LM_WARNING,
+ "could not enqueue write response error");
+ }
+
+ delete [] iov;
+ iov = 0;
+ continue;
+ }
+ }
+
+ // send data
+ if (map_entry->int_id_->sendv_n (iov, i) > 0)
+ {
+ FAPIA_DEBUG (LM_INFO, "request sent to %s",
+ request->destination_physical_object_address_.c_str ());
+ delete [] iov;
+ iov = 0;
+ }
+ else
+ {
+ delete [] iov;
+ iov = 0;
+ FAPIA_DEBUG (LM_WARNING,
+ "could not send request to %s. I'll try to enqueue an error.",
+ request->destination_physical_object_address_.c_str ());
+ StreamPtr useless_stream;
+
+ // close the stream
+ if (connections_.unbind (
+ request->destination_physical_object_address_,
+ useless_stream) == 0)
+ {
+ useless_stream->close ();
+ }
+
+ if (request_type == FAPIA_READ_REQUEST)
+ {
+ if (queue_read_error (rreq->communication_,
+ request->destination_physical_object_address_) != 0)
+ FAPIA_DEBUG (LM_WARNING,
+ "could not enqueue read response error");
+ }
+ else if (request_type == FAPIA_WRITE_REQUEST)
+ {
+ if (queue_write_error (wreq->communication_,
+ request->destination_physical_object_address_) != 0)
+ FAPIA_DEBUG (LM_WARNING,
+ "could not enqueue write response error");
+ }
+
+ continue;
+ }
+
+ } // end if no shutdown request
+ else
+ {
+ FAPIA_DEBUG (LM_NOTICE, "SenderService received shutdown request");
+ shutdown_flag = true;
+ }
+
+ } while (!shutdown_flag);
+
+// return this->close ();
+ return 0;
+}
+
+/*---------------------------------------------------------------------------*/
+
+int SenderService::queue_write_error (const Communication &c,
+ const ACE_CString &addr)
+{
+ FAPIA_TRACE;
+
+ // check if queue is available
+ if (receive_queue_ == NULL)
+ {
+ return -1;
+ }
+
+ // generate response
+ MethodRequestWriteResponse* response = new MethodRequestWriteResponse ();
+
+ response->communication_ = c;
+ response->communication_.communication_error_.error_code_ =
+ FAPIA_ERROR_DESTINATION_NOT_ONLINE;
+ response->communication_.communication_error_.reason_ =
+ "could not establish connection to ";
+ response->communication_.communication_error_.reason_ += addr;
+
+ ACE_Time_Value tv = ACE_OS::gettimeofday () +
+ ACE_static_cast(ACE_Time_Value, 100);
+
+ return receive_queue_->enqueue (response, &tv);
+}
+
+/*---------------------------------------------------------------------------*/
+
+int SenderService::queue_read_error (const Communication &c,
+ const ACE_CString &addr)
+{
+ FAPIA_TRACE;
+
+ // check if queue is available
+ if (receive_queue_ == NULL)
+ {
+ return -1;
+ }
+
+ // generate response
+ MethodRequestReadResponse* response = new MethodRequestReadResponse ();
+
+ response->communication_ = c;
+ response->communication_.communication_error_.error_code_ =
+ FAPIA_ERROR_DESTINATION_NOT_ONLINE;
+ response->communication_.communication_error_.reason_ =
+ "could not establish connection to ";
+ response->communication_.communication_error_.reason_ += addr;
+
+ ACE_Time_Value tv = ACE_OS::gettimeofday () +
+ ACE_static_cast(ACE_Time_Value, 100);
+
+ return receive_queue_->enqueue (response, &tv);
+}
+
+/*---------------------------------------------------------------------------*/
+
+int SenderService::shutdown (void)
+{
+ FAPIA_TRACE;
+
+ if (this->send_queue_ != NULL)
+ {
+ this->send_queue_->enqueue (
+ new FAPI::Acyclic::IPC::Parameter::MethodRequestFinish ());
+
+ return this->wait ();
+ }
+
+ return -1;
+}
+
+/*---------------------------------------------------------------------------*/
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterSenderService.h
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterSenderService.h Thu Jul 19 07:15:27 2007
@@ -0,0 +1,160 @@
+/* -*- C++ -*- */
+
+//=============================================================================
+/**
+ * @file FAPIAIPCParameterSenderService.h
+ *
+ * $Id$
+ *
+ * @author Friedhelm Wolf <friedhelm.wolf at homag.de>
+ */
+//=============================================================================
+
+#ifndef _FAPIA_IPC_PARAMETER_SENDER_SERVICE_H_
+#define _FAPIA_IPC_PARAMETER_SENDER_SERVICE_H_
+
+#include <ace/Svc_Handler.h>
+#include <ace/Hash_Map_Manager.h>
+#include <ace/Connector.h>
+#include <ace/Bound_Ptr.h>
+
+#include "FAPIAIPCParameterSocket.h"
+
+//forward declaration
+class ACE_Activation_Queue;
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+ // forward declarations
+ class SenderService;
+ class Communication;
+
+ /**
+ * @brief pointer to an ACE_SOCK_Stream
+ */
+
+ typedef ACE_Strong_Bound_Ptr <FAPIA_Stream,
+ ACE_RW_Mutex>
+ StreamPtr;
+
+ /**
+ * @brief Map which associates socket addresses in
+ * in stringified form with ACE_SOCK_Streams
+ */
+ typedef ACE_Hash_Map_Manager <ACE_CString,
+ StreamPtr,
+ ACE_RW_Mutex >
+ StreamMap;
+
+ /**
+ * @class SenderService
+ *
+ * @brief A service using the ACE_Svc_Handler technique
+ * to implement the sender part of FAPIA socket
+ * communication. It dequeues MethodRequests from
+ * an ACE_Activation_Queue filled by the Controller
+ * and sends them to a FAPIA server via a socket.
+ */
+ class SenderService :
+ public ACE_Svc_Handler<FAPIA_STREAM, ACE_MT_SYNCH>
+ {
+ public:
+
+ /**
+ * @brief standard constructor
+ */
+ SenderService (void);
+
+ /**
+ * @brief standard destructor
+ */
+ ~SenderService (void);
+
+ /**
+ * @brief initialization method to set the queue
+ * from which the requests are read
+ */
+ void send_queue (ACE_Activation_Queue*);
+
+ /**
+ * @brief initialization method to set the queue
+ * which handles replies (loopback)
+ */
+ void receive_queue (ACE_Activation_Queue*);
+
+ /**
+ * @brief terminates the thread.and performs
+ * a blocking wait on thread cancellation
+ * @return 0 if successful, -1 otherwise
+ */
+ int shutdown (void);
+
+ /**
+ * @brief closes all connections
+ * @sa ACE_Svc_Handler
+ */
+ virtual int close (u_long flags = 0);
+
+ protected:
+
+ /**
+ * @brief as the service is derived from ACE_Task,
+ * it has it's own thread of control
+ * @return 0 if successful, -1 otherwise
+ */
+ virtual int svc (void);
+
+ /**
+ * @brief bypasses socket communication and enqueues
+ * a MethodRequestWriteResponse with error code
+ * set to FAPIA_ERROR_DESTINATION_NOT_ONLINE
+ * into the receive queue of the process
+ * @param communication header of the request
+ * @param address of the destination
+ * @return 0 if successful, -1 otherwise
+ */
+ int queue_write_error (const Communication &,
+ const ACE_CString &);
+
+ /**
+ * @brief bypasses socket communication and enqueues
+ * a MethodRequestReadResponse with error code
+ * set to FAPIA_ERROR_DESTINATION_NOT_ONLINE
+ * into the receive queue of the process
+ * @param communication header of the request
+ * @param address of the destination
+ * @return 0 if successful, -1 otherwise
+ */
+ int queue_read_error (const Communication &,
+ const ACE_CString &);
+
+ private:
+
+ /// ACE Connector to establish new connections
+ FAPIA_Connector connector_;
+
+ /// map holding all open connections
+ StreamMap connections_;
+
+ /// input queue which contains the requests
+ ACE_Activation_Queue* send_queue_;
+
+ /// loopback queue to the own process
+ ACE_Activation_Queue* receive_queue_;
+
+ };
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
+
+
+#endif /* _FAPIA_IPC_PARAMETER_SENDER_SERVICE_H_ */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterSocket.h
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterSocket.h Thu Jul 19 07:15:27 2007
@@ -0,0 +1,51 @@
+/* -*- C -*- */
+
+//=============================================================================
+/**
+ * @file FAPIAIPCParameterSocket.h
+ *
+ * $Id$
+ *
+ * @brief this header encapsulates internet and UNIX domain socket
+ * communication
+ *
+ * @author Friedhelm Wolf <friedhelm.wolf at homag.de>
+ */
+//=============================================================================
+
+#ifndef _FAPI_ACYCLIC_PARAMETER_SOCKET_H_
+#define _FAPI_ACYCLIC_PARAMETER_SOCKET_H_
+
+#include /**/ <ace/config.h>
+
+#ifdef ACE_LACKS_UNIX_DOMAIN_SOCKETS
+
+#include /**/ <ace/SOCK_Acceptor.h>
+#include /**/ <ace/SOCK_Connector.h>
+
+#define FAPIA_HAS_NETWORK_SOCKETS
+
+#define FAPIA_STREAM ACE_SOCK_STREAM
+#define FAPIA_ACCEPTOR ACE_SOCK_ACCEPTOR
+
+typedef ACE_INET_Addr FAPIA_Addr;
+typedef ACE_SOCK_Stream FAPIA_Stream;
+typedef ACE_SOCK_Acceptor FAPIA_Acceptor;
+typedef ACE_SOCK_Connector FAPIA_Connector;
+
+#else
+
+#include /**/ <ace/LSOCK_Acceptor.h>
+#include /**/ <ace/LSOCK_Connector.h>
+
+#define FAPIA_STREAM ACE_LSOCK_STREAM
+#define FAPIA_ACCEPTOR ACE_LSOCK_ACCEPTOR
+
+typedef ACE_UNIX_Addr FAPIA_Addr;
+typedef ACE_LSOCK_Stream FAPIA_Stream;
+typedef ACE_LSOCK_Acceptor FAPIA_Acceptor;
+typedef ACE_LSOCK_Connector FAPIA_Connector;
+
+#endif
+
+#endif /* _FAPI_ACYCLIC_PARAMETER_SOCKET_H_ */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterStreaming.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterStreaming.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,237 @@
+// $Id$
+
+#include "FAPIAIPCParameterStreaming.h"
+
+/*---------------------------------------------------------------------------*/
+
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os,
+ const FAPI::Acyclic::IPC::Parameter::Parameter &p)
+{
+ return os << "parameter [" << p.parameter_name_.c_str () << "]";
+}
+
+/*---------------------------------------------------------------------------*/
+
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os,
+ const FAPI::Acyclic::IPC::Parameter::Parameters &p)
+{
+ os << "parameters (";
+ for (size_t i = 0; i < p.size (); i++)
+ {
+ os << p[i] << ", ";
+ }
+
+ return os << ")";
+}
+
+/*---------------------------------------------------------------------------*/
+
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os,
+ const FAPI::Acyclic::IPC::Parameter::Communication &c)
+{
+ return os << "communication [id=" << c.transaction_id_
+ << ", logical_name=" << c.logical_object_name_.c_str ()
+ << ", obj_name=" << c.source_physical_object_name_.c_str ()
+ << ", send_reply=" << c.send_reply_ << "]";
+}
+
+/*---------------------------------------------------------------------------*/
+
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os,
+ const FAPI::Acyclic::IPC::Parameter::Value &v)
+{
+ os << "value [type=" << v.data_type_ << ", len=" << v.data_len ();
+
+ if (v.data_len () > 0)
+ os << ", data=" << static_cast<const char*> (v.data_value ())[0];
+
+ if (v.data_len () > 1)
+ os << static_cast<const char*> (v.data_value ())[1];
+
+ if (v.data_len () > 2)
+ os << static_cast<const char*> (v.data_value ())[2];
+
+ if (v.data_len () > 3)
+ os << static_cast<const char*> (v.data_value ())[3];
+
+ return os << "]";
+}
+
+/*---------------------------------------------------------------------------*/
+
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os,
+ const FAPI::Acyclic::IPC::Parameter::Values &v)
+{
+ os << "values (";
+ for (size_t i = 0; i < v.size (); i++)
+ {
+ os << v[i] << ", ";
+ }
+
+ return os << ")";
+}
+
+/*---------------------------------------------------------------------------*/
+
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os,
+ const FAPI::Acyclic::IPC::Parameter::Info &v)
+{
+ os << "info [type=" << v.data_type_ << ", len=" << v.data_len_;
+
+ if (v.unit_.length () > 0)
+ os << ", unit=" << v.unit_.c_str ();
+
+ return os << "]";
+}
+
+/*---------------------------------------------------------------------------*/
+
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os,
+ const FAPI::Acyclic::IPC::Parameter::Infos &v)
+{
+ os << "infos (";
+ for (size_t i = 0; i < v.size (); i++)
+ {
+ os << v[i] << ", ";
+ }
+
+ return os << ")";
+}
+
+/*---------------------------------------------------------------------------*/
+
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os,
+ const FAPI::Acyclic::IPC::Parameter::Error &e)
+{
+ ACE_CString e_code;
+
+ switch (e.error_code_)
+ {
+ case FAPIA_ERROR_OK:
+ e_code = "FAPIA_ERROR_OK"; break;
+ case FAPIA_ERROR_COMMUNICATION:
+ e_code = "FAPIA_ERROR_COMMUNICATION"; break;
+ case FAPIA_ERROR_OBJECT_NOT_FOUND:
+ e_code = "FAPIA_ERROR_OBJECT_NOT_FOUND"; break;
+ case FAPIA_ERROR_PARAMETER_NOT_FOUND:
+ e_code = "FAPIA_ERROR_PARAMETER_NOT_FOUND"; break;
+ case FAPIA_ERROR_CONFIG_PARSE_ERROR:
+ e_code = "FAPIA_ERROR_CONFIG_PARSE_ERROR"; break;
+ case FAPIA_ERROR_DESTINATION_NOT_ONLINE:
+ e_code = "FAPIA_ERROR_DESTINATION_NOT_ONLINE"; break;
+ case FAPIA_ERROR_CONFIG_HAS_WRONG_FORMAT:
+ e_code = "FAPIA_ERROR_CONFIG_HAS_WRONG_FORMAT"; break;
+ default:
+ e_code = "UNKOWN";
+ }
+
+ return os << "error [code=" << e_code.c_str ()
+ << ", reason=" << e.reason_.c_str ()
+ << "]";
+}
+
+/*---------------------------------------------------------------------------*/
+
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os,
+ const FAPI::Acyclic::IPC::Parameter::Errors &e)
+{
+ os << "errors (";
+ for (size_t i = 0; i < e.size (); i++)
+ {
+ os << e[i] << ", ";
+ }
+
+ return os << ")";
+}
+
+/*---------------------------------------------------------------------------*/
+
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestReadRequest &rr)
+{
+ return os << "ReadRequest {" << endl
+ << "\t" << "prio=" << rr.priority () << endl
+ << "\t" << "dest=" << rr.destination_physical_object_address_
+ << endl << "\t" << rr.communication_
+ << endl << "\t" << rr.parameters_
+ << endl << "}" << endl;
+}
+
+/*---------------------------------------------------------------------------*/
+
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestReadResponse &rr)
+{
+ return os << "ReadResponse {" << endl
+ << "\t" << "prio=" << rr.priority () << endl
+ << "\t" << "dest=" << rr.destination_physical_object_address_
+ << endl << "\t" << rr.communication_
+ << endl << "\t" << rr.parameters_
+ << endl << "\t" << rr.values_
+ << endl << "\t" << rr.errors_
+ << endl << "}" << endl;
+}
+
+/*---------------------------------------------------------------------------*/
+
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestWriteRequest &wr)
+{
+ return os << "WriteRequest {" << endl
+ << "\t" << "prio=" << wr.priority () << endl
+ << "\t" << "dest=" << wr.destination_physical_object_address_
+ << endl << "\t" << wr.communication_
+ << endl << "\t" << wr.parameters_
+ << endl << "\t" << wr.values_
+ << endl << "}" << endl;
+}
+
+/*---------------------------------------------------------------------------*/
+
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestWriteResponse &wr)
+{
+ return os << "WriteResponse {" << endl
+ << "\t" << "prio=" << wr.priority () << endl
+ << "\t" << "dest=" << wr.destination_physical_object_address_
+ << endl << "\t" << wr.communication_
+ << endl << "\t" << wr.parameters_
+ << endl << "\t" << wr.errors_
+ << endl << "}" << endl;
+}
+
+/*---------------------------------------------------------------------------*/
+
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestInfoRequest &wr)
+{
+ return os << "InfoRequest {" << endl
+ << "\t" << "prio=" << wr.priority () << endl
+ << "\t" << "dest=" << wr.destination_physical_object_address_
+ << endl << "\t" << wr.communication_
+ << endl << "\t" << wr.parameters_
+ << endl << "}" << endl;
+}
+
+/*---------------------------------------------------------------------------*/
+
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestInfoResponse &wr)
+{
+ return os << "InfoResponse {" << endl
+ << "\t" << "prio=" << wr.priority () << endl
+ << "\t" << "dest=" << wr.destination_physical_object_address_
+ << endl << "\t" << wr.communication_
+ << endl << "\t" << wr.parameters_
+ << endl << "\t" << wr.infos_
+ << endl << "\t" << wr.errors_
+ << endl << "}" << endl;
+}
+
+/*---------------------------------------------------------------------------*/
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterStreaming.h
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterStreaming.h Thu Jul 19 07:15:27 2007
@@ -0,0 +1,132 @@
+/* -*- C -*- */
+
+//=============================================================================
+/**
+ * @file FAPIAIPCParameterStreaming.h
+ *
+ * $Id$
+ *
+ * @author Friedhelm Wolf <friedhelm.wolf at homag.de>
+ */
+//=============================================================================
+
+
+#ifndef _FAPI_ACYCLIC_PARAMETER_STREAMING_H_
+#define _FAPI_ACYCLIC_PARAMETER_STREAMING_H_
+
+
+#include <FAPIAIPCParameter/interface/FAPIAIPCParameterParameter.h>
+#include <FAPIAIPCParameter/interface/FAPIAIPCParameterCommunication.h>
+#include <FAPIAIPCParameter/interface/FAPIAIPCParameterValue.h>
+#include <FAPIAIPCParameter/interface/FAPIAIPCParameterError.h>
+
+#include \
+ <FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestReadRequest.h>
+#include \
+ <FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestReadResponse.h>
+#include \
+ <FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestWriteRequest.h>
+#include \
+ <FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestWriteResponse.h>
+#include \
+ <FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestInfoRequest.h>
+#include \
+ <FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestInfoResponse.h>
+
+/**
+ * @brief output streaming operator for the Parameter class
+ */
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &,
+ const FAPI::Acyclic::IPC::Parameter::Parameter &);
+
+/**
+ * @brief output streaming operator for the Parameters vector
+ */
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &,
+ const FAPI::Acyclic::IPC::Parameter::Parameters &);
+
+/**
+ * @brief output streaming operator for the Communication class
+ */
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &,
+ const FAPI::Acyclic::IPC::Parameter::Communication &);
+
+/**
+ * @brief output streaming operator for the Value class
+ */
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &,
+ const FAPI::Acyclic::IPC::Parameter::Value &);
+
+/**
+ * @brief output streaming operator for the Value class
+ */
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &,
+ const FAPI::Acyclic::IPC::Parameter::Values &);
+
+/**
+ * @brief output streaming operator for the Info class
+ */
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &,
+ const FAPI::Acyclic::IPC::Parameter::Info &);
+
+/**
+ * @brief output streaming operator for the Info class
+ */
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &,
+ const FAPI::Acyclic::IPC::Parameter::Infos &);
+
+/**
+ * @brief output streaming operator for the Error class
+ */
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &,
+ const FAPI::Acyclic::IPC::Parameter::Error &);
+
+/**
+ * @brief output streaming operator for the Error class
+ */
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &,
+ const FAPI::Acyclic::IPC::Parameter::Errors &);
+
+/**
+ * @brief output streaming operator for the MethodRequestReadRequest class
+ */
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestReadRequest &);
+
+/**
+ * @brief output streaming operator for the MethodRequestReadResponse class
+ */
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestReadResponse &);
+
+/**
+ * @brief output streaming operator for the MethodRequestWriteRequest class
+ */
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestWriteRequest &);
+
+/**
+ * @brief output streaming operator for the MethodRequestWriteResponse class.
+ */
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestWriteResponse &);
+
+/**
+ * @brief output streaming operator for the MethodRequestInfoRequest class
+ */
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestInfoRequest &);
+
+/**
+ * @brief output streaming operator for the MethodRequestInfoResponse class.
+ */
+ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &,
+ const FAPI::Acyclic::IPC::Parameter:: \
+ MethodRequestInfoResponse &);
+
+#endif /* _FAPI_ACYCLIC_PARAMETER_STREAMING_H_ */
Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterValue.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterValue.cpp Thu Jul 19 07:15:27 2007
@@ -0,0 +1,158 @@
+// $Id$
+
+
+#include "FAPIAIPCParameterValue.h"
+#include "FAPIATrace.h"
+
+namespace FAPI
+ {
+ namespace Acyclic
+ {
+ namespace IPC
+ {
+ namespace Parameter
+ {
+
+/*---------------------------------------------------------------------------*/
+
+ Value::Value (void)
+ {
+ open ();
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ Value::Value (const Value& value)
+ {
+ open ();
+ copy (value);
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ const Value& Value::operator= (const Value& value)
+ {
+ if (this != &value)
+ {
+ close ();
+ copy (value);
+ }
+
+ return *this;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ Value::~Value (void)
+ {
+ close ();
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ bool Value::operator!= (const Value& value) const
+ {
+ return ((this->data_type_ != value.data_type_) ||
+ (this->data_len_ != value.data_len_) ||
+ (ACE_OS::memcmp (this->data_value_,
+ value.data_value_,
+ value.data_len_))
+ );
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ unsigned long Value::data_len (void) const
+ {
+ return this->data_len_;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ const void* Value::data_value (void) const
+ {
+ return this->data_value_;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ long Value::data_value (const void* const value,
+ unsigned long len)
+ {
+ // delete previous value if necessary
+ if (this->data_value_ != NULL)
+ {
+ delete[] ACE_static_cast (u_char*, this->data_value_);
+ this->data_value_ = NULL;
+ this->data_len_ = 0;
+ }
+
+ // allocate memory for the value.
+ ACE_NEW_NORETURN (this->data_value_, char[len]);
+ if (this->data_value_ == NULL)
+ {
+ FAPIA_DEBUG (LM_CRITICAL,
+ "insufficient memory for heap allocation");
+ return -1;
+ }
+
+ // copy content
+ ACE_OS::memcpy (this->data_value_, value, len);
+
+ this->data_len_ = len;
+
+ return 0;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ void Value::open (void)
+ {
+ this->data_type_ = FAPIA_DATA_TYPE_UNS08;
+ this->data_len_ = 0;
+ this->data_value_ = NULL;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ void Value::copy (const Value& value)
+ {
+ unsigned long len = value.data_len ();
+
+ // allocate memory for the value.
+ ACE_NEW_NORETURN (this->data_value_, char[len]);
+ if (this->data_value_ == NULL)
+ {
+ FAPIA_DEBUG (LM_CRITICAL,
+ "insufficient memory for heap allocation");
+ return;
+ }
+
+ // copy content
+ ACE_OS::memcpy (this->data_value_,
+ value.data_value (),
+ len);
+
+ this->data_len_ = len;
+ this->data_type_ = value.data_type_;
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ void Value::close (void)
+ {
+ this->data_type_ = FAPIA_DATA_TYPE_UNS08;
+ this->data_len_ = 0;
+ if (this->data_value_ != NULL)
+ {
+ delete[] ACE_static_cast (u_char*, this->data_value_);
+ this->data_value_ = NULL;
+ }
+ }
+
+/*---------------------------------------------------------------------------*/
+
+ } /* namespace Parameter */
+ } /* namespace IPC */
+ } /* namespace Acyclic */
+ } /* namespace FAPI */
More information about the OSADL-svn-commits
mailing list