using namespace CORBA;
BusMessage::BusMessage() {
- _dataItemSeq = new DataItemSequence();
- log_debug("new BusMessage()\n");
+ _dataItemSeq = new DataItemSequence(0);
}
-BusMessage::BusMessage(const char *name_param, const char *value_param) {
- DataItem *item;
- DataItemSequence *seq;
+BusMessage::BusMessage(long type_param) {
+ _dataItemSeq = new DataItemSequence(0);
- if (name_param != NULL) {
- item = new DataItem();
- item->name = strdup(name_param);
- item->value <<= strdup(value_param);
+ add_long_parameter(CONST_MSG_ID_KEY_NAME, type_param);
+}
- seq = new DataItemSequence(0);
- seq->length(1);
- (*seq)[0] = *item;
- _dataItemSeq = seq;
- }
- else {
- _dataItemSeq = new DataItemSequence(0);
- }
+BusMessage::BusMessage(long type_param,
+ const char *arg_name_param,
+ const char *arg_string_value_param) {
+ _dataItemSeq = new DataItemSequence(0);
+ add_long_parameter(CONST_MSG_ID_KEY_NAME, type_param);
+ add_string_parameter(arg_name_param, arg_string_value_param);
}
BusMessage::~BusMessage() {
}
-int BusMessage::add_string_parameter(const char *name_param, const char *value_param)
+int BusMessage::add_string_parameter(const char *arg_name_param, const char *value_param)
{
long length;
int ret_val;
ret_val = 0;
seq = (DataItemSequence *)_dataItemSeq;
- if (name_param != NULL) {
+ if (arg_name_param != NULL) {
length = seq->length();
item = new DataItem();
- item->name = strdup(name_param);
+ item->name = strdup(arg_name_param);
if (value_param != NULL) {
item->value <<= strdup(value_param);
seq->length(length + 1);
}
}
else {
- seq->length(0);
ret_val = -1;
}
return ret_val;
}
-int BusMessage::add_long_parameter(const char *name_param, long value_param)
+int BusMessage::add_long_parameter(const char *arg_name_param, long value_param)
{
long length;
int ret_val;
ret_val = 0;
seq = (DataItemSequence *)_dataItemSeq;
- if (name_param != NULL) {
+ if (arg_name_param != NULL) {
length = seq->length();
item = new DataItem();
- item->name = strdup(name_param);
+ item->name = strdup(arg_name_param);
item->value <<= value_param;
seq->length(length + 1);
(*seq)[length] = *item;
}
else {
- seq->length(0);
ret_val = -1;
}
return ret_val;
}
-int BusMessage::add_int_parameter(const char *name_param, int value_param)
+int BusMessage::add_int_parameter(const char *arg_name_param, int value_param)
{
long length;
int ret_val;
ret_val = 0;
seq = (DataItemSequence *)_dataItemSeq;
- if (name_param != NULL) {
+ if (arg_name_param != NULL) {
length = seq->length();
item = new DataItem();
- item->name = strdup(name_param);
+ item->name = strdup(arg_name_param);
item->value <<= (long)value_param;
seq->length(length + 1);
(*seq)[length] = *item;
}
else {
- seq->length(0);
ret_val = -1;
}
return ret_val;
}
-int BusMessage::add_double_parameter(const char *name_param, double value_param)
+int BusMessage::add_double_parameter(const char *arg_name_param, double value_param)
{
long length;
int ret_val;
ret_val = 0;
log_debug("add_double_parameter() started\n");
seq = (DataItemSequence *)_dataItemSeq;
- if (name_param != NULL) {
+ if (arg_name_param != NULL) {
length = seq->length();
item = new DataItem();
- item->name = strdup(name_param);
+ item->name = strdup(arg_name_param);
item->value <<= (long)value_param;
seq->length(length + 1);
(*seq)[length] = *item;
}
else {
- 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)
+int BusMessage::add_float_parameter(const char *arg_name_param, float value_param)
{
long length;
int ret_val;
ret_val = 0;
seq = (DataItemSequence *)_dataItemSeq;
- if (name_param != NULL) {
+ if (arg_name_param != NULL) {
length = seq->length();
item = new DataItem();
- item->name = strdup(name_param);
+ item->name = strdup(arg_name_param);
item->value <<= (long)value_param;
seq->length(length + 1);
(*seq)[length] = *item;
}
else {
- seq->length(0);
ret_val = -1;
}
return ret_val;
#ifndef BUSMESSAGE_H_
#define BUSMESSAGE_H_
+#define CONST_MSG_ID_KEY_NAME "_msgid"
+
namespace plpbus {
class BusMessage
{
public:
void *_dataItemSeq;
- BusMessage();
- BusMessage(const char *name_param, const char *string_value_param);
+ BusMessage(long type_param);
+ BusMessage(long type_param, const char *arg_name_param, const char *arg_string_value_param);
virtual ~BusMessage();
- int add_string_parameter(const char *name_param, const char *string_value_param);
- int add_long_parameter(const char *name_param, long value_param);
- int add_int_parameter(const char *name_param, int value_param);
- int add_double_parameter(const char *name_param, double value_param);
- int add_float_parameter(const char *name_param, float value_param);
+ int add_string_parameter(const char *arg_name_param, const char *string_value_param);
+ int add_long_parameter(const char *arg_name_param, long value_param);
+ int add_int_parameter(const char *arg_name_param, int value_param);
+ int add_double_parameter(const char *arg_name_param, double value_param);
+ int add_float_parameter(const char *arg_name_param, float value_param);
void printout();
- private:
+ protected:
+ BusMessage();
void printout_dataitem(long index, void *item);
};
}