本文整理汇总了C++中corba::ORB_ptr::string_to_object方法的典型用法代码示例。如果您正苦于以下问题:C++ ORB_ptr::string_to_object方法的具体用法?C++ ORB_ptr::string_to_object怎么用?C++ ORB_ptr::string_to_object使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corba::ORB_ptr
的用法示例。
在下文中一共展示了ORB_ptr::string_to_object方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv) {
if( argc == 1 ) {
printf("usage:\n\t%s <server_url>\n", argv[0]);
return -1;
}
try {
CORBA::ORB_ptr orb = CORBA::ORB_init(argc, argv);
//
// destringify the URL (i.e. args[1]) to a programming object
//
CORBA::Object_var ref = orb->string_to_object(argv[1]);
sample::Greeting_var server = sample::Greeting::_narrow(ref.in());
//
// invoke the server and get reply.
//
CORBA::String_var reply = server->hello("hello greeting from Client");
printf("Client received a %s\n", reply.in());
}
catch(const CORBA::Exception& e) {
printf("Exception: %s\n", e._name());
return -1;
}
return 0;
}
示例2: catch
bool
test_string_to_object (CORBA::ORB_ptr orb, const char* ior, CORBA::ULong minor)
{
bool succeed = false;
try
{
// Get the object reference with the IOR
CORBA::Object_var object = orb->string_to_object (ior);
}
catch (const CORBA::BAD_PARAM& ex)
{
if ((ex.minor() & 0xFFFU) == minor)
{
succeed = true;
}
}
catch (const CORBA::Exception&)
{
}
if (!succeed)
{
ACE_ERROR ((LM_ERROR,
"(%t) ERROR, test_string_to_object for <%C> didn't result in minor code %d\n",
ior,
minor));
}
return succeed;
}
示例3: catch
int
Client_Task::narrow_servant (CORBA::ORB_ptr orb)
{
try
{
CORBA::Object_var object =
orb->string_to_object (this->ior_);
this->roundtrip_ =
Test::Roundtrip::_narrow (object.in ());
if (CORBA::is_nil (this->roundtrip_.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Nil Test::Roundtrip reference <%s>\n",
this->ior_),
0);
}
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught trying to narrow servant\n");
return 0;
}
return 1;
}
示例4:
static void
test_forward_permanent (CORBA::ORB_ptr orb)
{
CORBA::Object_var obj1 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:1111,iiop:192.168.1.3:1111/NameService");
// the permanent profile
CORBA::Object_var obj4 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:4444,iiop:192.168.1.3:4444/NameService");
TAO_Stub *stub1 = obj1->_stubobj ();
TAO_Stub *stub4 = obj4->_stubobj ();
TAO_Profile *profile = 0;
profile = stub1->profile_in_use ();
FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 1111));
// ----- forward to obj2 permanently
stub1->add_forward_profiles (stub4->base_profiles(), true /* permanent */ );
FRANKS_ASSERT (stub1->forward_profiles () != 0);
profile = stub1->next_profile ();
FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 4444));
// ----- stringified object reference must be equal to obj4->base_prpfiles().
FRANKS_ASSERT (marshaled_equal_to_other (orb, obj1.in (), &(stub4->base_profiles())) );
// ----- consume second profile of obj2
profile = stub1->next_profile ();
FRANKS_ASSERT (is_endpoint (profile, "192.168.1.3", 4444));
// ----- reached end, next_profile() must yield NULL
profile = stub1->next_profile ();
FRANKS_ASSERT (profile == 0);
FRANKS_ASSERT (stub1->forward_profiles () != 0);
}
示例5: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
int status = 0;
try
{
Supplier_Client client;
status = client.init (argc, argv);
if (status == 0)
{
CosNotifyChannelAdmin::EventChannel_var ec =
client.create_event_channel ("MyEventChannel", 1);
CORBA::ORB_ptr orb = client.orb ();
CORBA::Object_var object =
orb->string_to_object (ior);
MonitorTestInterface_var sig =
MonitorTestInterface::_narrow (object.in ());
if (CORBA::is_nil (sig.in ()))
ACE_ERROR_RETURN ((LM_ERROR, "Error: Structured Supplier: Narrow to MonitorTestInterface failed.\n"),1);
CosNotifyChannelAdmin::SupplierAdmin_var admin =
create_supplieradmin (ec.in ());
if (!CORBA::is_nil (admin.in ()))
{
create_suppliers (admin.in (), client.root_poa ());
sig->running (MonitorTestInterface::Supplier);
ACE_DEBUG ((LM_DEBUG,
"1 supplier sending %d events...\n", max_events));
for (int i = 0; i < max_events; ++i)
{
ACE_DEBUG ((LM_DEBUG, "+"));
SendEvent (i);
}
ACE_DEBUG ((LM_DEBUG,
"\nSupplier sent %d events.\n", max_events));
sig->finished (MonitorTestInterface::Supplier);
supplier_1->disconnect ();
}
}
}
catch (const CORBA::Exception& e)
{
e._tao_print_exception ("Supplier Error: ");
status = 1;
}
return status;
}
示例6: policies
Test::Hello_var
create_policies (CORBA::ORB_ptr orb, bool add_zlib_compressor)
{
CORBA::PolicyList policies(4);
policies.length(4);
policies[0] = create_compressor_id_level_list_policy (orb, add_zlib_compressor);
policies[1] = create_low_value_policy (orb);
policies[2] = create_compression_enabled_policy (orb);
policies[3] = create_min_ratio_policy (orb);
CORBA::Object_var tmp = orb->string_to_object(ior);
CORBA::Object_var tmp2 = tmp->_set_policy_overrides (policies, CORBA::ADD_OVERRIDE);
Test::Hello_var hello = Test::Hello::_narrow(tmp2.in ());
return hello._retn ();
}
示例7: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
int status = 0;
try
{
Consumer_Client client;
status = client.init (argc, argv);
ACE_UNUSED_ARG(status);
ACE_ASSERT(status == 0);
CosNotifyChannelAdmin::EventChannel_var ec =
client.create_event_channel ("MyEventChannel", 1);
CORBA::ORB_ptr orb = client.orb ();
CORBA::Object_var object =
orb->string_to_object (ior);
sig_var sig = sig::_narrow (object.in ());
ACE_ASSERT(! CORBA::is_nil (sig.in ()));
CosNotifyChannelAdmin::ConsumerAdmin_var admin =
create_consumeradmin (ec.in ());
ACE_ASSERT(!CORBA::is_nil (admin.in ()));
create_consumers (admin.in (), &client);
// Tell the supplier to go
sig->go ();
ACE_DEBUG((LM_DEBUG, "Consumer waiting for events...\n"));
client.ORB_run( );
ACE_DEBUG((LM_DEBUG, "Consumer done.\n"));
consumer_1->disconnect();
sig->done ();
}
catch (const CORBA::Exception& e)
{
e._tao_print_exception ("Error: ");
status = 1;
}
return status;
}
示例8: create_policies
Test::Hello_var
prepare_tests (CORBA::ORB_ptr orb, bool create_factories=true)
{
#if defined TAO_HAS_ZIOP && TAO_HAS_ZIOP == 1
if (create_factories)
{
register_factories(orb);
}
return create_policies (orb, !create_factories);
#else
ACE_UNUSED_ARG (create_factories);
CORBA::Object_var tmp = orb->string_to_object(ior);
Test::Hello_var hello = Test::Hello::_narrow(tmp.in ());
return hello._retn ();
#endif
}
示例9:
Smart_Messenger_Proxy_Factory::Smart_Messenger_Proxy_Factory(
CORBA::ORB_ptr orb)
{
std::cout << "Creating smart proxy factory" << std::endl;
// Convert the contents of the Logger.ior file to an object reference.
CORBA::Object_var obj = orb->string_to_object("file://Logger.ior");
if (CORBA::is_nil(obj.in())) {
std::cerr << "Nil Logger reference" << std::endl;
throw 0;
}
// Narrow the object reference to a Logger object reference.
logger_ = Logger::_narrow(obj.in());
if (CORBA::is_nil(logger_.in ())) {
std::cerr << "Not a Logger object reference" << std::endl;
throw 0;
}
}
示例10: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
int status = 0;
try
{
Consumer_Client client;
status = client.init (argc, argv);
if (status != 0)
ACE_ERROR_RETURN ((LM_ERROR, "Error: Client init failed.\n"),1);
CosNotifyChannelAdmin::EventChannel_var ec =
client.create_event_channel ("MyEventChannel", 1);
CORBA::ORB_ptr orb = client.orb ();
CORBA::Object_var object =
orb->string_to_object (ior);
sig_var sig = sig::_narrow (object.in ());
CosNotifyChannelAdmin::ConsumerAdmin_var admin =
create_consumeradmin (ec.in ());
if (CORBA::is_nil (admin.in ()))
ACE_ERROR_RETURN ((LM_ERROR, "Error: nil ConsumerAdmin.\n"),1);
create_consumers (admin.in (), &client);
ACE_DEBUG ((LM_DEBUG, "\nConsumer waiting for events...\n"));
sig->go ();
ACE_Time_Value tv (5);
orb->run (tv);
ACE_DEBUG ((LM_DEBUG, "Consumer done.\n"));
}
catch (const CORBA::Exception& e)
{
e._tao_print_exception ("Consumer Error: ");
status = 1;
}
return status;
}
示例11: name
static CORBA::Object_ptr
get_distributor_reference (CORBA::ORB_ptr orb)
{
if (use_naming)
{
CORBA::Object_var tmp =
orb->resolve_initial_references ("NameService");
CosNaming::NamingContext_var pns =
CosNaming::NamingContext::_narrow (tmp.in ());
CosNaming::Name name (1);
name.length (1);
name[0].id = distributor_name.c_str ();
return pns->resolve (name);
}
else
// Read and destringify the Stock_Distributor object's IOR.
return orb->string_to_object (ior.c_str ());
}
示例12: run
static void run (CORBA::ORB_ptr orb,
ACE_TCHAR *IOR)
{
if (IOR != 0)
{
// Get an object reference from the argument string.
CORBA::Object_var object = orb->string_to_object (IOR);
// Try to narrow the object reference to a reference.
T_var test = T::_narrow (object.in ());
ACE_Profile_Timer timer;
ACE_Profile_Timer::ACE_Elapsed_Time elapsed_time;
// We start an ACE_Profile_Timer here...
timer.start ();
CORBA::Long result = 0;
int i = 0;
for (i = 0; i < iterations ; i++)
{
// Invoke the doit() method on the reference.
result = test->doit ();
}
// stop the timer.
timer.stop ();
timer.elapsed_time (elapsed_time);
// compute average time.
print_stats (elapsed_time, i);
// Print the result of doit () method on the reference.
ACE_DEBUG ((LM_DEBUG,
"%d\n",
result));
}
}
示例13: test_impl
void test_impl(
CORBA::ORB_ptr orb,
ACE_TCHAR const * ior,
bool shutdown)
{
CORBA::Object_var object = orb->string_to_object(ior);
Test_var test = Test::_narrow(object.in());
if(CORBA::is_nil(test.in()))
{
throw "Nil reference after narrow";
}
for(int i = 0; i != niterations; ++i)
{
test->sendc_the_operation(AMI_TestHandler::_nil());
}
ACE_Time_Value wait_for_responses_interval(1, 0);
orb->run(wait_for_responses_interval);
if (shutdown)
test->shutdown ();
}
示例14: reader
CORBA::Object_ptr
TAO_FILE_Parser::parse_string (const char *ior, CORBA::ORB_ptr orb)
{
// Skip the prefix, we know it is there because this method in only
// called if <match_prefix> returns 1.
const char *filename =
ior + sizeof (::file_prefix)+1;
FILE* file = ACE_OS::fopen (ACE_TEXT_CHAR_TO_TCHAR (filename),
ACE_TEXT("r"));
if (file == 0)
return CORBA::Object::_nil ();
ACE_Read_Buffer reader (file, true);
char* string = reader.read ();
if (string == 0)
return CORBA::Object::_nil ();
CORBA::Object_ptr object = CORBA::Object::_nil ();
try
{
object = orb->string_to_object (string);
reader.alloc ()->free (string);
}
catch (const ::CORBA::Exception&)
{
reader.alloc ()->free (string);
throw;
}
return object;
}
示例15: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
Consumer_Client client;
int status = client.init (argc, argv);
ACE_ASSERT(status == 0);
ACE_UNUSED_ARG(status);
CosNotifyChannelAdmin::EventChannel_var ec =
client.create_event_channel ("MyEventChannel", 1);
CORBA::ORB_ptr orb = client.orb ();
CORBA::Object_var object =
orb->string_to_object (ior);
sig_var sig = sig::_narrow (object.in ());
ACE_ASSERT(! CORBA::is_nil (sig.in ()));
CosNotifyChannelAdmin::ConsumerAdmin_var admin =
create_consumeradmin (ec.in ());
if (filter)
{
CosNotifyFilter::FilterFactory_var ffact =
ec->default_filter_factory ();
CosNotifyFilter::Filter_var filter =
ffact->create_filter ("TCL");
ACE_ASSERT(! CORBA::is_nil(filter.in()));
CosNotifyFilter::ConstraintExpSeq constraint_list (1);
constraint_list.length(1);
constraint_list[0].event_types.length (0);
constraint_list[0].constraint_expr = CORBA::string_dup(ACE_TEXT_ALWAYS_CHAR (constraintString));
filter->add_constraints (constraint_list);
admin->add_filter(filter.in());
}
ACE_ASSERT (!CORBA::is_nil (admin.in ()));
create_consumers(admin.in (), &client);
// Tell the supplier to go
sig->go ();
client.ORB_run( );
ACE_DEBUG((LM_DEBUG, "Consumer done.\n"));
sig->done ();
return 0;
}
catch (const CORBA::Exception& e)
{
e._tao_print_exception ("Error: Consumer exception: ");
}
return 1;
}