summaryrefslogtreecommitdiff
path: root/TAO/tests/DynAny_Test/data.cpp
blob: 2f923cedd9b6c9e8c594e02b65ca753218179d36 (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
// -*- c++ -*-
// $Id$
// ============================================================================
//
// = LIBRARY
//    TAO/tests/DynAny_Test
//
// = FILENAME
//    data.cpp
//
// = DESCRIPTION
//    Implementation file for the class containing test constants.
//
// = AUTHOR
//    Jeff Parsons <jp4@cs.wustl.edu>
//
// ============================================================================

#include "data.h"

Data::Data (CORBA::ORB_var orb)
  : m_bool1 (1),                                m_bool2 (0),
    m_octet1 (8),                               m_octet2 (0),
    m_char1 ('z'),                              m_char2 (0),
    m_short1 (-5),                              m_short2 (0),
    m_long1 (-123456),                          m_long2 (0),
    m_ushort1 (5),                              m_ushort2 (0),
    m_ulong1 (123456),                          m_ulong2 (0),
    m_float1 (0.142857f),                       m_float2 (0.0f),
    m_double1 (3.14159),                        m_double2 (0.0),
    m_longlong1 (-654321),                      m_longlong2 (0),
    m_ulonglong1 (654321),                      m_ulonglong2 (0),
    m_string1 (CORBA::string_dup ("upchuck")),  m_string2 (0),

    m_typecode1 (CORBA::TypeCode::_duplicate (CORBA::_tc_long)),
    m_typecode2 (CORBA::TypeCode::_duplicate (CORBA::_tc_null)),

    m_wchar1 (666),                             m_wchar2 (0),
    m_any1 (CORBA::_tc_long),
    orb_ (orb)
{
  CORBA::Environment env;

  labels[0] = "type boolean";
  labels[1] = "type octet";
  labels[2] = "type char";
  labels[3] = "type short";
  labels[4] = "type long",
  labels[5] = "type ushort";
  labels[6] = "type ulong";
  labels[7] = "type float";
  labels[8] = "type double";
  labels[9] = "type longlong";
  labels[10] = "type ulonglong";
  labels[11] = "type string";
  labels[12] = "type typecode";
  labels[13] = "type wchar";
  labels[14] = "type any";
  labels[15] = "type objref";

  // Getting the RootPOA so we can generate object references.
  CORBA::Object_var obj = 
    this->orb_->resolve_initial_references ("RootPOA");

  if (CORBA::is_nil (obj.in ()))
    ACE_ERROR ((LM_ERROR,
                "(%P|%t) Unable to get root poa reference.\n"));

  // Get the POA_var object from Object_var.
  PortableServer::POA_var root_poa =
    PortableServer::POA::_narrow (obj.in (), 
                                  env);

  if (env.exception () != 0)
    env.print_exception ("PortableServer::POA::_narrow");

  // Generate values for the member variables.
  this->m_objref1 =
    root_poa->create_reference ("foo", 
                                env);

  if (env.exception () != 0)
    env.print_exception ("PortableServer::POA::create_reference_with_id");

  this->m_objref2 =
    root_poa->create_reference ("foo", 
                                env);

  if (env.exception () != 0)
    env.print_exception ("PortableServer::POA::create_reference_with_id");
  
  // Clean up after the POA
  root_poa->destroy (1,
                     1,
                     env);

  if (env.exception () != 0)
    env.print_exception ("PortableServer::POA::destroy");
}

Data::~Data (void)
{
  CORBA::string_free (m_string1);
  CORBA::string_free (m_string2);
  CORBA::release (m_typecode1);
  CORBA::release (m_typecode2);
}