本文整理汇总了C++中cosnotifychanneladmin::EventChannel_var::new_for_suppliers方法的典型用法代码示例。如果您正苦于以下问题:C++ EventChannel_var::new_for_suppliers方法的具体用法?C++ EventChannel_var::new_for_suppliers怎么用?C++ EventChannel_var::new_for_suppliers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cosnotifychanneladmin::EventChannel_var
的用法示例。
在下文中一共展示了EventChannel_var::new_for_suppliers方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
CosNotifyChannelAdmin::AdminID
IdAssignment::create_supplier_admin (CosNotifyChannelAdmin::ChannelID channel_id)
{
CosNotifyChannelAdmin::AdminID adminid;
CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
CosNotifyChannelAdmin::OR_OP;
CosNotifyChannelAdmin::EventChannel_var ec =
this->notify_factory_->get_event_channel (channel_id);
if (CORBA::is_nil (ec.in ()))
{
ACE_ERROR((LM_ERROR,
" (%P|%t) Unable to find event channel\n"));
return 0;
}
CosNotifyChannelAdmin::SupplierAdmin_var supplier_admin =
ec->new_for_suppliers (ifgop,
adminid);
if (CORBA::is_nil (supplier_admin.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Unable to create supplier admin\n"),0);
if (TAO_debug_level)
ACE_DEBUG ((LM_DEBUG,
"created supplier admin\n"));
return adminid;
}
示例2:
void
TAO_Notify_Lanes_Supplier_Client::initialize (void)
{
PortableServer::POAManager_var poa_manager =
this->orb_objects_.root_poa_->the_POAManager ();
poa_manager->activate ();
CosNotifyChannelAdmin::EventChannel_var ec = this->create_ec ();
// Create a Supplier Admin
CosNotifyChannelAdmin::AdminID adminid = 0;
CosNotifyChannelAdmin::SupplierAdmin_var supplier_admin =
ec->new_for_suppliers (CosNotifyChannelAdmin::AND_OP, adminid);
ACE_ASSERT (!CORBA::is_nil (supplier_admin.in ()));
// Create a Supplier
this->supplier_ = new TAO_Notify_Lanes_Supplier (this->orb_objects_);
// Initialize it.
this->supplier_->init (supplier_admin, this->consumer_count_);
}
示例3: ACE_TMAIN
int ACE_TMAIN(int argc, ACE_TCHAR * argv[])
{
try
{
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
CORBA::Object_var rootObj = orb->resolve_initial_references("NameService");
CosNaming::NamingContext_var rootNC =
CosNaming::NamingContext::_narrow(rootObj.in());
// Get reference to Root POA.
CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in());
// Activate POA manager
PortableServer::POAManager_var mgr = poa->the_POAManager();
mgr->activate();
// Create an Event Channel factory.
CosNotifyChannelAdmin::EventChannelFactory_var notify_factory =
TAO_Notify_EventChannelFactory_i::create(poa.in());
ACE_ASSERT (!CORBA::is_nil (notify_factory.in ()));
// Create an Event Channel.
CosNotifyChannelAdmin::ChannelID id;
CosNotification::QoSProperties initial_qos;
CosNotification::AdminProperties initial_admin;
CosNotifyChannelAdmin::EventChannel_var ec =
notify_factory->create_channel (initial_qos, initial_admin, id);
// Bind it in the Naming Service.
CosNaming::Name name(1);
name.length(1);
name[0].id = CORBA::string_dup("MyEventChannel");
rootNC->rebind(name, ec.in());
// Become a structured push supplier.
CosNotifyChannelAdmin::AdminID adminid;
CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
CosNotifyChannelAdmin::AND_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());
CosNotifyComm::StructuredPushSupplier_var supplier = servant->_this();
CosNotifyChannelAdmin::StructuredProxyPushConsumer_var consumer_proxy =
CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow(
proxy_consumer.in());
consumer_proxy->connect_structured_push_supplier(supplier.in());
// Set up events to push.
CosNotification::StructuredEvent event;
event.header.fixed_header.event_type.domain_name =
CORBA::string_dup("OCI_TAO");
event.header.fixed_header.event_type.type_name =
CORBA::string_dup("examples");
event.header.fixed_header.event_name = CORBA::string_dup("myevent");
event.filterable_data.length (1);
event.filterable_data[0].name = CORBA::string_dup("Message from:");
event.filterable_data[0].value <<= (const char *)user_name;
event.filterable_data.length (2);
event.filterable_data[1].name = CORBA::string_dup("Subject:");
event.filterable_data[1].value <<= (const char *)subject;
event.filterable_data.length (3);
event.filterable_data[2].name = CORBA::string_dup("Message:");
event.filterable_data[2].value <<= (const char *)message;
// Push events.
while (1) {
std::cout << "pushing " << std::endl;
consumer_proxy->push_structured_event (event);
ACE_OS::sleep (1);
}
}
catch(const CORBA::Exception& ex) {
return 1;
}
return 0;
}
示例4: 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());
}
示例5: main
int main(int argc, char* argv[]) {
char aux1[1000];
time_t seconds;
signal(SIGINT, TerminarEjecucion);
time(&seconds);
srand((unsigned int) seconds);
try {
// Inicializacion del ORB
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "");
// Recoge la referencia al canal
cin >> aux1;
CORBA::Object_var obj = orb->string_to_object(aux1);
// Obtiene el canal
CosNotifyChannelAdmin::EventChannel_var channel;
channel = CosNotifyChannelAdmin::EventChannel::_narrow(obj);
if (CORBA::is_nil(channel)) {
cerr << "[supplier2] ERROR: canal nulo " << endl;
return -1;
}
// Obtiene el SupplierAdmin
CosNotifyChannelAdmin::AdminID id;
_supplier_admin =
channel->new_for_suppliers(CosNotifyChannelAdmin::AND_OP, id);
cerr << "[supplier2] SupplierAdminId = " << id << endl;
CosNotifyChannelAdmin::ProxyID proxy_id;
CosNotifyChannelAdmin::ProxyConsumer_var proxy_consumer =
_supplier_admin->obtain_notification_push_consumer(
CosNotifyChannelAdmin::STRUCTURED_EVENT,
proxy_id);
cerr << "[supplier2] ProxyId = " << proxy_id << endl;
// Obtiene el StructuredProxyPushConsumer
_consumer =
CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow(proxy_consumer);
try{
CosNotifyComm::StructuredPushSupplier_var supplier =
CosNotifyComm::StructuredPushSupplier::_nil();
_consumer->connect_structured_push_supplier(supplier);
if (_consumer == NULL) cerr << "[supplier2] consumer NULO 5" << endl;
} catch (CORBA::Exception& exc) {
cerr << "[supplier2] Exception in _consumer->connect_push_supplier(...)";
cerr << exc << endl;
} catch (...) {
cerr << "[supplier2] Unknowed exception ";
cerr << "in _consumer->connect_push_supplier(...)";
}
#ifdef _TAO
sleep(1);
#elif defined _TIDORB
TIDThr::Thread::sleep(1000); // 1 ''
#endif
cerr << "[supplier2] Crea un structured event" << flush << endl;
try{
CosNotification::StructuredEvent* event = NULL;
int rnd = 0;
for(int i=0; i < 200; i++) {
rnd = rand();
TimeBase::UtcT current_utc = TIDorb::core::util::Time::currentUtcT();
TimeBase::UtcT future_utc = TIDorb::core::util::Time::currentUtcT();
TimeBase::UtcT pass_utc = TIDorb::core::util::Time::currentUtcT();
future_utc.time += (5 * 10000000); // now + 5 ''
pass_utc.time -= (5 * 10000000); // now - 5 ''
// Rellenamos la informacion del evento
event = new CosNotification::StructuredEvent();
event->header.fixed_header.event_name =
(rnd % 2) ? CORBA::string_dup("event_name") : CORBA::string_dup("other");
event->header.fixed_header.event_type.domain_name =
(rnd % 2) ? CORBA::string_dup("domain_name") : CORBA::string_dup("other");
event->header.fixed_header.event_type.type_name =
(rnd % 2) ? CORBA::string_dup("type_name") : CORBA::string_dup("other");
event->header.variable_header.length(5);
event->header.variable_header[0].name = CORBA::string_dup("EventReliability");
event->header.variable_header[0].value <<= (CORBA::Short) 0;
event->header.variable_header[1].name = CORBA::string_dup("Priority");
//.........这里部分代码省略.........
示例6: StructuredEventSupplier_i
Messenger_i::Messenger_i (CORBA::ORB_ptr orb)
: orb_(CORBA::ORB::_duplicate(orb))
{
CORBA::Object_var poa_object =
orb_->resolve_initial_references("RootPOA");
if (CORBA::is_nil (poa_object.in())) {
std::cerr << "Unable to initialize the POA." << std::endl;
}
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());
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());
if (CORBA::is_nil(notify_factory.in())) {
std::cerr << "Unable to find notify factory" << std::endl;
}
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 crete event channel" << std::endl;
}
// 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());
CosNotifyComm::StructuredPushSupplier_var supplier =
servant->_this();
s_proxy_consumer_ =
CosNotifyChannelAdmin::StructuredProxyPushConsumer::
_narrow(proxy_consumer.in());
if (CORBA::is_nil (s_proxy_consumer_.in())) {
std::cerr << "Unable to find structured proxy push consumer" << std::endl;
}
s_proxy_consumer_->
connect_structured_push_supplier(supplier.in());
CosNotification::EventTypeSeq added (1);
CosNotification::EventTypeSeq removed (1);
added.length (1);
removed.length (1);
added[0].domain_name = CORBA::string_dup ("OCI_TAO");
added[0].type_name = CORBA::string_dup ("examples");
removed[0].domain_name = CORBA::string_dup ("*");
removed[0].type_name = CORBA::string_dup ("*");
s_proxy_consumer_->offer_change(added, removed);
}
示例7: main
int main(int argc, char * argv[])
{
CORBA::Object_var obj;
//----------------------------------------------------------------------------
// initialize ORB
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
//----------------------------------------------------------------------------
// initialize POA
obj = orb->resolve_initial_references("RootPOA");
assert(!CORBA::is_nil(obj));
PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
PortableServer::POAManager_var poa_manager = root_poa->the_POAManager();
poa_manager->activate();
//----------------------------------------------------------------------------
// get naming service reference
obj = orb->resolve_initial_references("NameService");
assert(!CORBA::is_nil(obj));
CosNaming::NamingContext_var naming_service =
CosNaming::NamingContext::_narrow(obj);
//----------------------------------------------------------------------------
// get event channel reference
// resolving name in robots naming context
assert(argc >= 2);
std::string naming_context = argv[1];
CosNaming::Name name;
name.length(2);
name[0].id = naming_context.c_str();
name[1].id = string("NotifyEventChannel").c_str();
obj = naming_service->resolve(name);
// The event channel
CosNotifyChannelAdmin::EventChannel_var ec =
CosNotifyChannelAdmin::EventChannel::_narrow(obj);
//----------------------------------------------------------------------------
// creating a notification service supplier admin
// The group operator between admin-proxy's.
CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
CosNotifyChannelAdmin::OR_OP;
// The id of the created adin.
CosNotifyChannelAdmin::AdminID admin_id;
// The supplier admin used by supplier.
CosNotifyChannelAdmin::SupplierAdmin_var supplier_admin;
supplier_admin = ec->new_for_suppliers(ifgop, admin_id);
//----------------------------------------------------------------------------
// create a notification service proxy consumer, to send events to
// This proxy's id.
CosNotifyChannelAdmin::ProxyID proxy_id;
// The proxy that we are connected to.
CosNotifyChannelAdmin::StructuredProxyPushConsumer_var proxy_consumer;
obj = supplier_admin->
obtain_notification_push_consumer(CosNotifyChannelAdmin::STRUCTURED_EVENT,
proxy_id);
assert(!CORBA::is_nil(obj));
// narrow
proxy_consumer =
CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow(obj);
//----------------------------------------------------------------------------
// offer/subscription management
// don't call us on subscription changes
CosNotification::EventTypeSeq_var events =
proxy_consumer->
obtain_subscription_types(CosNotifyChannelAdmin::NONE_NOW_UPDATES_OFF);
// register the events we gonna offer
CosNotification::EventTypeSeq added;
CosNotification::EventTypeSeq removed;
added.length(1);
added[0].domain_name = string("Robot_Name").c_str();
added[0].type_name = string("Event_Name").c_str();
// remove default offer
removed.length(1);
removed[0].domain_name = string("*").c_str();
removed[0].type_name = string("*").c_str();
supplier_admin->offer_change(added, removed);
//----------------------------------------------------------------------------
// create and connect a supplier class
class MySupplier : public POA_CosNotifyComm::StructuredPushSupplier
//.........这里部分代码省略.........
示例8: 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;
}
}