本文整理汇总了C++中dds::Publisher_var::in方法的典型用法代码示例。如果您正苦于以下问题:C++ Publisher_var::in方法的具体用法?C++ Publisher_var::in怎么用?C++ Publisher_var::in使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dds::Publisher_var
的用法示例。
在下文中一共展示了Publisher_var::in方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
DDS::Publisher_var
Factory::publisher(const DDS::DomainParticipant_var& dp) const
{
DDS::PublisherQos pub_qos;
dp->get_default_publisher_qos(pub_qos);
if (opts_.entity_str == "rw")
{
pub_qos.entity_factory.autoenable_created_entities = opts_.entity_autoenable;
}
// Create the publisher
DDS::Publisher_var pub = dp->create_publisher(pub_qos,
DDS::PublisherListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
TEST_ASSERT(!CORBA::is_nil(pub.in()));
// If there is a ini file-based configuration name initialize
// the transport configuration for the corresponding Entity
if (opts_.configuration_str != "none" && opts_.entity_str == "pubsub")
{
OpenDDS::DCPS::TransportRegistry::instance()->bind_config(opts_.configuration_str, pub.in());
}
return pub;
}
示例2:
void
MonitorFactoryImpl::initialize()
{
DDS::DomainParticipantFactory_var dpf =
TheServiceParticipant->get_domain_participant_factory();
DDS::DomainParticipant_var participant =
dpf->create_participant(MONITOR_DOMAIN_ID,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(participant.in())) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("ERROR: %N:%l: MonitorFactoryImpl::initialize() -")
ACE_TEXT(" create_participant failed!\n")));
}
DDS::Publisher_var publisher =
participant->create_publisher(PUBLISHER_QOS_DEFAULT,
DDS::PublisherListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
static const std::string config_name = TransportRegistry::DEFAULT_INST_PREFIX
+ std::string("MonitorBITTransportConfig");
OpenDDS::DCPS::TransportConfig_rch config =
TheTransportRegistry->get_config (config_name);
if (config.is_nil ())
{
config = TransportRegistry::instance()->create_config(config_name);
std::string inst_name = TransportRegistry::DEFAULT_INST_PREFIX
+ std::string("FederationBITTCPTransportInst");
TransportInst_rch inst =
TransportRegistry::instance()->create_inst(inst_name, "tcp");
config->instances_.push_back(inst);
}
TransportRegistry::instance()->bind_config(config, publisher.in());
DDS::DataWriter_var writer;
DDS::DataWriterQos dw_qos;
publisher->get_default_datawriter_qos(dw_qos);
dw_qos.durability.kind = DDS::TRANSIENT_LOCAL_DURABILITY_QOS;
OpenDDS::DCPS::ServiceParticipantReportTypeSupport_var sp_ts =
new OpenDDS::DCPS::ServiceParticipantReportTypeSupportImpl();
::DDS::ReturnCode_t ret = sp_ts->register_type(participant.in(), "");
if (DDS::RETCODE_OK == ret) {
CORBA::String_var sp_type_name = sp_ts->get_type_name();
writer = create_data_writer(participant.in(),
publisher.in(),
sp_type_name.in(),
SERVICE_PARTICIPANT_MONITOR_TOPIC,
dw_qos);
this->sp_writer_ =
OpenDDS::DCPS::ServiceParticipantReportDataWriter::_narrow(writer.in());
if (CORBA::is_nil(this->sp_writer_)) {
ACE_DEBUG((LM_DEBUG, "MonitorFactoryImpl::initialize(): Failed to narrow sp_writer\n"));
}
} else {
ACE_DEBUG((LM_DEBUG, "MonitorFactoryImpl::initialize(): Failed to register sp_ts\n"));
}
OpenDDS::DCPS::DomainParticipantReportTypeSupport_var dp_ts =
new OpenDDS::DCPS::DomainParticipantReportTypeSupportImpl();
ret = dp_ts->register_type(participant.in(), "");
if (DDS::RETCODE_OK == ret) {
CORBA::String_var dp_type_name = dp_ts->get_type_name();
writer = create_data_writer(participant.in(),
publisher.in(),
dp_type_name.in(),
DOMAIN_PARTICIPANT_MONITOR_TOPIC,
dw_qos);
this->dp_writer_ =
OpenDDS::DCPS::DomainParticipantReportDataWriter::_narrow(writer.in());
if (CORBA::is_nil(this->dp_writer_)) {
ACE_DEBUG((LM_DEBUG, "MonitorFactoryImpl::initialize(): Failed to narrow dp_writer\n"));
}
} else {
ACE_DEBUG((LM_DEBUG, "MonitorFactoryImpl::initialize(): Failed to register dp_ts\n"));
}
OpenDDS::DCPS::TopicReportTypeSupport_var topic_ts =
new OpenDDS::DCPS::TopicReportTypeSupportImpl();
ret = topic_ts->register_type(participant.in(), "");
if (DDS::RETCODE_OK == ret) {
CORBA::String_var topic_type_name = topic_ts->get_type_name();
writer = create_data_writer(participant.in(),
publisher.in(),
topic_type_name.in(),
TOPIC_MONITOR_TOPIC,
dw_qos);
this->topic_writer_ =
OpenDDS::DCPS::TopicReportDataWriter::_narrow(writer.in());
if (CORBA::is_nil(this->topic_writer_)) {
ACE_DEBUG((LM_DEBUG, "MonitorFactoryImpl::initialize(): Failed to narrow topic_writer\n"));
}
} else {
ACE_DEBUG((LM_DEBUG, "MonitorFactoryImpl::initialize(): Failed to register topic_ts\n"));
}
//.........这里部分代码省略.........
示例3: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) {
int status = 0;
try
{
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
DDS::DomainParticipant_var 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;
}
DDS::DomainParticipant_var participant2 =
dpf->create_participant(411,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (participant2.in ())) {
cerr << "create_participant failed." << endl;
return 1;
}
OpenDDS::DCPS::TransportConfig_rch cfg = TheTransportRegistry->get_config("part1");
if (!cfg.is_nil()) {
TheTransportRegistry->bind_config(cfg, participant);
}
cfg = TheTransportRegistry->get_config("part2");
if (!cfg.is_nil()) {
TheTransportRegistry->bind_config(cfg, participant2);
}
if (parse_args (argc, argv) == -1) {
return -1;
}
MessageTypeSupport_var mts = new MessageTypeSupportImpl();
MessageTypeSupport_var mts2 = new MessageTypeSupportImpl();
if (DDS::RETCODE_OK != mts->register_type(participant.in (), "")) {
cerr << "register_type failed." << endl;
exit(1);
}
if (DDS::RETCODE_OK != mts2->register_type(participant2.in (), "")) {
cerr << "register_type failed." << endl;
exit(1);
}
CORBA::String_var type_name = mts->get_type_name ();
CORBA::String_var type_name2 = mts2->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 << "create_topic failed." << endl;
exit(1);
}
DDS::Topic_var topic2 =
participant2->create_topic ("Movie Discussion List",
type_name2.in (),
TOPIC_QOS_DEFAULT,
DDS::TopicListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (topic2.in ())) {
cerr << "create_topic failed." << endl;
exit(1);
}
DDS::Publisher_var pub =
participant->create_publisher(PUBLISHER_QOS_DEFAULT,
DDS::PublisherListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (pub.in ())) {
cerr << "create_publisher failed." << endl;
exit(1);
}
DDS::Publisher_var pub2 =
participant2->create_publisher(PUBLISHER_QOS_DEFAULT,
DDS::PublisherListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (pub2.in ())) {
cerr << "create_publisher failed." << endl;
exit(1);
}
DataWriterListenerImpl * dwl1_servant = new DataWriterListenerImpl;
::DDS::DataWriterListener_var dwl1 (dwl1_servant);
DataWriterListenerImpl * dwl2_servant = new DataWriterListenerImpl;
::DDS::DataWriterListener_var dwl2 (dwl2_servant);
DataWriterListenerImpl * dwl3_servant = new DataWriterListenerImpl;
::DDS::DataWriterListener_var dwl3 (dwl3_servant);
DataWriterListenerImpl * dwl4_servant = new DataWriterListenerImpl;
::DDS::DataWriterListener_var dwl4 (dwl4_servant);
//.........这里部分代码省略.........
示例4: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) {
try {
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
DDS::DomainParticipant_var 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* servant = new MessageTypeSupportImpl;
if (DDS::RETCODE_OK != servant->register_type(participant.in (), "")) {
cerr << "register_type failed." << endl;
exit(1);
}
CORBA::String_var type_name = 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 << "create_topic failed." << endl;
exit(1);
}
DDS::Publisher_var pub =
participant->create_publisher(PUBLISHER_QOS_DEFAULT,
DDS::PublisherListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (pub.in ())) {
cerr << "create_publisher failed." << endl;
exit(1);
}
// Create the datawriter
DDS::DataWriterQos dw_qos;
pub->get_default_datawriter_qos (dw_qos);
DDS::DataWriter_var dw =
pub->create_datawriter(topic.in (),
dw_qos,
DDS::DataWriterListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dw.in ())) {
cerr << "create_datawriter failed." << endl;
exit(1);
}
Writer* writer = new Writer(dw.in());
writer->start ();
while ( !writer->is_finished()) {
ACE_Time_Value small_time(0,250000);
ACE_OS::sleep (small_time);
}
// Cleanup
writer->end();
delete writer;
participant->delete_contained_entities();
dpf->delete_participant(participant);
TheServiceParticipant->shutdown();
} catch (CORBA::Exception& e) {
cerr << "Exception caught in main.cpp:" << endl
<< e << endl;
exit(1);
}
return 0;
}
示例5: guard
int
ParticipantTask::svc()
{
try
{
ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) -> PARTICIPANT STARTED\n")));
DDS::DomainParticipantFactory_var dpf = TheParticipantFactory;
DDS::DomainParticipant_var participant;
DDS::Publisher_var publisher;
DDS::DataWriter_var writer;
FooDataWriter_var writer_i;
DDS::StatusCondition_var cond;
DDS::WaitSet_var ws = new DDS::WaitSet;
{ // Scope for guard to serialize creating Entities.
GuardType guard(lock_);
// Create Participant
participant =
dpf->create_participant(42,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
#ifdef OPENDDS_SAFETY_PROFILE
// RTPS cannot be shared
char config_name[64], inst_name[64];
ACE_OS::snprintf(config_name, 64, "cfg_%d", thread_index_);
ACE_OS::snprintf(inst_name, 64, "rtps_%d", thread_index_);
++thread_index_;
ACE_DEBUG((LM_INFO,
"(%P|%t) -> PARTICIPANT creating transport config %C\n",
config_name));
OpenDDS::DCPS::TransportConfig_rch config =
TheTransportRegistry->create_config(config_name);
OpenDDS::DCPS::TransportInst_rch inst =
TheTransportRegistry->create_inst(inst_name, "rtps_udp");
config->instances_.push_back(inst);
TheTransportRegistry->bind_config(config_name, participant);
#endif
} // End of lock scope.
if (CORBA::is_nil(participant.in()))
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: svc()")
ACE_TEXT(" create_participant failed!\n")), 1);
{
// Create Publisher
publisher =
participant->create_publisher(PUBLISHER_QOS_DEFAULT,
DDS::PublisherListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(publisher.in()))
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: svc()")
ACE_TEXT(" create_publisher failed!\n")), 1);
// Register Type (FooType)
FooTypeSupport_var ts = new FooTypeSupportImpl;
if (ts->register_type(participant.in(), "") != DDS::RETCODE_OK)
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: svc()")
ACE_TEXT(" register_type failed!\n")), 1);
// Create Topic (FooTopic)
DDS::Topic_var topic =
participant->create_topic("FooTopic",
ts->get_type_name(),
TOPIC_QOS_DEFAULT,
DDS::TopicListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(topic.in()))
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: svc()")
ACE_TEXT(" create_topic failed!\n")), 1);
// Create DataWriter
DDS::DataWriterQos writer_qos;
publisher->get_default_datawriter_qos(writer_qos);
#ifndef OPENDDS_NO_OWNERSHIP_PROFILE
writer_qos.history.depth = samples_per_thread_;
#endif
writer =
publisher->create_datawriter(topic.in(),
writer_qos,
DDS::DataWriterListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(writer.in()))
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: svc()")
ACE_TEXT(" create_datawriter failed!\n")), 1);
//.........这里部分代码省略.........
示例6: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]){
try
{
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
DDS::DomainParticipant_var participant =
dpf->create_participant(311,
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* servant = new MessageTypeSupportImpl();
if (DDS::RETCODE_OK != servant->register_type(participant.in (), "")) {
cerr << "register_type failed." << endl;
exit(1);
}
CORBA::String_var type_name = 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 << "create_topic failed." << endl;
exit(1);
}
DDS::PublisherQos pub_qos;
participant->get_default_publisher_qos (pub_qos);
pub_qos.partition.name.length (1);
pub_qos.partition.name[0] = PARTITION_A;
DDS::Publisher_var pub =
participant->create_publisher(pub_qos, DDS::PublisherListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (pub.in ())) {
cerr << "create_publisher failed." << endl;
exit(1);
}
// ----------------------------------------------
// Create DataWriter which is belongs to PARTITION_A
DDS::DataWriter_var dw =
pub->create_datawriter (topic.in (),
DATAWRITER_QOS_DEFAULT,
DDS::DataWriterListener::_nil (),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
int const max_attempts = 15;
int attempts = 1;
// ----------------------------------------------
// Wait for first DataReader that belongs to PARTITION_A too,
// then write samples.
// cache handle for first reader.
::DDS::InstanceHandle_t handle = -1;
{
std::auto_ptr<Writer> writer (new Writer (dw.in ()));
cout << "Pub waiting for match on A partition." << std::endl;
if (OpenDDS::Model::WriterSync::wait_match(dw)) {
cerr << "Error waiting for match on A partition" << std::endl;
return 1;
}
while (attempts != max_attempts)
{
::DDS::InstanceHandleSeq handles;
dw->get_matched_subscriptions(handles);
cout << "Pub matched " << handles.length() << " A subs." << std::endl;
if (handles.length() == 1)
{
handle = handles[0];
break;
}
else
ACE_OS::sleep(1);
++attempts;
}
if (attempts == max_attempts)
{
cerr << "ERROR: failed to wait for first DataReader." << endl;
exit (1);
}
writer->start ();
//.........这里部分代码省略.........
示例7: ACE_TMAIN
int ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try {
// Initialize DomainParticipantFactory
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
int error;
if ((error = parse_args(argc, argv)) != 0) {
return error;
}
// Create DomainParticipant
DDS::DomainParticipant_var participant =
dpf->create_participant(111,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(participant.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_participant failed!\n")),
-1);
}
// Register TypeSupport (Messenger::Message)
Messenger::MessageTypeSupport_var mts =
new Messenger::MessageTypeSupportImpl();
if (mts->register_type(participant.in(), "") != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: register_type failed!\n")),
-1);
}
// Create Topic
DDS::Topic_var topic =
participant->create_topic("Movie Discussion List",
CORBA::String_var(mts->get_type_name()),
TOPIC_QOS_DEFAULT,
DDS::TopicListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(topic.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_topic failed!\n")),
-1);
}
::DDS::PublisherQos publisher_qos;
participant->get_default_publisher_qos (publisher_qos);
publisher_qos.presentation.access_scope = DDS::GROUP_PRESENTATION_QOS;
publisher_qos.presentation.coherent_access = true;
publisher_qos.presentation.ordered_access = true;
// Create Publisher
DDS::Publisher_var pub =
participant->create_publisher(publisher_qos,
DDS::PublisherListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(pub.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_publisher failed!\n")),
-1);
}
::DDS::DataWriterQos dw_qos;
pub->get_default_datawriter_qos (dw_qos);
dw_qos.history.kind = ::DDS::KEEP_ALL_HISTORY_QOS;
dw_qos.resource_limits.max_samples_per_instance = ::DDS::LENGTH_UNLIMITED;
// Create DataWriter
DDS::DataWriter_var dw1 =
pub->create_datawriter(topic.in(),
dw_qos,
DDS::DataWriterListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(dw1.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_datawriter failed!\n")),
-1);
}
DDS::DataWriter_var dw2 =
pub->create_datawriter(topic.in(),
dw_qos,
DDS::DataWriterListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(dw2.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_datawriter failed!\n")),
//.........这里部分代码省略.........
示例8: TheParticipantFactoryWithArgs
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs (argc, argv);
DDS::DomainParticipant_var 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 (parse_args (argc, argv) != 0)
return -1;
if (delete_data)
{
using OpenDDS::FileSystemStorage::Directory;
Directory::create (ACE_TEXT_ALWAYS_CHAR (dir))->remove ();
dpf->delete_participant (participant);
TheServiceParticipant->shutdown ();
return 0;
}
MessageTypeSupport_var servant = new MessageTypeSupportImpl ();
if (DDS::RETCODE_OK != servant->register_type(participant.in (), ""))
{
cerr << "register_type failed." << endl;
exit (1);
}
CORBA::String_var type_name = 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 << "create_topic failed." << endl;
exit (1);
}
DDS::Publisher_var pub =
participant->create_publisher (PUBLISHER_QOS_DEFAULT,
DDS::PublisherListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (pub.in ()))
{
cerr << "create_publisher failed." << endl;
exit (1);
}
// Configure DataWriter QoS policies.
DDS::DataWriterQos dw_qos;
pub->get_default_datawriter_qos (dw_qos);
dw_qos.durability.kind = DDS::PERSISTENT_DURABILITY_QOS;
dw_qos.durability_service.history_kind = ::DDS::KEEP_ALL_HISTORY_QOS;
dw_qos.reliability.kind = ::DDS::RELIABLE_RELIABILITY_QOS;
dw_qos.resource_limits.max_samples_per_instance = 1000;
dw_qos.history.kind = ::DDS::KEEP_ALL_HISTORY_QOS;
// -------------------------------------------------------
{
DataWriterListenerImpl* listener = new DataWriterListenerImpl;
DDS::DataWriterListener_var dwl = listener;
// Create a DataWriter.
// Upon exiting this scope, all unsent data should be
// transferred to OpenDDS's data durability cache since the
// run_test.pl script should not have started the subscriber
// until it detects the "Done writing" log text.
DDS::DataWriter_var dw =
pub->create_datawriter (topic.in (),
dw_qos,
dwl.in (),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dw.in ()))
{
cerr << "create_datawriter failed." << endl;
exit (1);
}
// Only write samples if configured to do so. The expectation
// is to otherwise retrieve the data from the PERSISTENT data
// durability cache.
if (do_write)
//.........这里部分代码省略.........
示例9: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]){
try
{
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
DDS::DomainParticipant_var 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;
}
else
{
ACE_DEBUG ((LM_DEBUG, "Created participant 1 with instance handle %d\n",
participant->get_instance_handle ()));
}
DDS::DomainParticipant_var participant2 =
dpf->create_participant(11,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (participant2.in ())) {
cerr << "create_participant2 failed." << endl;
return 1;
}
else
{
ACE_DEBUG ((LM_DEBUG, "Created participant 2 with instance handle %d\n",
participant2->get_instance_handle ()));
}
// Register TypeSupport (Messenger::Message)
Messenger::MessageTypeSupport_var mts =
new Messenger::MessageTypeSupportImpl();
if (mts->register_type(participant.in(), "") != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: register_type failed!\n")),
-1);
}
// Create Topic
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())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_topic failed!\n")),
-1);
}
// Create Publisher
DDS::Publisher_var pub =
participant->create_publisher(PUBLISHER_QOS_DEFAULT,
DDS::PublisherListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(pub.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_publisher failed!\n")),
-1);
}
// Create DataWriter
DDS::DataWriter_var dw =
pub->create_datawriter(topic.in(),
DATAWRITER_QOS_DEFAULT,
DDS::DataWriterListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(dw.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_datawriter failed!\n")),
-1);
}
DDS::ReturnCode_t retcode = participant2->delete_topic (topic.in ());
if (retcode != DDS::RETCODE_PRECONDITION_NOT_MET) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: should not be able to delete topic, not part of this participant!\n")),
-1);
}
DDS::ReturnCode_t retcode5 = participant->delete_topic (topic.in ());
if (retcode5 != DDS::RETCODE_PRECONDITION_NOT_MET) {
ACE_ERROR_RETURN((LM_ERROR,
//.........这里部分代码省略.........
示例10: test
int
ACE_TMAIN(int argc, ACE_TCHAR** argv)
{
try
{
TheParticipantFactoryWithArgs(argc, argv);
// Create Participant
DDS::DomainParticipant_var participant =
TheParticipantFactory->create_participant(42,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(participant.in()))
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_participant failed!\n")), 1);
// Create Subscriber
DDS::Subscriber_var subscriber =
participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT,
DDS::SubscriberListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(subscriber.in()))
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_subscriber failed!\n")), 2);
// Create Publisher
DDS::Publisher_var publisher =
participant->create_publisher(PUBLISHER_QOS_DEFAULT,
DDS::PublisherListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(publisher.in()))
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_publisher failed!\n")), 1);
OpenDDS::DCPS::TransportIdType transportId(0);
// Attach Subscriber Transport
++transportId;
OpenDDS::DCPS::TransportConfiguration_rch sub_config =
TheTransportFactory->get_or_create_configuration(transportId, ACE_TEXT("SimpleTcp"));
OpenDDS::DCPS::TransportImpl_rch sub_transport =
TheTransportFactory->create_transport_impl(transportId);
OpenDDS::DCPS::SubscriberImpl* subscriber_i =
dynamic_cast<OpenDDS::DCPS::SubscriberImpl*>(subscriber.in());
if (subscriber_i == 0)
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: dynamic_cast failed!\n")), 1);
OpenDDS::DCPS::AttachStatus sub_status =
subscriber_i->attach_transport(sub_transport.in());
if (sub_status != OpenDDS::DCPS::ATTACH_OK)
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: attach_transport failed!\n")), 1);
// Attach Publisher Transport
++transportId;
OpenDDS::DCPS::TransportConfiguration_rch pub_config =
TheTransportFactory->get_or_create_configuration(transportId, ACE_TEXT("SimpleTcp"));
OpenDDS::DCPS::TransportImpl_rch pub_transport =
TheTransportFactory->create_transport_impl(transportId);
OpenDDS::DCPS::PublisherImpl* publisher_i =
dynamic_cast<OpenDDS::DCPS::PublisherImpl*>(publisher.in());
if (publisher_i == 0)
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: dynamic_cast failed!\n")), 1);
OpenDDS::DCPS::AttachStatus pub_status =
publisher_i->attach_transport(pub_transport.in());
if (pub_status != OpenDDS::DCPS::ATTACH_OK)
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: attach_transport failed!\n")), 1);
// Register Type (FooType)
FooTypeSupport_var ts = new FooTypeSupportImpl;
if (ts->register_type(participant.in(), "") != DDS::RETCODE_OK)
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: register_type failed!\n")), 1);
//.........这里部分代码省略.........
示例11: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]){
try
{
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
OpenDDS::DCPS::TransportConfig_rch config =
OpenDDS::DCPS::TransportRegistry::instance()->get_config("dds4ccm_rtps");
if (config.is_nil())
{
config =
OpenDDS::DCPS::TransportRegistry::instance()->create_config("dds4ccm_rtps");
}
OpenDDS::DCPS::TransportInst_rch inst =
OpenDDS::DCPS::TransportRegistry::instance()->get_inst("the_rtps_transport");
if (inst.is_nil())
{
inst =
OpenDDS::DCPS::TransportRegistry::instance()->create_inst("the_rtps_transport",
"rtps_udp");
config->instances_.push_back(inst);
OpenDDS::DCPS::TransportRegistry::instance()->global_config(config);
}
// Create another transport instance for participant2 since RTPS transport instances
// cannot be shared by domain participants.
OpenDDS::DCPS::TransportConfig_rch config2 =
OpenDDS::DCPS::TransportRegistry::instance()->get_config("dds4ccm_rtps_2");
if (config2.is_nil())
{
config2 =
OpenDDS::DCPS::TransportRegistry::instance()->create_config("dds4ccm_rtps_2");
}
OpenDDS::DCPS::TransportInst_rch inst2 =
OpenDDS::DCPS::TransportRegistry::instance()->get_inst("the_rtps_transport_2");
if (inst2.is_nil())
{
inst2 =
OpenDDS::DCPS::TransportRegistry::instance()->create_inst("the_rtps_transport_2",
"rtps_udp");
config2->instances_.push_back(inst2);
}
#ifndef DDS_HAS_MINIMUM_BIT
OpenDDS::RTPS::RtpsDiscovery_rch disc =
new OpenDDS::RTPS::RtpsDiscovery(OpenDDS::DCPS::Discovery::DEFAULT_RTPS);
// The recommended value for the resend period is 2 seconds for
// the current implementation of OpenDDS.
disc->resend_period(ACE_Time_Value(2));
TheServiceParticipant->add_discovery(OpenDDS::DCPS::static_rchandle_cast<OpenDDS::DCPS::Discovery>(disc));
TheServiceParticipant->set_repo_domain(11, disc->key());
#endif
TheServiceParticipant->set_default_discovery (OpenDDS::DCPS::Discovery::DEFAULT_RTPS);
DDS::DomainParticipant_var 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;
}
else
{
ACE_DEBUG ((LM_DEBUG, "Created participant 1 with instance handle %d\n",
participant->get_instance_handle ()));
}
OpenDDS::DCPS::TransportRegistry::instance()->bind_config(config, participant.in());
DDS::DomainParticipant_var participant2 =
dpf->create_participant(11,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (participant2.in ())) {
cerr << "create_participant failed." << endl;
return 1;
}
else
{
ACE_DEBUG ((LM_DEBUG, "Created participant 2 with instance handle %d\n",
participant2->get_instance_handle ()));
}
try {
OpenDDS::DCPS::TransportRegistry::instance()->bind_config(config2, participant2.in());
//.........这里部分代码省略.........
示例12: ACE_TMAIN
int ACE_TMAIN(int argc, ACE_TCHAR* argv[])
{
try
{
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
DDS::DomainParticipant_var 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* servant = new Test::DataTypeSupportImpl();
if (DDS::RETCODE_OK != servant->register_type(participant.in (), "")) {
cerr << "register_type failed." << endl;
exit(1);
}
CORBA::String_var type_name = 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 << "create_topic failed." << endl;
exit(1);
}
size_t const num_partitions =
sizeof (Test::Offered::PartitionConfigs)
/ sizeof (Test::Offered::PartitionConfigs[0]);
Test::PartitionConfig const * const begin =
Test::Offered::PartitionConfigs;
Test::PartitionConfig const * const end =
begin + num_partitions;
// Keep the writers around long enough for the publications and
// subscriptions to match.
typedef std::vector<DDS::DataWriter_var> writers_type;
writers_type writers (num_partitions);
for (Test::PartitionConfig const * i = begin; i != end; ++i)
{
DDS::PublisherQos pub_qos;
participant->get_default_publisher_qos (pub_qos);
// Specify partitions we're offering.
CORBA::ULong n = 0;
DDS::StringSeq & names = pub_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;
}
DDS::Publisher_var pub =
participant->create_publisher (pub_qos,
DDS::PublisherListener::_nil (),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (pub.in ()))
{
cerr << "create_publisher failed." << endl;
exit(1);
}
DDS::DataWriterListener_var listener (
new Test::DataWriterListener ((*i).expected_matches));
// Create the datawriter
DDS::DataWriterQos dw_qos;
pub->get_default_datawriter_qos (dw_qos);
DDS::DataWriter_var dw =
pub->create_datawriter(topic.in (),
dw_qos,
listener.in (),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dw.in ()))
{
cerr << "create_datawriter failed." << endl;
exit(1);
}
writers.push_back (dw);
//.........这里部分代码省略.........
示例13: ACE_TMAIN
int ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
DDS::DomainParticipantFactory_var dpf;
DDS::DomainParticipant_var participant;
try {
std::cout << "Starting publisher" << std::endl;
{
// Initialize DomainParticipantFactory
dpf = TheParticipantFactoryWithArgs(argc, argv);
std::cout << "Starting publisher with " << argc << " args" << std::endl;
int error;
if ((error = parse_args(argc, argv)) != 0) {
return error;
}
// Create DomainParticipant
participant = dpf->create_participant(4,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(participant.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_participant failed!\n")),
-1);
}
// Register TypeSupport (Messenger::Message)
Messenger::MessageTypeSupport_var mts =
new Messenger::MessageTypeSupportImpl();
if (mts->register_type(participant.in(), "") != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: register_type failed!\n")),
-1);
}
// Create Topic
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())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_topic failed!\n")),
-1);
}
// Create Publisher
DDS::Publisher_var pub =
participant->create_publisher(PUBLISHER_QOS_DEFAULT,
DDS::PublisherListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(pub.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_publisher failed!\n")),
-1);
}
DDS::DataWriterQos qos;
pub->get_default_datawriter_qos(qos);
if (dw_reliable()) {
std::cout << "Reliable DataWriter" << std::endl;
qos.history.kind = DDS::KEEP_ALL_HISTORY_QOS;
qos.reliability.kind = DDS::RELIABLE_RELIABILITY_QOS;
}
// Create DataWriter
DDS::DataWriter_var dw =
pub->create_datawriter(topic.in(),
qos,
DDS::DataWriterListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(dw.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_datawriter failed!\n")),
-1);
}
// Start writing threads
std::cout << "Creating Writer" << std::endl;
Writer* writer = new Writer(dw.in());
std::cout << "Starting Writer" << std::endl;
writer->start();
while (!writer->is_finished()) {
//.........这里部分代码省略.........
示例14: ACE_TMAIN
int ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try {
// Initialize DomainParticipantFactory
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
if (parse_args (argc, argv) != 0) {
return 1;
}
TheServiceParticipant->monitor_factory_->initialize();
// Create DomainParticipant
DDS::DomainParticipant_var 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,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_participant failed!\n")),
-1);
}
// Register TypeSupport (Messenger::Message)
Messenger::MessageTypeSupport_var mts =
new Messenger::MessageTypeSupportImpl();
if (mts->register_type(participant.in(), "") != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: register_type failed!\n")),
-1);
}
// Create Topic
DDS::Topic_var topic =
participant->create_topic("Movie Discussion List",
mts->get_type_name(),
TOPIC_QOS_DEFAULT,
DDS::TopicListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(topic.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_topic failed!\n")),
-1);
}
// Create Publisher
DDS::Publisher_var pub =
participant->create_publisher(PUBLISHER_QOS_DEFAULT,
DDS::PublisherListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(pub.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_publisher failed!\n")),
-1);
}
// Create DataWriter
DDS::DataWriter_var dw =
pub->create_datawriter(topic.in(),
DATAWRITER_QOS_DEFAULT,
DDS::DataWriterListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(dw.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_datawriter failed!\n")),
-1);
}
// Start writing threads
Writer* writer = new Writer(dw.in());
writer->start();
while (!writer->is_finished()) {
ACE_Time_Value small_time(0, 250000);
ACE_OS::sleep(small_time);
}
writer->end();
delete writer;
// Clean-up!
participant->delete_contained_entities();
dpf->delete_participant(participant.in());
TheServiceParticipant->shutdown();
} catch (const CORBA::Exception& e) {
e._tao_print_exception("Exception caught in main():");
//.........这里部分代码省略.........
示例15: main
int main (int argc, char *argv[]) {
try
{
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
DDS::DomainParticipant_var participant =
dpf->create_participant(411,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil());
if (CORBA::is_nil (participant.in ())) {
cerr << "create_participant failed." << endl;
return 1;
}
if (parse_args (argc, argv) == -1) {
return -1;
}
{
// At this point we are connected to the Info Repo.
// Trigger the driver
std::ofstream ior_stream (driver_trigger.c_str());
if (!ior_stream) {
std::cerr << "Unable to open internal trigger file: "
<< driver_trigger << std::endl;
return -1;
}
ior_stream << "junk";
}
int max_wait_time = 30; //seconds
int count = 0;
while (true)
{
if (count > max_wait_time) {
std::cerr << "Timed out waiting for external file: "
<< publisher_trigger << std::endl;
return -1;
}
// check for file
ACE_stat my_stat;
if (ACE_OS::stat (publisher_trigger.c_str(), &my_stat) == 0) {
// found the trigger file.
break;
}
ACE_OS::sleep (1);
}
MessageTypeSupportImpl* servant = new MessageTypeSupportImpl();
PortableServer::ServantBase_var safe_servant = servant;
if (DDS::RETCODE_OK != servant->register_type(participant.in (), "")) {
cerr << "register_type failed." << endl;
exit(1);
}
CORBA::String_var type_name = 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 << "create_topic failed." << endl;
exit(1);
}
TAO::DCPS::TransportImpl_rch tcp_impl =
TheTransportFactory->create_transport_impl (transport_impl_id,
::TAO::DCPS::AUTO_CONFIG);
DDS::Publisher_var pub =
participant->create_publisher(PUBLISHER_QOS_DEFAULT,
DDS::PublisherListener::_nil());
if (CORBA::is_nil (pub.in ())) {
cerr << "create_publisher failed." << endl;
exit(1);
}
// Attach the publisher to the transport.
TAO::DCPS::PublisherImpl* pub_impl =
::TAO::DCPS::reference_to_servant< TAO::DCPS::PublisherImpl,
DDS::Publisher_ptr>(pub.in ());
if (0 == pub_impl) {
cerr << "Failed to obtain publisher servant" << endl;
exit(1);
}
TAO::DCPS::AttachStatus status = pub_impl->attach_transport(tcp_impl.in());
if (status != TAO::DCPS::ATTACH_OK) {
std::string status_str;
switch (status) {
case TAO::DCPS::ATTACH_BAD_TRANSPORT:
status_str = "ATTACH_BAD_TRANSPORT";
break;
//.........这里部分代码省略.........