summaryrefslogtreecommitdiff
path: root/DAnCE/tools/Logger_Backend/ndds/Log_Backend.h
blob: f8f1f6363cecf8cea080b1d20bdf7cd3657fbf91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// $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 "ace/Log_Msg_Backend.h"
#include "ace/Service_Object.h"

#include "DAnCE_NDDS_Log_Export.h"

#include <string>
#include <ndds/ndds_cpp.h>

#include "Log_RecordSupport.h"
#include "Log_RecordPlugin.h"

namespace DAnCE
{
  /**
   * @class NDDS_Log_Backend
   * @brief 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_;
    std::string qos_file_;

    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