summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam R. Otte <wotte@dre.vanderbilt.edu>2011-03-30 03:42:39 +0000
committerWilliam R. Otte <wotte@dre.vanderbilt.edu>2011-03-30 03:42:39 +0000
commit263d633fec1f21d122b3ff0d7f77579b0a004abd (patch)
tree951f404668f1f1af6db82785d6950a5d987ece14
parentc16150891c9cc706214c50f76b7a25be8e216a5a (diff)
downloadATCD-263d633fec1f21d122b3ff0d7f77579b0a004abd.tar.gz
Wed Mar 30 03:38:36 UTC 2011 William R. Otte <wotte@dre.vanderbilt.edu>
* tools/Logger_Backend: * tools/Logger_Backend/ndds: * tools/Logger_Backend/ndds/DAnCE_NDDS_Log_Export.h: * tools/Logger_Backend/ndds/Log_Backend.h: * tools/Logger_Backend/ndds/Log_Backend.cpp: * tools/Logger_Backend/ndds/Log_Record.idl: * tools/Logger_Backend/ndds/Log_RecordS.cpp: * tools/Logger_Backend/ndds/Log_Server.cpp: * tools/Logger_Backend/ndds/NDDS_Logger.mpc: NDDS-based logging backend for DAnCE. This serves as both a useful error reporting tool, and as a case study in DDS for myself. As such, the implementation is rather simple now, and possibly incorrect. In the future it will be expanded to take better advantage of DDS features. It has not yet been integrated into the Logger_Service as yet.
-rw-r--r--DAnCE/tools/Logger_Backend/ndds/DAnCE_NDDS_Log_Export.h58
-rw-r--r--DAnCE/tools/Logger_Backend/ndds/Log_Backend.cpp243
-rw-r--r--DAnCE/tools/Logger_Backend/ndds/Log_Backend.h76
-rw-r--r--DAnCE/tools/Logger_Backend/ndds/Log_Record.idl27
-rw-r--r--DAnCE/tools/Logger_Backend/ndds/Log_RecordS.cpp73
-rw-r--r--DAnCE/tools/Logger_Backend/ndds/Log_Server.cpp199
-rw-r--r--DAnCE/tools/Logger_Backend/ndds/NDDS_Logger.mpc34
7 files changed, 710 insertions, 0 deletions
diff --git a/DAnCE/tools/Logger_Backend/ndds/DAnCE_NDDS_Log_Export.h b/DAnCE/tools/Logger_Backend/ndds/DAnCE_NDDS_Log_Export.h
new file mode 100644
index 00000000000..2b6e6e417bc
--- /dev/null
+++ b/DAnCE/tools/Logger_Backend/ndds/DAnCE_NDDS_Log_Export.h
@@ -0,0 +1,58 @@
+
+// -*- C++ -*-
+// $Id$
+// Definition for Win32 Export directives.
+// This file is generated automatically by generate_export_file.pl DAnCE_NDDS_Log
+// ------------------------------
+#ifndef DANCE_NDDS_LOG_EXPORT_H
+#define DANCE_NDDS_LOG_EXPORT_H
+
+#include "ace/config-all.h"
+
+#if defined (ACE_AS_STATIC_LIBS) && !defined (DANCE_NDDS_LOG_HAS_DLL)
+# define DANCE_NDDS_LOG_HAS_DLL 0
+#endif /* ACE_AS_STATIC_LIBS && DANCE_NDDS_LOG_HAS_DLL */
+
+#if !defined (DANCE_NDDS_LOG_HAS_DLL)
+# define DANCE_NDDS_LOG_HAS_DLL 1
+#endif /* ! DANCE_NDDS_LOG_HAS_DLL */
+
+#if defined (DANCE_NDDS_LOG_HAS_DLL) && (DANCE_NDDS_LOG_HAS_DLL == 1)
+# if defined (DANCE_NDDS_LOG_BUILD_DLL)
+# define DAnCE_NDDS_Log_Export ACE_Proper_Export_Flag
+# define DANCE_NDDS_LOG_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
+# define DANCE_NDDS_LOG_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# else /* DANCE_NDDS_LOG_BUILD_DLL */
+# define DAnCE_NDDS_Log_Export ACE_Proper_Import_Flag
+# define DANCE_NDDS_LOG_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
+# define DANCE_NDDS_LOG_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# endif /* DANCE_NDDS_LOG_BUILD_DLL */
+#else /* DANCE_NDDS_LOG_HAS_DLL == 1 */
+# define DAnCE_NDDS_Log_Export
+# define DANCE_NDDS_LOG_SINGLETON_DECLARATION(T)
+# define DANCE_NDDS_LOG_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+#endif /* DANCE_NDDS_LOG_HAS_DLL == 1 */
+
+// Set DANCE_NDDS_LOG_NTRACE = 0 to turn on library specific tracing even if
+// tracing is turned off for ACE.
+#if !defined (DANCE_NDDS_LOG_NTRACE)
+# if (ACE_NTRACE == 1)
+# define DANCE_NDDS_LOG_NTRACE 1
+# else /* (ACE_NTRACE == 1) */
+# define DANCE_NDDS_LOG_NTRACE 0
+# endif /* (ACE_NTRACE == 1) */
+#endif /* !DANCE_NDDS_LOG_NTRACE */
+
+#if (DANCE_NDDS_LOG_NTRACE == 1)
+# define DANCE_NDDS_LOG_TRACE(X)
+#else /* (DANCE_NDDS_LOG_NTRACE == 1) */
+# if !defined (ACE_HAS_TRACE)
+# define ACE_HAS_TRACE
+# endif /* ACE_HAS_TRACE */
+# define DANCE_NDDS_LOG_TRACE(X) ACE_TRACE_IMPL(X)
+# include "ace/Trace.h"
+#endif /* (DANCE_NDDS_LOG_NTRACE == 1) */
+
+#endif /* DANCE_NDDS_LOG_EXPORT_H */
+
+// End of auto generated file.
diff --git a/DAnCE/tools/Logger_Backend/ndds/Log_Backend.cpp b/DAnCE/tools/Logger_Backend/ndds/Log_Backend.cpp
new file mode 100644
index 00000000000..6942e91f4cd
--- /dev/null
+++ b/DAnCE/tools/Logger_Backend/ndds/Log_Backend.cpp
@@ -0,0 +1,243 @@
+// $Id$
+#include "Log_Backend.h"
+
+#include "ace/Env_Value_T.h"
+#include "ace/Log_Msg.h"
+#include "ace/Log_Record.h"
+#include "ace/Get_Opt.h"
+
+namespace DAnCE
+{
+ NDDS_Log_Backend::NDDS_Log_Backend (void)
+ : domain_ (0),
+ participant_ (0),
+ topic_name_ (0),
+ publisher_ (0),
+ datawriter_ (0),
+ log_record_writer_ (0)
+ {
+ }
+
+ NDDS_Log_Backend::~NDDS_Log_Backend (void)
+ {
+ (void) this->close ();
+ }
+
+ int
+ NDDS_Log_Backend::init (int argc, ACE_TCHAR **argv)
+ {
+ ACE_Get_Opt opts (argc, argv, ACE_TEXT ("t:d:"), 1, 0,
+ ACE_Get_Opt::RETURN_IN_ORDER);
+ opts.long_option (ACE_TEXT ("topic"), 't', ACE_Get_Opt::ARG_REQUIRED);
+ opts.long_option (ACE_TEXT ("domain"), 'd', ACE_Get_Opt::ARG_REQUIRED);
+
+ int c = 0;
+
+ while ((c = opts ()) != -1)
+ {
+ switch (c)
+ {
+ case 't':
+ this->topic_name_ = opts.opt_arg ();
+ break;
+
+ case 'd':
+ this->domain_ = ACE_OS::atoi (opts.opt_arg ());
+ break;
+
+ default:
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("Unknown Option: %s\n"),
+ opts.last_option ()));
+ return -1;
+ }
+
+ return 0;
+ }
+ }
+
+ int
+ NDDS_Log_Backend::fini (void)
+ {
+
+ }
+
+ int
+ NDDS_Log_Backend::info (ACE_TCHAR **str, size_t len) const
+ {
+
+ }
+
+ int
+ NDDS_Log_Backend::get_configuration (const ACE_TCHAR *logger_key)
+ {
+ // for now, we ignore logger key until I figure out what to do with it.
+ ACE_Env_Value<long> env_domain (ACE_TEXT("DANCE_LOG_NDDS_DOMAIN"), this->domain_);
+ this->domain_ = env_domain;
+
+ ACE_Env_Value<const ACE_TCHAR *> env_topic (ACE_TEXT ("DANCE_LOG_NDDS_TOPIC"),
+ ACE_TEXT_CHAR_TO_TCHAR (this->topic_name_.c_str ()));
+ this->topic_name_ = ACE_TEXT_ALWAYS_CHAR (env_topic);
+
+ ACE_Env_Value<const ACE_TCHAR *> env_node (ACE_TEXT ("DANCE_LOG_NDDS_NODE_NAME"),
+ ACE_TEXT_CHAR_TO_TCHAR (this->node_.c_str ()));
+ this->node_ = ACE_TEXT_ALWAYS_CHAR (env_node);
+
+ return 0;
+ }
+
+ int
+ NDDS_Log_Backend::configure_dds (void)
+ {
+ this->participant_ = DDSDomainParticipantFactory::get_instance ()->
+ create_participant (this->domain_,
+ DDS_PARTICIPANT_QOS_DEFAULT,
+ 0,
+ DDS_STATUS_MASK_NONE);
+
+ if (this->participant_ == 0)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("NDDS_Log_Backend::open - Failed to create participant\n")));
+ return -1;
+ }
+
+ DDS_ReturnCode_t retval;
+
+ retval = Log_RecordTypeSupport::register_type (this->participant_,
+ Log_RecordTypeSupport::get_type_name ());
+
+ if (retval != DDS_RETCODE_OK)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("NDDS_Log_Backend::open - Failed to register type\n")));
+ (void) this->close ();
+ return -1;
+ }
+
+ this->topic_ = this->participant_->create_topic (this->topic_name_.c_str (),
+ Log_RecordTypeSupport::get_type_name (),
+ DDS_TOPIC_QOS_DEFAULT,
+ 0,
+ DDS_STATUS_MASK_NONE);
+
+ if (this->topic_ == 0)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("NDDS_Log_Backend::open - Failed to create topic\n")));
+ this->close ();
+ return -1;
+ }
+
+ this->publisher_ = this->participant_->create_publisher (DDS_PUBLISHER_QOS_DEFAULT,
+ 0,
+ DDS_STATUS_MASK_NONE);
+
+ if (this->publisher_ == 0)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("NDDS_Log_Backend::open - Failed to create publisher\n")));
+ this->close ();
+ return -1;
+ }
+
+ this->datawriter_ = this->publisher_->create_datawriter (this->topic_,
+ DDS_DATAWRITER_QOS_DEFAULT,
+ 0,
+ DDS_STATUS_MASK_NONE);
+ if (this->datawriter_ == 0)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("NDDS_Log_Backend::open - Failed to open the datawriter\n")));
+ this->close ();
+ return -1;
+ }
+
+ log_record_writer_ = Log_RecordDataWriter::narrow (this->datawriter_);
+ }
+
+ int
+ NDDS_Log_Backend::open (const ACE_TCHAR *logger_key)
+ {
+ if (this->get_configuration (logger_key) != 0)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("NDDS_Log_Backend::open - unable to get configuration\n")));
+ return -1;
+ }
+
+ if (this->configure_dds () != 0)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("NDDS_Log_Backend::open - unable to configure DDS entities\n")));
+ return -1;
+ }
+ }
+
+ int
+ NDDS_Log_Backend::reset (void)
+ {
+ return this->close ();
+ }
+
+ int
+ NDDS_Log_Backend::close (void)
+ {
+ if (this->participant_ != 0)
+ {
+ DDS_ReturnCode_t retval =
+ this->participant_->delete_contained_entities ();
+
+ if (retval != DDS_RETCODE_OK)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("NDDS_Log_Backend::close - Unable to delete participant contained entities\n")));
+ }
+
+ retval = DDSDomainParticipantFactory::get_instance ()->delete_participant (this->participant_);
+
+ if (retval != DDS_RETCODE_OK)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("NDDS_Log_Backend::close - Unable to delete participant\n")));
+ }
+ }
+
+ this->participant_ = 0;
+ this->topic_ = 0;
+ this->publisher_ = 0;
+ this->datawriter_ = 0;
+ this->log_record_writer_ = 0;
+
+ return 0;
+ }
+
+ ssize_t
+ NDDS_Log_Backend::log (ACE_Log_Record &log_record)
+ {
+ Log_Record *instance (0);
+
+ instance = Log_RecordTypeSupport::create_data_ex (DDS_BOOLEAN_FALSE);
+
+ if (instance == 0)
+ {
+ ACE_ERROR ((LM_EMERGENCY, ACE_TEXT ("Unable to create data sample for log record\n")));
+ return 0;
+ }
+
+ instance->node = this->node_.c_str ();
+ instance->pid = log_record.pid ();
+ instance->pid = log_record.pid ();
+ instance->message = ACE_TEXT_ALWAYS_CHAR (log_record.msg_data ());
+
+ DDS_ReturnCode_t retval = this->log_record_writer_->write (*instance, DDS_HANDLE_NIL);
+
+ if (retval != DDS_RETCODE_OK)
+ {
+ ACE_ERROR ((LM_EMERGENCY, ACE_TEXT ("Unable to write log record to DDS\n")));
+ return 0;
+ }
+
+ if (instance != 0)
+ {
+ Log_RecordTypeSupport::delete_data_ex (instance,
+ DDS_BOOLEAN_FALSE);
+ }
+
+ return log_record.msg_data_len ();
+ }
+
+ ACE_FACTORY_DEFINE (DAnCE_NDDS_Log, NDDS_Log_Backend);
+}
+
+
diff --git a/DAnCE/tools/Logger_Backend/ndds/Log_Backend.h b/DAnCE/tools/Logger_Backend/ndds/Log_Backend.h
new file mode 100644
index 00000000000..d01e3e4f414
--- /dev/null
+++ b/DAnCE/tools/Logger_Backend/ndds/Log_Backend.h
@@ -0,0 +1,76 @@
+// $Id$
+
+/**
+ * @file Log_Backend.h
+ * @author William R. Otte <wotte@dre.vanderbilt.edu>
+ *
+ * Provides a backend useable by the ACE logging infrastructure that transmits via NDDS.
+ */
+
+#ifndef DAnCE_LOG_BACKEND_H
+#define DAnCE_LOG_BACKEND_H
+
+#include <string>
+#include <ndds/ndds_cpp.h>
+
+#include "ace/Log_Msg_Backend.h"
+#include "ace/Service_Object.h"
+
+#include "DAnCE_NDDS_Log_Export.h"
+
+#include "Log_RecordSupport.h"
+#include "Log_RecordPlugin.h"
+
+namespace DAnCE
+{
+ /**
+ * @class NDDS_Log_Backend
+ * @breif Provides a logging backend that transmits records over DDS/.
+ */
+ class DAnCE_NDDS_Log_Export NDDS_Log_Backend :
+ public virtual ACE_Log_Msg_Backend,
+ public virtual ACE_Service_Object
+ {
+ public:
+ NDDS_Log_Backend (void);
+
+ virtual ~NDDS_Log_Backend (void);
+
+ // Methods from ACE_Log_Msg_Backend
+ virtual int open (const ACE_TCHAR *logger_key);
+
+ virtual int reset (void);
+
+ virtual int close (void);
+
+ virtual ssize_t log (ACE_Log_Record &log_record);
+
+ // Methods from ACE_Service_Object
+
+ virtual int init (int argc, ACE_TCHAR **argv);
+
+ virtual int fini (void);
+
+ virtual int info (ACE_TCHAR **str, size_t len) const;
+
+ private:
+ int get_configuration (const ACE_TCHAR *logger_key);
+ int configure_dds (void);
+
+ std::string topic_name_;
+ std::string node_;
+ long domain_;
+
+ DDSDomainParticipant *participant_;
+ DDSTopic *topic_;
+ DDSPublisher *publisher_;
+ DDSDataWriter *datawriter_;
+ Log_RecordDataWriter * log_record_writer_;
+ };
+
+ ACE_FACTORY_DECLARE (DAnCE_NDDS_Log, NDDS_Log_Backend);
+}
+
+
+
+#endif
diff --git a/DAnCE/tools/Logger_Backend/ndds/Log_Record.idl b/DAnCE/tools/Logger_Backend/ndds/Log_Record.idl
new file mode 100644
index 00000000000..e6d0d9e735c
--- /dev/null
+++ b/DAnCE/tools/Logger_Backend/ndds/Log_Record.idl
@@ -0,0 +1,27 @@
+// $Id$
+
+/**
+ * @file Log_Record.idl
+ * @author William R. Otte
+ *
+ * Defines a data structure for DAnCE log records.
+ */
+
+module DAnCE
+{
+
+ struct Log_Record
+ {
+ /// The name of the node this originates from, if available
+ string node; //@key
+
+ /// The process ID of the node.
+ long pid; //@key
+
+ /// The log priority of the message
+ unsigned long priority;
+
+ /// The error diagnostic
+ string message;
+ };
+}; \ No newline at end of file
diff --git a/DAnCE/tools/Logger_Backend/ndds/Log_RecordS.cpp b/DAnCE/tools/Logger_Backend/ndds/Log_RecordS.cpp
new file mode 100644
index 00000000000..8fa572b3242
--- /dev/null
+++ b/DAnCE/tools/Logger_Backend/ndds/Log_RecordS.cpp
@@ -0,0 +1,73 @@
+// -*- C++ -*-
+// $Id$
+
+/**
+ * Code generated by the The ACE ORB (TAO) IDL Compiler v2.0.1
+ * TAO and the TAO IDL Compiler have been developed by:
+ * Center for Distributed Object Computing
+ * Washington University
+ * St. Louis, MO
+ * USA
+ * http://www.cs.wustl.edu/~schmidt/doc-center.html
+ * and
+ * Distributed Object Computing Laboratory
+ * University of California at Irvine
+ * Irvine, CA
+ * USA
+ * and
+ * Institute for Software Integrated Systems
+ * Vanderbilt University
+ * Nashville, TN
+ * USA
+ * http://www.isis.vanderbilt.edu/
+ *
+ * Information about TAO is available at:
+ * http://www.cs.wustl.edu/~schmidt/TAO.html
+ **/
+
+
+// TAO_IDL - Generated from
+// be/be_codegen.cpp:659
+
+#ifndef _TAO_IDL_LOG_RECORDS_FHFBZC_CPP_
+#define _TAO_IDL_LOG_RECORDS_FHFBZC_CPP_
+
+
+#include "Log_RecordS.h"
+
+#if !defined (__ACE_INLINE__)
+#include "Log_RecordS.inl"
+#endif /* !defined INLINE */
+
+// TAO_IDL - Generated from
+// be/be_visitor_arg_traits.cpp:68
+
+TAO_BEGIN_VERSIONED_NAMESPACE_DECL
+
+
+// Arg traits specializations.
+namespace TAO
+{
+}
+
+TAO_END_VERSIONED_NAMESPACE_DECL
+
+
+
+// TAO_IDL - Generated from
+// be/be_visitor_arg_traits.cpp:68
+
+TAO_BEGIN_VERSIONED_NAMESPACE_DECL
+
+
+// Arg traits specializations.
+namespace TAO
+{
+}
+
+TAO_END_VERSIONED_NAMESPACE_DECL
+
+
+
+#endif /* ifndef */
+
diff --git a/DAnCE/tools/Logger_Backend/ndds/Log_Server.cpp b/DAnCE/tools/Logger_Backend/ndds/Log_Server.cpp
new file mode 100644
index 00000000000..12ac6852a3f
--- /dev/null
+++ b/DAnCE/tools/Logger_Backend/ndds/Log_Server.cpp
@@ -0,0 +1,199 @@
+// $Id$
+
+/**
+ * @file Log_Server.cpp
+ * @author William R. Otte <wotte@dre.vanderbilt.edu>
+ *
+ * A simple server daemon that prints DAnCE log records received over DDS.
+ */
+
+#include "ace/Log_Msg.h"
+#include "ace/OS_main.h"
+#include "ace/Get_Opt.h"
+#include "ndds/ndds_cpp.h"
+#include "Log_Record.h"
+#include "Log_RecordSupport.h"
+#include "Log_RecordPlugin.h"
+
+#include <string>
+#include <iostream>
+
+struct Options
+{
+ std::string topic_;
+ long domain_;
+};
+
+Options program_options;
+
+bool parse_args (int argc, ACE_TCHAR **argv)
+{
+ ACE_Get_Opt opts (argc, argv, ACE_TEXT ("t:d:"), 1, 0,
+ ACE_Get_Opt::RETURN_IN_ORDER);
+ opts.long_option (ACE_TEXT ("topic"), 't', ACE_Get_Opt::ARG_REQUIRED);
+ opts.long_option (ACE_TEXT ("domain"), 'd', ACE_Get_Opt::ARG_REQUIRED);
+
+ int c = 0;
+
+ while ((c = opts ()) != -1)
+ {
+ switch (c)
+ {
+ case 't':
+ program_options.topic_ = opts.opt_arg ();
+ break;
+
+ case 'd':
+ program_options.domain_ = ACE_OS::atoi (opts.opt_arg ());
+ break;
+
+ default:
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("Unknown Option: %s\n"),
+ opts.last_option ()));
+ return false;
+ }
+
+ return true;
+ }
+}
+
+int
+ACE_TMAIN (int argc, ACE_TCHAR **argv)
+{
+
+ if (!parse_args (argc, argv))
+ {
+ ACE_ERROR ((LM_EMERGENCY, ACE_TEXT ("Unable to parse commad line options\n")));
+ return -1;
+ }
+
+ DDSDomainParticipant *participant_ = 0;
+ DDSTopic *topic_ = 0;
+ DDSSubscriber *subscriber_ = 0;
+ DDSDataReader *datareader_ = 0;
+ DAnCE::Log_RecordDataReader * log_record_reader_ = 0;
+
+ try
+ {
+ participant_ = DDSDomainParticipantFactory::get_instance ()->
+ create_participant (program_options.domain_,
+ DDS_PARTICIPANT_QOS_DEFAULT,
+ 0,
+ DDS_STATUS_MASK_NONE);
+
+ if (participant_ == 0)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("NDDS_Log_Backend::open - Failed to create participant\n")));
+ return -1;
+ }
+
+ DDS_ReturnCode_t retval;
+
+ retval = DAnCE::Log_RecordTypeSupport::register_type (participant_,
+ DAnCE::Log_RecordTypeSupport::get_type_name ());
+
+ if (retval != DDS_RETCODE_OK)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("NDDS_Log_Backend::open - Failed to register type\n")));
+ throw 1;
+ }
+
+ topic_ = participant_->create_topic (program_options.topic_.c_str (),
+ DAnCE::Log_RecordTypeSupport::get_type_name (),
+ DDS_TOPIC_QOS_DEFAULT,
+ 0,
+ DDS_STATUS_MASK_NONE);
+
+ if (topic_ == 0)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("NDDS_Log_Backend::open - Failed to create topic\n")));
+ throw 1;
+ }
+
+ subscriber_ = participant_->create_subscriber (DDS_SUBSCRIBER_QOS_DEFAULT,
+ 0,
+ DDS_STATUS_MASK_NONE);
+
+ if (subscriber_ == 0)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("NDDS_Log_Backend::open - Failed to create publisher\n")));
+ throw 1;
+ }
+
+ datareader_ = subscriber_->create_datareader (topic_,
+ DDS_DATAREADER_QOS_DEFAULT,
+ 0,
+ DDS_STATUS_MASK_NONE);
+ if (datareader_ == 0)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("NDDS_Log_Backend::open - Failed to open the datawriter\n")));
+ throw 1;
+ }
+
+ log_record_reader_ = DAnCE::Log_RecordDataReader::narrow (datareader_);
+
+
+ for (;;)
+ {
+ DAnCE::Log_RecordSeq records;
+ DDS_SampleInfoSeq recordInfos;
+
+ DDS_ReturnCode_t result = log_record_reader_->take (records,
+ recordInfos,
+ DDS_LENGTH_UNLIMITED,
+ DDS_ANY_SAMPLE_STATE,
+ DDS_ANY_VIEW_STATE,
+ DDS_ANY_INSTANCE_STATE);
+
+ if (result == DDS_RETCODE_NO_DATA)
+ {
+ // try again
+ continue;
+ }
+ else
+ {
+ for (size_t i = 0; i < records.length (); ++i)
+ {
+ DDS_SampleInfo &info = recordInfos[i];
+
+ if (!info.valid_data)
+ continue;
+
+ std::cerr << records[i].node.in () << ':'
+ << records[i].pid << " - "
+ << records[i].message.in () << std::cerr;
+ }
+ }
+
+ log_record_reader_->return_loan (records, recordInfos);
+ }
+ }
+ catch (...)
+ {
+ if (participant_ != 0)
+ {
+ DDS_ReturnCode_t retval =
+ participant_->delete_contained_entities ();
+
+ if (retval != DDS_RETCODE_OK)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("NDDS_Log_Backend::close - Unable to delete participant contained entities\n")));
+ }
+
+ retval = DDSDomainParticipantFactory::get_instance ()->delete_participant (participant_);
+
+ if (retval != DDS_RETCODE_OK)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("NDDS_Log_Backend::close - Unable to delete participant\n")));
+ }
+ }
+
+ participant_ = 0;
+ topic_ = 0;
+ subscriber_ = 0;
+ datareader_ = 0;
+ log_record_reader_ = 0;
+
+ return 0;
+ }
+}
diff --git a/DAnCE/tools/Logger_Backend/ndds/NDDS_Logger.mpc b/DAnCE/tools/Logger_Backend/ndds/NDDS_Logger.mpc
new file mode 100644
index 00000000000..1f7cdd9e535
--- /dev/null
+++ b/DAnCE/tools/Logger_Backend/ndds/NDDS_Logger.mpc
@@ -0,0 +1,34 @@
+project(DAnCE_NDDS_Logger) : nddslib_with_idl, taolib_with_idl, dance_output, install {
+
+ dynamicflags += DANCE_NDDS_LOG_BUILD_DLL
+
+ idlflags += -SS -Sci \
+ -Wb,stub_export_macro=DAnCE_NDDS_Log_Stub_Export \
+ -Wb,stub_export_include=DAnCE_NDDS_Log_stub_export.h
+
+ NDDSTypeSupport_Files {
+ Log_Record.idl
+ }
+
+ IDL_Files {
+ idlflags += -Gxhst
+ Log_Record.idl
+ }
+
+ Source_Files {
+ Log_Backend.cpp
+ }
+}
+
+project(DAnCE_NDDS_Log_Server) : nddsexe_with_idl, taoidldefaults, taoclient, dance_output, install {
+ after += DAnCE_NDDS_Logger
+ exename = dance_ndds_log_server
+
+ Source_Files {
+ Log_Record.cxx
+ Log_RecordC.cpp
+ Log_RecordPlugin.cxx
+ Log_RecordSupport.cxx
+ Log_Server.cpp
+ }
+} \ No newline at end of file