summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwolff1 <wolff1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2007-12-13 15:51:00 +0000
committerwolff1 <wolff1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2007-12-13 15:51:00 +0000
commit0f06dc797fbac2a50e8b9607155a3030e56d732e (patch)
tree8e37d60f52cb6181aaf4be6dc87193a2f5d11b9b
parentb93eebe93647d2fe5f65053c46bdde46238ec5e2 (diff)
downloadATCD-0f06dc797fbac2a50e8b9607155a3030e56d732e.tar.gz
it is posssible to pass the topic Id as parameter to the publisher
-rw-r--r--CIAO/tests/DDS/Publisher/publisher.cpp37
-rwxr-xr-xCIAO/tests/DDS/tests/run_publisher.pl5
2 files changed, 39 insertions, 3 deletions
diff --git a/CIAO/tests/DDS/Publisher/publisher.cpp b/CIAO/tests/DDS/Publisher/publisher.cpp
index 6f412c89fd1..7d3bf57e8d8 100644
--- a/CIAO/tests/DDS/Publisher/publisher.cpp
+++ b/CIAO/tests/DDS/Publisher/publisher.cpp
@@ -12,6 +12,7 @@
#include <dds/DCPS/PublisherImpl.h>
#include <dds/DCPS/transport/framework/TheTransportFactory.h>
#include <ace/streams.h>
+#include <ace/Get_Opt.h>
// constant used by this publisher for transport;
// must match transport id in config file
@@ -22,6 +23,33 @@ DDS::DomainId_t DDSTOPIC_DOMAIN_ID = 467;
const char* DDSTOPIC_TYPE = "DDSTopic";
const char* DDSTEST_TOPIC = "DDSTopic Data";
+static char* option_id = "Publisher Message";
+
+static int parse_args(int argc, char* argv[])
+{
+ ACE_Get_Opt args (argc, argv, "i:");
+
+ int c = 0;
+ while ((c = args ()) != EOF)
+ {
+ switch (c)
+ {
+ case 'i' :
+ {
+ option_id = args.opt_arg ();
+ break;
+ }
+ default:
+ {
+ std::cerr << "usage: publisher [-i topic_id]" << std::endl;
+ return 1;
+ }
+ }
+ }
+
+ return 0;
+}
+
int main (int argc, char *argv[]) {
DDS::DomainParticipantFactory_var dpf = DDS::DomainParticipantFactory::_nil();
@@ -32,6 +60,11 @@ int main (int argc, char *argv[]) {
dpf = TheParticipantFactoryWithArgs(argc, argv);
+ if (parse_args (argc, argv) != 0)
+ {
+ return 1;
+ }
+
participant = dpf->create_participant(
DDSTOPIC_DOMAIN_ID,
PARTICIPANT_QOS_DEFAULT,
@@ -135,10 +168,10 @@ int main (int argc, char *argv[]) {
while(true)
{
DDSTopic ddstopic;
- ddstopic.id = CORBA::string_dup("Asynch Message");
+ ddstopic.id = CORBA::string_dup(option_id);
ddstopic.sequence_number = i++;
- cout << "Writing DDSTopic [" << i << "]" << endl;
+ cout << "Writing DDSTopic [" << i << ", " << ddstopic.id << "]" << endl;
DDS::ReturnCode_t ret = ddstopic_dw->write(ddstopic, topic_handle);
if (ret != DDS::RETCODE_OK) {
diff --git a/CIAO/tests/DDS/tests/run_publisher.pl b/CIAO/tests/DDS/tests/run_publisher.pl
index 50393564c1d..027f9a8ff42 100755
--- a/CIAO/tests/DDS/tests/run_publisher.pl
+++ b/CIAO/tests/DDS/tests/run_publisher.pl
@@ -16,6 +16,9 @@ $DAnCE = "$ENV{'CIAO_ROOT'}/DAnCE";
$irepo_running = 0;
$IREPO = 0;
+$publisher_id = "Publisher 1";
+if (@ARGV[0]) {$publisher_id = @ARGV[0];}
+
# DCPS info repository parameters
$svcconf = "../descriptors/tcp.conf";
$dcpsconf = "../descriptors/dds_tcp_conf.ini";
@@ -60,7 +63,7 @@ $irepo_running = 1;
# invoke publisher
print "Invoking DDS publisher\n";
$pub = new PerlACE::Process ("../Publisher/publisher",
- "-ORBSvcConf $svcconf -DCPSConfigFile $dcpsconf");
+ "-ORBSvcConf $svcconf -DCPSConfigFile $dcpsconf -i \"$publisher_id\"");
$pub->Spawn ();
print "\n*************************************************************************\n";