summaryrefslogtreecommitdiff
path: root/TAO/tests/OBV/Supports/Supports_Test_impl.cpp
blob: 47b5c9f816b7cf3619f2c4b09057327a3980ab6b (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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
// $Id$

#include "Supports_Test_impl.h"


/* vt_graph_impl */

vt_graph_impl::vt_graph_impl (void)
{
}

vt_graph_impl::vt_graph_impl (int num_nodes)
{
	nodes_ ().length (0);
	for (int i = 0; i < num_nodes; i++)
		{
			add_node ("OLD");
			//if (i != 0) nodes_ ()[i]->add_edge (nodes_ ()[0]);
		}
}

CORBA::Long vt_graph_impl::size (void)
{
	//cout << "Num nodes = " << nodes_ ().length () << endl;
	return nodes_ ().length ();
}

void vt_graph_impl::add_node (const char * name)
{
	Supports_Test::Node * new_node = 0;
  ACE_NEW (new_node, node_impl (name));
	nodes_ ().length (nodes_ ().length () + 1);
	nodes_ ()[nodes_ ().length () - 1] = new_node;
}

void vt_graph_impl::print (void)
{
  for (int i = 0; i < nodes_ ().length (); i++)
    {
      nodes_ ()[i]->print ();
    }

  cout << endl;
}



/* vt_graph_init_impl */

Supports_Test::vt_graph * vt_graph_init_impl::create (void)
{
	vt_graph_impl * ret_val = 0;
  ACE_NEW_RETURN (ret_val, vt_graph_impl, 0);
  return ret_val;
}

CORBA::ValueBase * vt_graph_init_impl::create_for_unmarshal (void)
{
	vt_graph_impl * ret_val = 0;
  ACE_NEW_RETURN (ret_val, vt_graph_impl, 0);
  return ret_val;
}


/* test_impl */

test_impl::test_impl (CORBA::ORB_ptr orb) : orb_ (CORBA::ORB::_duplicate (orb))
{
}

void test_impl::pass_obj_graph_in (Supports_Test::graph * graph_param ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException))
{

  //cout << "pass_obj_graph_in" << endl;

  ACE_ASSERT (graph_param->size () == 4);
	graph_param->add_node ("NEW1");
	ACE_ASSERT (graph_param->size () == 5);

  //cout << endl;

}

void test_impl::pass_vt_graph_in (Supports_Test::vt_graph * vt_graph_param ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException))
{

  //cout << "pass_vt_graph_in" << endl;

	ACE_ASSERT (vt_graph_param->size () == 3);
	vt_graph_param->add_node ("NEW1");
	ACE_ASSERT (vt_graph_param->size () == 4);

  //cout << endl;

}

void test_impl::pass_obj_graph_out (Supports_Test::graph_out graph_param ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException))
{

  //cout << "pass_obj_graph_out" << endl;

  vt_graph_impl * the_vt_graph = 0;
  ACE_NEW (the_vt_graph, vt_graph_impl (4));
  graph_param = the_vt_graph->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
	ACE_TRY_CHECK;

  ACE_ASSERT (graph_param->size () == 4);
	graph_param->add_node ("NEW1");
	ACE_ASSERT (graph_param->size () == 5);

}

void test_impl::pass_vt_graph_out (Supports_Test::vt_graph_out vt_graph_param ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException))
{

  //cout << "pass_vt_graph_out" << endl;

  vt_graph_impl * the_vt_graph = 0;
	ACE_NEW (the_vt_graph, vt_graph_impl (3));
	vt_graph_param = the_vt_graph;

	ACE_ASSERT (vt_graph_param->size () == 3);
	vt_graph_param->add_node ("NEW1");
	ACE_ASSERT (vt_graph_param->size () == 4);

  //cout << endl;

}

void test_impl::pass_obj_graph_inout (Supports_Test::graph * &graph_param ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException))
{

  //cout << "pass_obj_graph_inout" << endl;

  ACE_ASSERT (graph_param->size () == 6);
	graph_param->add_node ("NEW!");
	ACE_ASSERT (graph_param->size () == 7);

}

void test_impl::pass_vt_graph_inout (Supports_Test::vt_graph * &vt_graph_param ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException))
{

  //cout << "pass_vt_graph_inout" << endl;

	ACE_ASSERT (vt_graph_param->size () == 5);
	vt_graph_param->add_node ("NEW!");
	ACE_ASSERT (vt_graph_param->size () == 6);

  //cout << endl;

}

void test_impl::shutdown (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException))
{
	this->orb_->shutdown ();
}


/* node_impl */

node_impl::node_impl (void)
{
}

node_impl::node_impl (const char * name)
{
	name_ (name);
	weight_ (0);
	degree_ (0);
	neighbors_ ().length (0);
}

void node_impl::add_edge (Supports_Test::Node * neighbor)
{
	degree_ (degree_ () + 1);
	neighbors_ ().length (neighbors_ ().length () + 1);
	neighbors_ ()[neighbors_ ().length () - 1] = neighbor;
	return;
}
	
void node_impl::remove_edge (Supports_Test::Node * neighbor)
{
	
}

void node_impl::change_weight (CORBA::Long new_weight)
{
	weight_ (new_weight);
}

void node_impl::print (void)
{
  cout << "Name: " << name_ () << endl;
  cout << "Weight: " << weight_ () << endl;
  cout << "Degree: " << degree_ () << endl;
  cout << "Neighbors: " << endl;
  for (int i = 0; i < neighbors_ ().length (); i++)
    cout << "   " << neighbors_ ()[i]->name_ () << endl;
}

/* node_init_impl */

Supports_Test::Node * node_init_impl::create (void)
{
	node_impl * ret_val = 0;
  ACE_NEW_RETURN (ret_val, node_impl, 0);
  return ret_val;
}

CORBA::ValueBase * node_init_impl::create_for_unmarshal (void)
{
	node_impl * ret_val = 0;
  ACE_NEW_RETURN (ret_val, node_impl, 0);
  return ret_val;
}