本文整理汇总了C++中cosnotifychanneladmin::EventChannel_var类的典型用法代码示例。如果您正苦于以下问题:C++ EventChannel_var类的具体用法?C++ EventChannel_var怎么用?C++ EventChannel_var使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EventChannel_var类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
PortableServer::POAManager_var poa_manager;
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
CORBA::Object_var poa_obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa = PortableServer::POA::_narrow(poa_obj.in());
poa_manager = root_poa->the_POAManager();
if (parse_args (argc, argv) != 0)
return 1;
poa_manager->activate();
/*Get event_channel*/
std::cout << "Get event_channel now" << std::endl;
CosNotifyChannelAdmin::EventChannel_var ec = get_event_channel(orb.in());
//Instanciating the Consumer
CosNotifyComm::StructuredPushConsumer_var spc =
CosNotifyComm::StructuredPushConsumer::_nil();
CosNotifyCommImpl::StructuredPushConsumer *pImpl_spc = new CosNotifyCommImpl::StructuredPushConsumer;
spc = pImpl_spc->_this();
//Obtain a Consumer Admin
CosNotifyChannelAdmin::AdminID adminid = 0;
CosNotifyChannelAdmin::ConsumerAdmin_var ca =
ec->new_for_consumers (CosNotifyChannelAdmin::AND_OP, adminid);
if( ca.in() == CosNotifyChannelAdmin::ConsumerAdmin::_nil() ){
std::cerr << "ca is nil!" << std::endl;
return 1;
}
//Obtain a Proxy Consumer
CosNotifyChannelAdmin::ProxyID proxy_id;
CosNotifyChannelAdmin::ClientType ctype = CosNotifyChannelAdmin::STRUCTURED_EVENT;
CosNotifyChannelAdmin::ProxySupplier_var proxySupplier_obj;
try
{
proxySupplier_obj = ca->obtain_notification_push_supplier(ctype, proxy_id);
}
catch(CosNotifyChannelAdmin::AdminLimitExceeded err)
{
std::cerr << "CosNotifyChannelAdmin::AdminLimitExceeded Exception!" << std::endl;
throw;
}
CosNotifyChannelAdmin::StructuredProxyPushSupplier_var pps =
CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow(proxySupplier_obj.in());
//Attaching a filter to pps
CosNotifyFilter::FilterFactory_var dff =
ec->default_filter_factory();
ACE_ASSERT(!CORBA::is_nil(dff.in()));
CosNotifyFilter::Filter_var filter = dff->create_filter("EXTENDED_TCL");
CosNotification::EventTypeSeq event_types(1);
event_types.length(2);
event_types[0].domain_name = CORBA::string_dup("DomainA");
event_types[0].type_name = CORBA::string_dup("TypeA");
event_types[1].domain_name = CORBA::string_dup("DomainB");
event_types[1].type_name = CORBA::string_dup("TypeB");
CosNotifyFilter::ConstraintExpSeq constraints(1);
constraints.length(1);
constraints[0].event_types = event_types;
constraints[0].constraint_expr = CORBA::string_dup(
"");
filter->add_constraints(constraints);
pps->add_filter(filter.in());
std::cout << "Attached a filter to ProxyPushSupplier" << std::endl;
std::cout << "The filter's event_types[0].domain_name=" << event_types[0].domain_name << std::endl;
std::cout << "The filter's event_types[0].type_name=" << event_types[0].type_name << std::endl;
std::cout << "The filter's event_types[1].domain_name=" << event_types[1].domain_name << std::endl;
std::cout << "The filter's event_types[1].type_name=" << event_types[1].type_name << std::endl;
//Connecting a Supplier to a Proxy Consumer
try
{
pps->connect_structured_push_consumer(spc.in());
}
catch (CosEventChannelAdmin::AlreadyConnected ac)
{
std::cerr << "CosEventChannelAdmin::AlreadyConnected" << std::endl;
//.........这里部分代码省略.........
开发者ID:asdlei00,项目名称:ACE,代码行数:101,代码来源:consumer.cpp
示例2: StructuredEventSupplier_i
Messenger_i::Messenger_i (CORBA::ORB_ptr orb)
: orb_ (CORBA::ORB::_duplicate (orb))
{
CORBA::Object_var naming_obj =
orb_->resolve_initial_references ("NameService");
CosNaming::NamingContext_var naming_context =
CosNaming::NamingContext::_narrow (naming_obj.in());
CosNaming::Name name;
name.length (1);
name[0].id = CORBA::string_dup ("NotifyEventChannelFactory");
CORBA::Object_var obj = naming_context->resolve (name);
CosNotifyChannelAdmin::EventChannelFactory_var notify_factory =
CosNotifyChannelAdmin::EventChannelFactory::_narrow (obj.in ());
CosNotifyChannelAdmin::ChannelID id;
CosNotification::QoSProperties initial_qos;
CosNotification::AdminProperties initial_admin;
CosNotifyChannelAdmin::EventChannel_var ec =
notify_factory->create_channel (initial_qos,
initial_admin,
id);
name[0].id = CORBA::string_dup ("MyEventChannel");
naming_context->rebind (name, ec.in());
CosNotifyChannelAdmin::AdminID adminid;
CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
CosNotifyChannelAdmin::OR_OP;
CosNotifyChannelAdmin::SupplierAdmin_var supplier_admin =
ec->new_for_suppliers (ifgop, adminid);
CosNotifyChannelAdmin::ProxyID supplieradmin_proxy_id;
CosNotifyChannelAdmin::ProxyConsumer_var proxy_consumer =
supplier_admin->obtain_notification_push_consumer(
CosNotifyChannelAdmin::STRUCTURED_EVENT,
supplieradmin_proxy_id);
StructuredEventSupplier_i *servant =
new StructuredEventSupplier_i(orb_.in());
CORBA::Object_var poa_obj = orb_->resolve_initial_references ("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow (poa_obj.in ());
PortableServer::POAManager_var mgr = poa->the_POAManager ();
mgr->activate ();
PortableServer::ObjectId_var objectId = poa->activate_object (servant);
CORBA::Object_var supplier_obj = poa->id_to_reference (objectId.in ());
CosNotifyComm::StructuredPushSupplier_var supplier =
CosNotifyComm::StructuredPushSupplier::_narrow (supplier_obj.in ());
consumer_proxy_ =
CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow (proxy_consumer.in());
consumer_proxy_->
connect_structured_push_supplier (supplier.in());
}
开发者ID:asdlei00,项目名称:ACE,代码行数:67,代码来源:Messenger_i.cpp
示例3: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
int status = 0;
ACE_Auto_Ptr< sig_i > sig_impl;
try
{
Supplier_Client client;
status = client.init (argc, argv);
if (status == 0)
{
static const char* ec_name = "MyEventChannel";
CosNotifyChannelAdmin::EventChannel_var ec =
client.create_event_channel (ec_name, 0);
static const int max = 20;
int count = 0;
while(ACE_OS::access(ACE_TEXT_ALWAYS_CHAR(notify2ior), R_OK) == -1 && count < max)
{
ACE_OS::sleep (1);
count++;
}
if (count >= max)
{
ACE_ERROR_RETURN ((LM_ERROR,
"ERROR: Timed out waiting for the "
"second notify service\n"),
1);
}
ACE_OS::sleep (2);
// Due to the way that connections are handled, we need to
// perform the new event channel creation twice to flush out
// the connection to the first notification service
try
{
ec = client.create_event_channel (ec_name, 0);
}
catch (const CORBA::TRANSIENT&)
{
}
catch (const CORBA::COMM_FAILURE&)
{
}
ec = client.create_event_channel (ec_name, 0);
CORBA::ORB_ptr orb = client.orb ();
// Activate the signaler with the POA
sig_impl.reset( new sig_i( orb ) );
sig_var sig = sig_impl->_this ();
CORBA::String_var ior =
orb->object_to_string (sig.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 %s for "
"writing IOR: %C",
ior_output_file,
ior.in ()),
1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
}
CosNotifyChannelAdmin::SupplierAdmin_var admin =
create_supplieradmin (ec.in ());
if (!CORBA::is_nil (admin.in ()))
{
create_suppliers (admin.in (), client.root_poa ());
sig_impl->wait_for_startup();
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_impl->wait_for_completion();
ACE_OS::unlink (ior_output_file);
supplier_1->disconnect();
ec->destroy();
}
}
}
catch (const CORBA::Exception& e)
{
e._tao_print_exception ("Error: ");
//.........这里部分代码省略.........
开发者ID:akostrikov,项目名称:ATCD,代码行数:101,代码来源:Structured_Supplier.cpp
示例4: argcon
int
ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
int status = 0;
ACE_Auto_Ptr<sig_i> sig_impl;
try
{
Supplier_Client client;
ACE_Argv_Type_Converter argcon (argc, argv);
status = client.init (argcon.get_argc (), argcon.get_TCHAR_argv ());
if (status == 0)
{
CosNotifyChannelAdmin::EventChannel_var ec =
client.create_event_channel ("MyEventChannel", 0);
sig_impl.reset (new sig_i (client.orb ()));
sig_var sig = sig_impl->_this ();
// If the ior_output_file exists, output the ior to it
if (ior_output_file != 0)
{
CORBA::String_var ior =
client.orb ()->object_to_string (sig.in ());
FILE *output_file= ACE_OS::fopen (ior_output_file, ACE_TEXT ("w"));
ACE_ASSERT (output_file != 0);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
}
CosNotifyChannelAdmin::SupplierAdmin_var admin =
create_supplieradmin (ec.in ());
ACE_ASSERT (!CORBA::is_nil (admin.in ()));
create_suppliers (admin.in (), client.root_poa ());
sig_impl->wait_for_startup ();
// If this is changed, you should update max_events
// found in Notify_Push_Consumer.cpp
int batch_size = 4;
int num_events = 80 / batch_size;
ACE_DEBUG ((LM_DEBUG,
"1 supplier sending %d batches of %d events...\n",
num_events, batch_size));
CosNotification::EventBatch events;
events.length(batch_size);
for (int i = 0; i < num_events; ++i)
{
supplier_1->send_events (events);
}
ACE_DEBUG ((LM_DEBUG, "\nSupplier sent %d events.\n", num_events));
sig_impl->wait_for_completion ();
ACE_OS::unlink (ior_output_file);
supplier_1->disconnect ();
ec->destroy ();
}
}
catch (const CORBA::Exception& e)
{
e._tao_print_exception ("Error: ");
status = 1;
}
return status;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:71,代码来源:Supplier.cpp
示例5: name
Messenger_i::Messenger_i (CORBA::ORB_ptr orb)
: orb_ (CORBA::ORB::_duplicate(orb))
{
try
{
CORBA::Object_var poa_obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(poa_obj.in());
CORBA::Object_var naming_obj =
orb_->resolve_initial_references ("NameService");
if (CORBA::is_nil(naming_obj.in())) {
std::cerr << "Unable to find naming service" << std::endl;
}
CosNaming::NamingContext_var naming_context =
CosNaming::NamingContext::_narrow(naming_obj.in());
//
// Create an instance of TAO's notification event channel
//
CosNotifyChannelAdmin::EventChannelFactory_var notify_factory =
TAO_Notify_EventChannelFactory_i::create(poa.in());
if (CORBA::is_nil (notify_factory.in ())) {
std::cerr << "Unable to create the notify event channel" << std::endl;
return;
}
CosNotifyChannelAdmin::ChannelID id;
CosNotification::QoSProperties initial_qos;
CosNotification::AdminProperties initial_admin;
CosNotifyChannelAdmin::EventChannel_var ec =
notify_factory->create_channel (initial_qos,
initial_admin,
id);
if (CORBA::is_nil (ec.in())) {
std::cerr << "Unable to create event channel" << std::endl;
return;
}
CosNaming::Name name(1);
name.length(1);
name[0].id = CORBA::string_dup("MyEventChannel");
naming_context->rebind(name, ec.in());
CosNotifyChannelAdmin::AdminID adminid;
CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
CosNotifyChannelAdmin::AND_OP;
CosNotifyChannelAdmin::SupplierAdmin_var supplier_admin =
ec->new_for_suppliers (ifgop, adminid);
if (CORBA::is_nil (supplier_admin.in())) {
std::cerr << "Unable to find supplier admin" << std::endl;
}
CosNotifyChannelAdmin::ProxyID supplieradmin_proxy_id;
CosNotifyChannelAdmin::ProxyConsumer_var proxy_consumer =
supplier_admin->obtain_notification_push_consumer(
CosNotifyChannelAdmin::STRUCTURED_EVENT,
supplieradmin_proxy_id);
StructuredEventSupplier_i *servant =
new StructuredEventSupplier_i(orb_.in());
PortableServer::ObjectId_var oid = poa->activate_object(servant);
CORBA::Object_var supplier_obj = poa->id_to_reference(oid.in());
CosNotifyComm::StructuredPushSupplier_var supplier =
CosNotifyComm::StructuredPushSupplier::_narrow(supplier_obj.in());
consumer_proxy_ =
CosNotifyChannelAdmin::StructuredProxyPushConsumer::
_narrow(proxy_consumer.in());
if (CORBA::is_nil (consumer_proxy_.in())) {
std::cerr << "Unable to find structured proxy push consumer" << std::endl;
}
consumer_proxy_->connect_structured_push_supplier(supplier.in());
}
catch(const CORBA::Exception& ex) {
std::cerr << ex << std::endl;
}
}
开发者ID:asdlei00,项目名称:ACE,代码行数:95,代码来源:Messenger_i.cpp
示例6: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
ACE_Auto_Ptr< sig_i > sig_impl;
int status = 0;
try
{
Supplier_Client client;
status = client.init (argc, argv);
if (status == 0)
{
CosNotifyChannelAdmin::EventChannel_var ec =
client.create_event_channel ("MyEventChannel", 0);
CORBA::ORB_ptr orb = client.orb ();
sig_impl.reset( new sig_i( orb ) );
sig_var sig = sig_impl->_this ();
CORBA::String_var ior =
orb->object_to_string (sig.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 %s for "
"writing IOR: %C",
ior_output_file,
ior.in ()),
1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
}
CosNotifyChannelAdmin::SupplierAdmin_var admin =
create_supplieradmin (ec.in ());
if (!CORBA::is_nil (admin.in ()))
{
create_suppliers(admin.in (), client.root_poa ());
sig_impl->wait_for_startup();
ACE_DEBUG((LM_DEBUG, " 1 supplier sending %d events...\n", (max_events*amount)));
for (int i = 0; i < max_events; ++i)
{
SendEvents (i);
}
ACE_DEBUG((LM_DEBUG, "\nSupplier sent %d events.\n", (max_events*amount)));
sig_impl->wait_for_completion();
ACE_OS::unlink (ior_output_file);
ec->destroy();
}
}
}
catch (const CORBA::Exception& e)
{
e._tao_print_exception ("Error: Supplier exception: ");
status = 1;
}
return status;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:69,代码来源:Sequence_Supplier.cpp
示例7: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
ACE_Auto_Ptr< sig_i > sig_impl;
try
{
Consumer_Client client;
int status = client.init (argc, argv);
ACE_UNUSED_ARG(status);
ACE_ASSERT(status == 0);
CosNotifyChannelAdmin::EventChannel_var ec =
client.create_event_channel ("MyEventChannel", 0);
CORBA::ORB_ptr orb = client.orb ();
sig_impl.reset( new sig_i( orb ) );
sig_var sig = sig_impl->_this ();
CORBA::String_var ior =
orb->object_to_string (sig.in ());
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 %s for "
"writing IOR: %C",
ior_output_file,
ior.in ()),
1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
}
CosNotifyChannelAdmin::SupplierAdmin_var admin =
create_supplieradmin (ec.in ());
ACE_ASSERT(!CORBA::is_nil (admin.in ()));
create_suppliers (admin.in (), &client);
sig_impl->wait_for_startup();
ACE_DEBUG((LM_DEBUG, "%i supplier(s) sending %d events...\n", supplier_count, event_count));
for (int i = 0; i < event_count; ++i)
{
ACE_DEBUG((LM_DEBUG, "+"));
SendEvent (i);
}
ACE_DEBUG((LM_DEBUG, "\nEach Supplier sent %d events.\n", event_count));
sig_impl->wait_for_completion();
ACE_OS::unlink (ior_output_file);
disconnect_suppliers();
ec->destroy();
return 0;
}
catch (const CORBA::Exception& e)
{
e._tao_print_exception ("Error: ");
}
return 1;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:67,代码来源:Structured_Supplier.cpp
示例8: 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)
{
// If we are filtering, we will get half as many as originally
// expected
if (filter)
{
expected /= 2;
}
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 ());
if (CORBA::is_nil (sig.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Object reference <%s> is nil\n",
ior),
1);
}
CosNotifyChannelAdmin::ConsumerAdmin_var admin =
create_consumeradmin (ec.in ());
if (!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 ();
}
}
}
catch (const CORBA::Exception& e)
{
e._tao_print_exception ("Error: Consumer exception: ");
status = 1;
}
return status;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:61,代码来源:Sequence_Consumer.cpp
注:本文中的cosnotifychanneladmin::EventChannel_var类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论