本文整理汇总了C++中dds::Topic_var::in方法的典型用法代码示例。如果您正苦于以下问题:C++ Topic_var::in方法的具体用法?C++ Topic_var::in怎么用?C++ Topic_var::in使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dds::Topic_var
的用法示例。
在下文中一共展示了Topic_var::in方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
DWMonitorImpl::report() {
if (!CORBA::is_nil(this->dw_writer_.in())) {
DataWriterReport report;
report.dp_id = this->dw_->get_dp_id();
DDS::Publisher_var pub = this->dw_->get_publisher();
report.pub_handle = pub->get_instance_handle();
report.dw_id = this->dw_->get_publication_id();
DDS::Topic_var topic = this->dw_->get_topic();
report.topic_id = dynamic_cast<TopicImpl*>(topic.in())->get_id();
DataWriterImpl::InstanceHandleVec instances;
this->dw_->get_instance_handles(instances);
CORBA::ULong length = 0;
report.instances.length(static_cast<CORBA::ULong>(instances.size()));
for (DataWriterImpl::InstanceHandleVec::iterator iter = instances.begin();
iter != instances.end();
++iter) {
report.instances[length++] = *iter;
}
DataWriterImpl::IdSet readers;
this->dw_->get_readers(readers);
length = 0;
report.associations.length(static_cast<CORBA::ULong>(readers.size()));
for (DataWriterImpl::IdSet::iterator iter = readers.begin();
iter != readers.end();
++iter) {
report.associations[length].dr_id = *iter;
length++;
}
this->dw_writer_->write(report, DDS::HANDLE_NIL);
}
}
示例2:
DDS::DataWriter_ptr
MonitorFactoryImpl::create_data_writer(DDS::DomainParticipant_ptr participant,
DDS::Publisher_ptr publisher,
const char* type_name,
const char* topic_name,
const DDS::DataWriterQos& dw_qos)
{
DDS::Topic_var topic =
participant->create_topic(topic_name,
type_name,
TOPIC_QOS_DEFAULT,
DDS::TopicListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(topic)) {
ACE_DEBUG((LM_DEBUG, "MonitorFactoryImpl::create_data_writer(): Failed to create topic, name = %s\n", topic_name));
}
DDS::DataWriter_var writer =
publisher->create_datawriter(topic.in(),
dw_qos,
DDS::DataWriterListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(writer)) {
ACE_DEBUG((LM_DEBUG, "MonitorFactoryImpl::create_data_writer(): Failed to create data writer\n"));
}
return writer._retn();
}
示例3:
DDS::DataReader_ptr
create_data_reader(DDS::DomainParticipant_ptr participant,
DDS::Subscriber_ptr subscriber,
const char* type_name,
const char* topic_name,
const DDS::DataReaderQos& dr_qos,
DDS::DataReaderListener_ptr drl)
{
DDS::Topic_var topic =
participant->create_topic(topic_name,
type_name,
TOPIC_QOS_DEFAULT,
DDS::TopicListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(topic)) {
ACE_DEBUG((LM_DEBUG, "create_data_reader(): Failed to create topic, name = %s\n", topic_name));
}
DDS::DataReader_var reader =
subscriber->create_datareader(topic.in(),
dr_qos,
drl,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(reader)) {
ACE_DEBUG((LM_DEBUG, "create_data_reader(): Failed to create data reader\n"));
}
return reader._retn();
}
示例4: TestMessageTypeSupportImpl
DDS::Topic_var
TestBase::create_topic()
{
const char* name = DEFAULT_TOPIC;
TestMessageTypeSupport_var ts =
new TestMessageTypeSupportImpl();
if (ts->register_type(this->participant_.in(), "") != DDS::RETCODE_OK) {
ACE_ERROR((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: create_topic() -")
ACE_TEXT(" register_type failed!\n")));
ACE_OS::exit(-1);
}
CORBA::String_var s = ts->get_type_name();
const char* type_name = s.in();
DDS::TopicQos qos;
if (this->participant_->get_default_topic_qos(qos) != DDS::RETCODE_OK) {
ACE_ERROR((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: create_topic() -")
ACE_TEXT(" get_default_topic_qos failed!\n")));
ACE_OS::exit(-1);
}
DDS::TopicListener_ptr listener =
DDS::TopicListener::_nil();
DDS::StatusMask status = OpenDDS::DCPS::DEFAULT_STATUS_MASK;
if (init_topic(name, type_name, qos, listener, status) != DDS::RETCODE_OK) {
ACE_ERROR((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: create_topic() -")
ACE_TEXT(" init_topic failed!\n")));
ACE_OS::exit(-1);
}
DDS::Topic_var topic =
this->participant_->create_topic(name, type_name, qos, listener, status);
if (CORBA::is_nil(topic.in())) {
ACE_ERROR((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: create_topic() -")
ACE_TEXT(" create_topic failed!\n")));
ACE_OS::exit(-1);
}
return topic;
}
示例5: teardown
bool ExampleSubscriber::teardown()
{
/* Shutdown */
if (participant != NULL)
{
if (subscriber.in() != NULL) {
status = participant->delete_subscriber(subscriber.in());
checkStatus(status, "DDS::DomainParticipant::delete_subscriber");
}
status = participant->delete_topic(large_message_topic.in());
checkStatus(status, "DDS::DomainParticipant::delete_topic (large_message_topic)");
status = dpf->delete_participant(participant.in());
checkStatus(status, "DDS::DomainParticipantFactory::delete_participant");
}
DDS::string_free(large_message_type_name);
return true;
}
示例6: MessageTypeSupportImpl
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(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 Type (Messenger::Message)
Messenger::MessageTypeSupport_var ts =
new Messenger::MessageTypeSupportImpl();
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);
}
// Create Topic (Movie Discussion List)
DDS::Topic_var topic =
participant->create_topic("Movie Discussion List",
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 main()")
ACE_TEXT(" ERROR: create_topic() failed!\n")), -1);
}
::DDS::SubscriberQos subscriber_qos;
participant->get_default_subscriber_qos (subscriber_qos);
subscriber_qos.presentation.access_scope
= (::DDS::PresentationQosPolicyAccessScopeKind)acess_scope;
subscriber_qos.presentation.coherent_access = true;
subscriber_qos.presentation.ordered_access = true;
SubscriberListenerImpl* subscriber_listener_svt = new SubscriberListenerImpl();
DDS::SubscriberListener_var subscriber_listener(subscriber_listener_svt);
// Create Subscriber
DDS::Subscriber_var sub =
participant->create_subscriber(subscriber_qos,
subscriber_listener.in(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(sub.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: create_subscriber() failed!\n")), -1);
}
// Initialize Transport
OpenDDS::DCPS::TransportImpl_rch transport_impl =
TheTransportFactory->create_transport_impl(transport_impl_id,
OpenDDS::DCPS::AUTO_CONFIG);
OpenDDS::DCPS::AttachStatus status = transport_impl->attach(sub.in());
if (status != OpenDDS::DCPS::ATTACH_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: attach() failed!\n")), -1);
}
// Create DataReader
DataReaderListenerImpl* listener_svt1 = new DataReaderListenerImpl("DataReader1");
DataReaderListenerImpl* listener_svt2 = new DataReaderListenerImpl("DataReader2");
DDS::DataReaderListener_var listener1(listener_svt1);
DDS::DataReaderListener_var listener2(listener_svt2);
::DDS::DataReaderQos readerQos;
sub->get_default_datareader_qos( readerQos);
readerQos.history.kind = ::DDS::KEEP_ALL_HISTORY_QOS;
readerQos.resource_limits.max_samples_per_instance = ::DDS::LENGTH_UNLIMITED;
DDS::DataReader_var reader1 =
sub->create_datareader(topic.in(),
//.........这里部分代码省略.........
示例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[]) {
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);
//.........这里部分代码省略.........
示例9: ACE_TMAIN
int ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
int status = 0;
try {
// Initialize DomainParticipantFactory
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
bool reliable = true;
int num_msgs = 10;
int my_pid = ACE_OS::getpid();
parse_args(argc, argv, reliable, num_msgs, my_pid);
// 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
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);
qos.liveliness.kind = DDS::AUTOMATIC_LIVELINESS_QOS;
qos.liveliness.lease_duration.sec = 5;
qos.liveliness.lease_duration.nanosec = 0;
qos.history.kind = DDS::KEEP_ALL_HISTORY_QOS;
qos.durability.kind = DDS::TRANSIENT_LOCAL_DURABILITY_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);
}
DDS::DataWriter_var dw2 =
pub->create_datawriter(topic.in(),
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()")
//.........这里部分代码省略.........
示例10: 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);
//.........这里部分代码省略.........
示例11: 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;
}
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();
OpenDDS::DCPS::LocalObject_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(),
::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);
//.........这里部分代码省略.........
示例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(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);
//.........这里部分代码省略.........
示例13: 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;
}
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 listener.
DDS::DataWriterListener_var listener (new DataWriterListenerImpl);
if (CORBA::is_nil (listener.in ()))
{
cerr << "ERROR: listener is nil." << endl;
exit(1);
}
DDS::DataWriterQos dw_qos; // Good QoS.
pub->get_default_datawriter_qos (dw_qos);
assert (DEADLINE_PERIOD.sec > 1); // Requirement for the test.
// First data writer will have a listener to test listener
// callback on deadline expiration.
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 << "ERROR: create_datawriter failed." << endl;
exit(1);
}
dw_qos.deadline.period.sec = DEADLINE_PERIOD.sec;
dw_qos.deadline.period.nanosec = DEADLINE_PERIOD.nanosec;
// Set qos with deadline. The watch dog starts now.
if (dw->set_qos (dw_qos) != ::DDS::RETCODE_OK)
{
cerr << "ERROR: set deadline qos failed." << endl;
exit(1);
}
{
// Two threads use same datawriter to write different instances.
std::auto_ptr<Writer> writer1 (new Writer (dw.in (), 99, SLEEP_DURATION));
std::auto_ptr<Writer> writer2 (new Writer (dw.in (), 100, SLEEP_DURATION));
writer1->start ();
writer2->start ();
// ----------------------------------------------
// Wait for fully associate with DataReaders.
if (writer1->wait_for_start () == false || writer2->wait_for_start () == false)
{
cerr << "ERROR: took too long to associate. " << endl;
exit (1);
}
//.........这里部分代码省略.........
示例14: 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")),
//.........这里部分代码省略.........
示例15: 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);
//.........这里部分代码省略.........