summaryrefslogtreecommitdiff
path: root/CIAO/connectors/dds4ccm/impl/ndds/TopicListener_T.cpp
blob: 2f018babcf5d06f40308f53c13fec10cc25f700d (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$
#include "dds4ccm/impl/ndds/Utils.h"

#include "dds4ccm/impl/ndds/Topic.h"
#include "dds4ccm/impl/ndds/DDSCallbackStatusHandler.h"
#include "dds4ccm/impl/logger/Log_Macros.h"

template <typename DDS_TYPE, typename CCM_TYPE>
CIAO::DDS4CCM::TopicListener_T<DDS_TYPE, CCM_TYPE>::TopicListener_T (
  ::CCM_DDS::ConnectorStatusListener_ptr error_listener,
  ACE_Reactor* reactor) :
    error_listener_ (::CCM_DDS::ConnectorStatusListener::_duplicate (error_listener)),
    reactor_ (reactor)
{
  DDS4CCM_TRACE ("CIAO::DDS4CCM::TopicListener_T::TopicListener_T");
}

template <typename DDS_TYPE, typename CCM_TYPE>
CIAO::DDS4CCM::TopicListener_T<DDS_TYPE, CCM_TYPE>::~TopicListener_T (void)
{
  DDS4CCM_TRACE ("CIAO::DDS4CCM::TopicListener_T::~TopicListener_T");
}

template <typename DDS_TYPE, typename CCM_TYPE>
void
CIAO::DDS4CCM::TopicListener_T<DDS_TYPE, CCM_TYPE>::on_inconsistent_topic (
  ::DDS::Topic_ptr the_topic,
  const ::DDS::InconsistentTopicStatus & status)
{
  DDS4CCM_TRACE ("CIAO::DDS4CCM::TopicListener_T::on_inconsistent_topic");

  DDS4CCM_DEBUG (10, (LM_DEBUG, CLINFO
              ACE_TEXT ("TopicListener_T::on_inconsistent_topic: ")
              ACE_TEXT ("total count <%d> - total change <%d> - "),
              status.total_count, status.total_count_change));

  if (!CORBA::is_nil (this->error_listener_.in ()))
    {
      if (this->reactor_)
        {
          ::CIAO::DDS4CCM::OnInconsistentTopicHandler* rh = 0;
          ACE_NEW (rh,
                   ::CIAO::DDS4CCM::OnInconsistentTopicHandler (
                     this->error_listener_,
                     the_topic,
                     status));
          ACE_Event_Handler_var safe_handler (rh);
          if (this->reactor_->notify (rh) != 0)
            {
              DDS4CCM_ERROR (1, (LM_ERROR, CLINFO
                          ACE_TEXT ("TopicListener_T::on_inconsistent_topic: ")
                          ACE_TEXT ("failed to use reactor.\n")));
            }
        }
      else
        {
          this->error_listener_->on_inconsistent_topic (the_topic, status);
        }
    }
}

template <typename DDS_TYPE, typename CCM_TYPE>
::DDS::StatusMask
CIAO::DDS4CCM::TopicListener_T<DDS_TYPE, CCM_TYPE>::get_mask (
  CCM_DDS::ConnectorStatusListener_ptr error_listener)
{
  DDS4CCM_TRACE ("CIAO::DDS4CCM::TopicListener_T::get_mask");

  if (!CORBA::is_nil (error_listener) || CIAO_debug_level >= 10)
    {
      return ::DDS::INCONSISTENT_TOPIC_STATUS;
    }
  else
    {
      return 0;
    }
}