summaryrefslogtreecommitdiff
path: root/CIAO/tests/Collocation/Sender/Sender_exec.cpp
blob: 95310c3b1d80f039dc9fe4075d6ffc9418316cd7 (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
// -*- C++ -*-
// $Id$

#include "Sender_exec.h"

namespace CIAO_Sender_Impl
{
  /**
   * Facet Executor Implementation Class: hello_exec_i
   */
  hello_exec_i::hello_exec_i (::CCM_Sender_Context_ptr ctx)
    : ciao_context_ (::CCM_Sender_Context::_duplicate (ctx))
  {
  }

  hello_exec_i::~hello_exec_i (void)
  {
  }

  // Operations from ::Hello
  void
  hello_exec_i::set_point (const pointer_id &p, const char * strat)
   {
     CORBA::Boolean coll = false;

#if !defined (CCM_DIRECTCOLL)
     ACE_DEBUG ((LM_DEBUG,
                  "SENDER: hello_exec_i::set_point pointer"
                  "Strategy desired <%C>, but no collocation "
                  "because CIAO not build with  "
                  "ccm_direct_collocation = 1.\n",
                  strat));
#else
     if ((ACE_OS::strcmp("direct", strat) == 0) ||
         (ACE_OS::strcmp("best", strat) == 0))
       coll = true;
     else if (ACE_OS::strcmp("no_collocation", strat) == 0)
       coll = false;
     else
       ACE_ERROR ((LM_DEBUG, "Error: hello_exec_i::set_point - "
                             "Unexpected strategy <%C> \n",
                              strat));
#endif
     ACE_DEBUG ((LM_DEBUG,
                  "SENDER: hello_exec_i::set_point pointer <%@>\n",
                  (void *)&p));

     CORBA::Long ptr_nmb = (long)&p;
     if (coll)
       {

         // In case of collocation pointer p is still the same pointer
         // as at the point where poiner p was generated.
         // Direct or thru_poa collocation, but thru_poa collocation is disabled,
         // so remains direct .
         if (ptr_nmb == p.point)
           {
             ACE_DEBUG ((LM_DEBUG,
                 "hello_exec_i::set_point - current pointer  <%u> "
                 " is same as starting pointer <%u>,"
                 " direct collocation! \n",
                  ptr_nmb, p.point));
           }
         else
           {
             ACE_ERROR ((LM_ERROR,
                 "Error: hello_exec_i::set_point - current pointer  <%u> "
                 " is not the same as starting pointer <%u>"
                 ", No Collocation\n",
                 ptr_nmb, p.point));
           }
       }
     else
       {
         if (ptr_nmb == p.point)
           {
             ACE_ERROR ((
                 LM_DEBUG,
                 "Error: hello_exec_i::set_point - current pointer  <%u> "
                 " is the same as starting pointer <%u>"
                 ", Unexpected collocation\n",
                 ptr_nmb, p.point));
           }
         else
           {
             ACE_DEBUG ((LM_DEBUG,
                 "hello_exec_i::set_point - current pointer  <%u>"
                 "  is not the same as starting pointer <%u>,"
                 " No collocation, as expected ! \n",
                 ptr_nmb, p.point));
           }
       }
   }

  /**
   * Component Executor Implementation Class: Sender_exec_i
   */
  Sender_exec_i::Sender_exec_i (void)
  {
    ACE_DEBUG ((LM_DEBUG, "Sender_exec_i::Sender_exec_i \n "));
  }

  Sender_exec_i::~Sender_exec_i (void)
  {
  }


  // Component attributes and port operations.
  ::CCM_Hello_ptr
  Sender_exec_i::get_hello (void)
  {
    if ( ::CORBA::is_nil (this->ciao_hello_.in ()))
      {
        hello_exec_i *tmp = 0;
        ACE_NEW_RETURN (
          tmp,
          hello_exec_i (
            this->ciao_context_.in ()),
            ::CCM_Hello::_nil ());

          this->ciao_hello_ = tmp;
      }

    return
      ::CCM_Hello::_duplicate (
        this->ciao_hello_.in ());
  }


  // Operations from Components::SessionComponent.
  void
  Sender_exec_i::set_session_context (
    ::Components::SessionContext_ptr ctx)
  {
    ACE_DEBUG ((LM_DEBUG, "Sender_exec_i::set_session_context \n "));

    this->ciao_context_ =
      ::CCM_Sender_Context::_narrow (ctx);

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

  void
  Sender_exec_i::configuration_complete (void)
  {
    /* Your code here. */
    ACE_DEBUG ((LM_DEBUG, "Sender_exec_i::configuration_complete \n "));

  }

  void
  Sender_exec_i::ccm_activate (void)
  {
    ACE_DEBUG ((LM_DEBUG, "Sender_exec_i::ccm_activate \n "));
    /// Start the timer .
  }

  void
  Sender_exec_i::ccm_passivate (void)
  {
  }

  void
  Sender_exec_i::ccm_remove (void)
  {
    /* Your code here. */
    ACE_DEBUG ((LM_DEBUG, "Sender_exec_i::ccm_remove \n "));
  }

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

    ACE_NEW_NORETURN (
      retval,
      Sender_exec_i);

    return retval;
  }
}