本文整理汇总了C++中Simple_Server_var类的典型用法代码示例。如果您正苦于以下问题:C++ Simple_Server_var类的具体用法?C++ Simple_Server_var怎么用?C++ Simple_Server_var使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Simple_Server_var类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ACE_TMAIN
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
CORBA::Object_var poa_object =
orb->resolve_initial_references ("RootPOA");
if (CORBA::is_nil (poa_object.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Unable to initialize the POA.\n"),
1);
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in ());
PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();
// Policies for the childPOA to be created.
CORBA::PolicyList policies (1);
policies.length (1);
CORBA::Any pol;
pol <<= BiDirPolicy::BOTH;
policies[0] =
orb->create_policy (BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE, pol);
// Create POA as child of RootPOA with the above policies. This POA
// will receive request in the same connection in which it sent
// the request
PortableServer::POA_var child_poa =
root_poa->create_POA ("childPOA", poa_manager.in (), policies);
// Creation of childPOA is over. Destroy the Policy objects.
for (CORBA::ULong i = 0; i < policies.length (); ++i)
{
policies[i]->destroy ();
}
poa_manager->activate ();
if (parse_args (argc, argv) != 0)
return 1;
CORBA::Object_var object = orb->string_to_object (ior);
Simple_Server_var server = Simple_Server::_narrow (object.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Object reference <%C> is nil\n",
ior),
1);
}
Callback_i callback_impl (orb.in ());
PortableServer::ObjectId_var id =
PortableServer::string_to_ObjectId ("client_callback");
child_poa->activate_object_with_id (id.in (), &callback_impl);
CORBA::Object_var callback_object =
child_poa->id_to_reference (id.in ());
Callback_var callback = Callback::_narrow (callback_object.in ());
CORBA::String_var ior = orb->object_to_string (callback.in ());
ACE_DEBUG ((LM_DEBUG, "(%P|%t) Client callback activated as <%C>\n",
ior.in ()));
// Send the calback object to the server
server->callback_object (callback.in ());
int pre_call_connections =
orb->orb_core ()->lane_resources ().transport_cache ().current_size ();
// A method to kickstart callbacks from the server
CORBA::Long r = server->test_method (1);
if (r != 0)
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) unexpected result = %d ",
r));
}
orb->run ();
int cur_connections =
orb->orb_core ()->lane_resources ().transport_cache ().current_size ();
if (cur_connections > pre_call_connections)
{
ACE_ERROR ((LM_ERROR,
"(%P|%t) Expected %d "
//.........这里部分代码省略.........
示例2:
void
Worker::run_test (void)
{
CORBA::Object_var object =
this->orb_->string_to_object (ior);
Simple_Server_var server =
Simple_Server::_narrow (object.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR ((LM_ERROR,
"Object reference <%s> is nil.\n",
ior));
return;
}
CORBA::Boolean r =
server->test_is_a ("IDL:Foo:1.0");
if (r != 0)
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) unexpected result = %d\n",
r));
}
示例3: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
// Initialize the ORB
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
return 1;
// Get Object Reference using IOR file
CORBA::Object_var object =
orb->string_to_object (ior);
// Cast to Appropriate Type
Simple_Server_var server =
Simple_Server::_narrow (object.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Object reference <%s> is nil\n", ior),
1);
}
Client_Worker client (server.in (), niterations);
if (client.activate (THR_NEW_LWP | THR_JOINABLE, nthreads) != 0)
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Cannot Activate Client Threads\n"),
1);
client.thr_mgr ()->wait ();
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) threads finished\n"));
// Shut down the server if -x option given in command line
if (do_shutdown)
{
server->shutdown ();
}
// Destroying the ORB..
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return 1;
}
return 0;
}
示例4: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
return 1;
// Primary server
CORBA::Object_var object_primary =
orb->string_to_object (ior);
//Secondary server
CORBA::Object_var object_secondary =
orb->string_to_object (name);
// Get an object reference for the ORBs IORManipultion object!
CORBA::Object_ptr IORM =
orb->resolve_initial_references (TAO_OBJID_IORMANIPULATION,
0);
TAO_IOP::TAO_IOR_Manipulation_ptr iorm =
TAO_IOP::TAO_IOR_Manipulation::_narrow (IORM);
TAO_IOP::TAO_IOR_Manipulation::IORList iors (2);
iors.length(2);
iors [0] = object_primary;
iors [1] = object_secondary;
CORBA::Object_var merged = iorm->merge_iors (iors);
// Combined IOR stuff
Simple_Server_var server =
Simple_Server::_narrow (merged.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Object reference <%s> is nil.\n",
ior),
1);
}
run_test (server.in ());
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Caught an exception\n");
return -1;
}
return 0;
}
示例5: ACE_DEBUG
int
SelfClient::svc (void)
{
try
{
this->validate_connection ();
for (int i = 0; i < this->niterations_; ++i)
{
try
{
CORBA::Object_var probably_not_exist =
orb_->string_to_object (corbaloc_arg);
if (CORBA::is_nil (probably_not_exist.in()))
{
ACE_DEBUG ((LM_DEBUG, "not found\n", corbaloc_arg));
}
else
{
Simple_Server_var newserver =
Simple_Server::_narrow (probably_not_exist.in ());
// should throw an exception
if (CORBA::is_nil (newserver.in()))
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) Not found it\n"));
}
else
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) Found it\n"));
}
}
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("MT_SelfClient: exception raised");
}
// Just make a call
this->server_->test_method (i);
}
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("MT_SelfClient: exception raised");
}
return 0;
}
示例6: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
return 1;
CORBA::Object_var object =
orb->string_to_object (ior);
Simple_Server_var server =
Simple_Server::_narrow (object.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Object reference <%s> is nil.\n",
ior),
1);
}
CORBA::Boolean non_existent = server->_non_existent ();
if (non_existent)
result = 3;
else
result = 2;
ACE_DEBUG ((LM_DEBUG,
"client (%P) _non_existent() returned %d\n",
static_cast<int>(non_existent) ));
orb->destroy ();
}
catch (const CORBA::OBJECT_NOT_EXIST& ex)
{
ex._tao_print_exception ("ERROR: Exception caught:");
result = 4;
}
catch (const CORBA::TRANSIENT&)
{
result = 5;
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("ERROR: Exception caught:");
result = 6;
}
return result;
}
示例7: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
return 1;
CORBA::Object_var object =
orb->string_to_object (ior);
Simple_Server_var server =
Simple_Server::_narrow (object.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Object reference <%s> is nil.\n",
ior),
1);
}
for (int i = 0; i != niterations; ++i)
{
CORBA::Long r =
server->test_method (i);
if (r != i)
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) unexpected result = %d for %d",
r, i));
}
}
if (do_shutdown)
{
server->shutdown ();
}
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return 1;
}
return 0;
}
示例8: ACE_TMAIN
//int testClient (char* orbName, char* ior)
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc,
argv,
"ORB_Test_Client");
if (parse_args (argc, argv) != 0)
return 1;
CORBA::Object_var object =
orb->string_to_object (ior);
Simple_Server_var server =
Simple_Server::_narrow (object.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Object reference <%s> is nil.\n",
ior),
1);
}
CORBA::String_var string =
orb->object_to_string (server.in ());
ACE_DEBUG ((LM_DEBUG,
"Client: orb->object_to_string: <%C>\n",
string.in ()));
Client client (server.in (), niter);
client.svc ();
//ACE_DEBUG ((LM_DEBUG, "threads finished\n"));
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Caught exception:");
return 1;
}
return 0;
}
示例9: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
return 1;
CORBA::Object_var object =
orb->string_to_object (ior);
Simple_Server_var server =
Simple_Server::_narrow (object.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Object reference <%s> is nil\n",
ior),
1);
}
while (!feof (stdin))
{
ACE_Read_Buffer buf (stdin, 0);
char *line = buf.read ('\n');
if (line == 0)
break;
server->send_line (line);
buf.alloc ()->free (line);
}
server->shutdown ();
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Caught exception:");
return 1;
}
return 0;
}
示例10: ACE_ERROR
void
Client_i::init (void)
{
// Open the file for reading.
ACE_HANDLE f_handle = ACE_OS::open (ior_output_file,
0);
if (f_handle == ACE_INVALID_HANDLE)
ACE_ERROR ((LM_ERROR,
"Unable to open %s for writing: %p\n",
ior_output_file));
ACE_Read_Buffer ior_buffer (f_handle);
char *data = ior_buffer.read ();
if (data == 0)
ACE_ERROR ((LM_ERROR,
"Unable to read ior: %p\n"));
int argc = 0;
ACE_TCHAR **argv = 0;
this->orb_ = CORBA::ORB_init (argc, argv);
CORBA::Object_var object =
this->orb_->string_to_object (data);
// Combined IOR stuff
Simple_Server_var server =
Simple_Server::_narrow (object.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR ((LM_ERROR,
"Object reference <%C> is nil\n",
data));
}
run_test (server.in ());
ior_buffer.alloc ()->free (data);
ACE_OS::close (f_handle);
}
示例11: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
return 1;
CORBA::Object_var object = orb->string_to_object (ior);
Simple_Server_var server = Simple_Server::_narrow (object.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Object reference <%s> is nil.\n",
ior), 1);
}
if (do_shutdown)
{
server->shutdown ();
}
else
{
Worker wrk (server.in ());
wrk.activate (THR_NEW_LWP|THR_JOINABLE|THR_INHERIT_SCHED, nthreads);
wrk.thr_mgr ()->wait ();
}
}
catch (const CORBA::Exception& ex)
{
ACE_DEBUG ((LM_ERROR, ACE_TEXT ("(%P|%t) ERROR: Exception caught: \n%C\n"),
ex._info ().c_str ()));
return 1;
}
return 0;
}
示例12: catch
int
Client::svc (void)
{
try
{
for (int i = 0; i < this->niterations_; ++i)
{
// If we are using a global ORB this is a nop, otherwise it
// initializes the ORB resources for this thread.
int argc = 0;
CORBA::String_var argv0 = CORBA::string_dup ("dummy_argv");
char* argv[1] = { argv0.inout () };
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
CORBA::Object_var object =
orb->string_to_object (this->ior_);
Simple_Server_var server =
Simple_Server::_narrow (object.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Object reference <%s> is nil\n",
ior),
1);
}
server->test_method ();
if (TAO_debug_level > 0 && i % 100 == 0)
ACE_DEBUG ((LM_DEBUG, "(%P|%t) iteration = %d\n", i));
}
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("MT_Client: exception raised");
}
return 0;
}
示例13: do_shutdown_test
int do_shutdown_test (Simple_Server_var &server)
{
ACE_DEBUG ((LM_DEBUG,
"[client] invoking shutdown on the server \n "));
try
{
server->shutdown ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Client: exception caught during shutdown - ");
return 1;
}
return 0;
}
示例14: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
Fixed_Priority_Scheduler* scheduler=0;
RTScheduling::Current_var current;
long flags;
int sched_policy = ACE_SCHED_RR;
int sched_scope = ACE_SCOPE_THREAD;
if (sched_policy == ACE_SCHED_RR)
flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_RR;
else
flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_FIFO;
task_stats.init (100000);
try
{
RTScheduling::Scheduler_var sched_owner;
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
CORBA::Object_var poa_object =
orb->resolve_initial_references("RootPOA");
if (CORBA::is_nil (poa_object.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Unable to initialize the POA.\n"),
1);
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in ());
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
if (parse_args (argc, argv) != 0)
return 1;
if (enable_dynamic_scheduling)
{
CORBA::Object_var manager_obj =
orb->resolve_initial_references ("RTSchedulerManager");
TAO_RTScheduler_Manager_var manager =
TAO_RTScheduler_Manager::_narrow (manager_obj.in ());
Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type;
if (enable_yield)
{
disp_impl_type = Kokyu::DSRT_CV_BASED;
}
else
{
disp_impl_type = Kokyu::DSRT_OS_BASED;
}
ACE_NEW_RETURN (scheduler,
Fixed_Priority_Scheduler (orb.in (),
disp_impl_type,
sched_policy,
sched_scope), -1);
sched_owner = scheduler;
manager->rtscheduler (scheduler);
CORBA::Object_var object =
orb->resolve_initial_references ("RTScheduler_Current");
current =
RTScheduling::Current::_narrow (object.in ());
}
Simple_Server_i server_impl (orb.in (),
current.in (),
task_stats,
enable_yield);
Simple_Server_var server =
server_impl._this ();
CORBA::String_var ior =
orb->object_to_string (server.in ());
ACE_DEBUG ((LM_DEBUG, "Activated as <%C>\n", ior.in ()));
// If the ior_output_file exists, output the ior to it
if (ior_output_file != 0)
{
FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot open output file for writing IOR: %s",
ior_output_file),
1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
}
//.........这里部分代码省略.........
示例15: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
Fixed_Priority_Scheduler* scheduler=0;
RTScheduling::Current_var current;
int prio;
int max_prio;
ACE_Sched_Params::Policy sched_policy = ACE_SCHED_RR;
int sched_scope = ACE_SCOPE_THREAD;
long flags;
if (sched_policy == ACE_SCHED_RR)
flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_RR;
else
flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_FIFO;
ACE_hthread_t main_thr_handle;
ACE_Thread::self (main_thr_handle);
max_prio = ACE_Sched_Params::priority_max (sched_policy,
sched_scope);
//FUZZ: disable check_for_lack_ACE_OS
ACE_Sched_Params sched_params (sched_policy, max_prio);
//FUZZ: enable check_for_lack_ACE_OS
ACE_OS::sched_params (sched_params);
if (ACE_Thread::getprio (main_thr_handle, prio) == -1)
{
if (errno == ENOTSUP)
{
ACE_ERROR((LM_ERROR,
ACE_TEXT ("getprio not supported\n")
));
}
else
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n")
ACE_TEXT ("thr_getprio failed")));
}
}
ACE_DEBUG ((LM_DEBUG, "(%t): main thread prio is %d\n", prio));
try
{
RTScheduling::Scheduler_var sched_owner;
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
return 1;
CORBA::Object_var object =
orb->string_to_object (ior);
Simple_Server_var server =
Simple_Server::_narrow (object.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Object reference <%s> is nil.\n",
ior),
1);
}
if (enable_dynamic_scheduling)
{
ACE_DEBUG ((LM_DEBUG, "Dyn Sched enabled\n"));
CORBA::Object_var manager_obj =
orb->resolve_initial_references ("RTSchedulerManager");
TAO_RTScheduler_Manager_var manager =
TAO_RTScheduler_Manager::_narrow (manager_obj.in ());
Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type;
if (enable_yield)
{
disp_impl_type = Kokyu::DSRT_CV_BASED;
}
else
{
disp_impl_type = Kokyu::DSRT_OS_BASED;
}
ACE_NEW_RETURN (scheduler,
Fixed_Priority_Scheduler (orb.in (),
disp_impl_type,
sched_policy,
sched_scope), -1);
sched_owner = scheduler;
manager->rtscheduler (scheduler);
CORBA::Object_var object =
orb->resolve_initial_references ("RTScheduler_Current");
//.........这里部分代码省略.........