summaryrefslogtreecommitdiff
path: root/CIAO/connectors/dds4ccm/tests/SetConnectorAttributes/Component/SetConnectorAttribute_Component_exec.cpp
blob: 35a19a25c4139ab022bd2415dffd588c636534cf (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
// -*- C++ -*-
#include "SetConnectorAttribute_Component_exec.h"
#include "Connector/SetConnectorAttribute_Connector_conn.h"

#include "dds4ccm/impl/Utils.h"
#if (CIAO_DDS4CCM_NDDS == 1)
#include "dds4ccm/impl/ndds/DataWriter_T.h"
#include "Base/SetConnectorAttribute_BaseSupport.h"
#endif

#define DOMAIN_ID_IN_DP 56
#define TOPIC_NAME_IN_DP "SetConnectorAttribute"

#define DW_MAX_BLOCKING_TIME_SEC 11
#define DW_MAX_BLOCKING_TIME_NSEC 200

namespace CIAO_SetConnectorAttribute_SetConnectorAttributeComponent_Impl
{
  //============================================================
  // Component_exec_i
  //============================================================
  Component_exec_i::Component_exec_i (void)
  {
  }

  Component_exec_i::~Component_exec_i (void)
  {
  }

  void
  Component_exec_i::check_topic_name (DDSTopic * tp)
  {
#if (CIAO_DDS4CCM_NDDS == 1)
    if (ACE_OS::strcmp (tp->get_name (), TOPIC_NAME_IN_DP) == 0)
      {
        ACE_DEBUG ((LM_DEBUG, "Component_exec_i::check_topic_name - "
                              "Topic name set properly.\n"));
      }
    else
      {
        ACE_ERROR ((LM_ERROR, "Component_exec_i::check_topic_name - "
                              "Topic name not properly set: "
                              "expected <%C> - retrieved <%C>\n",
                              TOPIC_NAME_IN_DP,
                              tp->get_name ()));
      }
#else
    ACE_UNUSED_ARG (tp);
#endif
  }

  void
  Component_exec_i::check_domain_id (DDSPublisher * pub)
  {
#if (CIAO_DDS4CCM_NDDS == 1)
    DDSDomainParticipant * part = pub->get_participant ();
    if (part->get_domain_id () != DOMAIN_ID_IN_DP)
      {
        ACE_ERROR ((LM_ERROR, "Component_exec_i::check_domain_id - "
                              "ERROR: Domain ID not set properly: "
                              "expected <%u> - retrieved <%u>\n",
                              DOMAIN_ID_IN_DP,
                              part->get_domain_id ()));
      }
    else
      {
        ACE_DEBUG ((LM_DEBUG, "Component_exec_i::check_domain_id - "
                              "Domain ID set properly.\n"));
      }
#else
    ACE_UNUSED_ARG (pub);
#endif
  }

  void
  Component_exec_i::check_attributes (DDSDataWriter * dw)
  {
#if (CIAO_DDS4CCM_NDDS == 1)
    // Check topic name
    DDSTopic * tp = dw->get_topic ();
    if (!tp)
      {
        ACE_ERROR ((LM_ERROR, "Component_exec_i::check_attributes - "
                              "Unable to retrieve topic.\n"));
      }
    else
      {
        this->check_topic_name (tp);
      }
    //check domain id
    ::DDSPublisher * pub = dw->get_publisher ();
    if (!pub)
      {
        ACE_ERROR ((LM_ERROR, "Component_exec_i::check_attributes - "
                              "Unable to retrieve Publisher.\n"));
      }
    else
      {
        this->check_domain_id (pub);
        this->check_profile (pub);
      }
#else
    ACE_UNUSED_ARG (dw);
#endif
  }

  void
  Component_exec_i::check_profile (DDSPublisher * pub)
  {
#if (CIAO_DDS4CCM_NDDS == 1)
    DDS_DataWriterQos dw_qos;
    pub->get_default_datawriter_qos (dw_qos);
    if (dw_qos.reliability.max_blocking_time.sec == DW_MAX_BLOCKING_TIME_SEC &&
        dw_qos.reliability.max_blocking_time.nanosec == DW_MAX_BLOCKING_TIME_NSEC)
      {
      }
    else
      {
        ACE_ERROR ((LM_ERROR, "Component_exec_i::check_profile - "
                              "ERROR: Profile not set properly: "
                              "expected sec <%u> - retrieved sec <%u> and "
                              "expected nanosec <%u> - retrieved nanosec <%u>\n",
                              dw_qos.reliability.max_blocking_time.sec,
                              DW_MAX_BLOCKING_TIME_SEC,
                              dw_qos.reliability.max_blocking_time.nanosec,
                              DW_MAX_BLOCKING_TIME_NSEC));
      }
#else
    ACE_UNUSED_ARG (pub);
#endif
  }

  // Operations from Components::SessionComponent.
  void
  Component_exec_i::set_session_context (
    ::Components::SessionContext_ptr ctx)
  {
    this->context_ =
      ::SetConnectorAttribute::CCM_SetConnectorAttributeComponent_Context::_narrow (ctx);
    if ( ::CORBA::is_nil (this->context_.in ()))
      {
        throw ::CORBA::INTERNAL ();
      }
  }

  void
  Component_exec_i::configuration_complete (void)
  {
  }

  void
  Component_exec_i::ccm_activate (void)
  {
#if (CIAO_DDS4CCM_NDDS == 1)
    //check the settings on the connector
    DDS::DataWriter_var dds_dw =
      this->context_->get_connection_info_write_dds_entity ();

    typedef ::CIAO::NDDS::DDS_DataWriter_Base DataWriter_type;
    DataWriter_type * ccm_dds_dw = dynamic_cast <DataWriter_type*> (dds_dw.in ());
    if (!ccm_dds_dw)
      {
        ACE_DEBUG ((LM_DEBUG, "ERROR: Component_exec_i::ccm_activate - "
                              "Unable to cast\n"));
        return;
      }
    DDSDataWriter * dw = ccm_dds_dw->get_rti_entity ();
    if (dw)
      {
        this->check_attributes (dw);
      }
    else
      {
        ACE_ERROR ((LM_ERROR, "ERROR: Component_exec_i::ccm_activate - "
                              "Unable to retrieve DDSDataWriter.\n"));
      }
#endif
  }

  void
  Component_exec_i::ccm_passivate (void)
  {
  }

  void
  Component_exec_i::ccm_remove (void)
  {
  }

  extern "C" COMPONENT_EXEC_Export ::Components::EnterpriseComponent_ptr
  create_SetConnectorAttribute_Component_Impl (void)
  {
    ::Components::EnterpriseComponent_ptr retval =
      ::Components::EnterpriseComponent::_nil ();

    ACE_NEW_NORETURN (
      retval,
      Component_exec_i);

    return retval;
  }
}