#include <plp/log.h>
#include "BusMessage.hh"
+#include "RequestResponseBus.hh"
using namespace std;
using namespace plpbus_orb;
using namespace plpbus;
using namespace CORBA;
-BusMessage::BusMessage()
-{
- _dataItemSeq.length(0);
-
+BusMessage::BusMessage() {
+ _dataItemSeq = new DataItemSequence();
+ log_debug("new BusMessage()\n");
}
-BusMessage::BusMessage(const char *name_param, const char *value_param)
-{
- DataItem *item;
+BusMessage::BusMessage(const char *name_param, const char *value_param) {
+ DataItem *item;
+ DataItemSequence *seq;
if (name_param != NULL) {
item = new DataItem();
item->name = strdup(name_param);
item->value <<= strdup(value_param);
- _dataItemSeq.length(1);
- _dataItemSeq[0] = *item;
+ seq = new DataItemSequence(0);
+ seq->length(1);
+ (*seq)[0] = *item;
+ _dataItemSeq = seq;
}
else {
- _dataItemSeq.length(0);
+ _dataItemSeq = new DataItemSequence(0);
}
-
}
-BusMessage::~BusMessage()
-{
- // TODO Auto-generated destructor stub
+BusMessage::~BusMessage() {
}
int BusMessage::add_string_parameter(const char *name_param, const char *value_param)
{
- long length;
- int ret_val;
- DataItem *item;
+ long length;
+ int ret_val;
+ DataItem *item;
+ DataItemSequence *seq;
ret_val = 0;
+ seq = (DataItemSequence *)_dataItemSeq;
if (name_param != NULL) {
- length = _dataItemSeq.length();
+ length = seq->length();
item = new DataItem();
- item->name = strdup(name_param);
+ item->name = strdup(name_param);
if (value_param != NULL) {
item->value <<= strdup(value_param);
- _dataItemSeq.length(length + 1);
- _dataItemSeq[length] = *item;
+ seq->length(length + 1);
+ (*seq)[length] = *item;
}
}
else {
- _dataItemSeq.length(0);
+ seq->length(0);
ret_val = -1;
}
return ret_val;
int BusMessage::add_long_parameter(const char *name_param, long value_param)
{
- long length;
- int ret_val;
- DataItem *item;
+ long length;
+ int ret_val;
+ DataItem *item;
+ DataItemSequence *seq;
ret_val = 0;
+ seq = (DataItemSequence *)_dataItemSeq;
if (name_param != NULL) {
- length = _dataItemSeq.length();
+ length = seq->length();
item = new DataItem();
item->name = strdup(name_param);
item->value <<= value_param;
- _dataItemSeq.length(length + 1);
- _dataItemSeq[length] = *item;
+ seq->length(length + 1);
+ (*seq)[length] = *item;
}
else {
- _dataItemSeq.length(0);
+ seq->length(0);
ret_val = -1;
}
return ret_val;
int BusMessage::add_int_parameter(const char *name_param, int value_param)
{
- long length;
- int ret_val;
- DataItem *item;
+ long length;
+ int ret_val;
+ DataItem *item;
+ DataItemSequence *seq;
ret_val = 0;
+ seq = (DataItemSequence *)_dataItemSeq;
if (name_param != NULL) {
- length = _dataItemSeq.length();
+ length = seq->length();
item = new DataItem();
item->name = strdup(name_param);
item->value <<= (long)value_param;
- _dataItemSeq.length(length + 1);
- _dataItemSeq[length] = *item;
+ seq->length(length + 1);
+ (*seq)[length] = *item;
}
else {
- _dataItemSeq.length(0);
+ seq->length(0);
ret_val = -1;
}
return ret_val;
int BusMessage::add_double_parameter(const char *name_param, double value_param)
{
- long length;
- int ret_val;
- DataItem *item;
+ long length;
+ int ret_val;
+ DataItem *item;
+ DataItemSequence *seq;
ret_val = 0;
+ log_debug("add_double_parameter() started\n");
+ seq = (DataItemSequence *)_dataItemSeq;
if (name_param != NULL) {
- length = _dataItemSeq.length();
+ length = seq->length();
item = new DataItem();
item->name = strdup(name_param);
item->value <<= (long)value_param;
- _dataItemSeq.length(length + 1);
- _dataItemSeq[length] = *item;
+ seq->length(length + 1);
+ (*seq)[length] = *item;
}
else {
- _dataItemSeq.length(0);
+ seq->length(0);
ret_val = -1;
}
+ log_debug("add_double_parameter() done\n");
return ret_val;
}
int BusMessage::add_float_parameter(const char *name_param, float value_param)
{
- long length;
- int ret_val;
- DataItem *item;
+ long length;
+ int ret_val;
+ DataItem *item;
+ DataItemSequence *seq;
ret_val = 0;
+ seq = (DataItemSequence *)_dataItemSeq;
if (name_param != NULL) {
- length = _dataItemSeq.length();
+ length = seq->length();
item = new DataItem();
item->name = strdup(name_param);
item->value <<= (long)value_param;
- _dataItemSeq.length(length + 1);
- _dataItemSeq[length] = *item;
+ seq->length(length + 1);
+ (*seq)[length] = *item;
}
else {
- _dataItemSeq.length(0);
+ seq->length(0);
ret_val = -1;
}
return ret_val;
}
-void BusMessage::printout_dataitem(long index, plpbus_orb::DataItem *item) {
+void BusMessage::printout_dataitem(long index, void *item) {
CORBA::TCKind kind;
+ DataItem *dataitem;
+ dataitem = (DataItem *)item;
if (item != NULL) {
- if (item->name != NULL) {
- kind = item->value.type()->kind();
+ if (dataitem->name != NULL) {
+ kind = dataitem->value.type()->kind();
switch(kind) {
case tk_string:
{
const char *val;
- item->value >>= val;
- log_debug(" [%ld], value: %s\n", index, val);
+ dataitem->value >>= val;
+ log_debug("\t[%ld], value: %s\n", index, val);
}
break;
case tk_long:
{
long val;
- item->value >>= val;
- log_debug(" [%ld], value: %ld\n", index, val);
+ dataitem->value >>= val;
+ log_debug("\t[%ld], value: %ld\n", index, val);
//val_str = strdup("long");
}
break;
case tk_double:
{
double val;
- item->value >>= val;
- log_debug(" [%ld], value: %f\n", index, val);
+ dataitem->value >>= val;
+ log_debug("\t[%ld], value: %f\n", index, val);
//val_str = strdup("double");
}
break;
case tk_float:
{
float val;
- item->value >>= val;
- log_debug(" [l%ld] value: %f\n", index, val);
+ dataitem->value >>= val;
+ log_debug("\t[l%ld] value: %f\n", index, val);
//val_str = strdup("float");
}
break;
default:
- log_error(" [%ld], value unknown\n", index);
+ log_error("\t[%ld], value unknown\n", index);
}
}
else {
- log_error(" [%ld] Invalid data item name name or value\n", index);
+ log_error("\t[%ld] Invalid data item name name or value\n", index);
}
}
else {
- log_error(" [%ld] dataItem NULL.", index);
+ log_error("\t[%ld] dataItem NULL.", index);
}
}
void BusMessage::printout() {
- long int count;
- DataItem item;
+ long int count;
+ DataItem item;
+ DataItemSequence *seq;
- count = _dataItemSeq.length();
+ seq = (DataItemSequence *)_dataItemSeq;
+ count = seq->length();
log_debug("BusMessage.printout(): parameter count: %ld\n", count);
for (long ii = 0; ii < count; ii++) {
- item = _dataItemSeq[ii];
+ item = (*seq)[ii];
printout_dataitem(ii, &item);
}
log_debug("BusMessage.printout() done\n");;
if (_listener != NULL) {
log_debug("send_message_and_request_response(): %s, server callback != NULL\n", msg_req);
_listener->request_received(msg_req, &msg_rsp);
+ log_debug("send_message_and_request_response(), request_received\n");
response_listener_param->receive_response_message(msg_rsp);
}
else {
void OrbServerImpl::send_dataitem_message_and_request_response(OrbClient_ptr response_listener_param,
const ::DataItemSequence& msg_req_param) {
- BusMessage *msg_req;
- BusMessage *msg_rsp;
+ BusMessage *msg_req;
+ BusMessage *msg_rsp;
+ DataItemSequence *seq;
if (CORBA::is_nil(response_listener_param) == false) {
if (_listener != NULL) {
msg_req->printout();
msg_rsp = NULL;
_listener->request_received(msg_req, &msg_rsp);
- log_debug("msg_rsp length: %ld\n", msg_rsp->_dataItemSeq.length());
+ seq = (DataItemSequence *)msg_rsp->_dataItemSeq;
+ log_debug("msg_rsp length: %ld\n", seq->length());
msg_rsp->printout();
- response_listener_param->receive_response_dataitem_sequence(msg_rsp->_dataItemSeq);
+ response_listener_param->receive_response_dataitem_sequence(*seq);
}
else {
log_error("send_dataitem_message_and_request_response() error, server_callback == NULL\n");
}
CORBA::Long OrbServerImpl::send_dataitem_message_and_wait_response(const DataItemSequence& req_seq_param,
- DataItemSequence_out rsp_seq_param) {
- BusMessage *msg_req;
- BusMessage *msg_rsp;
+ DataItemSequence_out rsp_seq_param) {
+ BusMessage *msg_req;
+ BusMessage *msg_rsp;
+ DataItemSequence *seq;
msg_req = new BusMessageInternal(req_seq_param);
msg_rsp = NULL;
_listener->request_received(msg_req, &msg_rsp);
//rsp_seq_param = new DataItemSequence_out(msg_rsp._dataItemSeq);
- rsp_seq_param._data = &(msg_rsp->_dataItemSeq);
+ seq = (DataItemSequence *)msg_rsp->_dataItemSeq;
+ rsp_seq_param._data = seq;
return 0;
}
//this->_remove_ref();
naming_context = get_service_naming_context(CONST_CONTEXT_NAME__PLPBUS, CONST_CONTEXT_KIND__PLPBUS);
if (naming_context != NULL) {
- ok_flg = bind_naming_context_and_service(naming_context, server_ref, server_name, CONST_CONTEXT_KIND__PLPBUS);
+ ok_flg = bind_naming_context_and_service(naming_context,
+ server_ref,
+ server_name,
+ CONST_CONTEXT_KIND__PLPBUS);
if (ok_flg == true) {
cout << "Registered to naming service: " << server_name << endl;
_orb->run();