summaryrefslogtreecommitdiff
path: root/CIAO/connectors/dds4ccm/impl/ndds/Topic.cpp
blob: c1a625ceb255b2579599913e46940ef34e8c3afd (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#include "dds4ccm/impl/ndds/Topic.h"
#include "dds4ccm/impl/ndds/StatusCondition.h"
#include "dds4ccm/impl/ndds/TopicListener.h"

#include "dds4ccm/impl/ndds/convertors/InstanceHandle_t.h"
#include "dds4ccm/impl/ndds/convertors/InconsistentTopicStatus.h"
#include "dds4ccm/impl/ndds/convertors/TopicQos.h"

#include "dds4ccm/impl/logger/Log_Macros.h"

namespace CIAO
{
  namespace NDDS
  {
    DDS_Topic_i::DDS_Topic_i (::DDSTopic* topic,
                          ::DDS::DomainParticipant_ptr dp)
      : rti_entity_ (topic),
        dp_ (::DDS::DomainParticipant::_duplicate (dp))
    {
      DDS4CCM_TRACE ("DDS_Topic_i::DDS_Topic_i");
    }

    DDS_Topic_i::~DDS_Topic_i (void)
    {
      DDS4CCM_TRACE ("DDS_Topic_i::~DDS_Topic_i");
    }

    ::DDS::ReturnCode_t
    DDS_Topic_i::set_qos (const ::DDS::TopicQos &qos)
    {
      DDS4CCM_TRACE ("DDS_Topic_i::set_qos");
      ::DDS_TopicQos ccm_dds_qos;
      DDS_ReturnCode_t const retcode = this->rti_entity ()->get_qos (ccm_dds_qos);
      if (retcode != DDS_RETCODE_OK)
        {
          DDS4CCM_ERROR (DDS4CCM_LOG_LEVEL_ERROR, (LM_ERROR, DDS4CCM_INFO
                       "DDS_Topic_i"
                       "::set_qos - "
                       "Error: Unable to retrieve topic qos\n"));
          return retcode;
        }
      ccm_dds_qos <<= qos;
      return this->rti_entity ()->get_qos (ccm_dds_qos);
    }

    ::DDS::ReturnCode_t
    DDS_Topic_i::get_qos (::DDS::TopicQos &qos)
    {
      DDS4CCM_TRACE ("DDS_Topic_i::get_qos");
      ::DDS_TopicQos ccm_dds_qos;
      ccm_dds_qos <<= qos;
      ::DDS_ReturnCode_t const retval = this->rti_entity ()->get_qos (ccm_dds_qos);
      qos <<= ccm_dds_qos;
      return retval;
    }

    ::DDS::ReturnCode_t
    DDS_Topic_i::set_listener (
      ::DDS::TopicListener_ptr a_listener,
      ::DDS::StatusMask mask)
    {
      DDS4CCM_TRACE ("DDS_Topic_i::set_listener");

      // Retrieve the previously set listener
      DDSTopicListener *old_listener = this->rti_entity ()->get_listener ();

      DDSTopicListener *listener = 0;
      if (! ::CORBA::is_nil (a_listener))
        {
          ACE_NEW_THROW_EX (listener,
                            DDS_TopicListener_i (
                              this,
                              a_listener),
                            ::CORBA::NO_MEMORY ());
        }

      ::DDS::ReturnCode_t const retcode =
        this->rti_entity ()->set_listener (listener, mask);

      if (retcode != ::DDS::RETCODE_OK)
        {
          delete listener;
        }
      else
        {
          this->topic_listener_ = ::DDS::TopicListener::_duplicate (a_listener);
          delete old_listener;
        }

      return retcode;
    }

    ::DDS::TopicListener_ptr
    DDS_Topic_i::get_listener (void)
    {
      DDS4CCM_TRACE ("DDS_Topic_i::get_listener");

      return ::DDS::TopicListener::_duplicate (this->topic_listener_.in ());
    }

    ::DDS::ReturnCode_t
    DDS_Topic_i::get_inconsistent_topic_status (
      ::DDS::InconsistentTopicStatus & a_status)
    {
      DDS4CCM_TRACE ("DDS_Topic_i::get_inconsistent_topic_status");

      DDS_InconsistentTopicStatus ddsstatus;
      ::DDS::ReturnCode_t const retval =
        this->rti_entity ()->get_inconsistent_topic_status (ddsstatus);
      a_status <<= ddsstatus;
      return retval;
    }

    ::DDS::ReturnCode_t
    DDS_Topic_i::enable (void)
    {
      DDS4CCM_TRACE ("DDS_Topic_i::enable");

      return this->rti_entity ()->enable ();
    }

    ::DDS::StatusCondition_ptr
    DDS_Topic_i::get_statuscondition (void)
    {
      DDS4CCM_TRACE ("DDS_Topic_i::get_statuscondition");

      ::DDS::StatusCondition_var retval;
      DDSStatusCondition* sc = this->rti_entity ()->get_statuscondition ();
      ACE_NEW_THROW_EX (retval,
                        DDS_StatusCondition_i (sc, this->dp_.in ()),
                        ::CORBA::NO_MEMORY ());
      return retval._retn ();
    }

    ::DDS::StatusMask
    DDS_Topic_i::get_status_changes (void)
    {
      DDS4CCM_TRACE ("DDS_Topic_i::get_status_changes");

      return this->rti_entity ()->get_status_changes ();
    }

    ::DDS::InstanceHandle_t
    DDS_Topic_i::get_instance_handle (void)
    {
      DDS4CCM_TRACE ("DDS_Topic_i::get_instance_handle");

      ::DDS_InstanceHandle_t const rtihandle =
        this->rti_entity ()->get_instance_handle ();
      ::DDS::InstanceHandle_t handle;
      handle <<= rtihandle;
      return handle;
    }

    char *
    DDS_Topic_i::get_type_name (void)
    {
      DDS4CCM_TRACE ("DDS_Topic_i::get_type_name");

      return CORBA::string_dup (this->rti_entity ()->get_type_name ());
    }

    char *
    DDS_Topic_i::get_name (void)
    {
      DDS4CCM_TRACE ("DDS_Topic_i::get_name");

      return CORBA::string_dup (this->rti_entity ()->get_name ());
    }

    ::DDS::DomainParticipant_ptr
    DDS_Topic_i::get_participant (void)
    {
      DDS4CCM_TRACE ("DDS_Topic_i::get_participant");

      return ::DDS::DomainParticipant::_duplicate (this->dp_.in ());
    }

    DDSTopic *
    DDS_Topic_i::get_rti_entity (void)
    {
      return this->rti_entity_;
    }

    void
    DDS_Topic_i::set_rti_entity (::DDSTopic* topic)
    {
      this->rti_entity_ = topic;
    }

    DDSTopic *
    DDS_Topic_i::rti_entity (void)
    {
      if (!this->rti_entity_)
        {
          DDS4CCM_DEBUG (DDS4CCM_LOG_LEVEL_ACTION, (LM_DEBUG,
                        "DDS_Topic_i::rti_entity - "
                        "Throwing BAD_INV_ORDER.\n"));
          throw ::CORBA::BAD_INV_ORDER ();
        }
      return this->rti_entity_;
      }
  }
}