本文整理汇总了C++中rteceventchanneladmin::EventChannel_var类的典型用法代码示例。如果您正苦于以下问题:C++ EventChannel_var类的具体用法?C++ EventChannel_var怎么用?C++ EventChannel_var使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EventChannel_var类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
TAO_EC_Default_Factory::init_svcs ();
/// Move the test to the real-time class if it is possible.
RT_Class rt_class;
try
{
ORB_Holder orb (argc, argv, "");
if (parse_args (argc, argv) != 0)
return 1;
RTServer_Setup rtserver_setup (use_rt_corba,
orb,
rt_class,
nthreads);
PortableServer::POA_var root_poa =
RIR_Narrow<PortableServer::POA>::resolve (orb,
"RootPOA");
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
poa_manager->activate ();
PortableServer::POA_var ec_poa (rtserver_setup.poa ());
ORB_Task orb_task (orb);
ORB_Task_Activator orb_task_activator (rt_class.priority_high (),
rt_class.thr_sched_class (),
nthreads,
&orb_task);
ACE_DEBUG ((LM_DEBUG, "Finished ORB and POA configuration\n"));
Servant_var<TAO_EC_Event_Channel> ec_impl (
RTEC_Initializer::create (ec_poa.in (),
ec_poa.in (),
rtserver_setup.rtcorba_setup ())
);
ec_impl->activate ();
PortableServer::ObjectId_var ec_id =
ec_poa->activate_object (ec_impl.in ());
CORBA::Object_var ec_object =
ec_poa->id_to_reference (ec_id.in ());
RtecEventChannelAdmin::EventChannel_var ec =
RtecEventChannelAdmin::EventChannel::_narrow (ec_object.in ());
CORBA::String_var ior =
orb->object_to_string (ec.in ());
// Output the ior to the <ior_output_file>
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);
do {
ACE_Time_Value tv (1, 0);
orb->run (tv);
} while (ec_impl->destroyed () == 0);
ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return 1;
}
return 0;
}
示例2: catch
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
// We may want this to be alive beyond the next block.
PortableServer::Servant_var<Heartbeat_Application> app;
try
{
// Initialize ORB and POA, POA Manager, parse args.
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) == -1)
return 1;
CORBA::Object_var obj =
orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var poa =
PortableServer::POA::_narrow (obj.in ());
if (check_for_nil (poa.in (), "POA") == -1)
return 1;
PortableServer::POAManager_var manager =
poa->the_POAManager ();
// Obtain reference to EC.
obj = orb->resolve_initial_references ("Event_Service");
RtecEventChannelAdmin::EventChannel_var ec =
RtecEventChannelAdmin::EventChannel::_narrow (obj.in ());
if (check_for_nil (ec.in (), "EC") == -1)
return 1;
// Init our application.
app = new Heartbeat_Application;
if (!app.in ())
return 1;
app->init (orb, ec);
// Allow processing of CORBA requests.
manager->activate ();
// Receive events from EC.
orb->run ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception in Heartbeat Application:");
// Since there was an exception, application might not have had
// a chance to shutdown.
app->shutdown ();
return 1;
}
return 0;
}
示例3:
int
Heartbeat_Application::check_args (CORBA::ORB_var orb,
RtecEventChannelAdmin::EventChannel_var ec)
{
if (CORBA::is_nil (ec.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"%N (%l): Nil ec argument to "
"Heartbeat_Application::init\n"),
-1);
}
if (CORBA::is_nil (orb.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"%N (%l): Nil orb argument to "
"Heartbeat_Application::init\n"),
-1);
}
this->ec_ = ec;
this->orb_ = orb;
return 0;
}
示例4: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try{
orb = CORBA::ORB_init (argc, argv);
RtecEventChannelAdmin::EventChannel_var channel
= get_event_channel (argc, argv);
if (CORBA::is_nil (channel.in ()))
return -1;
PortableServer::POA_var poa =
resolve_init<PortableServer::POA> (orb.in (), "RootPOA");
PortableServer::POAManager_var mgr = poa->the_POAManager ();
mgr->activate ();
PushSupplier_impl push_supplier(orb.in ());
if (push_supplier.init(channel.in ()) == -1)
return -1;
RtecEventComm::PushSupplier_var
supplier = push_supplier._this();
orb->run();
}
catch (const CORBA::Exception& ex){
ex._tao_print_exception ("A CORBA Exception occurred.");
}
return 0;
}
示例5: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
// Initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
const ACE_TCHAR *ecname = ACE_TEXT ("EventService");
for (int i = 0; argv[i] != 0; i++) {
if (ACE_OS::strcmp(argv[i], ACE_TEXT("-ecname")) == 0) {
if (argv[i+1] != 0) {
ecname = argv[i+1];
} else {
std::cerr << "Missing Event channel name" << std::endl;
}
}
}
// Find the Naming Service.
CORBA::Object_var obj = orb->resolve_initial_references("NameService");
CosNaming::NamingContextExt_var root_context
= CosNaming::NamingContextExt::_narrow(obj.in());
// Find the EchoEventChannel.
obj = root_context->resolve_str (ACE_TEXT_ALWAYS_CHAR (ecname));
// Downcast the object reference to an EventChannel reference.
RtecEventChannelAdmin::EventChannel_var ec =
RtecEventChannelAdmin::EventChannel::_narrow(obj.in());
if (CORBA::is_nil(ec.in())) {
std::cerr << "Could not narrow EchoEventChannel." << std::endl;
return 1;
}
std::cout << "EchoEventConsumerMain.cpp: Found the EchoEventChannel." << std::endl;
// Obtain a reference to the consumer administration object.
RtecEventChannelAdmin::ConsumerAdmin_var admin = ec->for_consumers();
// Obtain a reference to the push supplier proxy.
RtecEventChannelAdmin::ProxyPushSupplier_var supplier =
admin->obtain_push_supplier();
// Get the RootPOA.
obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in());
// Instantiate an EchoEventConsumer_i servant and register it
// with the RootPOA
PortableServer::Servant_var<EchoEventConsumer_i> servant =
new EchoEventConsumer_i(orb.in(), supplier.in(), EVENT_LIMIT);
PortableServer::ObjectId_var oid = poa->activate_object(servant.in());
CORBA::Object_var consumer_obj = poa->id_to_reference(oid.in());
RtecEventComm::PushConsumer_var consumer =
RtecEventComm::PushConsumer::_narrow(consumer_obj.in());
// Connect as a consumer.
ACE_ConsumerQOS_Factory qos;
qos.start_disjunction_group ();
qos.insert (MY_SOURCE_ID, // Source ID
MY_EVENT_TYPE, // Event Type
0); // handle to the rt_info
supplier->connect_push_consumer (consumer.in (),
qos.get_ConsumerQOS ());
// Activate the POA via its POAManager.
PortableServer::POAManager_var poa_manager = poa->the_POAManager();
poa_manager->activate();
std::cout << "EchoEventConsumerMain.cpp: Ready to receive events..." << std::endl;
// Enter the ORB event loop.
orb->run();
// If we have reached this, we must be shutting down...
// Disconnect the ProxyPushSupplier.
orb->destroy();
std::cout << "Test completed." << std::endl;
return 0;
}
catch(const CORBA::Exception& exc)
{
std::cerr << "Caught CORBA::Exception" << std::endl << exc << std::endl;
}
return 1;
}
示例6: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
// Initialize the EC Factory so we can customize the EC
TAO_EC_Default_Factory::init_svcs ();
// Initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
const ACE_TCHAR *ecname = ACE_TEXT ("EventService");
const ACE_TCHAR *address = ACE_TEXT ("localhost");
const ACE_TCHAR *iorfile = 0;
u_short port = 12345;
u_short listenport = 12345;
int mcast = 1;
for (int i = 0; argv[i] != 0; i++)
{
if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-ecname")) == 0)
{
if (argv[i+1] != 0)
ecname = argv[++i];
else
ACE_ERROR_RETURN ((LM_ERROR, "Missing Event channel name\n"),0);
}
else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-address")) == 0)
{
if (argv[i+1] != 0)
address = argv[++i];
else
ACE_ERROR_RETURN ((LM_ERROR, "Missing address\n"),0);
}
else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-port")) == 0)
{
if (argv[i+1] != 0)
port = ACE_OS::atoi(argv[++i]);
else
ACE_ERROR_RETURN ((LM_ERROR, "Missing port\n"),0);
}
else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-listenport")) == 0)
{
if (argv[i+1] != 0)
listenport = ACE_OS::atoi(argv[++i]);
else
ACE_ERROR_RETURN ((LM_ERROR, "Missing port\n"), 0);
}
else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-iorfile")) == 0)
{
if (argv[i+1] != 0)
iorfile = argv[++i];
else
ACE_ERROR_RETURN ((LM_ERROR, "Missing ior file\n"), 0);
}
else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-udp")) == 0)
mcast = 0;
}
// Get the POA
CORBA::Object_var tmpobj = orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow (tmpobj.in ());
PortableServer::POAManager_var poa_manager = poa->the_POAManager ();
poa_manager->activate ();
// Create a local event channel and register it
TAO_EC_Event_Channel_Attributes attributes (poa.in (), poa.in ());
TAO_EC_Event_Channel ec_impl (attributes);
ec_impl.activate ();
PortableServer::ObjectId_var oid = poa->activate_object(&ec_impl);
tmpobj = poa->id_to_reference(oid.in());
RtecEventChannelAdmin::EventChannel_var ec =
RtecEventChannelAdmin::EventChannel::_narrow(tmpobj.in());
// Find the Naming Service.
tmpobj = orb->resolve_initial_references("NameService");
CosNaming::NamingContextExt_var root_context =
CosNaming::NamingContextExt::_narrow(tmpobj.in());
// Bind the Event Channel using Naming Services
CosNaming::Name_var name =
root_context->to_name (ACE_TEXT_ALWAYS_CHAR (ecname));
root_context->rebind(name.in(), ec.in());
// Get a proxy push consumer from the EventChannel.
RtecEventChannelAdmin::SupplierAdmin_var admin = ec->for_suppliers();
RtecEventChannelAdmin::ProxyPushConsumer_var consumer =
admin->obtain_push_consumer();
// Instantiate an EchoEventSupplier_i servant.
EchoEventSupplier_i servant(orb.in());
// Register it with the RootPOA.
oid = poa->activate_object(&servant);
tmpobj = poa->id_to_reference(oid.in());
RtecEventComm::PushSupplier_var supplier =
RtecEventComm::PushSupplier::_narrow(tmpobj.in());
// Connect to the EC.
ACE_SupplierQOS_Factory qos;
//.........这里部分代码省略.........
示例7: schedule_name
//.........这里部分代码省略.........
naming_context->rebind (schedule_name, scheduler.in ());
}
}
else if (this->scheduler_type_ == ES_SCHED_GLOBAL)
{
// Get reference to a scheduler from naming service
CORBA::Object_var tmp =
naming_context->resolve (schedule_name);
scheduler = RtecScheduler::Scheduler::_narrow (tmp.in ());
if (CORBA::is_nil (scheduler.in ()))
ORBSVCS_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Unable to resolve the Scheduling Service.\n"),
1);
}
TAO_EC_Event_Channel_Attributes attr (root_poa.in (),
root_poa.in ());
if (this->scheduler_type_ != ES_SCHED_NONE)
{
attr.scheduler = scheduler.in ();
}
TAO_EC_Event_Channel* ec_impl = 0;
ACE_NEW_RETURN (ec_impl,
TAO_EC_Event_Channel (attr),
1);
this->ec_impl_ = ec_impl;
ec_impl->activate ();
RtecEventChannelAdmin::EventChannel_var ec;
// If the object_id_ is empty and we don't use BiDIR GIOP, activate the
// servant under the default POA, else create a new child POA with
// the needed policies
int persistent = ACE_OS::strcmp(this->object_id_.c_str(), "");
if ((persistent == 0) && (this->use_bidir_giop_ == false))
{
// Notice that we activate *this* object with the POA, but we
// forward all the requests to the underlying EC
// implementation.
ec = this->_this ();
}
else
{
CORBA::ULong index = 0;
// Create child POA
CORBA::PolicyList policies (3);
if (persistent != 0)
{
policies.length (index++);
policies[index] =
root_poa->create_id_assignment_policy (PortableServer::USER_ID);
policies.length (index++);
policies[index] =
root_poa->create_lifespan_policy (PortableServer::PERSISTENT);
}
if (this->use_bidir_giop_ == true)
{
示例8: schedule_name
//.........这里部分代码省略.........
}
int min_priority =
ACE_Sched_Params::priority_min (ACE_SCHED_FIFO);
// Enable FIFO scheduling, e.g., RT scheduling class on Solaris.
if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO,
min_priority,
ACE_SCOPE_PROCESS)) != 0)
{
if (ACE_OS::last_error () == EPERM)
ACE_DEBUG ((LM_DEBUG,
"%s: user is not superuser, "
"so remain in time-sharing class\n", argv[0]));
else
ACE_ERROR ((LM_ERROR,
"%s: ACE_OS::sched_params failed\n", argv[0]));
}
if (ACE_OS::thr_setprio (min_priority) == -1)
{
ACE_ERROR ((LM_ERROR, "(%P|%t) main thr_setprio failed,"
"no real-time features\n"));
}
CORBA::Object_var naming_obj =
this->orb_->resolve_initial_references ("NameService");
if (CORBA::is_nil (naming_obj.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Unable to get the Naming Service.\n"),
1);
CosNaming::NamingContext_var naming_context =
CosNaming::NamingContext::_narrow (naming_obj.in ());
CosNaming::Name schedule_name (1);
schedule_name.length (1);
schedule_name[0].id = CORBA::string_dup ("ScheduleService");
CORBA::Object_var sched_obj =
naming_context->resolve (schedule_name);
if (CORBA::is_nil (sched_obj.in ()))
return 1;
RtecScheduler::Scheduler_var scheduler =
RtecScheduler::Scheduler::_narrow (sched_obj.in ());
CosNaming::Name name (1);
name.length (1);
name[0].id = CORBA::string_dup ("EventService");
CORBA::Object_var ec_obj =
naming_context->resolve (name);
RtecEventChannelAdmin::EventChannel_var channel;
if (CORBA::is_nil (ec_obj.in ()))
channel = RtecEventChannelAdmin::EventChannel::_nil ();
else
channel = RtecEventChannelAdmin::EventChannel::_narrow (ec_obj.in ());
poa_manager->activate ();
this->connect_consumers (scheduler.in (), channel.in ());
ACE_DEBUG ((LM_DEBUG, "connected consumer(s)\n"));
ACE_DEBUG ((LM_DEBUG, "running the test\n"));
for (;;)
{
ACE_Time_Value tv (1, 0);
this->orb_->perform_work (tv);
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 1);
if (this->active_count_ <= 0)
break;
}
ACE_DEBUG ((LM_DEBUG, "event loop finished\n"));
this->dump_results ();
this->disconnect_consumers ();
if (this->shutdown_event_channel_ != 0)
{
channel->destroy ();
}
root_poa->destroy (1, 1);
this->orb_->destroy ();
}
catch (const CORBA::SystemException& sys_ex)
{
sys_ex._tao_print_exception ("SYS_EX");
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("NON SYS EX");
}
return 0;
}
示例9: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
try {
// First initialize the ORB, that will remove some arguments...
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
CORBA::Object_var poa_object =
orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var poa =
PortableServer::POA::_narrow (poa_object.in ());
PortableServer::POAManager_var poa_manager =
poa->the_POAManager ();
poa_manager->activate ();
// Create the servant
Quoter_Stock_Factory_i stock_factory_i;
// Activate it to obtain the object reference
Quoter::Stock_Factory_var stock_factory =
stock_factory_i._this ();
// Get the Naming Context reference
CORBA::Object_var naming_context_object =
orb->resolve_initial_references ("NameService");
CosNaming::NamingContext_var naming_context =
CosNaming::NamingContext::_narrow (naming_context_object.in ());
// Create and initialize the name.
CosNaming::Name name (1);
name.length (1);
name[0].id = CORBA::string_dup ("Stock_Factory");
// Bind the object
naming_context->rebind (name, stock_factory.in ());
// Resolve the Event Service
name[0].id = CORBA::string_dup ("EventService");
CORBA::Object_var ec_object =
naming_context->resolve (name);
// Now downcast the object reference to the appropriate type
RtecEventChannelAdmin::EventChannel_var ec =
RtecEventChannelAdmin::EventChannel::_narrow (ec_object.in ());
RtecEventChannelAdmin::SupplierAdmin_var supplier_admin =
ec->for_suppliers ();
stock_factory_i.load_stock_objects (poa.in (),
poa_manager.in (),
supplier_admin.in ());
// ****************************************************************
for (int j = 0; j != 1000; ++j) {
for (int i = 1; i != argc; ++i) {
try {
// Get the stock object
Quoter::Stock_var stock =
stock_factory->get_stock (ACE_TEXT_ALWAYS_CHAR (argv[i]));
CORBA::String_var full_name = stock->full_name ();
// Get the price
CORBA::Double price = stock->price ();
Quoter::Modify_Stock_var modify_stock =
Quoter::Modify_Stock::_narrow (stock.in ());
modify_stock->set_price (price + 1);
cout << "Set the price of "
<< full_name.in ()
<< " to " << price + 1 << endl;
}
catch (Quoter::Invalid_Stock_Symbol &) {
cerr << "Invalid stock symbol <"
<< argv[i] << ">" << endl;
}
ACE_Time_Value tv (0, 500000);
ACE_OS::sleep (tv);
}
}
stock_factory_i.destroy_stock_objects ();
// Destroy the POA, waiting until the destruction terminates
poa->destroy (1, 1);
orb->destroy ();
}
catch (CORBA::Exception &) {
cerr << "CORBA exception raised!" << endl;
}
return 0;
}
示例10: main
int main (int argc, char* argv[])
{
try
{
// Initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
// Find the Naming Service.
CORBA::Object_var obj = orb->resolve_initial_references("NameService");
CosNaming::NamingContextExt_var naming_client = CosNaming::NamingContextExt::_narrow(obj.in());
// Get the Event Channel using Naming Services
obj = naming_client->resolve_str("EventService");
// Downcast the object reference to an EventChannel reference.
RtecEventChannelAdmin::EventChannel_var ec =
RtecEventChannelAdmin::EventChannel::_narrow(obj.in());
if (CORBA::is_nil(ec.in())) {
cerr << "Could not resolve EchoEventChannel." << endl;
return 1;
}
// Get a SupplierAdmin object from the EventChannel.
RtecEventChannelAdmin::SupplierAdmin_var admin = ec->for_suppliers();
// Get a ProxyPushConsumer from the SupplierAdmin.
RtecEventChannelAdmin::ProxyPushConsumer_var consumer =
admin->obtain_push_consumer();
// Get the RootPOA.
obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in());
// Instantiate an EchoEventConsumer_i servant.
EchoEventSupplier_i servant(orb.in());
// Register it with the RootPOA.
PortableServer::ObjectId_var oid = poa->activate_object(&servant);
CORBA::Object_var supplier_obj = poa->id_to_reference(oid.in());
RtecEventComm::PushSupplier_var supplier =
RtecEventComm::PushSupplier::_narrow(supplier_obj.in());
// Publish the events the supplier provides.
ACE_SupplierQOS_Factory qos;
qos.insert (MY_SOURCE_ID, // Supplier's unique id
MY_EVENT_TYPE, // Event type
0, // handle to the rt_info structure
1); // number of calls
// Connect as a supplier of the published events.
consumer->connect_push_supplier (supplier.in (),
qos.get_SupplierQOS ());
// Activate the POA via its POAManager.
PortableServer::POAManager_var poa_manager = poa->the_POAManager();
poa_manager->activate();
// Create an event (just a string in this case).
const CORBA::String_var eventData = CORBA::string_dup("Hello, world.");
// Create an event set for one event
RtecEventComm::EventSet events (1);
events.length (1);
// Initialize event header.
events[0].header.source = MY_SOURCE_ID;
events[0].header.type = MY_EVENT_TYPE;
// Initialize data fields in event.
events[0].data.any_value <<= eventData;
cout << "Supplier starting sending of events" << endl;
while (1) {
consumer->push (events);
ACE_Time_Value tv(0, 1000 * EVENT_DELAY_MS);
orb->run(tv);
}
orb->destroy();
return 0;
}
catch (CORBA::Exception& ex)
{
cerr << "Supplier::main() Caught CORBA::Exception" << endl << ex << endl;
}
return 1;
}
示例11: policy_list
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
TAO_EC_Default_Factory::init_svcs ();
int priority =
(ACE_Sched_Params::priority_min (ACE_SCHED_FIFO)
+ ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2;
priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO,
priority);
// Enable FIFO scheduling, e.g., RT scheduling class on Solaris.
if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO,
priority,
ACE_SCOPE_PROCESS)) != 0)
{
if (ACE_OS::last_error () == EPERM)
{
ACE_DEBUG ((LM_DEBUG,
"server (%P|%t): user is not superuser, "
"test runs in time-shared class\n"));
}
else
ACE_ERROR ((LM_ERROR,
"server (%P|%t): sched_params failed\n"));
}
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
#if (TAO_HAS_CORBA_MESSAGING == 1)
CORBA::Object_var manager_object =
orb->resolve_initial_references ("ORBPolicyManager");
CORBA::PolicyManager_var policy_manager =
CORBA::PolicyManager::_narrow (manager_object.in ());
CORBA::Any sync_scope;
sync_scope <<= Messaging::SYNC_WITH_TARGET;
CORBA::PolicyList policy_list (1);
policy_list.length (1);
policy_list[0] =
orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE,
sync_scope);
policy_manager->set_policy_overrides (policy_list,
CORBA::SET_OVERRIDE);
#else
ACE_DEBUG ((LM_DEBUG,
"CORBA Messaging disabled in this configuration,"
" test may not be optimally configured\n"));
#endif /* TAO_HAS_MESSAGING */
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 ();
poa_manager->activate ();
if (parse_args (argc, argv) != 0)
return 1;
TAO_EC_Event_Channel_Attributes attr (root_poa.in (),
root_poa.in ());
TAO_EC_Event_Channel ec_impl (attr);
ec_impl.activate ();
RtecEventChannelAdmin::EventChannel_var ec =
ec_impl._this ();
CORBA::String_var str =
orb->object_to_string (ec.in ());
if (ior_file_name != 0)
{
FILE *output_file= ACE_OS::fopen (ior_file_name, "w");
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot open output file for writing IOR: %s",
ior_file_name),
1);
ACE_OS::fprintf (output_file, "%s", str.in ());
ACE_OS::fclose (output_file);
}
orb->run ();
PortableServer::ObjectId_var id =
//.........这里部分代码省略.........
示例12: policies
int
EC::run (int argc, ACE_TCHAR* argv[])
{
TAO_EC_Default_Factory::init_svcs ();
try
{
// First parse our command line options
if (this->parse_args(argc, argv) != 0)
{
return -1;
}
// ORB initialization boiler plate...
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
CORBA::Object_var object =
orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var rootpoa =
PortableServer::POA::_narrow (object.in ());
PortableServer::POAManager_var root_poa_manager =
rootpoa->the_POAManager ();
// Create persistent POA
CORBA::PolicyList policies (2);
policies.length (2);
policies[0] =
rootpoa->create_id_assignment_policy (PortableServer::USER_ID);
policies[1] =
rootpoa->create_lifespan_policy (PortableServer::PERSISTENT);
ACE_CString poaname = "POA";
PortableServer::POA_var child_poa_ =
rootpoa->create_POA (poaname.c_str (),
root_poa_manager.in (),
policies);
// Create a local event channel and register it with the RootPOA.
TAO_EC_Event_Channel_Attributes attributes (rootpoa.in (), rootpoa.in ());
attributes.consumer_reconnect = 1;
attributes.supplier_reconnect = 1;
TAO_EC_Event_Channel ec_impl (attributes);
ec_impl.activate ();
PortableServer::ObjectId_var ecId =
PortableServer::string_to_ObjectId(ACE_TEXT_ALWAYS_CHAR(ecname));
child_poa_->activate_object_with_id(ecId.in(), &ec_impl);
CORBA::Object_var ec_obj = child_poa_->id_to_reference(ecId.in());
RtecEventChannelAdmin::EventChannel_var ec =
RtecEventChannelAdmin::EventChannel::_narrow(ec_obj.in());
// Find the Naming Service.
object = orb->resolve_initial_references("NameService");
CosNaming::NamingContextExt_var naming_context =
CosNaming::NamingContextExt::_narrow(object.in());
// Create a name.
CosNaming::Name name;
name.length (1);
name[0].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(ecname));
name[0].kind = CORBA::string_dup ("");
// Register with the name server
naming_context->rebind (name, ec.in ());
root_poa_manager->activate ();
// Wait for events, using work_pending()/perform_work() may help
// or using another thread, this example is too simple for that.
orb->run ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("EC::run");
return 1;
}
return 0;
}
示例13: scheduler_impl
//.........这里部分代码省略.........
CosNaming::NamingContext_var naming_context =
CosNaming::NamingContext::_narrow (naming_obj.in ());
// This is the name we (potentially) register the Scheduling
// Service in the Naming Service.
CosNaming::Name schedule_name (1);
schedule_name.length (1);
schedule_name[0].id = CORBA::string_dup ("ScheduleService");
CORBA::String_var str =
this->orb_->object_to_string (scheduler.in ());
ACE_DEBUG ((LM_DEBUG, "The (local) scheduler IOR is <%s>\n",
str.in ()));
// Register the servant with the Naming Context....
naming_context->rebind (schedule_name, scheduler.in ());
ACE_Scheduler_Factory::use_config (naming_context.in ());
#endif /* 0 */
auto_ptr<POA_RtecEventChannelAdmin::EventChannel> ec_impl;
TAO_EC_Event_Channel_Attributes attr (root_poa.in (),
root_poa.in ());
TAO_EC_Event_Channel *ec =
new TAO_EC_Event_Channel (attr);
ec->activate ();
auto_ptr<POA_RtecEventChannelAdmin::EventChannel> auto_ec_impl (ec);
ec_impl = auto_ec_impl;
RtecEventChannelAdmin::EventChannel_var channel =
ec_impl->_this ();
this->connect_consumers (scheduler.in (),
channel.in ());
ACE_DEBUG ((LM_DEBUG, "connected consumer(s)\n"));
this->connect_suppliers (scheduler.in (),
channel.in ());
ACE_DEBUG ((LM_DEBUG, "connected supplier(s)\n"));
this->activate_suppliers ();
ACE_DEBUG ((LM_DEBUG, "suppliers are active\n"));
// Wait for the supplier threads...
if (ACE_Thread_Manager::instance ()->wait () == -1)
{
ACE_ERROR ((LM_ERROR, "Thread_Manager wait failed\n"));
return 1;
}
ACE_DEBUG ((LM_DEBUG, "suppliers finished\n"));
this->dump_results ();
this->disconnect_consumers ();
ACE_DEBUG ((LM_DEBUG, "consumers disconnected\n"));
this->disconnect_suppliers ();
示例14: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
const CORBA::Long experiment_id = 1;
TAO_EC_Default_Factory::init_svcs ();
/// Move the test to the real-time class if it is possible.
RT_Class rt_class;
try
{
ORB_Holder orb (argc, argv, "");
Client_Options options (argc, argv);
if (argc != 1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"Usage: %s "
"-i iterations (iterations) "
"-h high_priority_period (usecs) "
"-l low_priority_period (usecs) "
"-w high_priority_workload (usecs) "
"-v low_priority_workload (usecs) "
"-r (enable RT-CORBA) "
"-n nthreads (low priority thread) "
"-d (dump history) "
"-z (disable low priority) "
"\n",
argv [0]),
1);
}
RTServer_Setup rtserver_setup (options.use_rt_corba,
orb,
rt_class,
1 // options.nthreads
);
PortableServer::POA_var root_poa =
RIR_Narrow<PortableServer::POA>::resolve (orb,
"RootPOA");
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
poa_manager->activate ();
PortableServer::POA_var ec_poa (rtserver_setup.poa ());
ACE_Thread_Manager my_thread_manager;
ORB_Task orb_task (orb);
orb_task.thr_mgr (&my_thread_manager);
ORB_Task_Activator orb_task_activator (rt_class.priority_high (),
rt_class.thr_sched_class (),
1,
&orb_task);
ACE_DEBUG ((LM_DEBUG, "Finished ORB and POA configuration\n"));
Servant_var<TAO_EC_Event_Channel> ec_impl (
RTEC_Initializer::create (ec_poa.in (),
ec_poa.in (),
rtserver_setup.rtcorba_setup ())
);
ec_impl->activate ();
PortableServer::ObjectId_var ec_id =
ec_poa->activate_object (ec_impl.in ());
CORBA::Object_var ec_object =
ec_poa->id_to_reference (ec_id.in ());
RtecEventChannelAdmin::EventChannel_var ec =
RtecEventChannelAdmin::EventChannel::_narrow (ec_object.in ());
EC_Destroyer ec_destroyer (ec.in ());
ACE_DEBUG ((LM_DEBUG, "Finished EC configuration and activation\n"));
int thread_count = 1 + options.nthreads;
ACE_Barrier the_barrier (thread_count);
ACE_DEBUG ((LM_DEBUG, "Calibrating high res timer ...."));
ACE_High_Res_Timer::calibrate ();
ACE_High_Res_Timer::global_scale_factor_type gsf =
ACE_High_Res_Timer::global_scale_factor ();
ACE_DEBUG ((LM_DEBUG, "Done (%d)\n", gsf));
CORBA::Long event_range = 1;
if (options.funky_supplier_publication)
{
if (options.unique_low_priority_event)
event_range = 1 + options.low_priority_consumers;
else
event_range = 2;
}
//.........这里部分代码省略.........
示例15: EC_Consumer
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
// Initialize ORB and POA, POA Manager, parse args.
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) == -1)
return 1;
CORBA::Object_var obj =
orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var poa =
PortableServer::POA::_narrow (obj.in ());
if (check_for_nil (poa.in (), "POA") == -1)
return 1;
PortableServer::POAManager_var manager =
poa->the_POAManager ();
// Obtain reference to EC.
obj = orb->resolve_initial_references ("Event_Service");
RtecEventChannelAdmin::EventChannel_var ec =
RtecEventChannelAdmin::EventChannel::_narrow (obj.in ());
if (check_for_nil (ec.in (), "EC") == -1)
return 1;
// Create the consumer and register it with POA.
PortableServer::Servant_var<EC_Consumer> consumer_impl =
new EC_Consumer (orb, ec);
if (!consumer_impl.in ())
return -1;
RtecEventComm::PushConsumer_var consumer;
TAO_EC_Object_Deactivator consumer_deactivator;
activate (consumer,
poa.in (),
consumer_impl.in (),
consumer_deactivator);
consumer_deactivator.disallow_deactivation ();
// Obtain reference to ConsumerAdmin.
RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin =
ec->for_consumers ();
// Obtain ProxyPushSupplier and connect this consumer.
RtecEventChannelAdmin::ProxyPushSupplier_var supplier =
consumer_admin->obtain_push_supplier ();
ACE_ConsumerQOS_Factory qos;
qos.start_disjunction_group (3);
qos.insert_type (A_EVENT_TYPE, 0);
qos.insert_type (B_EVENT_TYPE, 0);
qos.insert_type (C_EVENT_TYPE, 0);
supplier->connect_push_consumer (consumer.in (),
qos.get_ConsumerQOS ());
// Allow processing of CORBA requests.
manager->activate ();
// Receive events from EC.
orb->run ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception in Consumer:");
return 1;
}
return 0;
}