summaryrefslogtreecommitdiff
path: root/TAO/tests/Smart_Proxies/Smart_Proxy_Impl.cpp
blob: bb3bf989309bad51c4bd996feb6112ab373cea17 (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
// $Id$

#include "Smart_Proxy_Impl.h"

ACE_CString Smart_Test_Proxy::fake_ior_ ("This_is_my_fake_ior");

Smart_Test_Factory::Smart_Test_Factory (void)
{
  ACE_DEBUG ((LM_DEBUG,
              "Smart_Test_Factory\n"));
}

Test_ptr
Smart_Test_Factory::create_proxy (Test_ptr proxy)
 {
   ACE_DEBUG ((LM_DEBUG,
               "create_smart_proxy\n"));

   if (CORBA::is_nil (proxy) == 0)
       ACE_NEW_RETURN (proxy, Smart_Test_Proxy (proxy), 0);

   return proxy;

 }

Smart_Test_Proxy::Smart_Test_Proxy (Test_ptr proxy)
  : TAO_Smart_Proxy_Base (proxy)
{
}

bool
Smart_Test_Proxy::can_convert_to_ior (void) const
{
  // Even though a smart proxy is local, this one can be stringified
  return true;
}

char*
Smart_Test_Proxy::convert_to_ior (bool,
                                  const char*) const
{
  // If this implementation wasn't provided, the ORB would provide
  // a stringified representation of this object.
  return CORBA::string_dup (fake_ior_.c_str ());
}

CORBA::Short
Smart_Test_Proxy::method (CORBA::Short boo)
  ACE_THROW_SPEC ((CORBA::SystemException,
                   Test::Oops))
{
  ACE_DEBUG ((LM_DEBUG,
              "Yahoo, I am smart\n"));

  CORBA::Short retval = 0;
  try
    {
      retval = TAO_Test_Smart_Proxy_Base::method (boo);
    }
  catch (const Test::Oops& reason)
    {
      reason._tao_print_exception ("User Exception");
      return -1;
    }

  return retval;
}

const ACE_CString&
Smart_Test_Proxy::fake_ior (void)
{
  return fake_ior_;
}