本文整理汇总了C++中dds::Topic_var类的典型用法代码示例。如果您正苦于以下问题:C++ Topic_var类的具体用法?C++ Topic_var怎么用?C++ Topic_var使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Topic_var类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:binary42,项目名称:OCI,代码行数:32,代码来源:DWMonitorImpl.cpp
示例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();
}
开发者ID:AndroidDev77,项目名称:OpenDDS,代码行数:27,代码来源:MonitorFactoryImpl.cpp
示例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();
}
开发者ID:svn2github,项目名称:OpenDDS,代码行数:28,代码来源:monitor.cpp
示例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;
}
开发者ID:CapXilinx,项目名称:OpenDDS,代码行数:50,代码来源:TestFramework.cpp
示例5:
DDS::DataReader*
OpenDDS::Model::Delegate::createSubscription(
unsigned int which,
DDS::Subscriber* subscriber,
DDS::TopicDescription* topic,
const DDS::DataReaderQos& readerQos,
DDS::StatusMask mask,
const OPENDDS_STRING& transportConfig,
bool copyQosFromTopic
)
{
if( !this->service_) {
return 0;
}
DDS::DataReaderQos dr_qos = readerQos;
if (copyQosFromTopic) {
// Per the DDS Spec, copy from related topic for CF topic,
// Error if copy from mulitopic
DDS::TopicQos topicQos = TheServiceParticipant->initial_TopicQos();
DDS::Topic* qosTopic;
if ((qosTopic = dynamic_cast<DDS::Topic*>(topic)) != NULL) {
qosTopic->get_qos(topicQos);
#ifndef OPENDDS_NO_CONTENT_FILTERED_TOPIC
} else {
DDS::ContentFilteredTopic* qosCfTopic =
dynamic_cast<DDS::ContentFilteredTopic*>(topic);
if (qosCfTopic != NULL) {
DDS::Topic_var related = qosCfTopic->get_related_topic();
related->get_qos(topicQos);
}
#endif
}
subscriber->copy_from_topic_qos(dr_qos, topicQos);
}
this->service_->copySubscriptionQos(which, dr_qos);
return this->createReader(
subscriber,
topic,
dr_qos,
mask,
transportConfig
);
}
开发者ID:CapXilinx,项目名称:OpenDDS,代码行数:44,代码来源:Delegate.cpp
示例6: rd
DDS::DataReader_var
Factory::reader(const DDS::Subscriber_var& sub, const DDS::Topic_var& topic, const DDS::DataReaderListener_var& drl) const
{
// Create the data readers
DDS::DataReaderQos dr_qos;
sub->get_default_datareader_qos(dr_qos);
dr_qos.durability.kind = opts_.durability_kind;
dr_qos.liveliness.kind = opts_.liveliness_kind;
dr_qos.liveliness.lease_duration = opts_.LEASE_DURATION;
dr_qos.reliability.kind = opts_.reliability_kind;
DDS::DomainParticipant_var dp = sub->get_participant();
CORBA::String_var tn = topic->get_name();
DDS::TopicDescription_var description = dp->lookup_topicdescription(tn);
TEST_ASSERT(!CORBA::is_nil(description.in()));
DDS::DataReader_var rd(sub->create_datareader(description.in(),
dr_qos,
drl.in(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK));
// Initialize the transport configuration for the appropriate entity
TEST_ASSERT(!opts_.configuration_str.empty());
if (opts_.configuration_str != "none" && opts_.entity_str == "rw")
{
OpenDDS::DCPS::TransportRegistry::instance()->bind_config(opts_.configuration_str,
rd.in());
if (!opts_.entity_autoenable)
{
TEST_ASSERT(DDS::RETCODE_OK == rd->enable());
}
}
return rd;
}
开发者ID:FlavioFalcao,项目名称:DDS-1,代码行数:37,代码来源:Factory.cpp
示例7: 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(),
//.........这里部分代码省略.........
开发者ID:svn2github,项目名称:OpenDDS,代码行数:101,代码来源:subscriber.cpp
示例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(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;
//.........这里部分代码省略.........
开发者ID:yanbodiaoweng,项目名称:DDS,代码行数:101,代码来源:subscriber.cpp
示例9: 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);
//.........这里部分代码省略.........
开发者ID:Fantasticer,项目名称:OpenDDS,代码行数:101,代码来源:publisher.cpp
示例10: 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()")
//.........这里部分代码省略.........
开发者ID:shaominghaoo,项目名称:OpenDDS,代码行数:101,代码来源:publisher.cpp
示例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);
//.........这里部分代码省略.........
开发者ID:stonejiang208,项目名称:OpenDDS,代码行数:101,代码来源:publisher.cpp
示例12:
DDS::DataReader_var
OpenDDS::Model::Entities::reader(
const OPENDDS_STRING& name,
const OPENDDS_STRING& transportConfig)
{
StringToDataReaderMap::const_iterator which
= this->readerByString_.find( name);
if( which != this->readerByString_.end()) {
return DDS::DataReader::_duplicate( which->second);
}
// See if there is a configuration profile for it.
Config::ReaderProfileMap::const_iterator where
= this->config_.readerProfileMap().find( name);
if( where == this->config_.readerProfileMap().end()) {
ACE_ERROR((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: Entities::reader() - ")
ACE_TEXT("unable to find profile to configure ")
ACE_TEXT("reader: [%C].\n"),
name.c_str()
));
return 0;
}
ReaderProfile* profile = where->second;
// Find the containing Subscriber.
DDS::Subscriber_var subscriber = this->subscriber(profile->subscriber,
transportConfig);
if( !subscriber) {
ACE_ERROR((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: Entities::reader() - ")
ACE_TEXT("unable to find subscriber: [%C] for reader [%C].\n"),
profile->subscriber.c_str(), name.c_str()
));
return 0;
}
// We need the *name* of the participant in order to look up the Topic.
// This should be Ok since we will only be configuring Readers that have
// been successfully defined in a configuration file, implying that there
// exists a defined [subscriber] profile.
Config::SubscriberProfileMap::const_iterator location
= this->config_.subscriberProfileMap().find( profile->subscriber);
if( location == this->config_.subscriberProfileMap().end()) {
ACE_ERROR((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: Entities::reader() - ")
ACE_TEXT("unable to find profile to configure ")
ACE_TEXT("subscriber: [%C] for reader [%C].\n"),
profile->subscriber.c_str(), name.c_str()
));
return 0;
}
SubscriberProfile* subscriberProfile = location->second;
// Find the Topic.
DDS::Topic_var topic
= this->topic(profile->topic,
subscriberProfile->participant,
transportConfig);
if( !topic) {
ACE_ERROR((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: Entities::reader() - ")
ACE_TEXT("unable to find topic: [%C] for reader [%C] in participant [%C].\n"),
profile->topic.c_str(), name.c_str(),
subscriberProfile->participant.c_str()
));
return 0;
}
DDS::DataReaderQos readerQos;
DDS::TopicQos topicQos;
topic->get_qos( topicQos);
subscriber->get_default_datareader_qos( readerQos);
subscriber->copy_from_topic_qos( readerQos, topicQos);
profile->copyToReaderQos( readerQos);
if( OpenDDS::DCPS::DCPS_debug_level>1) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) Entities::reader() - ")
ACE_TEXT("Creating reader [%C] in subscriber [%C] in participant [%C] ")
ACE_TEXT("with topic [%C].\n"),
name.c_str(),
profile->subscriber.c_str(),
subscriberProfile->participant.c_str(),
profile->topic.c_str()
));
}
this->readerByString_[ name]
= this->delegate_.createReader(
subscriber,
topic,
readerQos,
OpenDDS::DCPS::DEFAULT_STATUS_MASK,
transportConfig
);
return this->readerByString_[ name];
}
开发者ID:AndroidDev77,项目名称:OpenDDS,代码行数:98,代码来源:Entities.cpp
示例13: 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);
//.........这里部分代码省略.........
开发者ID:AndroidDev77,项目名称:OpenDDS,代码行数:101,代码来源:Subscriber.cpp
示例14: 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);
}
//.........这里部分代码省略.........
开发者ID:yanbodiaoweng,项目名称:DDS,代码行数:101,代码来源:publisher.cpp
示例15: 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")),
//.........这里部分代码省略.........
开发者ID:oschwaldp-oci,项目名称:OpenDDS,代码行数:101,代码来源:publisher.cpp
-
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:18210|2023-10-27
-
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:9656|2022-11-06
-
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8168|2022-11-06
-
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8543|2022-11-06
-
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8449|2022-11-06
-
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9375|2022-11-06
-
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8418|2022-11-06
-
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:7855|2022-11-06
-
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8403|2022-11-06
-
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7391|2022-11-06
|
请发表评论