本文整理汇总了C++中ACE_Auto_Ptr::activate方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Auto_Ptr::activate方法的具体用法?C++ ACE_Auto_Ptr::activate怎么用?C++ ACE_Auto_Ptr::activate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Auto_Ptr
的用法示例。
在下文中一共展示了ACE_Auto_Ptr::activate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
// Initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
CORBA::ORB_var s_orb;
// Find the Naming Service.
CORBA::Object_var obj = orb->resolve_initial_references ("NameService");
CosNaming::NamingContextExt_var root_context =
CosNaming::NamingContextExt::_narrow (obj.in ());
obj = root_context->resolve_str ("CosEventService");
// Downcast the object reference to an EventChannel reference.
CosEventChannelAdmin::EventChannel_var ec =
CosEventChannelAdmin::EventChannel::_narrow (obj.in ());
if (CORBA::is_nil (ec.in ()))
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Could not narrow the EventChannel.\n")));
return 1;
}
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Found the EventChannel.\n")));
bool consumer = false;
bool supplier = false;
bool hang = false;
for (int i=1; i < argc; ++i)
{
if (0 == ACE_OS::strcasecmp (argv[i], ACE_TEXT ("-consumer")))
consumer = true;
else if (0 == ACE_OS::strcasecmp (argv[i], ACE_TEXT ("-supplier")))
supplier = true;
else if (0 == ACE_OS::strcasecmp (argv[i], ACE_TEXT ("-hang")))
hang = true;
}
TestEventConsumer_i servant (orb.in (), hang);
if (consumer)
{
// Register it with the RootPOA.
obj = orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var poa =
PortableServer::POA::_narrow (obj.in ());
PortableServer::ObjectId_var oid = poa->activate_object (&servant);
CORBA::Object_var consumer_obj = poa->id_to_reference (oid.in ());
CosEventComm::PushConsumer_var consumer =
CosEventComm::PushConsumer::_narrow (consumer_obj.in ());
// Get a ConsumerAdmin object from the EventChannel.
CosEventChannelAdmin::ConsumerAdmin_var consumerAdmin =
ec->for_consumers ();
// Get a ProxyPushSupplier from the ConsumerAdmin.
CosEventChannelAdmin::ProxyPushSupplier_var supplier =
consumerAdmin->obtain_push_supplier ();
// Connect to the ProxyPushSupplier, passing our PushConsumer object
// reference to it.
supplier->connect_push_consumer (consumer.in ());
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Consumer connected\n")));
// Activate the POA via its POAManager.
PortableServer::POAManager_var poa_manager = poa->the_POAManager ();
poa_manager->activate ();
servant.activate ();
}
ACE_Auto_Ptr<SupplierTask> pST;
if (supplier)
{
// The supplier will use its own ORB.
CORBA::String_var ec_str = orb->object_to_string (ec.in ());
int no_args = 0;
ACE_TCHAR **no_argv = 0;
s_orb = CORBA::ORB_init (no_args, no_argv,
"Supplier_pure_client_ORB");
CORBA::Object_var s_ec_obj = s_orb->string_to_object (ec_str.in ());
CosEventChannelAdmin::EventChannel_var s_ec =
CosEventChannelAdmin::EventChannel::_narrow (s_ec_obj.in ());
// Get a SupplierAdmin object from the EventChannel.
CosEventChannelAdmin::SupplierAdmin_var supplierAdmin =
s_ec->for_suppliers ();
// Get a ProxyPushConsumer from the SupplierAdmin.
CosEventChannelAdmin::ProxyPushConsumer_var consumer =
supplierAdmin->obtain_push_consumer ();
// Connect to the ProxyPushConsumer as a PushSupplier
// (passing a nil PushSupplier object reference to it because
// we don't care to be notified about disconnects).
consumer->connect_push_supplier
(CosEventComm::PushSupplier::_nil ());
//.........这里部分代码省略.........