summaryrefslogtreecommitdiff
path: root/TAO/tests/TransportCurrent/Framework/simple.cpp
blob: 2b945f788c157dd5e5313968bbbc4debf38bbfd5 (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
// -*- C++ -*-

#include "tao/ORB.h"
#include "tao/Object.h"

#include "ace/Service_Config.h"
#include "ace/Dynamic_Service.h"

ACE_RCSID (Transport_Current,
           simple,
           "$Id$")

int
testCurrentORBInitializer (int argc, char *argv[])
{
  CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

  if (orb.in () == 0)
    ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Unable to create orb\n")), -1);

  CORBA::Object_var obj =
    orb->resolve_initial_references ("TAO::Transport::Current"
                                     ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;

  if (obj.in () == 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Unable to get the Transport Current\n")), -1);


  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("testCurrentORBInitializer: OK\n")));
  return 0;
}


int
testCurrentLoader (int, char *[])
{

  ACE_Service_Object *factory = 0;

  factory = ACE_Dynamic_Service<ACE_Service_Object>::instance
    (ACE_TEXT ("TAO_Transport_Current_Loader"));

  int done =
#if defined (TAO_AS_STATIC_LIBS)
    true;
#else
  (factory != 0);
#endif /* TAO_AS_STATIC_LIBS */

  if (factory == 0)
    {
      if (done)
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("Unable to instantiate TAO::Transport::Current_Factory\n")),
                          -1);
      else
        {

#if !defined (TAO_AS_STATIC_LIBS)
          int ret = ACE_Service_Config::process_directive
            (ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_Transport_Current_Loader",
                                           "TAO_Transport_Current",
                                           "_make_TAO_Transport_Current_Loader",
                                           ""));
          ACE_ASSERT (ret == 0);

          factory = ACE_Dynamic_Service<ACE_Service_Object>::instance
            (ACE_TEXT ("TAO_Transport_Current_Loader"));

#endif /* !TAO_AS_STATIC_LIBS */
        }
    }

  //  ACE_ASSERT (factory != 0);
  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("testCurrentLoader: OK\n")));
  return 0;

}


int
main (int argc, char *argv[])
{
  return testCurrentLoader (argc, argv)
    || testCurrentORBInitializer (argc, argv);
}