本文整理汇总了C++中cosnotifychanneladmin::EventChannel_var::new_for_consumers方法的典型用法代码示例。如果您正苦于以下问题:C++ EventChannel_var::new_for_consumers方法的具体用法?C++ EventChannel_var::new_for_consumers怎么用?C++ EventChannel_var::new_for_consumers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cosnotifychanneladmin::EventChannel_var
的用法示例。
在下文中一共展示了EventChannel_var::new_for_consumers方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
CosNotifyChannelAdmin::AdminID
IdAssignment::create_consumer_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::ConsumerAdmin_var consumer_admin =
ec->new_for_consumers (ifgop,
adminid);
if (CORBA::is_nil (consumer_admin.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Unable to create consumer admin\n"),0);
if (TAO_debug_level)
ACE_DEBUG ((LM_DEBUG,
"created consumer admin\n"));
return adminid;
}
示例2: name
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())) {
std::cerr << "Unable to initialize the POA." << std::endl;
return 1;
}
PortableServer::POA_var poa =
PortableServer::POA::_narrow(poa_object.in());
// Activate POA manager
PortableServer::POAManager_var mgr = poa->the_POAManager();
mgr->activate();
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;
return 1;
}
CosNaming::NamingContext_var naming_context =
CosNaming::NamingContext::_narrow(naming_obj.in());
CosNaming::Name name(1);
name.length (1);
name[0].id = CORBA::string_dup("MyEventChannel");
CORBA::Object_var ecObj = naming_context->resolve(name);
CosNotifyChannelAdmin::EventChannel_var ec =
CosNotifyChannelAdmin::EventChannel::_narrow(ecObj.in());
if (CORBA::is_nil (ec.in())) {
std::cerr << "Unable to find event channel" << std::endl;
return 1;
}
CosNotifyChannelAdmin::AdminID adminid;
CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
CosNotifyChannelAdmin::AND_OP;
CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin =
ec->new_for_consumers(ifgop,
adminid);
if (CORBA::is_nil (consumer_admin.in())) {
std::cerr << "Unable to find consumer admin" << std::endl;
return 1;
}
PortableServer::Servant_var<StructuredEventConsumer_i> servant =
new StructuredEventConsumer_i(orb.in());
CosNotifyComm::StructuredPushConsumer_var consumer = servant->_this();
CosNotifyChannelAdmin::ProxyID consumeradmin_proxy_id;
CosNotifyChannelAdmin::ProxySupplier_var proxy_supplier =
consumer_admin->obtain_notification_push_supplier(
CosNotifyChannelAdmin::STRUCTURED_EVENT,
consumeradmin_proxy_id);
// The proxy that we are connected to.
CosNotifyChannelAdmin::StructuredProxyPushSupplier_var supplier_proxy;
supplier_proxy = CosNotifyChannelAdmin::StructuredProxyPushSupplier::
_narrow(proxy_supplier.in());
if (CORBA::is_nil (supplier_proxy.in())) {
std::cerr << "Unable to create structured push supplier proxy" << std::endl;
return 1;
}
supplier_proxy->connect_structured_push_consumer(consumer.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 ("*");
supplier_proxy->subscription_change(added, removed);
orb->run();
}
catch(const CORBA::Exception& ex)
{
//.........这里部分代码省略.........
示例3: 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;
//.........这里部分代码省略.........
示例4: main
int main(int argc, char * argv[])
{
Miro::Log::init(argc, argv);
Miro::Server server(argc, argv);
if (parseArgs(argc, argv) != 0)
return 1;
// The event channel
CosNotifyChannelAdmin::EventChannel_var ec =
server.resolveName<CosNotifyChannelAdmin::EventChannel>(channelName);
//----------------------------------------------------------------------------
// 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::ConsumerAdmin_var consumer_admin;
consumer_admin = ec->new_for_consumers(ifgop, admin_id);
//----------------------------------------------------------------------------
// create a notification service proxy consumer, to send events to
// Initial qos specified to the factory when creating the EC.
CosNotification::QoSProperties initial_qos;
// Initial admin props specified to the factory when creating the EC.
CosNotification::AdminProperties initial_admin;
// This proxy's id.
CosNotifyChannelAdmin::ProxyID proxy_id;
// The proxy that we are connected to.
CosNotifyChannelAdmin::StructuredProxyPushSupplier_var proxy_supplier;
CORBA::Object_var obj;
obj = consumer_admin->
obtain_notification_push_supplier(CosNotifyChannelAdmin::STRUCTURED_EVENT,
proxy_id);
assert(!CORBA::is_nil(obj));
// narrow
proxy_supplier =
CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow(obj);
//----------------------------------------------------------------------------
// offer/subscription management
// don't call us on offer changes
CosNotification::EventTypeSeq_var events =
proxy_supplier->
obtain_offered_types(CosNotifyChannelAdmin::ALL_NOW_UPDATES_OFF);
// tell about the events we gonna subscribe
CosNotification::EventTypeSeq added;
CosNotification::EventTypeSeq removed;
added.length(1);
added[0].domain_name = Miro::RobotParameters::instance()->namingContextName.c_str();
added[0].type_name = eventName.c_str();
// remove default subscription
removed.length(1);
removed[0].domain_name = string("*").c_str();
removed[0].type_name = string("*").c_str();
consumer_admin->subscription_change(added, removed);
//----------------------------------------------------------------------------
// create and connect a supplier class
class MyConsumer : public POA_CosNotifyComm::StructuredPushConsumer {
public:
MyConsumer() :
anyPrinter(printName,
printType,
printLength,
printEnums,
printTc,
printId,
maxSeqLen)
{}
virtual
void
push_structured_event(CosNotification::StructuredEvent const& event)
throw()
{
anyPrinter.print(cout, event.remainder_of_body);
cout << endl;
}
virtual
void
offer_change(const CosNotification::EventTypeSeq&, const CosNotification::EventTypeSeq&)
throw()
{}
//.........这里部分代码省略.........
示例5: main
int main(int argc, char * argv[])
{
Miro::Log::init(argc, argv);
Miro::Server server(argc, argv);
if (parseArgs(argc, argv) != 0)
return 1;
// The event channel
CosNotifyChannelAdmin::EventChannel_var ec =
server.resolveName<CosNotifyChannelAdmin::EventChannel>(channelName);
//----------------------------------------------------------------------------
// 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::ConsumerAdmin_var consumer_admin;
consumer_admin = ec->new_for_consumers(ifgop, admin_id);
//----------------------------------------------------------------------------
// create a notification service proxy consumer, to send events to
// Initial qos specified to the factory when creating the EC.
CosNotification::QoSProperties initial_qos;
// Initial admin props specified to the factory when creating the EC.
CosNotification::AdminProperties initial_admin;
// This proxy's id.
CosNotifyChannelAdmin::ProxyID proxy_id;
// The proxy that we are connected to.
CosNotifyChannelAdmin::StructuredProxyPushSupplier_var proxy_supplier;
CORBA::Object_var obj;
obj = consumer_admin->
obtain_notification_push_supplier(CosNotifyChannelAdmin::STRUCTURED_EVENT,
proxy_id);
assert(!CORBA::is_nil(obj));
// narrow
proxy_supplier =
CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow(obj);
//----------------------------------------------------------------------------
// offer/subscription management
// don't call us on offer changes
CosNotification::EventTypeSeq_var events =
proxy_supplier->
obtain_offered_types(CosNotifyChannelAdmin::ALL_NOW_UPDATES_OFF);
cout << "offered events (subscription management): " << endl;
for (CORBA::ULong i = 0; i < events->length(); ++i) {
cout << "domain name: "
<< events[i].domain_name << " "
<< "type name: "
<< events[i].type_name << endl;
}
//----------------------------------------------------------------------------
// create and connect a supplier class
class MyConsumer : public POA_CosNotifyComm::StructuredPushConsumer
{
typedef set<string> StringSet;
public:
MyConsumer() :
start(ACE_OS::gettimeofday()),
started(false)
{
start += timeout;
}
~MyConsumer() { cout << "Ctor of MyConsumer" << endl; }
void push_structured_event(CosNotification::StructuredEvent const& event)
throw()
{
string type =
string("domain name: ") +
string(event.header.fixed_header.event_type.domain_name) +
string(" ") +
string("type name: ") +
string(event.header.fixed_header.event_type.type_name);
unsigned int size = offers.size();
offers.insert(type);
if (ACE_OS::gettimeofday() < start)
return;
if (!started || size < offers.size()) {
cout << endl << endl << "updated offer set (received): " << endl;
//.........这里部分代码省略.........
示例6: EventSequenceConsumer_i
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
CORBA::Object_var obj = orb->resolve_initial_references("NameService");
CosNaming::NamingContextExt_var naming_context =
CosNaming::NamingContextExt::_narrow(obj.in());
obj = naming_context->resolve_str("MyEventChannel");
CosNotifyChannelAdmin::EventChannel_var ec =
CosNotifyChannelAdmin::EventChannel::_narrow(obj.in());
CosNotifyChannelAdmin::AdminID adminid;
CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
CosNotifyChannelAdmin::AND_OP;
CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin =
ec->new_for_consumers(ifgop,
adminid);
obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow (obj.in());
PortableServer::Servant_var<EventSequenceConsumer_i> servant =
new EventSequenceConsumer_i(orb.in());
PortableServer::ObjectId_var objectId = poa->activate_object(servant.in());
obj = poa->id_to_reference (objectId.in());
CosNotifyComm::SequencePushConsumer_var consumer =
CosNotifyComm::SequencePushConsumer::_narrow(obj.in());
CosNotifyChannelAdmin::ProxyID consumeradmin_proxy_id;
CosNotifyChannelAdmin::ProxySupplier_var proxy_supplier =
consumer_admin->obtain_notification_push_supplier(
CosNotifyChannelAdmin::SEQUENCE_EVENT,
consumeradmin_proxy_id);
CosNotifyChannelAdmin::SequenceProxyPushSupplier_var supplier_proxy =
CosNotifyChannelAdmin::SequenceProxyPushSupplier::_narrow(proxy_supplier.in());
supplier_proxy->connect_sequence_push_consumer(consumer.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 ("*");
supplier_proxy->subscription_change(added, removed);
PortableServer::POAManager_var poa_manager = poa->the_POAManager();
poa_manager->activate();
orb->run();
orb->destroy();
return 0;
}
catch(const CORBA::Exception& ex)
{
std::cerr << "Caught exception: " << ex << std::endl;
}
return 1;
}
示例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
CosNaming::Name name;
name.length(1);
name[1].id = NOTIFY_EVENT_CHANNEL;
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::ConsumerAdmin_var consumer_admin;
consumer_admin = ec->new_for_consumers(ifgop, admin_id);
//----------------------------------------------------------------------------
// create a notification service proxy consumer, to send events to
// Initial qos specified to the factory when creating the EC.
CosNotification::QoSProperties initial_qos;
// Initial admin props specified to the factory when creating the EC.
CosNotification::AdminProperties initial_admin;
// This proxy's id.
CosNotifyChannelAdmin::ProxyID proxy_id;
// The proxy that we are connected to.
CosNotifyChannelAdmin::StructuredProxyPushSupplier_var proxy_supplier;
obj = consumer_admin->
obtain_notification_push_supplier(CosNotifyChannelAdmin::STRUCTURED_EVENT,
proxy_id);
assert(!CORBA::is_nil(obj));
// narrow
proxy_supplier =
CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow(obj);
//----------------------------------------------------------------------------
// offer/subscription management
// don't call us on offer changes
CosNotification::EventTypeSeq_var events =
proxy_supplier->
obtain_offered_types(CosNotifyChannelAdmin::NONE_NOW_UPDATES_OFF);
// tell about the events we gonna subscribe
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();
added.length(1);
// remove default subscription
removed.length(1);
removed[0].domain_name = string("*").c_str();
removed[0].type_name = string("*").c_str();
consumer_admin->subscription_change(added, removed);
//----------------------------------------------------------------------------
// create and connect a supplier class
//.........这里部分代码省略.........
示例8: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
Consumer_Client client;
int status = client.init (argc, argv);
if (status != 0)
{
ACE_ERROR((LM_ERROR, "Error: Unable to init consumer.\n"));
return 1;
}
CosNotifyChannelAdmin::EventChannel_var ec =
client.create_event_channel ("Struct_Multi_Filter", 1);
CosNotifyChannelAdmin::AdminID adminid = 0;
CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin =
ec->new_for_consumers ((consumerFilter == OrOp
? CosNotifyChannelAdmin::OR_OP : CosNotifyChannelAdmin::AND_OP),
adminid);
ACE_ASSERT(! CORBA::is_nil (consumer_admin.in ()));
if (consumerFilter != None)
{
CosNotifyFilter::FilterFactory_var ffact =
ec->default_filter_factory ();
CosNotifyFilter::Filter_var filter =
ffact->create_filter (GRAMMAR);
if (CORBA::is_nil (filter.in ()))
{
ACE_ERROR ((LM_ERROR,
" (%P|%t) Consumer unable to initialize filter.\n"));
return 1;
}
CosNotifyFilter::ConstraintExpSeq constraint_list (1);
constraint_list.length (1);
constraint_list[0].event_types.length (0);
constraint_list[0].constraint_expr = CORBA::string_dup ("type != 1");
filter->add_constraints (constraint_list);
consumer_admin->add_filter (filter.in ());
}
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 ()));
create_consumer (consumer_admin.in (), ec.in (), &client);
ACE_DEBUG((LM_DEBUG, "\nConsumer waiting for events...\n"));
sig->go ();
client.ORB_run( );
ACE_DEBUG((LM_DEBUG, "\nConsumer done.\n"));
sig->done();
return 0;
}
catch (const CORBA::Exception& e)
{
e._tao_print_exception ("\nError: Consumer:");
}
return 1;
}
示例9: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
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;
return 1;
}
CosNaming::NamingContext_var naming_context =
CosNaming::NamingContext::_narrow(naming_obj.in());
CosNaming::Name name(1);
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;
return 1;
}
name.length (1);
name[0].id = CORBA::string_dup("MyEventChannel");
CORBA::Object_var ecObj = naming_context->resolve(name);
CosNotifyChannelAdmin::EventChannel_var ec =
CosNotifyChannelAdmin::EventChannel::_narrow(ecObj.in());
if (CORBA::is_nil (ec.in())) {
std::cerr << "Unable to find event channel" << std::endl;
return 1;
}
CosNotifyChannelAdmin::AdminID adminid;
CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
CosNotifyChannelAdmin::AND_OP;
CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin =
ec->new_for_consumers(ifgop,
adminid);
if (CORBA::is_nil (consumer_admin.in())) {
std::cerr << "Unable to find consumer admin" << std::endl;
return 1;
}
CosNotifyFilter::FilterFactory_var ffact =
ec->default_filter_factory ();
// setup a filter at the consumer admin
CosNotifyFilter::Filter_var ca_filter =
ffact->create_filter (TCL_GRAMMAR);
if (CORBA::is_nil (ca_filter.in())) {
std::cerr << "Unable to create filetr object" << std::endl;
return 1;
}
CosNotifyFilter::ConstraintExpSeq constraint_list (1);
constraint_list.length (1);
constraint_list[0].event_types.length (0);
constraint_list[0].constraint_expr = CORBA::string_dup (CA_FILTER);
ca_filter->add_constraints (constraint_list);
consumer_admin ->add_filter (ca_filter.in());
CosNotification::EventTypeSeq added(1);
CosNotification::EventTypeSeq removed (0);
added.length (1);
removed.length (0);
added[0].domain_name = CORBA::string_dup ("*");
added[0].type_name = CORBA::string_dup ("*");
consumer_admin->subscription_change (added, removed);
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;
return 1;
}
PortableServer::POA_var poa =
PortableServer::POA::_narrow(poa_object.in());
PortableServer::Servant_var<StructuredEventConsumer_i> servant =
new StructuredEventConsumer_i(orb.in());
//.........这里部分代码省略.........
示例10: lanes
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 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("MyEventChannel");
CORBA::Object_var ecObj = naming_context->resolve(name);
CosNotifyChannelAdmin::EventChannel_var ec =
CosNotifyChannelAdmin::EventChannel::_narrow(ecObj.in());
CosNotifyChannelAdmin::AdminID adminid;
CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
CosNotifyChannelAdmin::AND_OP;
CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin =
ec->new_for_consumers(ifgop,
adminid);
CORBA::Object_var poa_object =
orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa =
PortableServer::POA::_narrow (poa_object.in());
CORBA::Object_var rtorb_obj = orb->resolve_initial_references ("RTORB");
RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (rtorb_obj.in ());
// Create an RT POA with a lane at the given priority.
CORBA::Policy_var priority_model_policy =
rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED,
DEFAULT_PRIORITY);
RTCORBA::ThreadpoolLanes lanes (2);
lanes.length (2);
lanes[0].lane_priority = LOW_PRIORITY;
lanes[0].static_threads = 2;
lanes[0].dynamic_threads = 0;
lanes[1].lane_priority = HIGH_PRIORITY;
lanes[1].static_threads = 2;
lanes[1].dynamic_threads = 0;
// Create a thread-pool.
CORBA::ULong stacksize = 0;
CORBA::Boolean allow_request_buffering = 0;
CORBA::ULong max_buffered_requests = 0;
CORBA::ULong max_request_buffer_size = 0;
CORBA::Boolean allow_borrowing = 0;
// Create the thread-pool.
RTCORBA::ThreadpoolId threadpool_id =
rt_orb->create_threadpool_with_lanes (stacksize,
lanes,
allow_borrowing,
allow_request_buffering,
max_buffered_requests,
max_request_buffer_size);
// Create a thread-pool policy.
CORBA::Policy_var lanes_policy =
rt_orb->create_threadpool_policy (threadpool_id);
CORBA::PolicyList poa_policy_list(2);
poa_policy_list.length (2);
poa_policy_list[0] = priority_model_policy;
poa_policy_list[1] = lanes_policy;
PortableServer::POAManager_var poa_manager = poa->the_POAManager ();
PortableServer::POA_var rt_poa = poa->create_POA ("RT POA",
poa_manager.in (),
poa_policy_list);
PortableServer::Servant_var<StructuredEventConsumer_i> servant =
new StructuredEventConsumer_i(orb.in());
PortableServer::ObjectId_var objectId =
rt_poa->activate_object (servant.in());
CORBA::Object_var consumer_obj =
rt_poa->id_to_reference (objectId.in ());
CosNotifyComm::StructuredPushConsumer_var consumer =
CosNotifyComm::StructuredPushConsumer::_narrow (consumer_obj.in ());
//.........这里部分代码省略.........