summaryrefslogtreecommitdiff
path: root/TAO/interop-tests/AnyTypeCode/tao/Demo_i.cpp
blob: 9d2c8faa31223b4c22f64f59ae524a7a25332957 (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
// -*- C++ -*-
// FUZZ: disable check_for_ace_log_categories

/**
 * Code generated by the The ACE ORB (TAO) IDL Compiler v2.1.4
 * TAO and the TAO IDL Compiler have been developed by:
 *       Center for Distributed Object Computing
 *       Washington University
 *       St. Louis, MO
 *       USA
 *       http://www.cs.wustl.edu/~schmidt/doc-center.html
 * and
 *       Distributed Object Computing Laboratory
 *       University of California at Irvine
 *       Irvine, CA
 *       USA
 * and
 *       Institute for Software Integrated Systems
 *       Vanderbilt University
 *       Nashville, TN
 *       USA
 *       http://www.isis.vanderbilt.edu/
 *
 * Information about TAO is available at:
 *     http://www.dre.vanderbilt.edu/~schmidt/TAO.html
 **/

// TAO_IDL - Generated from
// be/be_codegen.cpp:1673

#include "Demo_i.h"
#include "ace/Log_Msg.h"

// Implementation skeleton constructor
ATC_Test_i::ATC_Test_i ()
{
}

// Implementation skeleton destructor
ATC_Test_i::~ATC_Test_i ()
{
}

char *
ATC_Test_i::do_union (const ::CORBA::Any & a)
{
  const Demo::NestedUnion *any_union = 0;
  const char *result = "do_union called";
  if (a >>= any_union)
    {
      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%P: a >>= any_union went well\n")));
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("%P: The discriminator is %d\n"),
                  any_union->_d ()));
      switch ( any_union->_d ())
        {
        case 1:
          {
            Demo::BaseUnion bar1 = any_union->bar1 ();
            if (bar1._d () == 1)
              {
                result = bar1.str ();
                ACE_DEBUG ((LM_DEBUG,
                            ACE_TEXT ("%P: bar1 has str = %s\n"),
                            result));
              }
          }
          break;
        case 2:
          {
            Demo::BaseUnion bar2 = any_union->bar2 ();
            if (bar2._d () == 2)
              {
                CORBA::Long l = bar2.l ();
                ACE_DEBUG ((LM_DEBUG,
                            ACE_TEXT ("%P: bar1 has l = %d\n"),
                            l));
                result = "bar2 has l";
              }
          }
          break;
        default:
          {
            Demo::BaseUnion defaultBar = any_union->defaultBar ();
            if (defaultBar._d () != 1 && defaultBar._d () != 2)
              {
                CORBA::Short s = defaultBar.s ();
                ACE_DEBUG ((LM_DEBUG,
                            ACE_TEXT ("%P: bar1 has s = %d\n"),
                            s));
                result = "defaultBar has s";
              }
          }
          break;
        }
    }
  else
    {
      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%P: a >>= any_union failed\n")));
    }
  return CORBA::string_dup (result);
}

char *
ATC_Test_i::do_struct (const ::CORBA::Any & a)
{
  const Demo::NestedStruct *bar = 0;
  const char *result = "do_struct called";
  if (a >>= bar)
    {
      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%P: a >>= any_struct went well\n")));
      Demo::BaseStruct foo1 = bar->foo1;
      Demo::BaseStruct foo2 = bar->foo2;
      Demo::BaseStruct foo3 = bar->foo3;
      Demo::NestedSeq bars = bar->bars;
      if (bars.length () > 0)
        {
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("%P: bars[0].foo1.str = %s\n"),
                      bars[0].foo1.str.in()));
        }
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("%P: foo1.str = %s, foo2.str = %s, ")
                  ACE_TEXT ("foo3.str = %s, bars.length() = %d\n"),
                  foo1.str.in (), foo2.str.in (), foo3.str.in (), bars.length ()));

      if (bars.length() > 0)
        {
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("%P: returning %s\n"),
                      bars[bars.length() - 1].foo3.str.in ()));
          return CORBA::string_dup(bars[bars.length() - 1].foo3.str);
        }
      else
        {
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("%P: bars.length = 0, returning %s\n"),
                      foo3.str.in()));
          return CORBA::string_dup(foo3.str);
        }
    }
  else
    {
      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%P: a >>= any_struct failed\n")));
    }
  return CORBA::string_dup (result);
}

char *
ATC_Test_i::do_value (const ::CORBA::Any & a)
{
  Demo::NestedValue *bar;
  const char *result = "do_value called";
  if (a >>= bar)
    {
      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%P: a >>= any_value went well\n")));
      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%P: returning %s\n"),
                                      bar->foo2()->str() ));
      return CORBA::string_dup(bar->foo2()->str());
    }
  else
    {
      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%P: a >>= any_value failed\n")));
    }
  return CORBA::string_dup (result);
}

void
ATC_Test_i::shutdown ()
{
  int argc = 0;
  ACE_TCHAR **argv = 0;

  CORBA::ORB_var def_orb = CORBA::ORB_init (argc, argv);
  def_orb->shutdown (false);
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("%P: shutdown called \n")));
}