本文整理汇总了C++中dds::DomainParticipantFactory_var类的典型用法代码示例。如果您正苦于以下问题:C++ DomainParticipantFactory_var类的具体用法?C++ DomainParticipantFactory_var怎么用?C++ DomainParticipantFactory_var使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DomainParticipantFactory_var类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: string
DDS::DomainParticipant_var
createParticipant(DDS::DomainParticipantFactory_var dpf)
{
// Create DomainParticipant
DDS::DomainParticipant_var participant =
dpf->create_participant(42, // made-up domain ID
PARTICIPANT_QOS_DEFAULT,
0, // no listener
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
// Check for failure
if (!participant) {
throw std::string("failed to create domain participant");
}
return participant;
}
开发者ID:yanbodiaoweng,项目名称:DDS,代码行数:16,代码来源:Boilerplate.cpp
示例2: sp_drl
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try {
// Initialize DomainParticipantFactory
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
// Create DomainParticipant
DDS::DomainParticipant_var participant =
dpf->create_participant(OpenDDS::DCPS::MONITOR_DOMAIN_ID,
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 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,
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);
}
DDS::DataReaderQos dr_qos;
sub->get_default_datareader_qos(dr_qos);
dr_qos.durability.kind = DDS::TRANSIENT_LOCAL_DURABILITY_QOS;
DDS::DataReader_var reader;
// Register for OpenDDS::DCPS::ServiceParticipantReport
OpenDDS::DCPS::ServiceParticipantReportTypeSupport_var sp_ts =
new OpenDDS::DCPS::ServiceParticipantReportTypeSupportImpl();
if (sp_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);
}
CORBA::String_var sp_type_name = sp_ts->get_type_name();
DDS::DataReaderListener_var sp_drl(new SPMDataReaderListenerImpl);
reader = create_data_reader(participant.in(),
sub.in(),
sp_type_name.in(),
OpenDDS::DCPS::SERVICE_PARTICIPANT_MONITOR_TOPIC,
dr_qos,
sp_drl);
if (CORBA::is_nil(reader.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: create_datareader() failed!\n")), -1);
}
// Register for OpenDDS::DCPS::DomainParticipantReport
OpenDDS::DCPS::DomainParticipantReportTypeSupport_var dp_ts =
new OpenDDS::DCPS::DomainParticipantReportTypeSupportImpl();
if (dp_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);
}
CORBA::String_var dp_type_name = dp_ts->get_type_name();
DDS::DataReaderListener_var dp_drl(new DPMDataReaderListenerImpl);
reader = create_data_reader(participant.in(),
sub.in(),
dp_type_name.in(),
OpenDDS::DCPS::DOMAIN_PARTICIPANT_MONITOR_TOPIC,
dr_qos,
dp_drl);
if (CORBA::is_nil(reader.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: create_datareader() failed!\n")), -1);
}
// Register for OpenDDS::DCPS::TopicReport
OpenDDS::DCPS::TopicReportTypeSupport_var topic_ts =
new OpenDDS::DCPS::TopicReportTypeSupportImpl();
if (topic_ts->register_type(participant.in(), "") != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
//.........这里部分代码省略.........
开发者ID:svn2github,项目名称:OpenDDS,代码行数:101,代码来源:monitor.cpp
示例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);
//.........这里部分代码省略.........
开发者ID:Fantasticer,项目名称:OpenDDS,代码行数:101,代码来源:publisher.cpp
示例4: 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
示例5: BadParticipantException
Subscriber::Subscriber( const Options& options)
: options_( options),
listener_( 0),
waiter_( new DDS::WaitSet)
{
DDS::DomainParticipantFactory_var dpf = TheParticipantFactory;
// Create the DomainParticipant
this->participant_
= dpf->create_participant(
this->options_.domain(),
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK
);
if( CORBA::is_nil( this->participant_.in())) {
ACE_ERROR((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: Subscriber::Subscriber() - ")
ACE_TEXT("failed to create a participant.\n")
));
throw BadParticipantException();
} else if( this->options_.verbose()) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) Subscriber::Subscriber() - ")
ACE_TEXT("created participant in domain %d.\n"),
this->options_.domain()
));
}
// Create the listener.
this->listener_ = new DataReaderListener( this->options_.verbose());
this->safe_listener_ = this->listener_;
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) Subscriber::Subscriber() - ")
ACE_TEXT("created reader listener.\n")
));
// Create and register the type support.
DataTypeSupportImpl::_var_type testData = new DataTypeSupportImpl();
CORBA::String_var type_name = testData->get_type_name();
if( ::DDS::RETCODE_OK
!= testData->register_type( this->participant_.in(), 0)) {
ACE_ERROR((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: Subscriber::Subscriber() - ")
ACE_TEXT("unable to install type %C support.\n"),
type_name.in()
));
throw BadTypeSupportException ();
}
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) Subscriber::Subscriber() - ")
ACE_TEXT("created type %C support.\n"),
type_name.in()
));
// Create the topic.
this->topic_ = this->participant_->create_topic(
this->options_.topicName().c_str(),
type_name,
TOPIC_QOS_DEFAULT,
::DDS::TopicListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK
);
if( CORBA::is_nil( this->topic_.in())) {
ACE_ERROR((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: Subscriber::Subscriber() - ")
ACE_TEXT("failed to create topic %C.\n"),
this->options_.topicName().c_str()
));
throw BadTopicException();
}
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) Subscriber::Subscriber() - ")
ACE_TEXT("created topic %C.\n"),
this->options_.topicName().c_str()
));
// Create the subscriber.
this->subscriber_ = this->participant_->create_subscriber(
SUBSCRIBER_QOS_DEFAULT,
::DDS::SubscriberListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK
);
if( CORBA::is_nil( this->subscriber_.in())) {
ACE_ERROR((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: Subscriber::Subscriber() - ")
ACE_TEXT("failed to create subscriber.\n")
));
throw BadSubscriberException();
}
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) Subscriber::Subscriber() - ")
ACE_TEXT("created subscriber.\n")
));
//.........这里部分代码省略.........
开发者ID:oschwaldp-oci,项目名称:OpenDDS,代码行数:101,代码来源:Subscriber.cpp
示例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 ();
//.........这里部分代码省略.........
开发者ID:FlavioFalcao,项目名称:DDS-1,代码行数:101,代码来源:publisher.cpp
示例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(411,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil());
if (CORBA::is_nil (participant.in ())) {
cerr << "create_participant failed." << endl;
return 1 ;
}
Messenger::MessageTypeSupportImpl* mts_servant =
new Messenger::MessageTypeSupportImpl;
if (DDS::RETCODE_OK != mts_servant->register_type(participant.in (),
""))
{
cerr << "Failed to register the MessageTypeTypeSupport." << endl;
exit(1);
}
CORBA::String_var type_name = mts_servant->get_type_name ();
DDS::TopicQos topic_qos;
participant->get_default_topic_qos(topic_qos);
DDS::Topic_var topic =
participant->create_topic("Movie Discussion List",
type_name.in (),
topic_qos,
DDS::TopicListener::_nil());
if (CORBA::is_nil (topic.in ())) {
cerr << "Failed to create_topic." << endl;
exit(1);
}
// Initialize the transport
OpenDDS::DCPS::TransportImpl_rch tcp_impl =
TheTransportFactory->create_transport_impl (
transport_impl_id,
::OpenDDS::DCPS::AUTO_CONFIG);
// Create the subscriber and attach to the corresponding
// transport.
DDS::Subscriber_var sub =
participant->create_subscriber (SUBSCRIBER_QOS_DEFAULT,
DDS::SubscriberListener::_nil());
if (CORBA::is_nil (sub.in ())) {
cerr << "Failed to create_subscriber." << endl;
exit(1);
}
// Attach the subscriber to the transport.
OpenDDS::DCPS::SubscriberImpl* sub_impl =
dynamic_cast<OpenDDS::DCPS::SubscriberImpl*> (sub.in ());
if (0 == sub_impl) {
cerr << "Failed to obtain subscriber servant\n" << endl;
exit(1);
}
OpenDDS::DCPS::AttachStatus const status =
sub_impl->attach_transport(tcp_impl.in());
if (status != OpenDDS::DCPS::ATTACH_OK) {
std::string status_str;
switch (status) {
case OpenDDS::DCPS::ATTACH_BAD_TRANSPORT:
status_str = "ATTACH_BAD_TRANSPORT";
break;
case OpenDDS::DCPS::ATTACH_ERROR:
status_str = "ATTACH_ERROR";
break;
case OpenDDS::DCPS::ATTACH_INCOMPATIBLE_QOS:
status_str = "ATTACH_INCOMPATIBLE_QOS";
break;
default:
status_str = "Unknown Status";
break;
}
cerr << "Failed to attach to the transport. Status == "
<< status_str.c_str() << endl;
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 1 second recurring deadline. DataReader creation
// should fail with this QoS since the requested deadline period
// will be less than the test configured offered deadline
//.........这里部分代码省略.........
开发者ID:svn2github,项目名称:OpenDDS,代码行数:101,代码来源:subscriber.cpp
示例8: 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():");
//.........这里部分代码省略.........
开发者ID:AndroidDev77,项目名称:OpenDDS,代码行数:101,代码来源:publisher.cpp
示例9: 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
示例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(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
示例11: options
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
bool ok = true;
bool generated_config = false;
try {
//Look to see if the config file (.ini) was generated
//for rtps participant processing
for(int i = 0; i < argc; ++i) {
if(ACE_OS::strstr(argv[i], ACE_TEXT("generated"))) {
generated_config = true;
}
}
// Initialize DomainParticipantFactory
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
// handle test performance issue on one platform
#if defined (sun)
const char* udpTransName = "udp";
OpenDDS::DCPS::TransportInst_rch inst = OpenDDS::DCPS::TransportRegistry::instance()->get_inst(udpTransName);
if (inst != 0) {
OpenDDS::DCPS::UdpInst_rch udp_inst = OpenDDS::DCPS::dynamic_rchandle_cast<OpenDDS::DCPS::UdpInst>(inst);
if (udp_inst == 0) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: retrieving transport config for: %C failed!\n"),
udpTransName), -1);
}
udp_inst->rcv_buffer_size_ = 0x40000;
}
#endif
const Options options(argc, argv);
// Create DomainParticipant
typedef std::vector<DDS::DomainParticipant_var> Participants;
Participants participants(options.num_sub_participants);
// Register Type (Messenger::Message)
Messenger::MessageTypeSupport_var ts =
new Messenger::MessageTypeSupportImpl();
CORBA::String_var type_name = ts->get_type_name();
typedef std::vector<DataReaderListenerImpl*> ListenerServants;
ListenerServants listener_servants;
std::vector<DDS::DataReaderListener_var> listeners;
std::stringstream ss;
ss << std::setw(5) << ACE_OS::getpid();
const std::string pid = ss.str();
ACE_DEBUG((LM_DEBUG, ACE_TEXT("%T (%P|%t) Created dpf\n")));
unsigned int part_index = 0;
for (Participants::iterator part = participants.begin();
part != participants.end();
++part, ++part_index) {
ACE_DEBUG((LM_DEBUG, ACE_TEXT("%T (%P|%t) Creating participant\n")));
*part =
dpf->create_participant(411,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(part->in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: create_participant() failed!\n")), -1);
}
if (generated_config) {
std::stringstream domain_config_stream;
std::string config_name = "domain_part_";
domain_config_stream << config_name << part_index;
std::string config;
config = domain_config_stream.str();
TheTransportRegistry->bind_config(config, *part);
}
if (ts->register_type(part->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 =
(*part)->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 Subscriber
DDS::Subscriber_var sub =
(*part)->create_subscriber(SUBSCRIBER_QOS_DEFAULT,
//.........这里部分代码省略.........
开发者ID:stonejiang208,项目名称:DDS,代码行数:101,代码来源:subscriber.cpp
示例12: listener
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try {
// Initialize DomainParticipantFactory
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
// Create DomainParticipant
DDS::DomainParticipant_var participant =
dpf->create_participant(42,
PARTICIPANT_QOS_DEFAULT,
0,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (!participant) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" create_participant failed!\n")), -1);
}
// Register Type (Messenger::Message)
Messenger::MessageTypeSupport_var ts =
new Messenger::MessageTypeSupportImpl;
if (ts->register_type(participant, "") != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" register_type failed!\n")), -1);
}
// Create Topic (Movie Discussion List)
CORBA::String_var type_name = ts->get_type_name();
DDS::Topic_var topic =
participant->create_topic("Movie Discussion List",
type_name,
TOPIC_QOS_DEFAULT,
0,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (!topic) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" create_topic failed!\n")), -1);
}
// Create Subscriber
DDS::Subscriber_var subscriber =
participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT,
0,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (!subscriber) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" create_subscriber failed!\n")), -1);
}
// Create DataReader
DDS::DataReaderListener_var listener(new DataReaderListenerImpl);
DDS::DataReader_var reader =
subscriber->create_datareader(topic,
DATAREADER_QOS_DEFAULT,
listener,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (!reader) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" create_datareader failed!\n")), -1);
}
Messenger::MessageDataReader_var reader_i =
Messenger::MessageDataReader::_narrow(reader);
if (!reader_i) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" _narrow failed!\n")),
-1);
}
// Block until Publisher completes
DDS::StatusCondition_var condition = reader->get_statuscondition();
condition->set_enabled_statuses(DDS::SUBSCRIPTION_MATCHED_STATUS);
DDS::WaitSet_var ws = new DDS::WaitSet;
ws->attach_condition(condition);
while (true) {
DDS::SubscriptionMatchedStatus matches;
if (reader->get_subscription_matched_status(matches) != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" get_subscription_matched_status failed!\n")), -1);
}
if (matches.current_count == 0 && matches.total_count > 0) {
break;
//.........这里部分代码省略.........
开发者ID:Fantasticer,项目名称:OpenDDS,代码行数:101,代码来源:Subscriber.cpp
示例13: BadParticipantException
Publisher::Publisher( const Options& options)
: status_( 0),
options_( options),
participant_(0),
publisher_(0),
waiter_( new DDS::WaitSet)
{
DDS::DomainParticipantFactory_var dpf = TheParticipantFactory;
// Create the DomainParticipant
this->participant_
= dpf->create_participant(
this->options_.domain(),
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK
);
if( CORBA::is_nil( this->participant_.in())) {
ACE_ERROR((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: Publisher::Publisher() - ")
ACE_TEXT("failed to create a participant.\n")
));
throw BadParticipantException();
} else if( this->options_.verbose()) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) Publisher::Publisher() - ")
ACE_TEXT("created participant in domain %d.\n"),
this->options_.domain()
));
}
// Create and register the type support.
DataTypeSupportImpl* testData = new DataTypeSupportImpl();
CORBA::String_var type_name = testData->get_type_name();
if( ::DDS::RETCODE_OK
!= testData->register_type( this->participant_.in(), 0)) {
ACE_ERROR((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: Publisher::Publisher() - ")
ACE_TEXT("unable to install type %C support.\n"),
type_name.in()
));
throw BadTypeSupportException ();
} else if( this->options_.verbose()) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) Publisher::Publisher() - ")
ACE_TEXT("created type %C support.\n"),
type_name.in()
));
}
// Create the topic.
DDS::Topic_var topic = this->participant_->create_topic(
this->options_.topicName().c_str(),
type_name,
TOPIC_QOS_DEFAULT,
::DDS::TopicListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK
);
if( CORBA::is_nil( topic.in())) {
ACE_ERROR((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: Publisher::Publisher() - ")
ACE_TEXT("failed to create topic %C.\n"),
this->options_.topicName().c_str()
));
throw BadTopicException();
} else if( this->options_.verbose()) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) Publisher::Publisher() - ")
ACE_TEXT("created topic %C.\n"),
this->options_.topicName().c_str()
));
}
// Create the publisher.
this->publisher_ = this->participant_->create_publisher(
PUBLISHER_QOS_DEFAULT,
::DDS::PublisherListener::_nil(),
::OpenDDS::DC
|
请发表评论