diff options
author | gokhale <asgokhale@users.noreply.github.com> | 1997-08-10 14:24:06 +0000 |
---|---|---|
committer | gokhale <asgokhale@users.noreply.github.com> | 1997-08-10 14:24:06 +0000 |
commit | d077ed015c889a3704c3e8cd8e705453252c99c5 (patch) | |
tree | 8cf6e1ab2c9378e2ed38f4c7bff75d383d5625dc /TAO/Benchmark | |
parent | 1dfb01b1d933034bd7a9b53623328daba18a642c (diff) | |
download | ATCD-d077ed015c889a3704c3e8cd8e705453252c99c5.tar.gz |
A new suite of benchmark code is added. This one for TAO.
Diffstat (limited to 'TAO/Benchmark')
17 files changed, 3855 insertions, 0 deletions
diff --git a/TAO/Benchmark/Marshal_Test/TAO/Makefile b/TAO/Benchmark/Marshal_Test/TAO/Makefile new file mode 100644 index 00000000000..8089081ecce --- /dev/null +++ b/TAO/Benchmark/Marshal_Test/TAO/Makefile @@ -0,0 +1,64 @@ +#---------------------------------------------------------------------------- +# $Id$ +# +# Top-level Makefile for the Tao Marshal Benchmark +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +LDLIBS = -lACE -lbenchmark -lTAO + +PROG_SRCS = marshalC.cpp marshalS.cpp tao_marshal_client.cpp tao_marshal_server.cpp \ + tao_marshal_impl.cpp client.cpp server.cpp + +LSRC = $(PROG_SRCS) + +MARSHAL_CLIENT_OBJS = marshalC.o tao_marshal_client.o client.o + +MARSHAL_SERVER_OBJS = marshalC.o marshalS.o tao_marshal_impl.o tao_marshal_server.o server.o + +BIN = client server + +BUILD = $(BIN) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU +include $(ACE_ROOT)/include/makeinclude/rules.lib.GNU +#include $(ACE_ROOT)/include/makeinclude/rules.bin.GNU +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local modifications to variables imported by includes above. +#---------------------------------------------------------------------------- + +ifndef TAO_ROOT +TAO_ROOT = $(ACE_ROOT)/TAO +endif + +CPPFLAGS += -I$(TAO_ROOT) -I$(TAO_ROOT)/Benchmark -I$(TAO_ROOT)/tao/compat +server: $(addprefix $(VDIR),$(MARSHAL_SERVER_OBJS)) + $(LINK.cc) $(LDFLAGS) -o $@ $^ $(VLDLIBS) + +client: $(addprefix $(VDIR),$(MARSHAL_CLIENT_OBJS)) + $(LINK.cc) $(LDFLAGS) -o $@ $^ $(VLDLIBS) + +clean: + rm -f core *.o *~ client server + $(MAKE) realclean + + + + + + + diff --git a/TAO/Benchmark/Marshal_Test/TAO/client.cpp b/TAO/Benchmark/Marshal_Test/TAO/client.cpp new file mode 100644 index 00000000000..b38fef81023 --- /dev/null +++ b/TAO/Benchmark/Marshal_Test/TAO/client.cpp @@ -0,0 +1,12 @@ +#include "benchmark/driver.h" +#include "tao_marshal_client.h" + +int main (int argc, char *argv []) +{ + // instantiate a DRIVER with the Tao_Client_Proxy as the template + CORBA_Benchmark_Driver<Tao_Marshal_Client_Proxy> driver (new + Tao_Marshal_Client_Proxy ()); + + // let the driver do everything for us so that we remain very simple + return driver.run (argc, argv); +} diff --git a/TAO/Benchmark/Marshal_Test/TAO/marshal.idl b/TAO/Benchmark/Marshal_Test/TAO/marshal.idl new file mode 100644 index 00000000000..7ddc5423db4 --- /dev/null +++ b/TAO/Benchmark/Marshal_Test/TAO/marshal.idl @@ -0,0 +1,89 @@ +// Interface for the marshal benchmark + +interface Marshal +{ + struct Marshal_Struct + { + short s; + long l; + char c; + octet o; + double d; + }; + + enum discrim {e_0th, e_1st, e_2nd, e_3rd, e_4th, e_5th, e_6th}; + + union Marshal_Union + switch (discrim) + { + case e_0th: + short s; + case e_1st: + long l; + case e_2nd: + char c; + case e_3rd: + octet o; + case e_4th: + double d; + case e_5th: + default: // this will test typecode indirection + Marshal_Struct ms; + }; + + /* + typedef sequence<short> ShortSeq; + typedef sequence<long> LongSeq; + typedef sequence<octet> OctetSeq; + typedef sequence<char> CharSeq; + typedef sequence<double> DoubleSeq; + typedef sequence<Marshal_Struct> StructSeq; + typedef sequence<Marshal_Union> UnionSeq; + */ + // for testing sequences of Any + typedef sequence<any> AnySeq; + + // testing recursive behavior + // complex. + struct Marshal_Recursive + { + // we use this to test the limited recursion allowed by IDL. This is an + // ideal test for indirected typecodes. + + // simulate a behavior of a list node + any value; + sequence <Marshal_Recursive> next; + }; + + void test_short (in short s1, out short s2); // test a short + void test_long (in long l1, out long l2); // test a long + void test_octet (in octet o1, out octet o2); // test an octet + void test_char (in char c1, out char c2); // test a char + void test_double (in double d1, out double d2); // test a double + void test_struct (in Marshal_Struct ms1, out Marshal_Struct ms2); // test a + // struct + void test_union (in Marshal_Union u1, out Marshal_Union u2); // test a + // union. + void test_any (in any a1, out any a2); // test an Any + /* + void test_sequence (in ShortSeq ss1, in LongSeq ls1, in OctetSeq os1, in + CharSeq cs1, in DoubleSeq ds1, in StructSeq Ss1, in + UnionSeq us1, in AnySeq as1, + out ShortSeq ss2, out LongSeq ls2, out OctetSeq os2, out + CharSeq cs2, out DoubleSeq ds2, out StructSeq Ss2, out + UnionSeq us2, out AnySeq as2); + */ + void test_sequence (in AnySeq as1, out AnySeq as2); // this will result in a + // 3 level indirection - + // sequence, any, and its + // value type + void test_recursive (in Marshal_Recursive mr1, out Marshal_Recursive mr2); // + // very complicated +}; + + + + + + + diff --git a/TAO/Benchmark/Marshal_Test/TAO/marshalC.cpp b/TAO/Benchmark/Marshal_Test/TAO/marshalC.cpp new file mode 100644 index 00000000000..3a8b4465fba --- /dev/null +++ b/TAO/Benchmark/Marshal_Test/TAO/marshalC.cpp @@ -0,0 +1,585 @@ +#include <stdio.h> +#include "marshalC.h" + +// constructor +Marshal::Marshal(STUB_Object *refdata) + : CORBA_Object(refdata) +{ +} + +// static duplicate method +Marshal_ptr Marshal::_duplicate(Marshal_ptr obj) +{ + void *dupl; + + if (obj) + { + obj->AddRef(); + } + return obj; +} + +// static _narrow method +Marshal_ptr Marshal::_narrow(CORBA_Object_ptr obj) +{ + CORBA_Environment env; + if (obj->_is_a("IDL:Marshal:1.0", env)){ + STUB_Object *istub; + if (obj->QueryInterface(IID_STUB_Object, (void **)&istub) != NOERROR){ + return Marshal::_nil(); + } + Marshal_ptr new_obj = new Marshal(istub); + return Marshal::_duplicate(new_obj); + } + return Marshal::_nil(); +} + +Marshal_ptr Marshal::_nil() +{ + return (Marshal_ptr)NULL; +} + +Marshal::Marshal_Union::Marshal_Union(const Marshal::Marshal_Union& obj) +{ + _disc = obj._d(); + switch (_disc) { + case e_0th: + __s = obj.__s; + break; + case e_1st: + __l = obj.__l; + break; + case e_2nd: + __c = obj.__c; + break; + case e_3rd: + __o = obj.__o; + break; + case e_4th: + __d = obj.__d; + break; + case e_5th: + default: + __ms = obj.__ms; + break; + } +} + +Marshal::Marshal_Union& Marshal::Marshal_Union::operator=(const Marshal::Marshal_Union& obj) +{ + _disc = obj._d(); + switch (_disc) { + case e_0th: + __s = obj.__s; + break; + case e_1st: + __l = obj.__l; + break; + case e_2nd: + __c = obj.__c; + break; + case e_3rd: + __o = obj.__o; + break; + case e_4th: + __d = obj.__d; + break; + case e_5th: + default: + __ms = obj.__ms; + break; + } + return *this; +} + +// AnySeq methods +Marshal::AnySeq::AnySeq (CORBA_ULong max) + : _maximum(max), + _length(0), + _release(CORBA_B_FALSE) +{ + if (this->_maximum > 0){ + this->_buffer = new CORBA_Any [this->_maximum]; + } else { + this->_buffer = 0; + } +} + +Marshal::AnySeq::AnySeq (CORBA_ULong max, CORBA_ULong length, + CORBA_Any *value, CORBA_Boolean release) + : _maximum(max), + _length(length), + _buffer(value), + _release(release) +{ +} + +Marshal::AnySeq::~AnySeq() +{ + this->_maximum = this->_length = 0; + if (this->_release != CORBA_B_FALSE) + delete this->_buffer; +} + +void Marshal::AnySeq::length (CORBA_ULong newlen) +{ + if (newlen > this->_maximum) { + CORBA_Any *temp = new CORBA_Any [newlen]; + ::memcpy(temp, this->_buffer, (size_t(this->_length) * sizeof (CORBA_Any))); + if (this->_release) + delete this->_buffer; + else + this->_release = 1; + + this->_maximum = newlen; + this->_buffer = temp; + } + if (newlen > this->_length) + memset(&this->_buffer[this->_length], 0, size_t(newlen - this->_length) * + sizeof(CORBA_Any)); + this->_length = newlen; +} + +CORBA_ULong Marshal::AnySeq::length() const +{ + return this->_length; +} + +CORBA_Any &Marshal::AnySeq::operator[](CORBA_ULong index) +{ + if (index >= this->_length) + exit(1); + return this->_buffer[index]; +} + +const CORBA_Any& Marshal::AnySeq::operator[](CORBA_ULong index) const +{ + if (index >= this->_length) + exit(1); + return this->_buffer[index]; +} + + +/***************** TypeCodes **************/ +// In the typecode, all repoIDs and names are omitted by providing their length +// as 1 that stands for the NULL terminator + +// encapsulated parameters for struct Marshal_Struct typecode +static const CORBA_Long _oc_Marshal_Struct [] = { + MY_BYTE_SEX, // byte order + 1, 0, // repoID omitted (16, "IDL:Marshal/Marshal:1.0") + 1, 0, // struct name (15, "Marshal_Struct") omitted + 5, // 5 struct elements + + // short + 1, 0, // should be 2, "s", + tk_short, + + // long + 1, 0, // should be 2, "l", + tk_long, + + // char + 1, 0, // should be 2, "c", + tk_char, + + // octet + 1, 0, // should be 2, "o", + tk_octet, + + // double + 1, 0, // should be 2, "d", + tk_double, +}; + + +static CORBA_TypeCode _tc__tc_Marshal_Struct (tk_struct, + sizeof _oc_Marshal_Struct, + (unsigned char *) &_oc_Marshal_Struct, + CORBA_B_FALSE); +CORBA_TypeCode_ptr Marshal::_tc_Marshal_Struct = &_tc__tc_Marshal_Struct; + + +static const CORBA_Long _oc_discrim [] = { + MY_BYTE_SEX, // byte order flag (TRICKY) + 1, 0, // should be 20, "IDL:Marshal/discrim", + 1, 0, // should be 8, "discrim", + 7, // 7 elements in the enum + + 1, 0, // 6, "e_0th", // omitted member name, "e_0th" + 1, 0, // 6, "e_1st", // omitted member name, "e_1st" + 1, 0, // 6, "e_2nd", // omitted member name, "e_2nd" + 1, 0, // 6, "e_3rd", // omitted member name, "e_3rd" + 1, 0, // 6, "e_4th", // omitted member name, "e_4th" + 1, 0, // 6, "e_5th", // omitted member name, "e_5th" + 1, 0 //6, "e_6th" // omitted member name, "e_6th" +}; + +static CORBA_TypeCode _tc__tc_discrim (tk_enum, + sizeof _oc_discrim, + (unsigned char *) &_oc_discrim, + CORBA_B_FALSE); + +CORBA_TypeCode_ptr Marshal::_tc_discrim = &_tc__tc_discrim; + +// Union +static const CORBA_Long _oc_Marshal_Union [] = +{ + MY_BYTE_SEX, // byte order flag (TRICKY) + 1, 0, // 26, "IDL:Marshal/Marshal_Union", // omitted repository/type ID + 1, 0, // 14, "Marshal_Union", // union name + + // + // discriminant typecode: + // + + tk_enum, // tk_enum + 80, // encapsulation length + MY_BYTE_SEX, + 1, 0, // repoID + 1, 0, // name + 7, // 7 elements in the enum + + 1, 0, // e_Oth + 1, 0, + 1, 0, + 1, 0, + 1, 0, + 1, 0, + 1, 0, // e_6th + + 5, // default member index (zero based) + 6, // number of union members + + // the 1st union branch arm + Marshal::e_0th, // member label value + 1, 0, // omitted member name, "s" + tk_short, // member typecode + + // the 2nd union branch arm + Marshal::e_1st, // member label value + 1, 0, // omitted member name, "l" + tk_long, // member typecode + + // the 3rd union branch arm + Marshal::e_2nd, // member label value + 1, 0, // omitted member name, "c" + tk_char, // member typecode + + // the 4th union branch arm + Marshal::e_3rd, // member label value + 1, 0, // omitted member name, "o" + tk_octet, // member typecode + + // the 5th union branch arm + Marshal::e_4th, // member label value + 1, 0, // omitted member name, "d" + tk_double, + + // the 6th union branch + Marshal::e_5th, // member label value + 1, 0, // omitted member name, "ms" + tk_struct, // tk_struct + 84, // encapsulation length + + MY_BYTE_SEX, // byte order + 1, 0, // repoID omitted (16, "IDL:Marshal/Marshal:1.0") + 1, 0, // struct name (15, "Marshal_Struct") omitted + 5, // 5 struct elements + + // short + 1, 0, // should be 2, "s", + tk_short, + + // long + 1, 0, // should be 2, "l", + tk_long, + + // char + 1, 0, // should be 2, "c", + tk_char, + + // octet + 1, 0, // should be 2, "o", + tk_octet, + + // double + 1, 0, // should be 2, "d", + tk_double, + + // default case + 6, // 7th member, default index val + 1, 0, // struct name "ms" + ~0, // indirected typecode + -108 // has to point to tk_struct in this stream +}; + +static CORBA_TypeCode _tc__tc_Marshal_Union (tk_union, + sizeof _oc_Marshal_Union, + (unsigned char *) &_oc_Marshal_Union, + CORBA_B_FALSE); + +CORBA_TypeCode_ptr Marshal::_tc_Marshal_Union = &_tc__tc_Marshal_Union; + +// AnySeq +static const CORBA_Long _oc_AnySeq [] = { + MY_BYTE_SEX, // byte order + tk_any, // sequence of any + 0, // a length of 0 => unbounded sequence +}; +static CORBA_TypeCode _tc__tc_AnySeq (tk_sequence, + sizeof + _oc_AnySeq, + (unsigned char *) + &_oc_AnySeq, + CORBA_B_FALSE); + +CORBA_TypeCode_ptr Marshal::_tc_AnySeq = &_tc__tc_AnySeq; + +/***************** All the methods ********************/ +// test_short +static const TAO_Param_Data marshal_test_short_paramdata [] = { + {_tc_CORBA_Void, PARAM_RETURN, 0}, + {_tc_CORBA_Short, PARAM_IN, 0}, + {_tc_CORBA_Short, PARAM_OUT, 0} +}; + +static const TAO_Call_Data marshal_test_short_calldata = { + "test_short", // op_name + CORBA_B_TRUE, // twoway, although it returns void + 3, // param count + & marshal_test_short_paramdata [0], // + 0, 0 +}; + +// The stub +void Marshal::test_short (CORBA_Short s1, CORBA_Short &s2, CORBA_Environment &env) +{ + STUB_Object *istub; + if (this->QueryInterface (IID_STUB_Object, (void **) &istub) != NOERROR){ + env.exception (new CORBA_DATA_CONVERSION (COMPLETED_NO)); + return; + } + // twoway + istub->do_call(env, &marshal_test_short_calldata, 0, &s1, &s2); +} + +// test_long +static const TAO_Param_Data marshal_test_long_paramdata [] = { + {_tc_CORBA_Void, PARAM_RETURN, 0}, + {_tc_CORBA_Long, PARAM_IN, 0}, + {_tc_CORBA_Long, PARAM_OUT, 0} +}; + +static const TAO_Call_Data marshal_test_long_calldata = { + "test_long", // op_name + CORBA_B_TRUE, // twoway, although it returns void + 3, // param count + & marshal_test_long_paramdata [0], // + 0, 0 +}; + +// The stub +void Marshal::test_long (CORBA_Long l1, CORBA_Long &l2, CORBA_Environment &env) +{ + STUB_Object *istub; + if (this->QueryInterface (IID_STUB_Object, (void **) &istub) != NOERROR){ + env.exception (new CORBA_DATA_CONVERSION (COMPLETED_NO)); + return; + } + // twoway + istub->do_call(env, &marshal_test_long_calldata, 0, &l1, &l2); +} + +// test_octet +static const TAO_Param_Data marshal_test_octet_paramdata [] = { + {_tc_CORBA_Void, PARAM_RETURN, 0}, + {_tc_CORBA_Octet, PARAM_IN, 0}, + {_tc_CORBA_Octet, PARAM_OUT, 0} +}; + +static const TAO_Call_Data marshal_test_octet_calldata = { + "test_octet", // op_name + CORBA_B_TRUE, // twoway, although it returns void + 3, // param count + & marshal_test_octet_paramdata [0], // + 0, 0 +}; + +// The stub +void Marshal::test_octet (CORBA_Octet o1, CORBA_Octet &o2, CORBA_Environment &env) +{ + STUB_Object *istub; + if (this->QueryInterface (IID_STUB_Object, (void **) &istub) != NOERROR){ + env.exception (new CORBA_DATA_CONVERSION (COMPLETED_NO)); + return; + } + // twoway + istub->do_call(env, &marshal_test_octet_calldata, 0, &o1, &o2); +} + +// test_char +static const TAO_Param_Data marshal_test_char_paramdata [] = { + {_tc_CORBA_Void, PARAM_RETURN, 0}, + {_tc_CORBA_Char, PARAM_IN, 0}, + {_tc_CORBA_Char, PARAM_OUT, 0} +}; + +static const TAO_Call_Data marshal_test_char_calldata = { + "test_char", // op_name + CORBA_B_TRUE, // twoway, although it returns void + 3, // param count + & marshal_test_char_paramdata [0], // + 0, 0 +}; + +// The stub +void Marshal::test_char (CORBA_Char c1, CORBA_Char &c2, CORBA_Environment &env) +{ + STUB_Object *istub; + if (this->QueryInterface (IID_STUB_Object, (void **) &istub) != NOERROR){ + env.exception (new CORBA_DATA_CONVERSION (COMPLETED_NO)); + return; + } + // twoway + istub->do_call(env, &marshal_test_char_calldata, 0, &c1, &c2); +} + +// test_double +static const TAO_Param_Data marshal_test_double_paramdata [] = { + {_tc_CORBA_Void, PARAM_RETURN, 0}, + {_tc_CORBA_Double, PARAM_IN, 0}, + {_tc_CORBA_Double, PARAM_OUT, 0} +}; + +static const TAO_Call_Data marshal_test_double_calldata = { + "test_double", // op_name + CORBA_B_TRUE, // twoway, although it returns void + 3, // param count + & marshal_test_double_paramdata [0], // + 0, 0 +}; + +// The stub +void Marshal::test_double (CORBA_Double d1, CORBA_Double &d2, CORBA_Environment &env) +{ + STUB_Object *istub; + if (this->QueryInterface (IID_STUB_Object, (void **) &istub) != NOERROR){ + env.exception (new CORBA_DATA_CONVERSION (COMPLETED_NO)); + return; + } + // twoway + istub->do_call (env, &marshal_test_double_calldata, 0, &d1, &d2); +} + +// test_struct +static const TAO_Param_Data marshal_test_struct_paramdata [] = { + {_tc_CORBA_Void, PARAM_RETURN, 0}, + {Marshal::_tc_Marshal_Struct, PARAM_IN, 0}, + {Marshal::_tc_Marshal_Struct, PARAM_OUT, 0} +}; + +static const TAO_Call_Data marshal_test_struct_calldata = { + "test_struct", // op_name + CORBA_B_TRUE, // twoway, although it returns void + 3, // param count + & marshal_test_struct_paramdata [0], // + 0, 0 +}; + +// The stub +void Marshal::test_struct (const Marshal::Marshal_Struct &ms1, Marshal::Marshal_Struct + &ms2, CORBA_Environment &env) +{ + STUB_Object *istub; + if (this->QueryInterface (IID_STUB_Object, (void **) &istub) != NOERROR){ + env.exception (new CORBA_DATA_CONVERSION (COMPLETED_NO)); + return; + } + // twoway + istub->do_call(env, &marshal_test_struct_calldata, 0, &ms1, &ms2); +} + +// test_union +static const TAO_Param_Data marshal_test_union_paramdata [] = { + {_tc_CORBA_Void, PARAM_RETURN, 0}, + {Marshal::_tc_Marshal_Union, PARAM_IN, 0}, + {Marshal::_tc_Marshal_Union, PARAM_OUT, 0} +}; + +static const TAO_Call_Data marshal_test_union_calldata = { + "test_union", // op_name + CORBA_B_TRUE, // twoway, although it returns void + 3, // param count + & marshal_test_union_paramdata [0], // + 0, 0 +}; + +// The stub +void Marshal::test_union (const Marshal_Union &u1, Marshal::Marshal_Union + &u2, CORBA_Environment &env) +{ + STUB_Object *istub; + if (this->QueryInterface (IID_STUB_Object, (void **) &istub) != NOERROR){ + env.exception (new CORBA_DATA_CONVERSION (COMPLETED_NO)); + return; + } + // twoway + istub->do_call (env, &marshal_test_union_calldata, 0, &u1, &u2); +} + +// test_any +static const TAO_Param_Data marshal_test_any_paramdata [] = { + {_tc_CORBA_Void, PARAM_RETURN, 0}, + {_tc_CORBA_Any, PARAM_IN, 0}, + {_tc_CORBA_Any, PARAM_OUT, 0} +}; + +static const TAO_Call_Data marshal_test_any_calldata = { + "test_any", // op_name + CORBA_B_TRUE, // twoway, although it returns void + 3, // param count + & marshal_test_any_paramdata[0], // + 0, 0 +}; + +// The stub +void Marshal::test_any (const CORBA_Any &a1, CORBA_Any *&a2, CORBA_Environment &env) +{ + STUB_Object *istub; + if (this->QueryInterface (IID_STUB_Object, (void **) &istub) != NOERROR){ + env.exception (new CORBA_DATA_CONVERSION (COMPLETED_NO)); + return; + } + // twoway + istub->do_call(env, &marshal_test_any_calldata, 0, &a1, &a2); +} + +// test_sequence +static const TAO_Param_Data marshal_test_sequence_paramdata [] = { + { _tc_CORBA_Void, PARAM_RETURN, 0}, + { Marshal::_tc_AnySeq, PARAM_IN, 0}, + { Marshal::_tc_AnySeq, PARAM_OUT, 0} +}; + +static const TAO_Call_Data marshal_test_sequence_calldata = { + "test_sequence", // opname + CORBA_B_TRUE, // twoway + 2, // param count + &marshal_test_sequence_paramdata [0], + 0, 0 +}; + +// stub +void Marshal::test_sequence (const Marshal::AnySeq &as1, Marshal::AnySeq *&as2, + CORBA_Environment &env) +{ + STUB_Object *istub; + if (this->QueryInterface (IID_STUB_Object, (void **) &istub) != NOERROR){ + env.exception (new CORBA_DATA_CONVERSION (COMPLETED_NO)); + return; + } + // twoway + istub->do_call(env, &marshal_test_sequence_calldata, 0, &as1, &as2); +} + diff --git a/TAO/Benchmark/Marshal_Test/TAO/marshalC.h b/TAO/Benchmark/Marshal_Test/TAO/marshalC.h new file mode 100644 index 00000000000..505de16fafb --- /dev/null +++ b/TAO/Benchmark/Marshal_Test/TAO/marshalC.h @@ -0,0 +1,194 @@ +/************************************************************************** +This file has been hand-crafted to work with the ORB API of TAO +***************************************************************************/ + +#ifndef MARSHAL_C_H +#define MARSHAL_C_H + +#include <stdlib.h> +#include <string.h> + +#include "tao/orb.h" +#include "tao/orbobj.h" +#include "tao/object.h" +#include "tao/stub.h" +#include "tao/typecode.h" +#include "tao/cdr.h" + +class Marshal; +typedef Marshal *Marshal_ptr; +typedef Marshal_ptr MarshalRef; + +class Marshal: public virtual CORBA_Object +{ +public: + static Marshal_ptr _duplicate (Marshal_ptr obj); + static Marshal_ptr _narrow (CORBA_Object_ptr obj); + static Marshal_ptr _nil (); + + struct Marshal_Struct { + CORBA_Short s; + CORBA_Long l; + CORBA_Char c; + CORBA_Octet o; + CORBA_Double d; + }; + static CORBA_TypeCode_ptr _tc_Marshal_Struct; + + enum discrim { + e_0th, + e_1st, + e_2nd, + e_3rd, + e_4th, + e_5th, + e_6th + }; + + static CORBA_TypeCode_ptr _tc_discrim; + + class Marshal_Union + { + private: + discrim _disc; + CORBA_Short __s; + CORBA_Long __l; + CORBA_Char __c; + CORBA_Octet __o; + CORBA_Double __d; + Marshal::Marshal_Struct __ms; + public: + Marshal_Union() : _disc(discrim(0)) {} + ~Marshal_Union() {} + Marshal_Union(const Marshal_Union& obj); + Marshal_Union& operator=(const Marshal_Union& obj); + + void _d(discrim val) { _disc = val; } + discrim _d() const { return _disc; } + + void s(CORBA_Short val) { + __s = val; + _disc = Marshal::e_0th; + } + CORBA_Short s() const { return __s; } + + void l(CORBA_Long val) { + __l = val; + _disc = Marshal::e_1st; + } + CORBA_Long l() const { return __l; } + + void c(CORBA_Char val) { + __c = val; + _disc = Marshal::e_2nd; + } + CORBA_Char c() const { return __c; } + + void o(CORBA_Octet val) { + __o = val; + _disc = Marshal::e_3rd; + } + CORBA_Octet o() const { return __o; } + + void d(CORBA_Double val) { + __d = val; + _disc = Marshal::e_4th; + } + CORBA_Double d() const { return __d; } + + void ms(const Marshal::Marshal_Struct& val) { + __ms = val; + _disc = Marshal::e_5th; + } + const Marshal::Marshal_Struct& ms() const { return __ms; } + Marshal::Marshal_Struct& ms() { return __ms; } + + }; + + static CORBA_TypeCode_ptr _tc_Marshal_Union; + + class AnySeq + { + public: + static CORBA_Any *allocbuf (CORBA_ULong nelems); + static void freebuf (CORBA_Any *data); + AnySeq (CORBA_ULong max=0); + AnySeq (CORBA_ULong max, + CORBA_ULong length, + CORBA_Any *value, + CORBA_Boolean release = CORBA_B_FALSE + ); + // AnySeq (const AnySeq&); + ~AnySeq (); + CORBA_ULong maximum () const; + void length (CORBA_ULong); + CORBA_ULong length () const; + CORBA_Any &operator[] (CORBA_ULong index); + const CORBA_Any &operator[] (CORBA_ULong index) const; + private: + CORBA_ULong _maximum; + CORBA_ULong _length; + CORBA_Any *_buffer; + CORBA_Boolean _release; + }; + static CORBA_TypeCode_ptr _tc_AnySeq; + + + // now the methods + virtual void test_short(CORBA_Short s1, + CORBA_Short& s2, + CORBA_Environment &env); + + virtual void test_long(CORBA_Long l1, + CORBA_Long& l2, + CORBA_Environment &env); + + virtual void test_octet(CORBA_Octet o1, + CORBA_Octet& o2, + CORBA_Environment &env); + + virtual void test_char(CORBA_Char c1, + CORBA_Char& c2, + CORBA_Environment &env); + + virtual void test_double(CORBA_Double d1, + CORBA_Double& d2, + CORBA_Environment &env); + + virtual void test_struct(const Marshal::Marshal_Struct& ms1, + Marshal::Marshal_Struct& ms2, + CORBA_Environment &env); + + virtual void test_union(const Marshal::Marshal_Union& u1, + Marshal::Marshal_Union& u2, + CORBA_Environment &env); + + virtual void test_any(const CORBA_Any& a1, + CORBA_Any *& a2, + CORBA_Environment &env); + + virtual void test_sequence(const Marshal::AnySeq& as1, + Marshal::AnySeq *& as2, + CORBA_Environment &env); + +#if 0 + virtual void test_recursive(const Marshal::Marshal_Recursive& mr1, + Marshal::Marshal_Recursive *& mr2, + CORBA_Environment &env); +#endif + +protected: + Marshal() {} + Marshal(STUB_Object *refdata); + virtual ~Marshal() {} + +private: + Marshal(const Marshal &) {} + void operator=(const Marshal &) {} +}; + +#endif + + + + diff --git a/TAO/Benchmark/Marshal_Test/TAO/marshalS.cpp b/TAO/Benchmark/Marshal_Test/TAO/marshalS.cpp new file mode 100644 index 00000000000..c265e7c9c2f --- /dev/null +++ b/TAO/Benchmark/Marshal_Test/TAO/marshalS.cpp @@ -0,0 +1,168 @@ +#include <iostream.h> +#include "marshalS.h" + +static const TAO_operation_db_entry Marshal_operations[] = { + {"_is_a", &_skel_Marshal::_Marshal_is_a_skel}, + { "test_short", &_skel_Marshal::_Marshal_test_short_skel}, + { "test_long", &_skel_Marshal::_Marshal_test_long_skel}, + { "test_octet", &_skel_Marshal::_Marshal_test_octet_skel}, + { "test_char", &_skel_Marshal::_Marshal_test_char_skel}, + { "test_double", &_skel_Marshal::_Marshal_test_double_skel}, + { "test_struct", &_skel_Marshal::_Marshal_test_struct_skel}, + { "test_union", &_skel_Marshal::_Marshal_test_union_skel}, + { "test_any", &_skel_Marshal::_Marshal_test_any_skel}, + { "test_sequence", &_skel_Marshal::_Marshal_test_sequence_skel}, + { 0, 0 } +}; + +TAO_Dynamic_Hash_OpTable tao_Marshal_optable(Marshal_operations, 10, + // 9 + 1 operations on our + // interface + 20); +// constructor +_skel_Marshal::_skel_Marshal (const char *obj_name) +{ + const CORBA_String repoID = "IDL:Marshal:1.0"; // repository ID + IIOP_Object *data; // IIOP object + CORBA_BOA_ptr oa = TAO_OA_PARAMS::instance()->oa(); // underlying BOA + this->optable_ = &tao_Marshal_optable; // operation database + CORBA_Long i; + + // setup an IIOP object + data = new IIOP_Object (CORBA_string_dup (repoID)); + data->profile.iiop_version.major = IIOP::MY_MAJOR; + data->profile.iiop_version.minor = IIOP::MY_MINOR; + data->profile.host = ACE_OS::strdup(oa->get_addr().get_host_name()); + data->profile.port = oa->get_addr().get_port_number(); + data->profile.object_key.length = ACE_OS::strlen(obj_name); + data->profile.object_key.maximum = data->profile.object_key.length; + data->profile.object_key.buffer = new CORBA_Octet [(size_t)data->profile.object_key.length+1]; + ACE_OS::memcpy (data->profile.object_key.buffer, obj_name, + data->profile.object_key.length); // set the object key + this->set_parent(data); // store the IIOP obj reference with ourselves + this->sub_ = this; // set the most derived class to be ourselves + if (oa) oa->bind(data->profile.object_key, this);// register ourselves +} + +// skeletons +void _skel_Marshal::_Marshal_test_short_skel(CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) +{ +#if 0 + CORBA_NVList_ptr nvlist; + CORBA_NamedValue_ptr nv; + CORBA_Any temp_value(_tc_CORBA_Short); + Marshal_ptr impl; + + // now create a request and populate it with the typecodes + req.orb()->create_list (0, nvlist); + nv = nvlist->add_value(0, temp_value, CORBA_ARG_IN, env); + + // retrieve params - call the interpreter to interpret the parameters for us. + req.params(nvlist, env); + + Marshal::ShortSeq *value = (Marshal::ShortSeq *)nv->value()->value(); + + // now invoke the implementation + impl = (Marshal_ptr)(obj->get_subclass()); + // now the magic of dynamic binding + impl->sendShortSeq(*value, env); + + // result - NO result + CORBA_Any *any = new CORBA_Any(_tc_CORBA_Void, 0, CORBA_B_TRUE); + req.result(any, env); +#endif + + // One immediate thought is to do the following: + // define a specialized marshal factory derived from TAO_Marshal_Factory + // then: + // CDR compiledStream (req._incoming.next, req._incoming.remaining, + // byte_order, consume_buf = 0, instance of our marshal factory +} + +void _skel_Marshal::_Marshal_test_long_skel(CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) +{ +} + +void _skel_Marshal::_Marshal_test_octet_skel(CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) +{ +} + +void _skel_Marshal::_Marshal_test_char_skel(CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) +{ +} + +void _skel_Marshal::_Marshal_test_double_skel(CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) +{ +} + +void _skel_Marshal::_Marshal_test_struct_skel(CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) +{ +} + +void _skel_Marshal::_Marshal_test_union_skel(CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) +{ +} + +void _skel_Marshal::_Marshal_test_any_skel(CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) +{ +} + +void _skel_Marshal::_Marshal_test_sequence_skel(CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) +{ +} + +void _skel_Marshal::_Marshal_is_a_skel ( + CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env + ) +{ + CORBA_NVList_ptr nvlist; + CORBA_NamedValue_ptr nv; + CORBA_Any temp_value (_tc_CORBA_String); + char *type_id = "IDL:Marshal:1.0"; + + req.orb()->create_list (0, nvlist); + nv = nvlist->add_value (0, temp_value, CORBA_ARG_IN, env); + + req.params (nvlist, env); + if (env.exception () != 0) { + dexc (env, "is_a_skel, get params"); + return; + } + + CORBA_Boolean *retval; + CORBA_String value = *(CORBA_String *)nv->value ()->value (); + + cout << "object id = " << ((char *)value) << endl; + if (strcmp ((char *)value, (char *)type_id) == 0 + || strcmp ((char *)value, _tc_CORBA_Object->id(env)) == 0) + retval = new CORBA_Boolean (CORBA_B_TRUE); + else + retval = new CORBA_Boolean (CORBA_B_FALSE); + + CORBA_Any *any = + new CORBA_Any (_tc_CORBA_Boolean, retval, CORBA_B_TRUE); + + req.result (any, env); + dexc (env, "_is_a, result"); +} + diff --git a/TAO/Benchmark/Marshal_Test/TAO/marshalS.h b/TAO/Benchmark/Marshal_Test/TAO/marshalS.h new file mode 100644 index 00000000000..5980be4f737 --- /dev/null +++ b/TAO/Benchmark/Marshal_Test/TAO/marshalS.h @@ -0,0 +1,108 @@ +/************************************************************************** +This file has been hand-crafted to work with the ORB API of TAO +***************************************************************************/ + +#ifndef MARSHAL_S_H +#define MARSHAL_S_H + +#include <stdlib.h> +#include <string.h> + +#include "marshalC.h" +#include "tao/connect.h" +#include "tao/orb.h" +#include "tao/params.h" +#include "tao/iiopobj.h" +#include "tao/optable.h" // for registering our methods +#include "tao/corbacom.h" +#include "tao/nvlist.h" +#include "tao/orbobj.h" +#include "tao/debug.h" + + +class _skel_Marshal; +typedef _skel_Marshal *_skel_Marshal_ptr; +typedef _skel_Marshal *_skel_Marshal_ref; + +class _skel_Marshal: public Marshal +{ +public: + // pure virtual functions implemented by the implementation class + virtual void test_short(CORBA_Short s1, + CORBA_Short& s2, + CORBA_Environment &env) = 0; + + virtual void test_long(CORBA_Long l1, + CORBA_Long& l2, + CORBA_Environment &env) = 0; + + virtual void test_octet(CORBA_Octet o1, + CORBA_Octet& o2, + CORBA_Environment &env) = 0; + + virtual void test_char(CORBA_Char c1, + CORBA_Char& c2, + CORBA_Environment &env) = 0; + + virtual void test_double(CORBA_Double d1, + CORBA_Double& d2, + CORBA_Environment &env) = 0; + + virtual void test_struct(const Marshal::Marshal_Struct& ms1, + Marshal::Marshal_Struct& ms2, + CORBA_Environment &env) = 0; + + virtual void test_union(const Marshal::Marshal_Union& u1, + Marshal::Marshal_Union& u2, + CORBA_Environment &env) = 0; + + virtual void test_any(const CORBA_Any& a1, + CORBA_Any *& a2, + CORBA_Environment &env) = 0; + + virtual void test_sequence(const Marshal::AnySeq& as1, + Marshal::AnySeq *& as2, + CORBA_Environment &env) = 0; + + + // skeletons that do the upcall + static void _Marshal_is_a_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); + static void _Marshal_test_short_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); + static void _Marshal_test_long_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); + static void _Marshal_test_octet_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); + static void _Marshal_test_char_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); + static void _Marshal_test_double_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); + static void _Marshal_test_struct_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); + static void _Marshal_test_union_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); + static void _Marshal_test_any_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); + static void _Marshal_test_sequence_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); +protected: + _skel_Marshal (const char *obj_name = 0); + virtual ~_skel_Marshal () {} +}; + +#endif + + + + diff --git a/TAO/Benchmark/Marshal_Test/TAO/server.cpp b/TAO/Benchmark/Marshal_Test/TAO/server.cpp new file mode 100644 index 00000000000..930322be5c3 --- /dev/null +++ b/TAO/Benchmark/Marshal_Test/TAO/server.cpp @@ -0,0 +1,12 @@ +#include "benchmark/driver.h" +#include "tao_marshal_server.h" + +int main (int argc, char *argv []) +{ + // instantiate a DRIVER with the Tao_Client_Proxy as the template + CORBA_Benchmark_Driver<Tao_Marshal_Server_Proxy> driver (new + Tao_Marshal_Server_Proxy ()); + + // let the driver do everything for us so that we remain very simple + return driver.run (argc, argv); +} diff --git a/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_client.cpp b/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_client.cpp new file mode 100644 index 00000000000..157050ba3d8 --- /dev/null +++ b/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_client.cpp @@ -0,0 +1,1424 @@ +// ============================================================================ +// +// = LIBRARY +// CORBA Tao marshal benchmark +// +// = FILENAME +// tao_marshal_proxy.cpp +// +// = AUTHOR +// Aniruddha Gokhale +// +// ============================================================================ + +#include <iostream.h> +#include <fstream.h> +#include "tao_marshal_client.h" + +#if !defined (__ACE_INLINE__) +#include "tao_marshal_client.i" +#endif /* __ACE_INLINE__ */ + +int +Tao_Marshal_Client_Proxy::run (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) +{ + char **argv; + int argc; + CORBA_Object_ptr target; + CORBA_Environment env; + CORBA_String str; // IOR + fstream iorfile; // persistent storage + + // get the argument list to be passed on to the ORB_init method + argv = options.orb_init_args (argc); + + // get the orb. Pass any ORB_init arguments + this->orb_ = CORBA_ORB_init (argc, (char *const *)argv, "IOR", env); + if (this->orb_ == 0) + { + ACE_DEBUG ((LM_DEBUG, "ORB_init failed\n")); + return -1; + } + + str = CORBA_string_alloc(500); + + // read the IOR from the file ior.txt + iorfile.open("ior.txt", ios::in); + iorfile >> ((char *)str); + iorfile.close(); + + cout << "Read IOR string as: " << ((char *)str) << endl; + + target = this->orb_->string_to_object(str, env); + if (env.exception() != 0){ + ACE_DEBUG ((LM_ERROR, "str to obj failed")); + return 1; + } + CORBA_string_free(str); + +#if 0 + // get the obj ref by binding it to the specified host using the specified obj_name + target = Marshal::_bind (options.object_name (), options.hostname ()); + if (CORBA_is_nil (target)) + { + ACE_DEBUG ((LM_DEBUG, "bind call failed\n")); + return -1; + } +#endif + + this->ref_ = Marshal::_narrow (target); + if (CORBA_is_nil (this->ref_)) + { + ACE_DEBUG ((LM_DEBUG, "narrow to Marshal failed\n")); + return -1; + } + + // tell the "results" object what file it must store the results into + results.filename (options.filename ()); + + // use SII or DII accordingly + switch (options.policy ()) + { + case CORBA_Marshal_Options::STATIC : // use SII + return this->use_sii (options, results); + break; + case CORBA_Marshal_Options::DYNAMIC : // use DII + return this->use_dii (options, results); + break; + default: + ACE_DEBUG ((LM_DEBUG, "bad policy\n")); + return -1; + } + // hopefully we are never here, else something is seriously wrong + return -1; +} + +int +Tao_Marshal_Client_Proxy::use_sii (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) +{ + int i; + int status = 0; + // This method tests the static invocation interface + + for (i=0; i < options.iterations () && !status; i++) + { + switch (options.data_type ()) + { + // shorts + case CORBA_Marshal_Options::SHORT: + status = sii_test_short (options, results); + break; + // longs + case CORBA_Marshal_Options::LONG: + status = sii_test_long (options, results); + break; + // octets + case CORBA_Marshal_Options::OCTET: + status = sii_test_octet (options, results); + break; + // chars + case CORBA_Marshal_Options::CHAR: + status = sii_test_char (options, results); + break; + // doubles + case CORBA_Marshal_Options::DOUBLE: + status = sii_test_double (options, results); + break; + // Structs + case CORBA_Marshal_Options::STRUCT: + status = sii_test_struct (options, results); + break; + // unions + case CORBA_Marshal_Options::UNION: + status = sii_test_union (options, results); + break; + // anys + case CORBA_Marshal_Options::ANY: + status = sii_test_any (options, results); + break; + // sequences + case CORBA_Marshal_Options::SEQUENCE: + status = sii_test_sequence (options, results); + break; + // longs + case CORBA_Marshal_Options::RECURSIVE: + // status = sii_test_recursive (options, results); + // doesn't work + break; + default: + status = -1; + } // end of switch + } // for loop + + if (!status) + return 0; + else + return -1; +} + +int +Tao_Marshal_Client_Proxy::use_dii (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) +{ + int i; + int status = 0; + // This method tests the dynamic invocation interface + + for (i=0; i < options.iterations () && !status; i++) + { + switch (options.data_type ()) + { + // shorts + case CORBA_Marshal_Options::SHORT: + status = dii_test_short (options, results); + break; + // longs + case CORBA_Marshal_Options::LONG: + status = dii_test_long (options, results); + break; + // octets + case CORBA_Marshal_Options::OCTET: + status = dii_test_octet (options, results); + break; + // chars + case CORBA_Marshal_Options::CHAR: + status = dii_test_char (options, results); + break; + // doubles + case CORBA_Marshal_Options::DOUBLE: + status = dii_test_double (options, results); + break; + // Structs + case CORBA_Marshal_Options::STRUCT: + status = dii_test_struct (options, results); + break; + // unions + case CORBA_Marshal_Options::UNION: + status = dii_test_union (options, results); + break; + // anys + case CORBA_Marshal_Options::ANY: + status = dii_test_any (options, results); + break; + // sequences + case CORBA_Marshal_Options::SEQUENCE: + status = dii_test_sequence (options, results); + break; + // longs + case CORBA_Marshal_Options::RECURSIVE: + // status = dii_test_recursive (options, results); + // doesn't work + break; + default: + status = -1; + } // end of switch + } // for loop + + if (!status) + return 0; + else + return -1; +} + + +// all helper functions : SII +int +Tao_Marshal_Client_Proxy::sii_test_short (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) +{ + CORBA_Short s1, s2; + CORBA_Environment env; + + s1 = 3; + ref_->test_short (s1, s2, env); + if (s2 == 2*s1) + { + ACE_DEBUG ((LM_DEBUG, "SII test_short success: s1 = %d, s2 = %d\n", s1, s2)); + } + else + { + ACE_DEBUG ((LM_DEBUG, "SII test_short failed: s1 = %d, s2 = %d\n", s1, s2)); + } + return 0; +} + +int +Tao_Marshal_Client_Proxy::sii_test_long (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) +{ + CORBA_Long l1, l2; + CORBA_Environment env; + + l1 = 256; + ref_->test_long (l1, l2, env); + if (l2 == 3*l1) + { + ACE_DEBUG ((LM_DEBUG, "SII test_long success: l1 = %d, l2 = %d\n", l1, l2)); + } + else + { + ACE_DEBUG ((LM_DEBUG, "SII test_long failed: l1 = %d, l2 = %d\n", l1, l2)); + } + return 0; +} + +int +Tao_Marshal_Client_Proxy::sii_test_octet (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) + // octets +{ + CORBA_Octet o1, o2; + CORBA_Environment env; + + o1 = (CORBA_Octet) 127; + ref_->test_octet (o1, o2, env); + if (o1 == o2) + { + ACE_DEBUG ((LM_DEBUG, "SII test_octet success: o1 = %c, o2 = %c\n", o1, o2)); + } + else + { + ACE_DEBUG ((LM_DEBUG, "SII test_octet failed: o1 = %c, o2 = %c\n", o1, o2)); + } + return 0; +} + +int +Tao_Marshal_Client_Proxy::sii_test_char (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) + // chars +{ + CORBA_Char c1, c2; + CORBA_Environment env; + + c1 = 'B'; + ref_->test_char (c1, c2, env); + if (c1 == c2) + { + ACE_DEBUG ((LM_DEBUG, "SII test_char success: c1 = %c, c2 = %c\n", c1, c2)); + } + else + { + ACE_DEBUG ((LM_DEBUG, "SII test_char failed: c1 = %c, c2 = %c\n", c1, c2)); + } + return 0; +} + +int +Tao_Marshal_Client_Proxy::sii_test_double (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) + // doubles +{ + CORBA_Double d1, d2; + CORBA_Environment env; + + d1 = 3.1415; + ref_->test_double (d1, d2, env); + if (d2 == d1/2) + { + ACE_DEBUG ((LM_DEBUG, "SII test_double success: d1 = %f, d2 = %f\n", d1, d2)); + } + else + { + ACE_DEBUG ((LM_DEBUG, "SII test_double failed: d1 = %f, d2 = %f\n", d1, d2)); + } + return 0; +} + +int +Tao_Marshal_Client_Proxy::sii_test_struct (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) + // structs +{ + Marshal::Marshal_Struct ms1, ms2; + CORBA_Environment env; + + + ms1.s = 3; + ms1.l = 256; + ms1.c = 'B'; + ms1.o = (CORBA_Octet) 127; + ms1.d = 3.1415; + + ref_->test_struct (ms1, ms2, env); + if (ms1.s == ms2.s && ms1.l == ms2.l && ms1.c == ms2.c && ms1.o == ms2.o && + ms1.d == ms2.d) + { + ACE_DEBUG ((LM_DEBUG, "SII test_struct success\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "SII test_struct failed\n")); + } + return 0; +} + +int +Tao_Marshal_Client_Proxy::sii_test_union (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) + // unions +{ + Marshal::Marshal_Union u1, u2; + Marshal::Marshal_Struct ms1, ms2; + CORBA_Environment env; + + // first test an enumerated case + u1._d (Marshal::e_1st); + u1.l (4567); + + ref_->test_union (u1, u2, env); + if ( (u1._d () == u2._d()) && (u1.l () == u2.l ())) + { + ACE_DEBUG ((LM_DEBUG, "SII test_union for long (case e_1st) success\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "SII test_union for long (case e_1st) failed\n")); + } + + // now test the default case + u1._d (Marshal::e_6th); // this case doesn't exist which will lead to using + // the default case + + u1.ms ().s = 3; + u1.ms ().l = 256; + u1.ms ().c = 'B'; + u1.ms ().o = (CORBA_Octet) 127; + u1.ms ().d = 3.1415; + + ref_->test_union (u1, u2, env); + + if (u1.ms ().s == u2.ms ().s && u1.ms ().l == u2.ms ().l && u1.ms ().c == u2.ms ().c && u1.ms ().o == u2.ms ().o && + u1.ms ().d == u2.ms ().d) + { + ACE_DEBUG ((LM_DEBUG, "SII test_union for default (case e_6th) success\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "SII test_union for default (case e_6th) failed\n")); + } + return 0; +} + +int +Tao_Marshal_Client_Proxy::sii_test_any (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) +{ + // we send a struct thru the any + CORBA_Any a1, *a2; + Marshal::Marshal_Struct ms1, *ms2; + CORBA_Environment env; + + + ms1.s = 3; + ms1.l = 256; + ms1.c = 'B'; + ms1.o = (CORBA_Octet) 127; + ms1.d = 3.1415; + + // populate the any with a MarshalStruct + // a1 <<= ms1; // not in TAO yet + a1.replace (Marshal::_tc_Marshal_Struct, &ms1, 0, env); + + a2 = new CORBA_Any; + + // now test it + ref_->test_any (a1, a2, env); + + // check if the two typecodes are equal + if (a2->type ()->equal (Marshal::_tc_Marshal_Struct, env)) + { + // now see if the values are same + ms2 = (Marshal::Marshal_Struct *)a2->value (); + if (ms1.s == ms2->s && ms1.l == ms2->l && ms1.c == ms2->c && ms1.o == ms2->o && + ms1.d == ms2->d) + { + ACE_DEBUG ((LM_DEBUG, "SII test_any success\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "SII test_any value match failed\n")); + } + } + else + { + ACE_DEBUG ((LM_DEBUG, "SII test_any failed due to typecode mismatch\n")); + } + return 0; +} + +int +Tao_Marshal_Client_Proxy::sii_test_sequence (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) +{ + // make a sequence of Anys and fill each one with a different data type + Marshal::AnySeq as1 (7), *as2; + Marshal::Marshal_Struct ms; + Marshal::Marshal_Union u; + CORBA_Environment env; + + + ms.s = 3; + ms.l = 256; + ms.c = 'B'; + ms.o = (CORBA_Octet) 127; + ms.d = 3.1415; + + u._d (Marshal::e_5th); // somehow, the default case e_6th doesn't seem to + // work here + u.ms ().s = 3; + u.ms ().l = 256; + u.ms ().c = 'B'; + u.ms ().o = (CORBA_Octet) 127; + u.ms ().d = 3.1415; + + // it looks like we must tell the sequence how many elements it is going to + // carry. By just fixing the max value does not work. + + as1.length (7); + +#if 0 // to be supported later + as1[0] <<= (CORBA_Short)3; + as1[1] <<= (CORBA_Long) 256; + as1[2] <<= CORBA_Any::from_octet ((CORBA_Octet)127); + as1[3] <<= CORBA_Any::from_char ('B'); + as1[4] <<= (CORBA_Double)3.1415; // double + as1[5] <<= ms; // struct + as1[6] <<= u; // union +#endif + as1[0].replace (_tc_CORBA_Short, new CORBA_Short (3), 1, env); + as1[1].replace (_tc_CORBA_Long, new CORBA_Long (256), 1, env); + as1[2].replace (_tc_CORBA_Octet, new CORBA_Octet ((CORBA_Octet)127), 1, env); + as1[3].replace (_tc_CORBA_Char, new CORBA_Char ('B'), 1, env); + as1[4].replace (_tc_CORBA_Double, new CORBA_Double (3.1415), 1, env); + as1[5].replace (Marshal::_tc_Marshal_Struct, new Marshal::Marshal_Struct + (ms), 1, env); + as1[6].replace (Marshal::_tc_Marshal_Union, new Marshal::Marshal_Union (u), 1, env); + + as2 = new Marshal::AnySeq; + + ref_->test_sequence (as1, as2, env); + + ACE_DEBUG ((LM_DEBUG, "SII test_sequence\n")); + if (as1.length () == as2->length ()) + { + // now make sure that the elements are same + for (int i=0; i < as1.length (); i++) + { + if (as1[i].type ()->equal ((*as2)[i].type (), env)) + { + // now see if the values are same + switch (i) + { + case 0: + if (*(CORBA_Short *)as1[i].value () == *(CORBA_Short + *)(*as2)[i].value ()) + { + ACE_DEBUG ((LM_DEBUG, "\tSII test_sequence, shorts matched\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "\tSII test_sequence failed on shorts match\n")); + } + break; + case 1: + if (*(CORBA_Long *)as1[i].value () == *(CORBA_Long + *)(*as2)[i].value ()) + { + ACE_DEBUG ((LM_DEBUG, "\tSII test_sequence, longs matched\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "\tSII test_sequence failed on longs match\n")); + } + break; + case 2: + if (*(CORBA_Octet *)as1[i].value () == *(CORBA_Octet + *)(*as2)[i].value ()) + { + ACE_DEBUG ((LM_DEBUG, "\tSII test_sequence, octets matched\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "\tSII test_sequence failed on octets match\n")); + } + break; + case 3: + if (*(CORBA_Char *)as1[i].value () == *(CORBA_Char + *)(*as2)[i].value ()) + { + ACE_DEBUG ((LM_DEBUG, "\tSII test_sequence, chars matched\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "\tSII test_sequence failed on chars match\n")); + } + break; + case 4: + if (*(CORBA_Double *)as1[i].value () == *(CORBA_Double + *)(*as2)[i].value ()) + { + ACE_DEBUG ((LM_DEBUG, "\tSII test_sequence, doubles matched\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "\tSII test_sequence failed on doubles match\n")); + } + break; + case 5: + { + Marshal::Marshal_Struct *ms1, *ms2; + + ms1 = (Marshal::Marshal_Struct *)as1[i].value (); + ms2 = (Marshal::Marshal_Struct *)(*as2)[i].value (); + + if (ms1->s == ms2->s && ms1->l == ms2->l && ms1->c == ms2->c && ms1->o == ms2->o && + ms1->d == ms2->d) + { + ACE_DEBUG ((LM_DEBUG, "\tSII test_sequence, structs matched\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "\tSII test_sequence failed on structs match\n")); + } + } + break; + case 6: + { + Marshal::Marshal_Union *u1, *u2; + + u1 = (Marshal::Marshal_Union *)as1[i].value (); + u2 = (Marshal::Marshal_Union *)(*as2)[i].value (); + + if (u1->_d () == u2->_d () && u1->ms ().s == u2->ms ().s && + u1->ms ().l == u2->ms ().l && + u1->ms ().c == u2->ms ().c && u1->ms ().o == u2->ms ().o && + u1->ms ().d == u2->ms ().d) + { + ACE_DEBUG ((LM_DEBUG, "\tSII test_sequence, unions matched\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "\tSII test_sequence failed on unions match\n")); + } + } + break; + } + } + else + { + ACE_DEBUG ((LM_DEBUG, + "SII test_sequence: typecode mismatch for element %d\n", i)); + break; + } + } + } + else + { + ACE_DEBUG ((LM_DEBUG, "SII test_sequence failed: as2->length = %d\n", + as2->length ())); + } + return 0; +} + +#if 0 +int +Tao_Marshal_Client_Proxy::sii_test_recursive (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) +{ + // we will try a simple one here + Marshal::Marshal_Recursive mr1, *elem1, *mr2, *elem2; + CORBA_Environment env; + + + mr1.value <<= (CORBA_Long)1; + mr1.next.length (1); // sequence of length 1 + + // fill the element + elem1 = &mr1.next[0]; + elem1->value <<= CORBA_Any::from_char ('D'); + elem1->next.length (0); // end of seq + + mr2 = new Marshal::Marshal_Recursive; + + try { + ref_->test_recursive (mr1, mr2, env); + } + catch (CORBA_SystemException &se){ + cerr << "error invoking request: " << se << endl; + } + + elem2 = &mr2->next[0]; + + if ((*(CORBA_Long *)mr1.value.value () == *(CORBA_Long*)mr2->value.value ()) + && (mr1.next.length () == mr2->next.length ()) // same length sequence + && (*(CORBA_Char *)elem1->value.value () == *(CORBA_Char *)elem2->value.value ()) + && (elem1->next.length () == elem2->next.length ())) + { + ACE_DEBUG ((LM_DEBUG, "SII test_recursive success\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "SII test_recursive failure\n")); + } + + return 0; +} +#endif + +// ------------------------------------------------------- +// all helper functions : DII +// ------------------------------------------------------- + +int +Tao_Marshal_Client_Proxy::dii_test_short (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) +{ + // DII variables + CORBA_Request_ptr request = 0; //CORBA_Request::_nil(); // DII request + CORBA_NVList_ptr arglist = 0; //CORBA_NVList::_nil(); // argument list + // CORBA_Context_ptr ctx = CORBA_Context::_nil(); // context + CORBA_NVList_ptr result_list = 0; //CORBA_NVList::_nil(); // result list + CORBA_NamedValue_ptr result = 0; //CORBA_NamedValue::_nil();// actual result + CORBA_Short s1, s2; + CORBA_Environment env; + + s1 = 3; + s2 = 0; + + orb_->create_list(0, arglist); // 2 arguments to be added + // *(arglist->add (CORBA_ARG_IN)->value ()) <<= s1; + arglist->add_value ("s1", CORBA_Any (_tc_CORBA_Short, &s1, CORBA_B_FALSE), + CORBA_ARG_IN, env); + // this usage is also correct. All we care is to supply a storage area for + // the OUT parameter + // arglist->add (CORBA_ARG_OUT)->value ()->replace (CORBA__tc_short, &s2); + // *(arglist->add (CORBA_ARG_OUT)->value ()) <<= s2; + arglist->add_value ("s2", CORBA_Any (_tc_CORBA_Short, &s2, CORBA_B_FALSE), + CORBA_ARG_OUT, env); + orb_->create_list(1, result_list); // 1 result + result = result_list->item (0); + + // create a request + ref_->_create_request(//ctx, + "test_short", + arglist, + result, + request, + 0, env); + + request->invoke (); // 2 way + // *(arglist->item(1)->value()) >>= s2; + s2 = *(CORBA_Short *)arglist->item(1)->value()->value(); + + if (s2 == 2*s1) + { + ACE_DEBUG ((LM_DEBUG, "DII test_short success: s1 = %d, s2 = %d\n", s1, s2)); + } + else + { + ACE_DEBUG ((LM_DEBUG, "DII test_short failed: s1 = %d, s2 = %d\n", s1, s2)); + } + CORBA_release (request); + CORBA_release (arglist); + CORBA_release (result); + CORBA_release (result_list); + return 0; +} + +int +Tao_Marshal_Client_Proxy::dii_test_long (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) +{ + // DII variables + CORBA_Request_ptr request = 0; //CORBA_Request::_nil(); // DII request + CORBA_NVList_ptr arglist = 0; //CORBA_NVList::_nil(); // argument list + // CORBA_Context_ptr ctx = CORBA_Context::_nil(); // context + CORBA_NVList_ptr result_list = 0; //CORBA_NVList::_nil(); // result list + CORBA_NamedValue_ptr result = 0; //CORBA_NamedValue::_nil();// actual result + CORBA_Long l1, l2; + CORBA_Environment env; + + l1 = 256; + + orb_->create_list(0, arglist); // 2 arguments to be added + // *(arglist->add(CORBA_ARG_IN)->value()) <<= l1; + arglist->add_value ("l1", CORBA_Any (_tc_CORBA_Long, &l1, CORBA_B_FALSE), + CORBA_ARG_IN, env); + // arglist->add(CORBA_ARG_OUT)->value()->replace (CORBA__tc_long, &l2); + arglist->add_value ("l2", CORBA_Any (_tc_CORBA_Long, &l2, CORBA_B_FALSE), + CORBA_ARG_OUT, env); + orb_->create_list(1, result_list); // 1 result + result = result_list->item(0); + + // create a request + ref_->_create_request(//ctx, + "test_long", + arglist, + result, + request, + 0, env); + + request->invoke (); // 2 way + // *(arglist->item(1)->value()) >>= l2; + l2 = *(CORBA_Long *)arglist->item (1)->value ()->value (); + + if (l2 == 3*l1) + { + ACE_DEBUG ((LM_DEBUG, "DII: test_long success: l1 = %d, l2 = %d\n", l1, l2)); + } + else + { + ACE_DEBUG ((LM_DEBUG, "DII: test_long failed: l1 = %d, l2 = %d\n", l1, l2)); + } + CORBA_release (request); + CORBA_release (arglist); + CORBA_release (result); + CORBA_release (result_list); + return 0; +} + +int +Tao_Marshal_Client_Proxy::dii_test_octet (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) + // octets +{ + // DII variables + CORBA_Request_ptr request = 0; //CORBA_Request::_nil(); // DII request + CORBA_NVList_ptr arglist = 0; //CORBA_NVList::_nil(); // argument list + // CORBA_Context_ptr ctx = CORBA_Context::_nil(); // context + CORBA_NVList_ptr result_list = 0; //CORBA_NVList::_nil(); // result list + CORBA_NamedValue_ptr result = 0; //CORBA_NamedValue::_nil();// actual result + CORBA_Octet o1, o2; + CORBA_Environment env; + + o1 = (CORBA_Octet) 127; + + orb_->create_list(0, arglist); // 2 arguments to be added + // *(arglist->add(CORBA_ARG_IN)->value()) <<= CORBA_Any::from_octet (o1); + // arglist->add(CORBA_ARG_OUT)->value()->replace (CORBA__tc_octet, &o2); + arglist->add_value ("o1", CORBA_Any (_tc_CORBA_Octet, &o1, CORBA_B_FALSE), + CORBA_ARG_IN, env); + arglist->add_value ("o2", CORBA_Any (_tc_CORBA_Octet, &o2, CORBA_B_FALSE), + CORBA_ARG_OUT, env); + orb_->create_list(1, result_list); // 1 result + result = result_list->item(0); + + // create a request + ref_->_create_request(//ctx, + "test_octet", + arglist, + result, + request, + 0, env); + + request->invoke (); // 2 way + // *(arglist->item(1)->value()) >>= CORBA_Any::to_octet (o2); + o2 = *(CORBA_Octet *)arglist->item (1)->value ()->value (); + + if (o1 == o2) + { + ACE_DEBUG ((LM_DEBUG, "DII test_octet success: o1 = %c, o2 = %c\n", o1, o2)); + } + else + { + ACE_DEBUG ((LM_DEBUG, "DII test_octet failed: o1 = %c, o2 = %c\n", o1, o2)); + } + CORBA_release (request); + CORBA_release (arglist); + CORBA_release (result); + CORBA_release (result_list); + return 0; +} + +int +Tao_Marshal_Client_Proxy::dii_test_char (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) + // chars +{ + // DII variables + CORBA_Request_ptr request = 0; //CORBA_Request::_nil(); // DII request + CORBA_NVList_ptr arglist = 0; //CORBA_NVList::_nil(); // argument list + // CORBA_Context_ptr ctx = CORBA_Context::_nil(); // context + CORBA_NVList_ptr result_list = 0; //CORBA_NVList::_nil(); // result list + CORBA_NamedValue_ptr result = 0; //CORBA_NamedValue::_nil();// actual result + CORBA_Char c1, c2; + CORBA_Environment env; + + c1 = 'B'; + + orb_->create_list(0, arglist); // 2 arguments to be added + // *(arglist->add(CORBA_ARG_IN)->value()) <<= CORBA_Any::from_char (c1); + // arglist->add(CORBA_ARG_OUT)->value()->replace (CORBA__tc_char, &c2); + arglist->add_value ("c1", CORBA_Any (_tc_CORBA_Char, &c1, CORBA_B_FALSE), + CORBA_ARG_IN, env); + arglist->add_value ("c2", CORBA_Any (_tc_CORBA_Char, &c2, CORBA_B_FALSE), + CORBA_ARG_OUT, env); + orb_->create_list(1, result_list); // 1 result + result = result_list->item(0); + + // create a request + ref_->_create_request(//ctx, + "test_char", + arglist, + result, + request, + 0, env); + + request->invoke (); // 2 way + // *(arglist->item(1)->value()) >>= CORBA_Any::to_char (c2); + c2 = *(CORBA_Char *)arglist->item (1)->value ()->value (); + + if (c1 == c2) + { + ACE_DEBUG ((LM_DEBUG, "DII test_char success: c1 = %c, c2 = %c\n", c1, c2)); + } + else + { + ACE_DEBUG ((LM_DEBUG, "DII test_char failed: c1 = %c, c2 = %c\n", c1, c2)); + } + CORBA_release (request); + CORBA_release (arglist); + CORBA_release (result); + CORBA_release (result_list); + return 0; +} + +int +Tao_Marshal_Client_Proxy::dii_test_double (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) + // doubles +{ + // DII variables + CORBA_Request_ptr request = 0; //CORBA_Request::_nil(); // DII request + CORBA_NVList_ptr arglist = 0; //CORBA_NVList::_nil(); // argument list + // CORBA_Context_ptr ctx = CORBA_Context::_nil(); // context + CORBA_NVList_ptr result_list = 0; //CORBA_NVList::_nil(); // result list + CORBA_NamedValue_ptr result = 0; //CORBA_NamedValue::_nil();// actual result + CORBA_Double d1, d2; + CORBA_Environment env; + + d1 = 3.1415; + + orb_->create_list(0, arglist); // 2 arguments to be added + // *(arglist->add(CORBA_ARG_IN)->value()) <<= d1; + // arglist->add(CORBA_ARG_OUT)->value()->replace (CORBA__tc_double, &d2); + arglist->add_value ("d1", CORBA_Any (_tc_CORBA_Double, &d1, CORBA_B_FALSE), + CORBA_ARG_IN, env); + arglist->add_value ("d2", CORBA_Any (_tc_CORBA_Double, &d2, CORBA_B_FALSE), + CORBA_ARG_OUT, env); + orb_->create_list(1, result_list); // 1 result + result = result_list->item(0); + + // create a request + ref_->_create_request(//ctx, + "test_double", + arglist, + result, + request, + 0, env); + + request->invoke (); // 2 way + // *(arglist->item(1)->value()) >>= d2; + d2 = *(CORBA_Double *)arglist->item (1)->value ()->value (); + + if (d2 == d1/2) + { + ACE_DEBUG ((LM_DEBUG, "DII test_double success: d1 = %f, d2 = %f\n", d1, d2)); + } + else + { + ACE_DEBUG ((LM_DEBUG, "DII test_double failed: d1 = %f, d2 = %f\n", d1, d2)); + } + CORBA_release (request); + CORBA_release (arglist); + CORBA_release (result); + CORBA_release (result_list); + return 0; +} + +int +Tao_Marshal_Client_Proxy::dii_test_struct (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) + // structs +{ + // DII variables + CORBA_Request_ptr request = 0; //CORBA_Request::_nil(); // DII request + CORBA_NVList_ptr arglist = 0; //CORBA_NVList::_nil(); // argument list + // CORBA_Context_ptr ctx = CORBA_Context::_nil(); // context + CORBA_NVList_ptr result_list = 0; //CORBA_NVList::_nil(); // result list + CORBA_NamedValue_ptr result = 0; //CORBA_NamedValue::_nil();// actual result + Marshal::Marshal_Struct ms1, ms2; + CORBA_Environment env; + + ms1.s = 3; + ms1.l = 256; + ms1.c = 'B'; + ms1.o = (CORBA_Octet) 127; + ms1.d = 3.1415; + + orb_->create_list(0, arglist); // 2 arguments to be added + // *(arglist->add(CORBA_ARG_IN)->value()) <<= ms1; + // arglist->add(CORBA_ARG_OUT)->value()->replace (Marshal::_tc_Marshal_Struct, &ms2); + arglist->add_value ("ms1", CORBA_Any (Marshal::_tc_Marshal_Struct, &ms1, CORBA_B_FALSE), + CORBA_ARG_IN, env); + arglist->add_value ("ms2", CORBA_Any (Marshal::_tc_Marshal_Struct, &ms2, CORBA_B_FALSE), + CORBA_ARG_OUT, env); + orb_->create_list(1, result_list); // 1 result + result = result_list->item(0); + + // create a request + ref_->_create_request(//ctx, + "test_struct", + arglist, + result, + request, + 0, env); + + request->invoke (); // 2 way + // *(arglist->item(1)->value()) >>= ms2; + ms2 = *(Marshal::Marshal_Struct *)arglist->item (1)->value ()->value (); + + if (ms1.s == ms2.s && ms1.l == ms2.l && ms1.c == ms2.c && ms1.o == ms2.o && + ms1.d == ms2.d) + { + ACE_DEBUG ((LM_DEBUG, "DII test_struct success\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "DII test_struct failed\n")); + } + CORBA_release (request); + CORBA_release (arglist); + CORBA_release (result); + CORBA_release (result_list); + return 0; +} + +int +Tao_Marshal_Client_Proxy::dii_test_union (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) + // unions +{ + // DII variables + CORBA_Request_ptr request = 0; //CORBA_Request::_nil(); // DII request + CORBA_NVList_ptr arglist = 0; //CORBA_NVList::_nil(); // argument list + // CORBA_Context_ptr ctx = CORBA_Context::_nil(); // context + CORBA_NVList_ptr result_list = 0; //CORBA_NVList::_nil(); // result list + CORBA_NamedValue_ptr result = 0; //CORBA_NamedValue::_nil();// actual result + Marshal::Marshal_Union u1, u2; + Marshal::Marshal_Struct ms1, ms2; + CORBA_Environment env; + + + // first test an enumerated case + u1._d (Marshal::e_1st); + u1.l (4567); + + orb_->create_list(0, arglist); // 2 arguments to be added + // *(arglist->add(CORBA_ARG_IN)->value()) <<= u1; + // arglist->add(CORBA_ARG_OUT)->value()->replace (Marshal::_tc_Marshal_Union, &u2); + arglist->add_value ("u1", CORBA_Any (Marshal::_tc_Marshal_Union, &u1, CORBA_B_FALSE), + CORBA_ARG_IN, env); + arglist->add_value ("u2", CORBA_Any (Marshal::_tc_Marshal_Union, &u2, CORBA_B_FALSE), + CORBA_ARG_OUT, env); + orb_->create_list(1, result_list); // 1 result + result = result_list->item(0); + + // create a request + ref_->_create_request(//ctx, + "test_union", + arglist, + result, + request, + 0, env); + + request->invoke (); // 2 way + // *(arglist->item(1)->value()) >>= u2; + u2 = *(Marshal::Marshal_Union *)arglist->item (1)->value ()->value (); + + if ( (u1._d () == u2._d()) && (u1.l () == u2.l ())) + { + ACE_DEBUG ((LM_DEBUG, "DII test_union for long (case e_1st) success\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "DII test_union for long (case e_1st) failed\n")); + } + CORBA_release (request); + CORBA_release (arglist); + CORBA_release (result); + CORBA_release (result_list); + + // now test the default case + u1._d (Marshal::e_5th); // e_6th doesn't work + + u1.ms ().s = 3; + u1.ms ().l = 256; + u1.ms ().c = 'B'; + u1.ms ().o = (CORBA_Octet) 127; + u1.ms ().d = 3.1415; + + + orb_->create_list(0, arglist); // 2 arguments to be added + // *(arglist->add(CORBA_ARG_IN)->value()) <<= u1; + //arglist->add(CORBA_ARG_OUT)->value()->replace (Marshal::_tc_Marshal_Union, &u2); + arglist->add_value ("u1", CORBA_Any (Marshal::_tc_Marshal_Union, &u1, CORBA_B_FALSE), + CORBA_ARG_IN, env); + arglist->add_value ("u2", CORBA_Any (Marshal::_tc_Marshal_Union, &u2, CORBA_B_FALSE), + CORBA_ARG_OUT, env); + orb_->create_list(1, result_list); // 1 result + result = result_list->item(0); + + // create a request + ref_->_create_request(//ctx, + "test_union", + arglist, + result, + request, + 0, env); + + request->invoke (); // 2 way + // *(arglist->item(1)->value()) >>= u2; + u2 = *(Marshal::Marshal_Union *)arglist->item (1)->value ()->value (); + + if (u1.ms ().s == u2.ms ().s && u1.ms ().l == u2.ms ().l && u1.ms ().c == u2.ms ().c && u1.ms ().o == u2.ms ().o && + u1.ms ().d == u2.ms ().d) + { + ACE_DEBUG ((LM_DEBUG, "DII test_union for default (case e_6th) success\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "DII test_union for default (case e_6th) failed\n")); + } + CORBA_release (request); + CORBA_release (arglist); + CORBA_release (result); + CORBA_release (result_list); + return 0; +} + +int +Tao_Marshal_Client_Proxy::dii_test_any (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) +{ + // DII variables + CORBA_Request_ptr request = 0; //CORBA_Request::_nil(); // DII request + CORBA_NVList_ptr arglist = 0; //CORBA_NVList::_nil(); // argument list + // CORBA_Context_ptr ctx = CORBA_Context::_nil(); // context + CORBA_NVList_ptr result_list = 0; //CORBA_NVList::_nil(); // result list + CORBA_NamedValue_ptr result = 0; //CORBA_NamedValue::_nil();// actual result + // we send a struct thru the any + CORBA_Any a1, *a2; + Marshal::Marshal_Struct ms1, *ms2; + CORBA_Environment env; + + ms1.s = 3; + ms1.l = 256; + ms1.c = 'B'; + ms1.o = (CORBA_Octet) 127; + ms1.d = 3.1415; + + // populate the any with a MarshalStruct + // a1 <<= ms1; + a1.replace (Marshal::_tc_Marshal_Struct, &ms1, CORBA_B_FALSE, env); + + a2 = new CORBA_Any; + + // now test it + orb_->create_list(0, arglist); // 2 arguments to be added + // *(arglist->add(CORBA_ARG_IN)->value()) <<= a1; + // arglist->add(CORBA_ARG_OUT)->value()->replace (CORBA__tc_any, a2); + arglist->add_value ("a1", CORBA_Any (_tc_CORBA_Any, &a1, CORBA_B_FALSE), + CORBA_ARG_IN, env); + arglist->add_value ("a2", CORBA_Any (_tc_CORBA_Any, a2, CORBA_B_FALSE), + CORBA_ARG_OUT, env); + orb_->create_list(1, result_list); // 1 result + result = result_list->item(0); + + // create a request + ref_->_create_request(//ctx, + "test_any", + arglist, + result, + request, + 0, env); + + request->invoke (); // 2 way + // *(arglist->item(1)->value()) >>= (*a2); + a2->replace (_tc_CORBA_Any, (CORBA_Any *)arglist->item (1)->value ()->value + (), 1, env); + + // check if the two typecodes are equal + if (a2->type ()->equal (Marshal::_tc_Marshal_Struct, env)) + { + // now see if the values are same + ms2 = (Marshal::Marshal_Struct *)a2->value (); + if (ms1.s == ms2->s && ms1.l == ms2->l && ms1.c == ms2->c && ms1.o == ms2->o && + ms1.d == ms2->d) + { + ACE_DEBUG ((LM_DEBUG, "DII test_any success\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "DII test_any value match failed\n")); + } + } + else + { + ACE_DEBUG ((LM_DEBUG, "DII test_any failed due to typecode mismatch\n")); + } + CORBA_release (request); + CORBA_release (arglist); + CORBA_release (result); + CORBA_release (result_list); + return 0; +} + +int +Tao_Marshal_Client_Proxy::dii_test_sequence (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) +{ + // DII variables + CORBA_Request_ptr request = 0; //CORBA_Request::_nil(); // DII request + CORBA_NVList_ptr arglist = 0; //CORBA_NVList::_nil(); // argument list + // CORBA_Context_ptr ctx = CORBA_Context::_nil(); // context + CORBA_NVList_ptr result_list = 0; //CORBA_NVList::_nil(); // result list + CORBA_NamedValue_ptr result = 0; //CORBA_NamedValue::_nil();// actual result + // make a sequence of Anys and fill each one with a different data type + Marshal::AnySeq as1 (7), *as2; + Marshal::Marshal_Struct ms; + Marshal::Marshal_Union u; + CORBA_Environment env; + + ms.s = 3; + ms.l = 256; + ms.c = 'B'; + ms.o = (CORBA_Octet) 127; + ms.d = 3.1415; + + u._d (Marshal::e_5th); // somehow, the default case e_6th doesn't seem to + // work here + u.ms ().s = 3; + u.ms ().l = 256; + u.ms ().c = 'B'; + u.ms ().o = (CORBA_Octet) 127; + u.ms ().d = 3.1415; + + // it looks like we must tell the sequence how many elements it is going to + // carry. By just fixing the max value does not work. + + as1.length (7); + +#if 0 + as1[0] <<= (CORBA_Short)3; + as1[1] <<= (CORBA_Long) 256; + as1[2] <<= CORBA_Any::from_octet ((CORBA_Octet)127); + as1[3] <<= CORBA_Any::from_char ('B'); + as1[4] <<= (CORBA_Double)3.1415; // double + as1[5] <<= ms; // struct + as1[6] <<= u; // union +#endif + as1[0].replace (_tc_CORBA_Short, new CORBA_Short (3), 1, env); + as1[1].replace (_tc_CORBA_Long, new CORBA_Long (256), 1, env); + as1[2].replace (_tc_CORBA_Octet, new CORBA_Octet ((CORBA_Octet)127), 1, env); + as1[3].replace (_tc_CORBA_Char, new CORBA_Char ('B'), 1, env); + as1[4].replace (_tc_CORBA_Double, new CORBA_Double (3.1415), 1, env); + as1[5].replace (Marshal::_tc_Marshal_Struct, new Marshal::Marshal_Struct + (ms), 1, env); + as1[6].replace (Marshal::_tc_Marshal_Union, new Marshal::Marshal_Union (u), 1, env); + + as2 = new Marshal::AnySeq; + + orb_->create_list(0, arglist); // 2 arguments to be added + // *(arglist->add(CORBA_ARG_IN)->value()) <<= as1; + // arglist->add(CORBA_ARG_OUT)->value()->replace (Marshal::_tc_AnySeq, as2); + arglist->add_value ("as1", CORBA_Any (Marshal::_tc_AnySeq, &as1, CORBA_B_FALSE), + CORBA_ARG_IN, env); + arglist->add_value ("o2", CORBA_Any (Marshal::_tc_AnySeq, as2, CORBA_B_FALSE), + CORBA_ARG_OUT, env); + orb_->create_list(1, result_list); // 1 result + result = result_list->item(0); + + // create a request + ref_->_create_request(//ctx, + "test_sequence", + arglist, + result, + request, + 0, env); + + request->invoke (); // 2 way + // *(arglist->item(1)->value()) >>= (*as2); + *as2 = *(Marshal::AnySeq *)arglist->item (1)->value ()->value (); + + ACE_DEBUG ((LM_DEBUG, "DII test_sequence\n")); + if (as1.length () == as2->length ()) + { + // now make sure that the elements are same + for (int i=0; i < as1.length (); i++) + { + if (as1[i].type ()->equal ((*as2)[i].type (), env)) + { + // now see if the values are same + switch (i) + { + case 0: + if (*(CORBA_Short *)as1[i].value () == *(CORBA_Short + *)(*as2)[i].value ()) + { + ACE_DEBUG ((LM_DEBUG, "\tDII test_sequence, shorts matched\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "\tDII test_sequence failed on shorts match\n")); + } + break; + case 1: + if (*(CORBA_Long *)as1[i].value () == *(CORBA_Long + *)(*as2)[i].value ()) + { + ACE_DEBUG ((LM_DEBUG, "\tDII test_sequence, longs matched\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "\tDII test_sequence failed on longs match\n")); + } + break; + case 2: + if (*(CORBA_Octet *)as1[i].value () == *(CORBA_Octet + *)(*as2)[i].value ()) + { + ACE_DEBUG ((LM_DEBUG, "\tDII test_sequence, octets matched\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "\tDII test_sequence failed on octets match\n")); + } + break; + case 3: + if (*(CORBA_Char *)as1[i].value () == *(CORBA_Char + *)(*as2)[i].value ()) + { + ACE_DEBUG ((LM_DEBUG, "\tDII test_sequence, chars matched\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "\tDII test_sequence failed on chars match\n")); + } + break; + case 4: + if (*(CORBA_Double *)as1[i].value () == *(CORBA_Double + *)(*as2)[i].value ()) + { + ACE_DEBUG ((LM_DEBUG, "\tDII test_sequence, doubles matched\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "\tDII test_sequence failed on doubles match\n")); + } + break; + case 5: + { + Marshal::Marshal_Struct *ms1, *ms2; + + ms1 = (Marshal::Marshal_Struct *)as1[i].value (); + ms2 = (Marshal::Marshal_Struct *)(*as2)[i].value (); + + if (ms1->s == ms2->s && ms1->l == ms2->l && ms1->c == ms2->c && ms1->o == ms2->o && + ms1->d == ms2->d) + { + ACE_DEBUG ((LM_DEBUG, "\tDII test_sequence, structs matched\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "\tDII test_sequence failed on structs match\n")); + } + } + break; + case 6: + { + Marshal::Marshal_Union *u1, *u2; + + u1 = (Marshal::Marshal_Union *)as1[i].value (); + u2 = (Marshal::Marshal_Union *)(*as2)[i].value (); + + if (u1->_d () == u2->_d () && u1->ms ().s == u2->ms ().s && + u1->ms ().l == u2->ms ().l && + u1->ms ().c == u2->ms ().c && u1->ms ().o == u2->ms ().o && + u1->ms ().d == u2->ms ().d) + { + ACE_DEBUG ((LM_DEBUG, "\tDII test_sequence, unions matched\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "\tDII test_sequence failed on unions match\n")); + } + } + break; + } + } + else + { + ACE_DEBUG ((LM_DEBUG, + "DII test_sequence: typecode mismatch for element %d\n", i)); + break; + } + } + } + else + { + ACE_DEBUG ((LM_DEBUG, "DII test_sequence failed: as2->length = %d\n", + as2->length ())); + } + CORBA_release (request); + CORBA_release (arglist); + CORBA_release (result); + CORBA_release (result_list); + return 0; +} + +#if 0 +int +Tao_Marshal_Client_Proxy::dii_test_recursive (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) +{ + // we will try a simple one here + Marshal::Marshal_Recursive mr1, *elem1, *mr2, *elem2; + + mr1.value <<= (CORBA_Long)1; + mr1.next.length (1); // sequence of length 1 + + // fill the element + elem1 = &mr1.next[0]; + elem1->value <<= CORBA_Any::from_char ('D'); + elem1->next.length (0); // end of seq + + mr2 = new Marshal::Marshal_Recursive; + + try { + ref_->test_recursive (mr1, mr2); + } + catch (CORBA_SystemException &se){ + cerr << "error invoking request: " << se << endl; + } + + elem2 = &mr2->next[0]; + + if ((*(CORBA_Long *)mr1.value.value () == *(CORBA_Long*)mr2->value.value ()) + && (mr1.next.length () == mr2->next.length ()) // same length sequence + && (*(CORBA_Char *)elem1->value.value () == *(CORBA_Char *)elem2->value.value ()) + && (elem1->next.length () == elem2->next.length ())) + { + ACE_DEBUG ((LM_DEBUG, "DII test_recursive success\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "DII test_recursive failure\n")); + } + + return 0; +} +#endif diff --git a/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_client.h b/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_client.h new file mode 100644 index 00000000000..0bf7ef78660 --- /dev/null +++ b/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_client.h @@ -0,0 +1,124 @@ +// ============================================================================ +// +// = LIBRARY +// CORBA Marshal Tao Benchmark +// +// = FILENAME +// tao_marshal_client.h +// +// = AUTHOR +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined(_TAO_MARSHAL_CLIENT_H_) +#define _TAO_MARSHAL_CLIENT_H_ + +// benchmark library includes +#include "benchmark/marshal_options.h" +#include "benchmark/marshal_results.h" +#include "benchmark/marshal_proxy.h" + +// include Tao specific include files +#include "marshalC.h" // generated by IDL compiler +#include "tao/nvlist.h" + +class Tao_Marshal_Client_Proxy : public CORBA_Marshal_Proxy +{ + // =TITLE + // Tao_Marshal_Client_Proxy + // =DESCRIPTION + // Tao client size specialization of the CORBA Marshal proxy class +public: + Tao_Marshal_Client_Proxy (void); + // constructor + + ~Tao_Marshal_Client_Proxy (void); + // destructor + + virtual int run (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + // do the actual work + + virtual int use_sii (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + // use the static invocation interface + + virtual int use_dii (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + // use the dynamic invocation interface +private: + // =helper functions + int sii_test_short (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + int sii_test_long (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + int sii_test_octet (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + int sii_test_char (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + int sii_test_double (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + int sii_test_struct (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + int sii_test_union (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + int sii_test_any (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + int sii_test_sequence (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + int sii_test_recursive (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + // all the DII helpers + int dii_test_short (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + int dii_test_long (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + int dii_test_octet (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + int dii_test_char (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + int dii_test_double (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + int dii_test_struct (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + int dii_test_union (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + int dii_test_any (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + int dii_test_sequence (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + int dii_test_recursive (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + + CORBA_ORB_ptr orb_; + // handle to the underlying orb + + Marshal_ptr ref_; + // the object reference +}; + +#if defined (__ACE_INLINE__) +#include "tao_marshal_client.i" +#endif /* __ACE_INLINE__ */ + +#endif diff --git a/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_client.i b/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_client.i new file mode 100644 index 00000000000..2606962892b --- /dev/null +++ b/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_client.i @@ -0,0 +1,21 @@ + +ACE_INLINE +Tao_Marshal_Client_Proxy::Tao_Marshal_Client_Proxy (void) + : orb_ (0), + ref_ (0) +{ +} + +ACE_INLINE +Tao_Marshal_Client_Proxy::~Tao_Marshal_Client_Proxy (void) +{ + // releasing order is important + + // release the reference + CORBA_release (ref_); + + // release the ORB + CORBA_release (orb_); +} + + diff --git a/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_impl.cpp b/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_impl.cpp new file mode 100644 index 00000000000..6d5005f83ad --- /dev/null +++ b/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_impl.cpp @@ -0,0 +1,650 @@ +#include "tao_marshal_impl.h" + +#if !defined (__ACE_INLINE__) +#include "tao_marshal_impl.i" +#endif /* __ACE_INLINE__ */ + +// All the methods of the SSI class +void +Marshal_SSI_Impl::test_short (CORBA_Short s1, + CORBA_Short &s2, + CORBA_Environment &env) +{ + s2 = 2*s1; +} + +void +Marshal_SSI_Impl::test_long (CORBA_Long l1, + CORBA_Long &l2, + CORBA_Environment &env) +{ + l2 = 3*l1; +} + +void +Marshal_SSI_Impl::test_octet (CORBA_Octet o1, + CORBA_Octet &o2, + CORBA_Environment &env) +{ + o2 = o1; +} + +void +Marshal_SSI_Impl::test_char (CORBA_Char c1, + CORBA_Char &c2, + CORBA_Environment &env) +{ + c2 = c1; +} + +void +Marshal_SSI_Impl::test_double (CORBA_Double d1, + CORBA_Double &d2, + CORBA_Environment &env) +{ + d2 = d1/2; +} + +void +Marshal_SSI_Impl::test_struct (const Marshal::Marshal_Struct& ms1, + Marshal::Marshal_Struct& ms2, + CORBA_Environment &env) +{ + ms2.s = ms1.s; + ms2.l = ms1.l; + ms2.c = ms1.c; + ms2.o = ms1.o; + ms2.d = ms1.d; +} + +void +Marshal_SSI_Impl::test_union (const Marshal::Marshal_Union& u1, + Marshal::Marshal_Union& u2, + CORBA_Environment &env) +{ + u2._d (u1._d ()); // set the discriminant value + + switch (u1._d ()) + { + case Marshal::e_0th: + u2.s (u1.s ()); // set short + break; + case Marshal::e_1st: + u2.l (u1.l ()); // set long + break; + case Marshal::e_2nd: + u2.c (u1.c ()); // set char + break; + case Marshal::e_3rd: + u2.o (u1.o ()); // set octet + break; + case Marshal::e_4th: + u2.d (u1.d ()); // set double + break; + case Marshal::e_5th: + default: + u2.ms (u1. ms ()); // set structs + break; + } +} + +void +Marshal_SSI_Impl::test_any (const CORBA_Any &a1, + CORBA_Any *&a2, + CORBA_Environment &env) +{ + a2 = new CORBA_Any (a1.type (), (void *)a1.value ()); // will do a deep copy +} + +void +Marshal_SSI_Impl::test_sequence (const Marshal::AnySeq& as1, + Marshal::AnySeq *& as2, + CORBA_Environment &env) +{ + as2 = new Marshal::AnySeq (as1); +} + +#if 0 +void +Marshal_SSI_Impl::test_recursive (const Marshal::Marshal_Recursive &mr1, + Marshal::Marshal_Recursive *&mr2, + CORBA_Environment &env) +{ +} +#endif + +//---------------------------------------------------------------------------- +//the methods of the DSI implementation class + +static const TAO_operation_db_entry Marshal_DSI_operations[] = { + {"_is_a", &Marshal_DSI_Impl::_Marshal_is_a_skel}, + { "test_short", &Marshal_DSI_Impl::_Marshal_test_short_skel}, + { "test_long", &Marshal_DSI_Impl::_Marshal_test_long_skel}, + { "test_octet", &Marshal_DSI_Impl::_Marshal_test_octet_skel}, + { "test_char", &Marshal_DSI_Impl::_Marshal_test_char_skel}, + { "test_double", &Marshal_DSI_Impl::_Marshal_test_double_skel}, + { "test_struct", &Marshal_DSI_Impl::_Marshal_test_struct_skel}, + { "test_union", &Marshal_DSI_Impl::_Marshal_test_union_skel}, + { "test_any", &Marshal_DSI_Impl::_Marshal_test_any_skel}, + { "test_sequence", &Marshal_DSI_Impl::_Marshal_test_sequence_skel}, + { 0, 0 } +}; + +// Note that we use a linear table because rest of the DSI implementations we +// compare with also use linear search in their "invoke" method. +TAO_Linear_OpTable tao_Marshal_DSI_optable (Marshal_DSI_operations, 10); + +// constructor +Marshal_DSI_Impl::Marshal_DSI_Impl (CORBA_ORB_ptr orb, const char *obj_name) + : orb_ (orb) + //,CORBA_DynamicImplementation ("Marshal", obj_name) // interface name is necessary +{ + // Note that this is a HACK to achieve DSI behavior. But this way we can + // cleanly integrate ourselves with the dispatch mechanism of the OA. + + const CORBA_String repoID = "IDL:Marshal:1.0"; // repository ID + IIOP_Object *data; // IIOP object + CORBA_BOA_ptr oa = TAO_OA_PARAMS::instance()->oa(); // underlying BOA + this->optable_ = &tao_Marshal_DSI_optable; // operation database + CORBA_Long i; + + // setup an IIOP object + data = new IIOP_Object (CORBA_string_dup (repoID)); + data->profile.iiop_version.major = IIOP::MY_MAJOR; + data->profile.iiop_version.minor = IIOP::MY_MINOR; + data->profile.host = ACE_OS::strdup (oa->get_addr ().get_host_name ()); + data->profile.port = oa->get_addr ().get_port_number (); + data->profile.object_key.length = ACE_OS::strlen (obj_name); + data->profile.object_key.maximum = data->profile.object_key.length; + data->profile.object_key.buffer = new CORBA_Octet [(size_t)data->profile.object_key.length+1]; + ACE_OS::memcpy (data->profile.object_key.buffer, obj_name, + data->profile.object_key.length); // set the object key + this->set_parent (data); // store the IIOP obj reference with ourselves + this->sub_ = this; // set the most derived class to be ourselves + if (oa) oa->bind (data->profile.object_key, this);// register ourselves +} + +void +Marshal_DSI_Impl::invoke (CORBA_ServerRequest& req, CORBA_Environment &env) +{ + // parse the incoming request and find out for what operation it is. We use a + // simple linear search here + if (!ACE_OS::strcmp (req.op_name (), "test_short")) + { + } + else if (!ACE_OS::strcmp (req.op_name (), "test_long")) + { + } + else if (!ACE_OS::strcmp (req.op_name (), "test_octet")) + { + } + else if (!ACE_OS::strcmp (req.op_name (), "test_char")) + { + } + else if (!ACE_OS::strcmp (req.op_name (), "test_double")) + { + } + else if (!ACE_OS::strcmp (req.op_name (), "test_struct")) + { + } + else if (!ACE_OS::strcmp (req.op_name (), "test_union")) + { + } + else if (!ACE_OS::strcmp (req.op_name (), "test_any")) + { + } + else if (!ACE_OS::strcmp (req.op_name (), "test_sequence")) + { + } +} + +// simulate the skeletons +void Marshal_DSI_Impl::_Marshal_is_a_skel(CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) +{ + CORBA_NVList_ptr nvlist; + CORBA_NamedValue_ptr nv; + CORBA_Any temp_value (_tc_CORBA_String); + char *type_id = "IDL:Marshal:1.0"; + + req.orb()->create_list (0, nvlist); + nv = nvlist->add_value (0, temp_value, CORBA_ARG_IN, env); + + req.params (nvlist, env); + if (env.exception () != 0) { + dexc (env, "is_a_skel, get params"); + return; + } + + CORBA_Boolean *retval; + CORBA_String value = *(CORBA_String *)nv->value ()->value (); + + cout << "object id = " << ((char *)value) << endl; + if (strcmp ((char *)value, (char *)type_id) == 0 + || strcmp ((char *)value, _tc_CORBA_Object->id(env)) == 0) + retval = new CORBA_Boolean (CORBA_B_TRUE); + else + retval = new CORBA_Boolean (CORBA_B_FALSE); + + CORBA_Any *any = + new CORBA_Any (_tc_CORBA_Boolean, retval, CORBA_B_TRUE); + + req.result (any, env); + dexc (env, "_is_a, result"); +} + +void Marshal_DSI_Impl::_Marshal_test_short_skel(CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) +{ + CORBA_NVList_ptr nvlist; + CORBA_NamedValue_ptr nv1, nv2; + CORBA_Any any_s1 (_tc_CORBA_Short); + CORBA_Any any_s2 (_tc_CORBA_Short); + Marshal_DSI_Impl* impl; + CORBA_Short s1, s2; + + // now create a request and populate it with the typecodes + req.orb()->create_list (0, nvlist); + nv1 = nvlist->add_value (0, any_s1, CORBA_ARG_IN, env); + nv2 = nvlist->add_value (0, any_s2, CORBA_ARG_OUT, env); + + // retrieve params - call the interpreter to interpret the parameters for us. + req.params(nvlist, env); + + s1 = *(CORBA_Short *) nv1->value ()->value (); + + // now invoke the implementation + impl = (Marshal_DSI_Impl *)(obj->get_subclass ()); + // now the magic of dynamic binding + impl->test_short (s1, s2, env); + + nv2->value ()->replace (_tc_CORBA_Short, &s2, 0, env); + + // result - NO result + CORBA_Any *any = new CORBA_Any(_tc_CORBA_Void, 0, CORBA_B_TRUE); + req.result(any, env); +} + +void Marshal_DSI_Impl::_Marshal_test_long_skel(CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) +{ + CORBA_NVList_ptr nvlist; + CORBA_NamedValue_ptr nv1, nv2; + CORBA_Any any_l1 (_tc_CORBA_Long); + CORBA_Any any_l2 (_tc_CORBA_Long); + Marshal_DSI_Impl* impl; + CORBA_Long l1, l2; + + // now create a request and populate it with the typecodes + req.orb()->create_list (0, nvlist); + nv1 = nvlist->add_value (0, any_l1, CORBA_ARG_IN, env); + nv2 = nvlist->add_value (0, any_l2, CORBA_ARG_OUT, env); + + // retrieve params - call the interpreter to interpret the parameters for us. + req.params(nvlist, env); + + l1 = *(CORBA_Long *) nv1->value ()->value (); + + // now invoke the implementation + impl = (Marshal_DSI_Impl *)(obj->get_subclass ()); + // now the magic of dynamic binding + impl->test_long (l1, l2, env); + + nv2->value ()->replace (_tc_CORBA_Long, &l2, 0, env); + + // result - NO result + CORBA_Any *any = new CORBA_Any(_tc_CORBA_Void, 0, CORBA_B_TRUE); + req.result(any, env); +} + +void Marshal_DSI_Impl::_Marshal_test_octet_skel(CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) +{ + CORBA_NVList_ptr nvlist; + CORBA_NamedValue_ptr nv1, nv2; + CORBA_Any any_o1 (_tc_CORBA_Octet); + CORBA_Any any_o2 (_tc_CORBA_Octet); + Marshal_DSI_Impl* impl; + CORBA_Octet o1, o2; + + // now create a request and populate it with the typecodes + req.orb()->create_list (0, nvlist); + nv1 = nvlist->add_value (0, any_o1, CORBA_ARG_IN, env); + nv2 = nvlist->add_value (0, any_o2, CORBA_ARG_OUT, env); + + // retrieve params - call the interpreter to interpret the parameters for us. + req.params(nvlist, env); + + o1 = *(CORBA_Octet *) nv1->value ()->value (); + + // now invoke the implementation + impl = (Marshal_DSI_Impl *)(obj->get_subclass ()); + // now the magic of dynamic binding + impl->test_octet (o1, o2, env); + + nv2->value ()->replace (_tc_CORBA_Octet, &o2, 0, env); + + // result - NO result + CORBA_Any *any = new CORBA_Any(_tc_CORBA_Void, 0, CORBA_B_TRUE); + req.result(any, env); +} + +void Marshal_DSI_Impl::_Marshal_test_char_skel(CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) +{ + CORBA_NVList_ptr nvlist; + CORBA_NamedValue_ptr nv1, nv2; + CORBA_Any any_c1 (_tc_CORBA_Char); + CORBA_Any any_c2 (_tc_CORBA_Char); + Marshal_DSI_Impl* impl; + CORBA_Char c1, c2; + + // now create a request and populate it with the typecodes + req.orb()->create_list (0, nvlist); + nv1 = nvlist->add_value (0, any_c1, CORBA_ARG_IN, env); + nv2 = nvlist->add_value (0, any_c2, CORBA_ARG_OUT, env); + + // retrieve params - call the interpreter to interpret the parameters for us. + req.params(nvlist, env); + + c1 = *(CORBA_Char *) nv1->value ()->value (); + + // now invoke the implementation + impl = (Marshal_DSI_Impl *)(obj->get_subclass ()); + // now the magic of dynamic binding + impl->test_char (c1, c2, env); + + nv2->value ()->replace (_tc_CORBA_Char, &c2, 0, env); + + // result - NO result + CORBA_Any *any = new CORBA_Any(_tc_CORBA_Void, 0, CORBA_B_TRUE); + req.result(any, env); +} + +void Marshal_DSI_Impl::_Marshal_test_double_skel(CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) +{ + CORBA_NVList_ptr nvlist; + CORBA_NamedValue_ptr nv1, nv2; + CORBA_Any any_d1 (_tc_CORBA_Double); + CORBA_Any any_d2 (_tc_CORBA_Double); + Marshal_DSI_Impl* impl; + CORBA_Double d1, d2; + + // now create a request and populate it with the typecodes + req.orb()->create_list (0, nvlist); + nv1 = nvlist->add_value (0, any_d1, CORBA_ARG_IN, env); + nv2 = nvlist->add_value (0, any_d2, CORBA_ARG_OUT, env); + + // retrieve params - call the interpreter to interpret the parameters for us. + req.params(nvlist, env); + + d1 = *(CORBA_Double *) nv1->value ()->value (); + + // now invoke the implementation + impl = (Marshal_DSI_Impl *)(obj->get_subclass ()); + // now the magic of dynamic binding + impl->test_double (d1, d2, env); + + nv2->value ()->replace (_tc_CORBA_Double, &d2, 0, env); + + // result - NO result + CORBA_Any *any = new CORBA_Any(_tc_CORBA_Void, 0, CORBA_B_TRUE); + req.result(any, env); +} + +void Marshal_DSI_Impl::_Marshal_test_struct_skel(CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) +{ + CORBA_NVList_ptr nvlist; + CORBA_NamedValue_ptr nv1, nv2; + CORBA_Any any_ms1 (Marshal::_tc_Marshal_Struct); + CORBA_Any any_ms2 (Marshal::_tc_Marshal_Struct); + Marshal_DSI_Impl* impl; + Marshal::Marshal_Struct ms1, *ms2; + + // now create a request and populate it with the typecodes + req.orb()->create_list (0, nvlist); + nv1 = nvlist->add_value (0, any_ms1, CORBA_ARG_IN, env); + nv2 = nvlist->add_value (0, any_ms2, CORBA_ARG_OUT, env); + + // retrieve params - call the interpreter to interpret the parameters for us. + req.params(nvlist, env); + + // note that the second parameter being an out parameter, we are allocating + // it from heap and filling it up. We will then insert it into the Any that + // will get written to the stream. We should have done this for the + // primitives too, but somehow they worked (because nothing got written onto + // the stack frame onto which they existed, but this phenomenon was occuring + // here and possibly will occur for the rest of the case + ms1 = *(Marshal::Marshal_Struct *) nv1->value ()->value (); + ms2 = new Marshal::Marshal_Struct; + + // now invoke the implementation + impl = (Marshal_DSI_Impl *)(obj->get_subclass ()); + // now the magic of dynamic binding + impl->test_struct (ms1, *ms2, env); + + nv2->value ()->replace (Marshal::_tc_Marshal_Struct, ms2, 1, env); + + // result - NO result + // CORBA_Any *any = new CORBA_Any(_tc_CORBA_Void, 0, CORBA_B_TRUE); + // req.result(any, env); +} + +void Marshal_DSI_Impl::_Marshal_test_union_skel(CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) +{ + CORBA_NVList_ptr nvlist; + CORBA_NamedValue_ptr nv1, nv2; + CORBA_Any any_u1 (Marshal::_tc_Marshal_Union); + CORBA_Any any_u2 (Marshal::_tc_Marshal_Union); + Marshal_DSI_Impl* impl; + Marshal::Marshal_Union u1, *u2; + + // now create a request and populate it with the typecodes + req.orb()->create_list (0, nvlist); + nv1 = nvlist->add_value (0, any_u1, CORBA_ARG_IN, env); + nv2 = nvlist->add_value (0, any_u2, CORBA_ARG_OUT, env); + + // retrieve params - call the interpreter to interpret the parameters for us. + req.params(nvlist, env); + + u1 = *(Marshal::Marshal_Union *) nv1->value ()->value (); + u2 = new Marshal::Marshal_Union; + + // now invoke the implementation + impl = (Marshal_DSI_Impl *)(obj->get_subclass ()); + // now the magic of dynamic binding + impl->test_union (u1, *u2, env); + + nv2->value ()->replace (Marshal::_tc_Marshal_Union, u2, 0, env); + + // result - NO result + // CORBA_Any *any = new CORBA_Any(_tc_CORBA_Void, 0, CORBA_B_TRUE); + // req.result(any, env); +} + +void Marshal_DSI_Impl::_Marshal_test_any_skel(CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) +{ + CORBA_NVList_ptr nvlist; + CORBA_NamedValue_ptr nv1, nv2; + CORBA_Any *a1=0, *a2=0; + CORBA_Any any_a1 (_tc_CORBA_Any, &a1); + CORBA_Any any_a2 (_tc_CORBA_Any); + Marshal_DSI_Impl* impl; + + // now create a request and populate it with the typecodes + req.orb()->create_list (0, nvlist); + nv1 = nvlist->add_value (0, any_a1, CORBA_ARG_IN, env); + nv2 = nvlist->add_value (0, any_a2, CORBA_ARG_OUT, env); + + // retrieve params - call the interpreter to interpret the parameters for us. + req.params(nvlist, env); + + a1 = (CORBA_Any *) nv1->value ()->value (); + + // now invoke the implementation + impl = (Marshal_DSI_Impl *)(obj->get_subclass ()); + // now the magic of dynamic binding + impl->test_any (*a1, a2, env); + + nv2->value ()->replace (_tc_CORBA_Any, a2, 1, env); + + // result - NO result + // CORBA_Any *any = new CORBA_Any(_tc_CORBA_Void, 0, CORBA_B_TRUE); + // req.result(any, env); +} + +void Marshal_DSI_Impl::_Marshal_test_sequence_skel(CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env) +{ + CORBA_NVList_ptr nvlist; + CORBA_NamedValue_ptr nv1, nv2; + CORBA_Any any_as1 (Marshal::_tc_AnySeq); + CORBA_Any any_as2 (Marshal::_tc_AnySeq); + Marshal_DSI_Impl* impl; + Marshal::AnySeq *as1, *as2; + + // now create a request and populate it with the typecodes + req.orb()->create_list (0, nvlist); + nv1 = nvlist->add_value (0, any_as1, CORBA_ARG_IN, env); + nv2 = nvlist->add_value (0, any_as2, CORBA_ARG_OUT, env); + + // retrieve params - call the interpreter to interpret the parameters for us. + req.params(nvlist, env); + + as1 = (Marshal::AnySeq *) nv1->value ()->value (); + + // now invoke the implementation + impl = (Marshal_DSI_Impl *)(obj->get_subclass ()); + // now the magic of dynamic binding + impl->test_sequence (*as1, as2, env); + + nv2->value ()->replace (Marshal::_tc_AnySeq, as2, 1, env); + + // result - NO result + // CORBA_Any *any = new CORBA_Any(_tc_CORBA_Void, 0, CORBA_B_TRUE); + // req.result(any, env); +} + +// private methods of our DSI class +void +Marshal_DSI_Impl::test_short (CORBA_Short s1, + CORBA_Short &s2, + CORBA_Environment &env) +{ + s2 = 2*s1; +} + +void +Marshal_DSI_Impl::test_long (CORBA_Long l1, + CORBA_Long &l2, + CORBA_Environment &env) +{ + l2 = 3*l1; +} + +void +Marshal_DSI_Impl::test_octet (CORBA_Octet o1, + CORBA_Octet &o2, + CORBA_Environment &env) +{ + o2 = o1; +} + +void +Marshal_DSI_Impl::test_char (CORBA_Char c1, + CORBA_Char &c2, + CORBA_Environment &env) +{ + c2 = c1; +} + +void +Marshal_DSI_Impl::test_double (CORBA_Double d1, + CORBA_Double &d2, + CORBA_Environment &env) +{ + d2 = d1/2; +} + +void +Marshal_DSI_Impl::test_struct (const Marshal::Marshal_Struct& ms1, + Marshal::Marshal_Struct& ms2, + CORBA_Environment &env) +{ + ms2.s = ms1.s; + ms2.l = ms1.l; + ms2.c = ms1.c; + ms2.o = ms1.o; + ms2.d = ms1.d; +} + +void +Marshal_DSI_Impl::test_union (const Marshal::Marshal_Union& u1, + Marshal::Marshal_Union& u2, + CORBA_Environment &env) +{ + u2._d (u1._d ()); // set the discriminant value + + switch (u1._d ()) + { + case Marshal::e_0th: + u2.s (u1.s ()); // set short + break; + case Marshal::e_1st: + u2.l (u1.l ()); // set long + break; + case Marshal::e_2nd: + u2.c (u1.c ()); // set char + break; + case Marshal::e_3rd: + u2.o (u1.o ()); // set octet + break; + case Marshal::e_4th: + u2.d (u1.d ()); // set double + break; + case Marshal::e_5th: + default: + u2.ms (u1. ms ()); // set structs + break; + } +} + +void +Marshal_DSI_Impl::test_any (const CORBA_Any &a1, + CORBA_Any *&a2, + CORBA_Environment &env) +{ + a2 = new CORBA_Any (a1.type (), (void *)a1.value ()); // will do a deep copy +} + +void +Marshal_DSI_Impl::test_sequence (const Marshal::AnySeq& as1, + Marshal::AnySeq *& as2, + CORBA_Environment &env) +{ + as2 = new Marshal::AnySeq (as1); +} + +#if 0 +void +Marshal_DSI_Impl::test_recursive (const Marshal::Marshal_Recursive &mr1, + Marshal::Marshal_Recursive *&mr2, + CORBA_Environment &env) +{ +} +#endif + diff --git a/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_impl.h b/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_impl.h new file mode 100644 index 00000000000..0ecec0fc87c --- /dev/null +++ b/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_impl.h @@ -0,0 +1,190 @@ +#if !defined (TAO_MARSHAL_IMPL_H) +#define TAO_MARSHAL_IMPL_H + +// to include DSI related files + +#include "ace/OS.h" + +#include "marshalS.h" +//#include "tao/dynimpl.h" + +class Marshal_SSI_Impl + : public virtual _skel_Marshal +{ + // =TITLE + // Marshal_SSI_Impl + // =DESCRIPTION + // Implementation of the interface using the static skeleton interface +public: + Marshal_SSI_Impl (const char *object_name = (const char *)NULL); + // constructor + + ~Marshal_SSI_Impl (void); + // destructor + + virtual void test_short (CORBA_Short s1, + CORBA_Short& s2, + CORBA_Environment &env); + // test short + + virtual void test_long (CORBA_Long l1, + CORBA_Long& l2, + CORBA_Environment &env); + // test long + + virtual void test_octet (CORBA_Octet o1, + CORBA_Octet& o2, + CORBA_Environment &env); + // test octet + + virtual void test_char (CORBA_Char c1, + CORBA_Char& c2, + CORBA_Environment &env); + // test char + + virtual void test_double (CORBA_Double d1, + CORBA_Double& d2, + CORBA_Environment &env); + // test double + + virtual void test_struct (const Marshal::Marshal_Struct& ms1, + Marshal::Marshal_Struct& ms2, + CORBA_Environment &env); + // test struct + + virtual void test_union (const Marshal::Marshal_Union& u1, + Marshal::Marshal_Union& u2, + CORBA_Environment &env); + // test union + + virtual void test_any (const CORBA_Any& a1, + CORBA_Any *& a2, + CORBA_Environment &env); + // test any + + virtual void test_sequence (const Marshal::AnySeq& a1, + Marshal::AnySeq *& a2, + CORBA_Environment &env); + // test sequence + +#if 0 + virtual void test_recursive (const Marshal::Marshal_Recursive& mr1, + Marshal::Marshal_Recursive *& mr2, + CORBA_Environment &env); + // test struct +#endif + +}; + +class Marshal_DSI_Impl : public CORBA_Object //: public CORBA_DynamicImplementation +{ + // =TITLE + // Marshal_DSI_Impl + // =DESCRIPTION + // Implementation of the interface using the dynamic skeleton interface + // =NOTES + // We do not have a DynamicImplementation as yet. So we do a trick here. We + // simulate the skeletons here and these call the private methods defined below: +public: + Marshal_DSI_Impl (CORBA_ORB_ptr orb, const char *object_name = (const char *)NULL); + // constructor + + ~Marshal_DSI_Impl (void); + // destructor + + virtual void invoke (CORBA_ServerRequest & req, CORBA_Environment &env); + // This method is a must, but of no use + + // skeletons that do the upcall + static void _Marshal_is_a_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); + static void _Marshal_test_short_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); + static void _Marshal_test_long_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); + static void _Marshal_test_octet_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); + static void _Marshal_test_char_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); + static void _Marshal_test_double_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); + static void _Marshal_test_struct_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); + static void _Marshal_test_union_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); + static void _Marshal_test_any_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); + static void _Marshal_test_sequence_skel (CORBA_ServerRequest &req, + CORBA_Object_ptr obj, + CORBA_Environment &env); +private: + void test_short (CORBA_Short s1, + CORBA_Short& s2, + CORBA_Environment &env); + // test short + + void test_long (CORBA_Long l1, + CORBA_Long& l2, + CORBA_Environment &env); + // test long + + void test_octet (CORBA_Octet o1, + CORBA_Octet& o2, + CORBA_Environment &env); + // test octet + + void test_char (CORBA_Char c1, + CORBA_Char& c2, + CORBA_Environment &env); + // test char + + void test_double (CORBA_Double d1, + CORBA_Double& d2, + CORBA_Environment &env); + // test double + + void test_struct (const Marshal::Marshal_Struct& ms1, + Marshal::Marshal_Struct& ms2, + CORBA_Environment &env); + // test struct + + void test_union (const Marshal::Marshal_Union& u1, + Marshal::Marshal_Union& u2, + CORBA_Environment &env); + // test union + + void test_any (const CORBA_Any& a1, + CORBA_Any *& a2, + CORBA_Environment &env); + // test any + + void test_sequence (const Marshal::AnySeq& a1, + Marshal::AnySeq *& a2, + CORBA_Environment &env); + // test sequence + +#if 0 + void test_recursive (const Marshal::Marshal_Recursive& mr1, + Marshal::Marshal_Recursive *& mr2, + CORBA_Environment &env); + // test struct +#endif + + // we need the orb to create argument lists (NVList) for us + CORBA_ORB_ptr orb_; // not owned by us +}; + +#if defined (__ACE_INLINE__) +#include "tao_marshal_impl.i" +#endif /* __ACE_INLINE__ */ + +#endif // defined (TAO_MARSHAL_IMPL_H) diff --git a/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_impl.i b/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_impl.i new file mode 100644 index 00000000000..aee9bc6b043 --- /dev/null +++ b/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_impl.i @@ -0,0 +1,21 @@ +// constructor +ACE_INLINE +Marshal_SSI_Impl::Marshal_SSI_Impl (const char *obj_name) + : _skel_Marshal (obj_name) +{ +} + +// destructor +ACE_INLINE +Marshal_SSI_Impl::~Marshal_SSI_Impl (void) +{ +} + +// destructor +ACE_INLINE +Marshal_DSI_Impl::~Marshal_DSI_Impl (void) +{ + orb_ = 0;//CORBA::ORB::_nil (); +} + + diff --git a/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_server.cpp b/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_server.cpp new file mode 100644 index 00000000000..ed6a5a041c7 --- /dev/null +++ b/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_server.cpp @@ -0,0 +1,110 @@ +// ============================================================================ +// +// = LIBRARY +// CORBA Tao marshal benchmark +// +// = FILENAME +// tao_marshal_server.cpp +// +// = AUTHOR +// Aniruddha Gokhale +// +// ============================================================================ + +#include "tao_marshal_server.h" +#include <iostream.h> +#include <fstream.h> + +#if !defined (__ACE_INLINE__) +#include "tao_marshal_server.i" +#endif /* __ACE_INLINE__ */ + +int +Tao_Marshal_Server_Proxy::run (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results) +{ + char **argv; + int argc; + CORBA_Environment env; + CORBA_String str; // for the IOR string + fstream iorfile; // persistent storage for IOR + + // get the argument list to be passed on to the ORB_init method + argv = options.orb_init_args (argc); + + // get the orb. Pass any ORB_init arguments + this->orb_ = CORBA_ORB_init (argc, (char *const *)argv, "IOR", env); + if (this->orb_ == 0) + { + ACE_DEBUG ((LM_DEBUG, "ORB_init failed\n")); + return -1; + } + + // get the argument list to be passed on to the BOA_init method + argv = options.boa_init_args (argc); + + char *foo [] = {"-OAhost","mambo"}; argc = 2; + // get the orb. Pass any ORB_init arguments + this->boa_ = this->orb_->BOA_init (argc, foo, "ROA");//(argc, (char *const *)argv); + if (this->boa_ == 0) + { + ACE_DEBUG ((LM_DEBUG, "ORB_init failed\n")); + return -1; + } + + // tell the "results" object what file it must store the results into + results.filename (options.filename ()); + + // use SII or DII accordingly + switch (options.policy ()) + { + case CORBA_Marshal_Options::STATIC : // use SSI + this->ssi_ = new Marshal_SSI_Impl (options.object_name ()); + // register with the BOA + // this->boa_->obj_is_ready (this->ssi_); + + // get a stringified representation of the object reference created above + str = this->orb_->object_to_string (this->dsi_, env); + if (env.exception() != 0) + { + // print_exception (env.exception(), "object_to_string", stdout); + return 1; + } + + // save the IOR in persistent storage so that clients can read this and obtain + // object references. We need to do this since we do not yet have some kind + // of a naming service that will allow clients to "bind" to desired objects + iorfile.open ("./ior.txt", ios::out); + iorfile << ((char *)str) << endl; + iorfile.close (); + break; + case CORBA_Marshal_Options::DYNAMIC : // use DSI + this->dsi_ = new Marshal_DSI_Impl (this->orb_, ACE_OS::strdup (options.object_name ())); + // register with the BOA + // this->boa_->obj_is_ready (this->dsi_); + + // get a stringified representation of the object reference created above + str = this->orb_->object_to_string (this->dsi_, env); + if (env.exception() != 0) + { + ACE_DEBUG ((LM_ERROR, "cannot get IOR from DSI object" )); + // print_exception (env.exception(), "object_to_string", stdout); + return 1; + } + + // save the IOR in persistent storage so that clients can read this and obtain + // object references. We need to do this since we do not yet have some kind + // of a naming service that will allow clients to "bind" to desired objects + iorfile.open ("./ior.txt", ios::out); + iorfile << ((char *)str) << endl; + iorfile.close (); + break; + default: + ACE_DEBUG ((LM_DEBUG, "bad policy\n")); + return -1; + } + + ACE_Reactor::run_event_loop (); // should be replaced by impl_is_ready + return 0; +} + diff --git a/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_server.h b/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_server.h new file mode 100644 index 00000000000..adbd782c3d3 --- /dev/null +++ b/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_server.h @@ -0,0 +1,57 @@ +// ============================================================================ +// +// = LIBRARY +// CORBA Marshal Tao Benchmark +// +// = FILENAME +// tao_marshal_server.h +// +// = AUTHOR +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined(_TAO_MARSHAL_SERVER_H_) +#define _TAO_MARSHAL_SERVER_H_ + +// benchmark library includes +#include "benchmark/marshal_options.h" +#include "benchmark/marshal_results.h" +#include "benchmark/marshal_proxy.h" + +// implementation classes +#include "tao_marshal_impl.h" + +// include Tao specific include files +#include "marshalS.h" // generated by IDL compiler + +class Tao_Marshal_Server_Proxy : public CORBA_Marshal_Proxy +{ +public: + Tao_Marshal_Server_Proxy (void); + // constructor + + ~Tao_Marshal_Server_Proxy (void); + // destructor + + virtual int run (CORBA_Marshal_Proxy::OPTIONS &options, + CORBA_Marshal_Proxy::RESULTS &results); + // do the actual work +private: + CORBA_ORB_ptr orb_; + // underlying orb; + + CORBA_BOA_ptr boa_; + // underlying boa; + + Marshal_SSI_Impl *ssi_; + Marshal_DSI_Impl *dsi_; + // the implementation (SSI or DSI) +}; + + +#if defined (__ACE_INLINE__) +#include "tao_marshal_server.i" +#endif /* __ACE_INLINE__ */ + +#endif diff --git a/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_server.i b/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_server.i new file mode 100644 index 00000000000..721a329c03b --- /dev/null +++ b/TAO/Benchmark/Marshal_Test/TAO/tao_marshal_server.i @@ -0,0 +1,26 @@ +// constructor +ACE_INLINE +Tao_Marshal_Server_Proxy::Tao_Marshal_Server_Proxy (void) + : orb_ (0), + boa_ (0), + ssi_ (0), + dsi_ (0) +{ +} + +// destructor +ACE_INLINE +Tao_Marshal_Server_Proxy::~Tao_Marshal_Server_Proxy (void) +{ + // releasing order is important + + // release the impl + delete ssi_; + delete dsi_; + + // release the BOA + CORBA_release (boa_); + + // release the ORB + CORBA_release (orb_); +} |