summaryrefslogtreecommitdiff
path: root/CIAO/connectors/ami4ccm/examples/Hello/Connector/AMI_exec.cpp
blob: cbc342b0f7c168935357879034eed5ac2ce148c1 (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
// -*- C++ -*-
// $Id$

#include "AMI_exec.h"
#include "ciao/Logger/Log_Macros.h"
#include "AMI_MyFoo_i.h"

namespace CIAO_Hello_AMI_Sender_Impl
{
  AMI_MyFoo_exec_i::AMI_MyFoo_exec_i ()
  {
  }

  AMI_MyFoo_exec_i::~AMI_MyFoo_exec_i (void)
  {
  }

  void
  AMI_MyFoo_exec_i::provide_receiver (::Hello::MyFoo_ptr receiver_foo)
  {
    this->ami_foo_server_ = ::Hello::MyFoo::_duplicate (receiver_foo);
  }

  void
  AMI_MyFoo_exec_i::sendc_foo (
    ::Hello::AMI_MyFooCallback_ptr ami_handler,
    const char * in_str)
  {
    printf ("AMI (FOO) :\tsendc_foo <%s>\n", in_str);
    if (!::CORBA::is_nil (this->ami_foo_server_.in ()))
      {
        Hello::AMI_MyFooHandler_var the_handler_var;
        if (!::CORBA::is_nil (ami_handler))
          {
            ::CCM_CORBA_AMI_MyFoo_Impl::AMI_MyFoo_reply_handler*  handler =
              new ::CCM_CORBA_AMI_MyFoo_Impl::AMI_MyFoo_reply_handler (ami_handler);
            the_handler_var = handler->_this ();
          }
        printf ("AMI (FOO) :\tSending string <%s> to AMI CORBA server\n", in_str);
        this->ami_foo_server_->sendc_foo (the_handler_var.in (), in_str);
        printf ("AMI (FOO) : \tInvoked sendc_foo\n");
      }
  }

  void
  AMI_MyFoo_exec_i::sendc_hello (
    ::Hello::AMI_MyFooCallback_ptr ami_handler)
  {
    printf ("AMI (FOO) :\tsendc_hello\n");
    if (!::CORBA::is_nil (this->ami_foo_server_.in ()))
      {
        Hello::AMI_MyFooHandler_var the_handler_var;
        if (!::CORBA::is_nil (ami_handler))
          {
            ::CCM_CORBA_AMI_MyFoo_Impl::AMI_MyFoo_reply_handler*  handler =
              new ::CCM_CORBA_AMI_MyFoo_Impl::AMI_MyFoo_reply_handler (ami_handler);
            the_handler_var = handler->_this ();
          }
        printf ("AMI (FOO) :\tCalling AMI CORBA server\n");
        this->ami_foo_server_->sendc_hello (the_handler_var.in ());
        printf ("AMI (FOO) : \tInvoked sendc_foo\n");
      }
  }

  void
  AMI_MyFoo_exec_i::sendc_get_rw_attrib (
    ::Hello::AMI_MyFooCallback_ptr ami_handler)
  {
    printf ("AMI (FOO) :\tsendc_get_rw_attrib\n");
    if (!::CORBA::is_nil (this->ami_foo_server_.in ()))
      {
        Hello::AMI_MyFooHandler_var the_handler_var;
        if (!::CORBA::is_nil (ami_handler))
          {
            ::CCM_CORBA_AMI_MyFoo_Impl::AMI_MyFoo_reply_handler*  handler =
              new ::CCM_CORBA_AMI_MyFoo_Impl::AMI_MyFoo_reply_handler (ami_handler);
            the_handler_var = handler->_this ();
          }
        this->ami_foo_server_->sendc_get_rw_attrib (the_handler_var.in ());
        printf ("AMI (FOO) : \tInvoked sendc_get_rw_attrib\n");
      }
  }

  void
  AMI_MyFoo_exec_i::sendc_set_rw_attrib (
    ::Hello::AMI_MyFooCallback_ptr ami_handler,
    CORBA::Short rw_attrib)
  {
    printf ("AMI (FOO) :\tsendc_set_rw_attrib\n");
    if (!::CORBA::is_nil (this->ami_foo_server_.in ()))
      {
        Hello::AMI_MyFooHandler_var the_handler_var;
        if (!::CORBA::is_nil (ami_handler))
          {
            ::CCM_CORBA_AMI_MyFoo_Impl::AMI_MyFoo_reply_handler*  handler =
              new ::CCM_CORBA_AMI_MyFoo_Impl::AMI_MyFoo_reply_handler (ami_handler);
            the_handler_var = handler->_this ();
          }
        printf ("AMI (FOO) : \tSet rw_attrib <%d>\n", rw_attrib);
        this->ami_foo_server_->sendc_set_rw_attrib (the_handler_var.in (), rw_attrib);
        printf ("AMI (FOO) : \tInvoked sendc_set_rw_attrib\n");
      }
  }

  void
  AMI_MyFoo_exec_i::sendc_get_ro_attrib (
    ::Hello::AMI_MyFooCallback_ptr ami_handler)
  {
    printf ("AMI (FOO) :\tsendc_get_ro_attrib\n");
    if (!::CORBA::is_nil (this->ami_foo_server_.in ()))
      {
        Hello::AMI_MyFooHandler_var the_handler_var;
        if (!::CORBA::is_nil (ami_handler))
          {
            ::CCM_CORBA_AMI_MyFoo_Impl::AMI_MyFoo_reply_handler*  handler =
              new ::CCM_CORBA_AMI_MyFoo_Impl::AMI_MyFoo_reply_handler (ami_handler);
            the_handler_var = handler->_this ();
          }
        this->ami_foo_server_->sendc_get_ro_attrib (the_handler_var.in ());
        printf ("AMI (FOO) : \tInvoked sendc_get_ro_attrib\n");
      }
  }
  //============================================================
  // Component Executor Implementation Class: AMI_exec_i
  //============================================================

  AMI_exec_i::AMI_exec_i (void)
    : myfoo_ (new AMI_MyFoo_exec_i ())
  {
  }

  AMI_exec_i::~AMI_exec_i (void)
  {
    delete myfoo_;
  }

  // Supported operations and attributes.

  // Component attributes.

  // Port operations.

  ::Hello::CCM_AMI_MyFoo_ptr
  AMI_exec_i::get_sendc_run_my_foo (void)
  {
    return this->myfoo_;
  }
  // Operations from Components::SessionComponent.

  void
  AMI_exec_i::set_session_context (
    ::Components::SessionContext_ptr ctx)
  {
    this->context_ =
      ::Hello::CCM_AMI_Sender_Context::_narrow (ctx);

    if ( ::CORBA::is_nil (this->context_.in ()))
      {
        throw ::CORBA::INTERNAL ();
      }
  }

  void
  AMI_exec_i::configuration_complete (void)
  {
    this->receiver_foo_ =
      this->context_->get_connection_run_my_foo ();

    this->myfoo_->provide_receiver (receiver_foo_.in ());
  }

  void
  AMI_exec_i::ccm_activate (void)
  {
  }

  void
  AMI_exec_i::ccm_passivate (void)
  {
  }

  void
  AMI_exec_i::ccm_remove (void)
  {
  }

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

    ACE_NEW_RETURN (
      retval,
      AMI_exec_i,
      ::Components::EnterpriseComponent::_nil ());

    return retval;
  }
}