本文整理汇总了C++中dds::DomainParticipantFactory_var::in方法的典型用法代码示例。如果您正苦于以下问题:C++ DomainParticipantFactory_var::in方法的具体用法?C++ DomainParticipantFactory_var::in怎么用?C++ DomainParticipantFactory_var::in使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dds::DomainParticipantFactory_var
的用法示例。
在下文中一共展示了DomainParticipantFactory_var::in方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
OpenDDS_Domain_Manager::~OpenDDS_Domain_Manager ()
{
// delete the participant's contained entities
if (!CORBA::is_nil (dp_.in ()))
dp_->delete_contained_entities ();
DDS::DomainParticipantFactory_var dpf =
OpenDDS::DCPS::Service_Participant::instance()->
get_domain_participant_factory ();
if (!CORBA::is_nil (dpf.in ()))
dpf->delete_participant(dp_.in ());
// shut down the service participant
OpenDDS::DCPS::Service_Participant::instance ()->shutdown ();
}
示例2: find
dds::domain::DomainParticipant find(uint32_t id)
{
DDS::DomainParticipantFactory_var dpf = DDS::DomainParticipantFactory::get_instance();
if(dpf.in() == 0)
{
throw dds::core::PreconditionNotMetError(org::opensplice::core::exception_helper(
OSPL_CONTEXT_LITERAL(
"dds::core::PreconditionNotMetError: Unable to resolve the DomainParticipant Factory.")));
}
DDS::DomainParticipant_ptr ddsdp = dpf->lookup_participant(id);
if(ddsdp)
{
dds::domain::DomainParticipant dp =
org::opensplice::core::EntityRegistry<DDS::DomainParticipant_ptr, dds::domain::DomainParticipant>::get(ddsdp);
if(dp != dds::core::null)
{
return dp;
}
}
return dds::domain::DomainParticipant(dds::core::null);
}
示例3:
void
SPMonitorImpl::report()
{
if (CORBA::is_nil(this->sp_writer_.in())) {
this->sp_writer_ = this->monitor_factory_->get_sp_writer();
}
// If the SP writer is not available, it is too soon to report
if (!CORBA::is_nil(this->sp_writer_.in())) {
ServiceParticipantReport report;
report.host = this->hostname_.c_str();
report.pid = this->pid_;
DDS::DomainParticipantFactory_var pf = TheParticipantFactory;
const DomainParticipantFactoryImpl::DPMap& participants =
dynamic_cast<DomainParticipantFactoryImpl*>(pf.in())->participants();
CORBA::ULong length = 0;
for (DomainParticipantFactoryImpl::DPMap::const_iterator mapIter = participants.begin();
mapIter != participants.end();
++mapIter) {
for (DomainParticipantFactoryImpl::DPSet::const_iterator iter = mapIter->second.begin();
iter != mapIter->second.end();
++iter) {
report.domain_participants.length(length+1);
report.domain_participants[length] = iter->svt_->get_id();
length++;
}
}
length = 0;
// TODO: Redo the transport-related monitor publishing here...
//const TransportFactory::ImplMap& transports =
// TransportFactory::instance()->get_transport_impl_map();
//report.transports.length(static_cast<CORBA::ULong>(transports.size()));
//for (TransportFactory::ImplMap::const_iterator mapIter = transports.begin();
// mapIter != transports.end();
// ++mapIter) {
// report.transports[length++] = mapIter->first;
//}
this->sp_writer_->write(report, DDS::HANDLE_NIL);
}
}
示例4: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) {
DDS::DomainParticipantFactory_var dpf = DDS::DomainParticipantFactory::_nil();
DDS::DomainParticipant_var participant = DDS::DomainParticipant::_nil();
try {
// Initialize, and create a DomainParticipant
// (same as publishe
dpf = TheParticipantFactoryWithArgs(argc, argv);
participant = dpf->create_participant(
QUOTER_DOMAIN_ID,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (participant.in ())) {
cerr << "create_participant failed." << endl;
ACE_OS::exit(1);
}
// Create a subscriber for the two topics
// (SUBSCRIBER_QOS_DEFAULT is defined in Marked_Default_Qos.h)
DDS::Subscriber_var sub =
participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT,
DDS::SubscriberListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (sub.in ())) {
cerr << "create_subscriber failed." << endl;
ACE_OS::exit(1);
}
// Initialize the transport; the TRANSPORT_IMPL_ID must match the
// value in the configuration file.
OpenDDS::DCPS::TransportImpl_rch trans_impl =
TheTransportFactory->create_transport_impl (TRANSPORT_IMPL_ID,
OpenDDS::DCPS::AUTO_CONFIG);
// Attach the subscriber to the TCP transport.
// (almost identical to the publisher)
OpenDDS::DCPS::SubscriberImpl* sub_impl =
dynamic_cast< OpenDDS::DCPS::SubscriberImpl* >(sub.in ());
if (0 == sub_impl) {
cerr << "Failed to obtain subscriber servant" << endl;
ACE_OS::exit(1);
}
OpenDDS::DCPS::AttachStatus status = sub_impl->attach_transport(trans_impl.in());
if (status != OpenDDS::DCPS::ATTACH_OK) {
std::string status_str;
switch (status) {
case OpenDDS::DCPS::ATTACH_BAD_TRANSPORT:
status_str = "ATTACH_BAD_TRANSPORT";
break;
case OpenDDS::DCPS::ATTACH_ERROR:
status_str = "ATTACH_ERROR";
break;
case OpenDDS::DCPS::ATTACH_INCOMPATIBLE_QOS:
status_str = "ATTACH_INCOMPATIBLE_QOS";
break;
default:
status_str = "Unknown Status";
break;
}
cerr << "Failed to attach to the transport. Status == "
<< status_str.c_str() << endl;
ACE_OS::exit(1);
}
// Register the Quote type
// (same as publisher)
StockQuoter::QuoteTypeSupport_var quote_servant
= new StockQuoter::QuoteTypeSupportImpl();
if (DDS::RETCODE_OK != quote_servant->register_type(participant.in (),
QUOTER_QUOTE_TYPE)) {
cerr << "register_type for " << QUOTER_QUOTE_TYPE << " failed." << endl;
ACE_OS::exit(1);
}
// Register the ExchangeEvent type
// (same as publisher)
StockQuoter::ExchangeEventTypeSupport_var exchange_evt_servant
= new StockQuoter::ExchangeEventTypeSupportImpl();
if (DDS::RETCODE_OK != exchange_evt_servant->register_type(participant.in (),
QUOTER_EXCHANGE_EVENT_TYPE)) {
cerr << "register_type for " << QUOTER_EXCHANGE_EVENT_TYPE
<< " failed." << endl;
ACE_OS::exit(1);
}
// Get QoS to use for our two topics
// (same as publisher)
DDS::TopicQos default_topic_qos;
participant->get_default_topic_qos(default_topic_qos);
// Create a topic for the Quote type...
// Could also use TOPIC_QOS_DEFAULT instead
// (same as publisher)
//.........这里部分代码省略.........
示例5: ACE_TMAIN
int ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
int status = 0;
try
{
ACE_DEBUG((LM_INFO,"(%P|%t) %T publisher main\n"));
dpf = TheParticipantFactoryWithArgs(argc, argv);
// let the Service_Participant (in above line) strip out -DCPSxxx parameters
// and then get application specific parameters.
parse_args (argc, argv);
init ();
// Indicate that the publisher is ready
FILE* writers_ready = ACE_OS::fopen (pub_ready_filename.c_str (), ACE_TEXT("w"));
if (writers_ready == 0)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: Unable to create publisher ready file\n")));
}
// Wait for the subscriber to be ready.
FILE* readers_ready = 0;
do
{
ACE_Time_Value small_time(0,250000);
ACE_OS::sleep (small_time);
readers_ready = ACE_OS::fopen (sub_ready_filename.c_str (), ACE_TEXT("r"));
} while (0 == readers_ready);
ACE_OS::fclose(writers_ready);
ACE_OS::fclose(readers_ready);
// ensure the associations are fully established before writing.
ACE_OS::sleep(3);
{ // Extra scope for VC6
for (int i = 0; i < num_datawriters; i ++)
{
writers[i]->start ();
}
}
int timeout_writes = 0;
bool writers_finished = false;
while ( !writers_finished )
{
writers_finished = true;
for (int i = 0; i < num_datawriters; i ++)
{
writers_finished = writers_finished && writers[i]->is_finished();
}
}
{ // Extra scope for VC6
for (int i = 0; i < num_datawriters; i ++)
{
timeout_writes += writers[i]->get_timeout_writes();
}
}
// Indicate that the publisher is done
FILE* writers_completed = ACE_OS::fopen (pub_finished_filename.c_str (), ACE_TEXT("w"));
if (writers_completed == 0)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: Unable to i publisher completed file\n")));
}
else
{
ACE_OS::fprintf (writers_completed, "%d\n", timeout_writes);
}
// Wait for the subscriber to finish.
FILE* readers_completed = 0;
do
{
ACE_Time_Value small_time(0,250000);
ACE_OS::sleep (small_time);
readers_completed = ACE_OS::fopen (sub_finished_filename.c_str (), ACE_TEXT("r"));
} while (0 == readers_completed);
ACE_OS::fclose(writers_completed);
ACE_OS::fclose(readers_completed);
{ // Extra scope for VC6
for (int i = 0; i < num_datawriters; i ++)
{
writers[i]->end ();
delete writers[i];
}
}
}
catch (const TestException&)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT("(%P|%t) TestException caught in main (). ")));
//.........这里部分代码省略.........
示例6: ACE_TMAIN
int ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
int status = 0;
try
{
ACE_DEBUG((LM_INFO,"(%P|%t) %T subscriber main\n"));
dpf = TheParticipantFactoryWithArgs(argc, argv);
// let the Service_Participant (in above line) strip out -DCPSxxx parameters
// and then get application specific parameters.
parse_args (argc, argv);
init_listener ();
init_dcps_objects (0);
init_dcps_objects (1);
// Indicate that the subscriber is ready
FILE* readers_ready = ACE_OS::fopen (sub_ready_filename.c_str (), ACE_TEXT("w"));
if (readers_ready == 0)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: Unable to create subscriber completed file\n")));
}
// Wait for the publisher to be ready
FILE* writers_ready = 0;
do
{
ACE_Time_Value small_time(0,250000);
ACE_OS::sleep (small_time);
writers_ready = ACE_OS::fopen (pub_ready_filename.c_str (), ACE_TEXT("r"));
} while (0 == writers_ready);
ACE_OS::fclose(readers_ready);
ACE_OS::fclose(writers_ready);
int expected
= num_datawriters * num_instances_per_writer * num_samples_per_instance;
FILE* writers_completed = 0;
int timeout_writes = 0;
while ( num_reads < expected)
{
// Get the number of the timed out writes from publisher so we
// can re-calculate the number of expected messages. Otherwise,
// the blocking timeout test will never exit from this loop.
if (writers_completed == 0)
{
writers_completed = ACE_OS::fopen (pub_finished_filename.c_str (), ACE_TEXT("r"));
if (writers_completed != 0)
{
//writers_completed = ACE_OS::fopen (pub_finished_filename.c_str (), ACE_TEXT("r"));
fscanf (writers_completed, "%d\n", &timeout_writes);
expected -= timeout_writes;
ACE_DEBUG((LM_DEBUG,
ACE_TEXT ("(%P|%t) timed out writes %d, we expect %d\n"),
timeout_writes, expected));
}
}
ACE_OS::sleep (1);
}
// Indicate that the subscriber is done
FILE* readers_completed = ACE_OS::fopen (sub_finished_filename.c_str (), ACE_TEXT("w"));
if (readers_completed == 0)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: Unable to create subscriber completed file\n")));
}
// Wait for the publisher to finish
while (writers_completed == 0)
{
ACE_Time_Value small_time(0,250000);
ACE_OS::sleep (small_time);
writers_completed = ACE_OS::fopen (pub_finished_filename.c_str (), ACE_TEXT("r"));
}
ACE_OS::fclose(readers_completed);
ACE_OS::fclose(writers_completed);
}
catch (const TestException&)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT("(%P|%t) TestException caught in main (). ")));
status = 1;
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught in main ():");
status = 1;
}
try
{
for (int i = 0; i < 2; ++i)
//.........这里部分代码省略.........
示例7: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
DDS::DomainParticipantFactory_var dpf;
DDS::DomainParticipant_var participant;
dpf = TheParticipantFactoryWithArgs(argc, argv);
participant =
dpf->create_participant(11,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (participant.in ())) {
cerr << "create_participant failed." << endl;
return 1 ;
}
Messenger::MessageTypeSupportImpl* mts_servant =
new Messenger::MessageTypeSupportImpl;
if (DDS::RETCODE_OK != mts_servant->register_type(participant.in (),
""))
{
cerr << "Failed to register the MessageTypeTypeSupport." << endl;
exit(1);
}
CORBA::String_var type_name = mts_servant->get_type_name ();
DDS::TopicQos topic_qos;
participant->get_default_topic_qos(topic_qos);
DDS::Topic_var topic =
participant->create_topic("Movie Discussion List",
type_name.in (),
topic_qos,
DDS::TopicListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (topic.in ())) {
cerr << "Failed to create_topic." << endl;
exit(1);
}
// Create the subscriber and attach to the corresponding
// transport.
DDS::Subscriber_var sub =
participant->create_subscriber (SUBSCRIBER_QOS_DEFAULT,
DDS::SubscriberListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (sub.in ())) {
cerr << "Failed to create_subscriber." << endl;
exit(1);
}
// ----------------------------------------------
{
// Attempt to create a DataReader with intentionally
// incompatible QoS.
DDS::DataReaderQos bogus_qos;
sub->get_default_datareader_qos (bogus_qos);
// Set up a 2 second recurring deadline. DataReader creation
// should fail with this QoS since the requested deadline period
// will be less than the test configured offered deadline
// period.
bogus_qos.deadline.period.sec = 2;
bogus_qos.deadline.period.nanosec = 0;
DDS::DataReader_var tmp_dr =
sub->create_datareader (topic.in (),
bogus_qos,
DDS::DataReaderListener::_nil (),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (tmp_dr.in ()))
{
cerr << "ERROR: DataReader creation with bogus QoS failed."
<< endl;
exit (1);
}
DDS::StatusCondition_var cond = tmp_dr->get_statuscondition();
cond->set_enabled_statuses(DDS::REQUESTED_INCOMPATIBLE_QOS_STATUS);
DDS::WaitSet_var ws = new DDS::WaitSet;
ws->attach_condition(cond);
DDS::Duration_t four_sec = {4, 0};
DDS::ConditionSeq active;
ws->wait(active, four_sec);
// Check if the incompatible deadline was correctly flagged.
if ((active.length() == 0) || (active[0] != cond)) {
cerr << "ERROR: Failed to get requested incompatible qos status" << endl;
exit (1);
}
DDS::RequestedIncompatibleQosStatus incompatible_status;
if (tmp_dr->get_requested_incompatible_qos_status (incompatible_status) != ::DDS::RETCODE_OK)
{
cerr << "ERROR: Failed to get requested incompatible qos status" << endl;
//.........这里部分代码省略.........
示例8: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
DDS::DomainParticipantFactory_var dpf;
DDS::DomainParticipant_var participant;
dpf = TheParticipantFactoryWithArgs(argc, argv);
participant =
dpf->create_participant(411,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil());
if (CORBA::is_nil (participant.in ())) {
cerr << "create_participant failed." << endl;
return 1 ;
}
Messenger::MessageTypeSupportImpl* mts_servant =
new Messenger::MessageTypeSupportImpl;
if (DDS::RETCODE_OK != mts_servant->register_type(participant.in (),
""))
{
cerr << "Failed to register the MessageTypeTypeSupport." << endl;
exit(1);
}
CORBA::String_var type_name = mts_servant->get_type_name ();
DDS::TopicQos topic_qos;
participant->get_default_topic_qos(topic_qos);
DDS::Topic_var topic =
participant->create_topic("Movie Discussion List",
type_name.in (),
topic_qos,
DDS::TopicListener::_nil());
if (CORBA::is_nil (topic.in ())) {
cerr << "Failed to create_topic." << endl;
exit(1);
}
// Initialize the transport
OpenDDS::DCPS::TransportImpl_rch tcp_impl =
TheTransportFactory->create_transport_impl (
transport_impl_id,
::OpenDDS::DCPS::AUTO_CONFIG);
// Create the first subscriber belongs to PARTITION A
DDS::SubscriberQos sub_qos1;
participant->get_default_subscriber_qos (sub_qos1);
sub_qos1.partition.name.length (1);
sub_qos1.partition.name[0] = PARTITION_A;
DDS::Subscriber_var sub1 =
participant->create_subscriber (sub_qos1,
DDS::SubscriberListener::_nil());
if (CORBA::is_nil (sub1.in ())) {
cerr << "Failed to create_subscriber." << endl;
exit(1);
}
// Create the second subscriber belongs to PARTITION B
DDS::SubscriberQos sub_qos2;
participant->get_default_subscriber_qos (sub_qos2);
sub_qos2.partition.name.length (1);
sub_qos2.partition.name[0] = PARTITION_B;
DDS::Subscriber_var sub2 =
participant->create_subscriber (sub_qos2,
DDS::SubscriberListener::_nil());
if (CORBA::is_nil (sub2.in ())) {
cerr << "Failed to create_subscriber." << endl;
exit(1);
}
// Attach the subscribers to the transport.
OpenDDS::DCPS::SubscriberImpl* sub_impl1 =
dynamic_cast<OpenDDS::DCPS::SubscriberImpl*> (sub1.in ());
if (0 == sub_impl1) {
cerr << "Failed to obtain subscriber1 servant \n" << endl;
exit(1);
}
OpenDDS::DCPS::SubscriberImpl* sub_impl2 =
dynamic_cast<OpenDDS::DCPS::SubscriberImpl*> (sub2.in ());
if (0 == sub_impl2) {
cerr << "Failed to obtain subscriber2 servant \n" << endl;
exit(1);
}
OpenDDS::DCPS::AttachStatus status =
sub_impl1->attach_transport(tcp_impl.in());
if (status != OpenDDS::DCPS::ATTACH_OK) {
std::string status_str;
switch (status) {
case OpenDDS::DCPS::ATTACH_BAD_TRANSPORT:
status_str = "ATTACH_BAD_TRANSPORT";
break;
//.........这里部分代码省略.........
示例9: listener
int
ACE_TMAIN(int argc, ACE_TCHAR* argv[])
{
try {
DDS::DomainParticipantFactory_var dpf;
DDS::DomainParticipant_var participant;
dpf = TheParticipantFactoryWithArgs(argc, argv);
participant =
dpf->create_participant(411,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (participant.in ())) {
cerr << "create_participant failed." << endl;
return 1 ;
}
MessageTypeSupportImpl* mts_servant = new MessageTypeSupportImpl;
if (DDS::RETCODE_OK != mts_servant->register_type(participant.in (),
"")) {
cerr << "Failed to register the MessageTypeTypeSupport." << endl;
exit(1);
}
CORBA::String_var type_name = mts_servant->get_type_name ();
DDS::TopicQos topic_qos;
participant->get_default_topic_qos(topic_qos);
DDS::Topic_var topic =
participant->create_topic("Movie Discussion List",
type_name.in (),
topic_qos,
DDS::TopicListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (topic.in ())) {
cerr << "Failed to create_topic." << endl;
exit(1);
}
// Create the subscriber and attach to the corresponding
// transport.
DDS::Subscriber_var sub =
participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT,
DDS::SubscriberListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (sub.in ())) {
cerr << "Failed to create_subscriber." << endl;
exit(1);
}
// activate the listener
DDS::DataReaderListener_var listener (new DataReaderListenerImpl);
if (CORBA::is_nil (listener.in ())) {
cerr << "listener is nil." << endl;
exit(1);
}
DataReaderListenerImpl* listener_servant =
dynamic_cast<DataReaderListenerImpl*>(listener.in());
// Create the Datareaders
DDS::DataReaderQos dr_qos;
sub->get_default_datareader_qos (dr_qos);
DDS::DataReader_var dr
= sub->create_datareader(topic.in (),
dr_qos,
listener.in (),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dr.in ())) {
cerr << "create_datareader failed." << endl;
exit(1);
}
while ( ! listener_servant->received_all ()) {
ACE_OS::sleep (1);
}
if (! listener_servant->passed ()) {
cerr << "test failed - see errors." << endl;
return 1;
}
if (!CORBA::is_nil (participant.in ())) {
participant->delete_contained_entities();
}
if (!CORBA::is_nil (dpf.in ())) {
dpf->delete_participant(participant.in ());
}
::DDS::InstanceHandleSeq handles;
while (1)
{
ACE_OS::sleep(1);
dr->get_matched_publications(handles);
if (handles.length() == 0)
break;
}
//.........这里部分代码省略.........
示例10: main
int main (int argc, char *argv[])
{
const int domainId = 411;
const char *topicName = "Stock Quotes";
try {
DDS::DomainParticipantFactory_var dpf;
DDS::DomainParticipant_var participant;
dpf = TheParticipantFactoryWithArgs(argc, argv);
// To Do: Create the participant
participant =
dpf->create_participant(domainId,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil());
if (CORBA::is_nil (participant.in ())) {
cerr << "create_participant failed." << endl;
return 1 ;
}
// End: Create the participant
QuoterTypeSupportImpl* servant = new QuoterTypeSupportImpl();
PortableServer::ServantBase_var safe_servant = servant;
// To Do: Register the type
if (DDS::RETCODE_OK != servant->register_type(participant.in (),
"")) {
cerr << "Failed to register the QuoterTypeTypeSupport." << endl;
exit(1);
}
// End: Register the type
CORBA::String_var type_name = servant->get_type_name ();
// To Do: Get the (default) topic QoS and create the topic
DDS::TopicQos topic_qos;
participant->get_default_topic_qos(topic_qos);
DDS::Topic_var topic =
participant->create_topic(topicName,
type_name.in (),
topic_qos,
DDS::TopicListener::_nil());
if (CORBA::is_nil (topic.in ())) {
cerr << "Failed to create_topic." << endl;
exit(1);
}
// End: Get the (default) topic QoS and create the topic
// To Do: Create the subscriber
DDS::Subscriber_var sub =
participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT,
DDS::SubscriberListener::_nil());
if (CORBA::is_nil (sub.in ())) {
cerr << "Failed to create_subscriber." << endl;
exit(1);
}
// End: Create the subscriber
// jhoffert
// There seem to be problems using auto configurations with an application
// distributed across different nodes. Take this out for now.
// Initialize the transport
TAO::DCPS::TransportImpl_rch tcp_impl =
TheTransportFactory->create_transport_impl (TCP_IMPL_ID,
//::TAO::DCPS::AUTO_CONFIG);
::TAO::DCPS::DONT_AUTO_CONFIG);
TAO::DCPS::TransportConfiguration_rch reader_config =
//TheTransportFactory->get_configuration (SUB_TRAFFIC);
TheTransportFactory->get_configuration (TCP_IMPL_ID);
TAO::DCPS::SimpleTcpConfiguration* reader_tcp_config =
static_cast <TAO::DCPS::SimpleTcpConfiguration*> (reader_config.in ());
if (0 != ACE_OS::strcmp ("default", reader_address_str)) {
ACE_INET_Addr reader_address (reader_address_str);
reader_tcp_config->local_address_ = reader_address;
}
if (0 != tcp_impl->configure (reader_config.in ())) {
ACE_ERROR ((LM_ERROR,
ACE_TEXT("(%P|%t) ::main: ")
ACE_TEXT("Failed to configure the transport.\n")));
exit(1);
}
// jhoffert - End of transport configuration changes
// Attach the subscriber to the transport.
TAO::DCPS::SubscriberImpl* sub_impl =
::TAO::DCPS::reference_to_servant< TAO::DCPS::SubscriberImpl,
DDS::Subscriber_ptr> (sub.in ());
if (0 == sub_impl) {
cerr << "Failed to obtain subscriber servant\n" << endl;
exit(1);
}
TAO::DCPS::AttachStatus status = sub_impl->attach_transport(tcp_impl.in());
if (status != TAO::DCPS::ATTACH_OK) {
std::string status_str;
//.........这里部分代码省略.........
示例11: main
int main (int argc, char *argv[])
{
try {
DDS::DomainParticipantFactory_var dpf;
DDS::DomainParticipant_var participant;
dpf = TheParticipantFactoryWithArgs(argc, argv);
if( parse_args(argc, argv) != 0)
return 1;
participant =
dpf->create_participant(411,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil());
if (CORBA::is_nil (participant.in ())) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) create_participant failed.\n")
, -1);
}
MessageTypeSupportImpl* mts_servant = new MessageTypeSupportImpl();
PortableServer::ServantBase_var safe_servant = mts_servant;
if (DDS::RETCODE_OK != mts_servant->register_type(participant.in (),
"")) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Failed to register the MessageTypeTypeSupport.\n")
, -1);
}
CORBA::String_var type_name = mts_servant->get_type_name ();
DDS::TopicQos topic_qos;
participant->get_default_topic_qos(topic_qos);
DDS::Topic_var topic =
participant->create_topic("Movie Discussion List",
type_name.in (),
topic_qos,
DDS::TopicListener::_nil());
if (CORBA::is_nil (topic.in ())) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Failed to create_topic.\n")
, -1);
}
// Initialize the transport
TAO::DCPS::TransportImpl_rch tcp_impl =
TheTransportFactory->create_transport_impl (TCP_IMPL_ID, ::TAO::DCPS::AUTO_CONFIG);
// Indicate that the subscriber is about to become ready
FILE* readers_ready = ACE_OS::fopen (sub_ready_filename, "w");
if (readers_ready == 0) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) ERROR Unable to create subscriber ready file.\n")
, -1);
}
ACE_OS::fclose(readers_ready);
// Check if the publisher is up and running
ACE_stat stats;
while (ACE_OS::stat (pub_ready_filename, &stats) == -1)
{
ACE_Time_Value small(0,250000);
ACE_OS::sleep (small);
}
for (int count = 1; count <= sub_reinit_itr; count++)
{
if (verbose) {
ACE_DEBUG ((LM_DEBUG, "(%P|%t) Reinitializing subscriber.\n"));
}
// Create the subscriber and attach to the corresponding
// transport.
DDS::Subscriber_var sub =
participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT,
DDS::SubscriberListener::_nil());
if (CORBA::is_nil (sub.in ())) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Failed to create_subscriber.\n")
, -1);
}
// Attach the subscriber to the transport.
TAO::DCPS::SubscriberImpl* sub_impl =
::TAO::DCPS::reference_to_servant
< TAO::DCPS::SubscriberImpl, DDS::Subscriber_ptr> (sub.in ());
if (0 == sub_impl) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Failed to obtain subscriber servant.\n")
, -1);
}
TAO::DCPS::AttachStatus status = sub_impl->attach_transport(tcp_impl.in());
if (status != TAO::DCPS::ATTACH_OK)
{
std::string status_str;
switch (status)
{
case TAO::DCPS::ATTACH_BAD_TRANSPORT:
//.........这里部分代码省略.........
示例12: ACE_TMAIN
int ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
DDS::DomainParticipantFactory_var dpf;
DDS::DomainParticipant_var participant;
dpf = TheParticipantFactoryWithArgs(argc, argv);
participant = dpf->create_participant(111,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (participant.in ())) {
cerr << "create_participant failed." << endl;
return 1 ;
}
Messenger::MessageTypeSupport_var mts_servant =
new Messenger::MessageTypeSupportImpl;
if (DDS::RETCODE_OK != mts_servant->register_type (participant.in (),
""))
{
cerr << "Failed to register the MessageTypeTypeSupport." << endl;
exit(1);
}
CORBA::String_var type_name = mts_servant->get_type_name ();
DDS::TopicQos topic_qos;
participant->get_default_topic_qos(topic_qos);
topic_qos.lifespan.duration.sec = 10;
topic_qos.lifespan.duration.nanosec = 0;
topic_qos.durability.kind = DDS::TRANSIENT_LOCAL_DURABILITY_QOS;
DDS::Topic_var topic =
participant->create_topic ("Movie Discussion List",
type_name.in (),
topic_qos,
DDS::TopicListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (topic.in ()))
{
cerr << "Failed to create_topic." << endl;
exit(1);
}
// Create the subscriber and attach to the corresponding
// transport.
DDS::Subscriber_var sub =
participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT,
DDS::SubscriberListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (sub.in ()))
{
cerr << "Failed to create_subscriber." << endl;
exit(1);
}
// activate the listener
DDS::DataReaderListener_var listener (new DataReaderListenerImpl);
DataReaderListenerImpl* const listener_servant =
dynamic_cast<DataReaderListenerImpl*>(listener.in());
if (CORBA::is_nil (listener.in ())) {
cerr << "listener is nil." << endl;
exit(1);
}
if (!listener_servant) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: listener_servant is nil (dynamic_cast failed)!\n")), -1);
}
// Create the Datareaders
DDS::DataReader_var dr = sub->create_datareader(topic.in (),
DATAREADER_QOS_USE_TOPIC_QOS,
listener.in (),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dr.in ())) {
cerr << "create_datareader failed." << endl;
exit(1);
}
ACE_OS::sleep (10);
if (listener_servant->num_reads () != 1)
{
cerr << "ERROR: Incorrect number of samples received." << endl
<< " Expired data was probably read." << endl;
exit (1);
}
if (!CORBA::is_nil (participant.in ())) {
participant->delete_contained_entities();
}
if (!CORBA::is_nil (dpf.in ())) {
dpf->delete_participant(participant.in ());
}
ACE_OS::sleep(2);
TheServiceParticipant->shutdown ();
//.........这里部分代码省略.........
示例13: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
DDS::DomainParticipantFactory_var dpf;
DDS::DomainParticipant_var participant;
dpf = TheParticipantFactoryWithArgs(argc, argv);
if( parse_args(argc, argv) != 0)
return 1;
participant =
dpf->create_participant(411,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (participant.in ())) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) create_participant failed.\n")
, -1);
}
MessageTypeSupportImpl* mts_servant = new MessageTypeSupportImpl;
if (DDS::RETCODE_OK != mts_servant->register_type(participant.in (),
"")) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Failed to register the MessageTypeTypeSupport.\n")
, -1);
}
CORBA::String_var type_name = mts_servant->get_type_name ();
DDS::TopicQos topic_qos;
participant->get_default_topic_qos(topic_qos);
DDS::Topic_var topic =
participant->create_topic("Movie Discussion List",
type_name.in (),
topic_qos,
DDS::TopicListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (topic.in ())) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Failed to create_topic.\n")
, -1);
}
// Indicate that the subscriber is about to become ready
FILE* readers_ready = ACE_OS::fopen (sub_ready_filename, ACE_TEXT("w"));
if (readers_ready == 0) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) ERROR: Unable to create subscriber ready file.\n")
, -1);
}
ACE_OS::fclose(readers_ready);
// Check if the publisher is up and running
ACE_stat stats;
while (ACE_OS::stat (pub_ready_filename, &stats) == -1)
{
ACE_Time_Value small_time(0,250000);
ACE_OS::sleep (small_time);
}
for (int count = 1; count <= sub_reinit_itr; count++)
{
if (verbose) {
ACE_DEBUG ((LM_DEBUG, "(%P|%t) Reinitializing subscriber.\n"));
}
// Create the subscriber and attach to the corresponding
// transport.
DDS::Subscriber_var sub =
participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT,
DDS::SubscriberListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (sub.in ())) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Failed to create_subscriber.\n")
, -1);
}
// Create the Datareaders
DDS::DataReaderQos dr_qos;
sub->get_default_datareader_qos (dr_qos);
DDS::DataReader_var dr = sub->create_datareader(topic.in (),
dr_qos,
DDS::DataReaderListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dr.in ())) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) create_datareader failed.\n")
, -1);
}
// This is where a speed-bump should be.
while (true)
{
::DDS::InstanceHandleSeq handles;
dr->get_matched_publications (handles);
//.........这里部分代码省略.........
示例14: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
DDS::DomainParticipantFactory_var dpf;
DDS::DomainParticipant_var participant;
dpf = TheParticipantFactoryWithArgs(argc, argv);
// Default DomainParticipantFactory qos is to auto enable.
::DDS::DomainParticipantFactoryQos fqos;
if (dpf->get_qos (fqos) != ::DDS::RETCODE_OK)
{
cerr << "DomainParticipantFactory get_qos failed." << endl;
return 1;
}
if (fqos.entity_factory.autoenable_created_entities == 0)
{
cerr << "The DomainParticipantFactory defaults to autoenable upon entities creation." << endl;
return 1;
}
// Now disable DomainParticipantFactory autoenable
fqos.entity_factory.autoenable_created_entities = 0;
if (dpf->set_qos (fqos) != ::DDS::RETCODE_OK)
{
cerr << "DomainParticipantFactory set_qos failed." << endl;
return 1;
}
participant = dpf->create_participant(411,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (participant.in ())) {
cerr << "create_participant failed." << endl;
return 1 ;
}
if (participant->enable () != ::DDS::RETCODE_PRECONDITION_NOT_MET)
{
cerr << "DomainParticipant can not be enabled because factory autoenable is off." << endl;
return 1;
}
MessageTypeSupport_var mts = new MessageTypeSupportImpl();
if (DDS::RETCODE_OK != mts->register_type(participant.in (), "")) {
cerr << "Failed to register the MessageTypeTypeSupport." << endl;
exit(1);
}
CORBA::String_var type_name = mts->get_type_name ();
DDS::Topic_var topic = participant->create_topic("Movie Discussion List",
type_name.in (),
TOPIC_QOS_DEFAULT,
DDS::TopicListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (topic.in ())) {
cerr << "Failed to create_topic." << endl;
exit(1);
}
if (topic->enable () != ::DDS::RETCODE_PRECONDITION_NOT_MET)
{
cerr << "Topic can not be enabled because DomainParticipant is not enabled." << endl;
return 1;
}
// Initialize the transport
OpenDDS::DCPS::TransportImpl_rch transport_impl =
TheTransportFactory->create_transport_impl (transport_impl_id,
::OpenDDS::DCPS::AUTO_CONFIG);
// Create the subscriber and attach to the corresponding
// transport.
DDS::Subscriber_var sub =
participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT,
DDS::SubscriberListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (sub.in ())) {
cerr << "Failed to create_subscriber." << endl;
exit(1);
}
if (sub->enable () != ::DDS::RETCODE_PRECONDITION_NOT_MET)
{
cerr << "Publisher can not be enabled because DomainParticipant is not enabled." << endl;
return 1;
}
// Attach the subscriber to the transport.
OpenDDS::DCPS::SubscriberImpl* sub_impl =
dynamic_cast<OpenDDS::DCPS::SubscriberImpl*> (sub.in ());
if (0 == sub_impl) {
cerr << "Failed to obtain subscriber servant\n" << endl;
exit(1);
}
//.........这里部分代码省略.........
示例15: ACE_TMAIN
int ACE_TMAIN(int argc, ACE_TCHAR* argv[])
{
try
{
DDS::DomainParticipantFactory_var dpf;
DDS::DomainParticipant_var participant;
dpf = TheParticipantFactoryWithArgs(argc, argv);
participant = dpf->create_participant(411,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (participant.in ())) {
cerr << "create_participant failed." << endl;
return 1 ;
}
Test::DataTypeSupportImpl * const dts_servant =
new Test::DataTypeSupportImpl;
if (DDS::RETCODE_OK != dts_servant->register_type(participant.in (),
""))
{
cerr << "Failed to register the DataTypeSupport." << endl;
exit(1);
}
CORBA::String_var type_name = dts_servant->get_type_name ();
DDS::TopicQos topic_qos;
participant->get_default_topic_qos(topic_qos);
DDS::Topic_var topic =
participant->create_topic("Data",
type_name.in (),
topic_qos,
DDS::TopicListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (topic.in ())) {
cerr << "Failed to create_topic." << endl;
exit(1);
}
size_t const num_partitions =
sizeof (Test::Requested::PartitionConfigs)
/ sizeof (Test::Requested::PartitionConfigs[0]);
Test::PartitionConfig const * const begin =
Test::Requested::PartitionConfigs;
Test::PartitionConfig const * const end =
begin + num_partitions;
// Keep the readers around long enough for the publications and
// subscriptions to match.
std::vector<DDS::DataReader_var> readers (num_partitions);
for (Test::PartitionConfig const * i = begin; i != end; ++i)
{
DDS::SubscriberQos sub_qos;
participant->get_default_subscriber_qos (sub_qos);
// Specify partitions we're requesting.
CORBA::ULong n = 0;
DDS::StringSeq & names = sub_qos.partition.name;
for (char const * const * s = (*i).partitions;
s != 0 && *s != 0;
++s, ++n)
{
CORBA::ULong const new_len = names.length () + 1;
names.length (new_len);
names[n] = *s;
}
// Create the subscriber and attach to the corresponding
// transport.
DDS::Subscriber_var sub =
participant->create_subscriber (sub_qos,
DDS::SubscriberListener::_nil (),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (sub.in ()))
{
cerr << "Failed to create_subscriber." << endl;
exit(1);
}
DDS::DataReaderListener_var listener (
new Test::DataReaderListener ((*i).expected_matches));
// Create the Datareaders
DDS::DataReaderQos dr_qos;
sub->get_default_datareader_qos (dr_qos);
DDS::DataReader_var dr = sub->create_datareader (topic.in (),
dr_qos,
listener.in (),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dr.in ())) {
cerr << "create_datareader failed." << endl;
exit(1);
}
readers.push_back (dr);
//.........这里部分代码省略.........