1 // FUZZ: disable check_for_streams_include
3 #include "Supports_Test_impl.h"
5 #include "ace/streams.h"
9 vt_graph_impl::vt_graph_impl ()
13 // Creates a vt_graph_impl with the given number of nodes. There will be one
14 // root node and the rest will be children of it.
15 vt_graph_impl::vt_graph_impl (int num_nodes
)
19 for (int i
= 1; i
< num_nodes
; i
++)
22 nodes_ ()[0]->add_edge (nodes_ ()[i
]);
26 // Get the number of nodes in the vt_graph.
27 CORBA::Long
vt_graph_impl::size ()
29 return nodes_ ().length ();
32 // Add a node to the graph with no edges.
34 vt_graph_impl::add_node (const char * name
)
36 Supports_Test::Node
* new_node
= 0;
37 ACE_NEW (new_node
, node_impl (name
));
38 nodes_ ().length (nodes_ ().length () + 1);
39 nodes_ ()[nodes_ ().length () - 1] = new_node
;
42 // Print out information about each node.
44 vt_graph_impl::print ()
47 "Printing graph data...\n"));
50 "Number of nodes: [%d]\n", nodes_ ().length ()));
52 for (size_t i
= 0; i
< nodes_ ().length (); i
++)
53 nodes_ ()[i
]->print ();
57 /* vt_graph_init_impl - factory operations */
59 Supports_Test::vt_graph
*
60 vt_graph_init_impl::create ()
62 vt_graph_impl
* ret_val
= 0;
63 ACE_NEW_RETURN (ret_val
, vt_graph_impl
, 0);
68 vt_graph_init_impl::create_for_unmarshal ()
70 vt_graph_impl
* ret_val
= 0;
71 ACE_NEW_RETURN (ret_val
, vt_graph_impl
, 0);
78 test_impl::test_impl (CORBA::ORB_ptr orb
) : orb_ (CORBA::ORB::_duplicate (orb
))
82 test_impl::~test_impl ()
87 test_impl::pass_obj_graph_in (
88 Supports_Test::graph
* graph_param
)
90 ACE_ASSERT (graph_param
->size () == 3);
91 graph_param
->add_node ("NEW1");
92 ACE_ASSERT (graph_param
->size () == 4);
96 test_impl::pass_vt_graph_in (
97 Supports_Test::vt_graph
* vt_graph_param
)
99 ACE_ASSERT (vt_graph_param
->size () == 3);
100 vt_graph_param
->add_node ("NEW1");
101 ACE_ASSERT (vt_graph_param
->size () == 4);
105 test_impl::pass_obj_graph_out (
106 Supports_Test::graph_out graph_param
)
108 vt_graph_impl
* the_vt_graph
= 0;
109 ACE_NEW (the_vt_graph
, vt_graph_impl (4));
110 graph_param
= the_vt_graph
->_this ();
112 ACE_ASSERT (graph_param
->size () == 4);
113 graph_param
->add_node ("NEW1");
114 ACE_ASSERT (graph_param
->size () == 5);
118 test_impl::pass_vt_graph_out (
119 Supports_Test::vt_graph_out vt_graph_param
)
121 vt_graph_impl
* the_vt_graph
= 0;
122 ACE_NEW (the_vt_graph
, vt_graph_impl (4));
123 vt_graph_param
= the_vt_graph
;
125 ACE_ASSERT (vt_graph_param
->size () == 4);
126 vt_graph_param
->add_node ("NEW1");
127 ACE_ASSERT (vt_graph_param
->size () == 5);
131 test_impl::pass_obj_graph_inout (
132 Supports_Test::graph
* &graph_param
)
134 ACE_ASSERT (graph_param
->size () == 6);
135 graph_param
->add_node ("NEW3");
136 ACE_ASSERT (graph_param
->size () == 7);
140 test_impl::pass_vt_graph_inout (
141 Supports_Test::vt_graph
* &vt_graph_param
)
143 ACE_ASSERT (vt_graph_param
->size () == 6);
144 vt_graph_param
->add_node ("NEW3");
145 ACE_ASSERT (vt_graph_param
->size () == 7);
156 this->orb_
->shutdown (false);
162 node_impl::node_impl ()
167 node_impl::node_impl (const char * name
)
172 neighbors_ ().length (0);
175 // Add an edge from this node to neighbor.
177 node_impl::add_edge (Supports_Test::Node
* neighbor
)
179 degree_ (degree_ () + 1);
180 neighbors_ ().length (neighbors_ ().length () + 1);
181 neighbors_ ()[neighbors_ ().length () - 1] = neighbor
;
182 neighbor
->_add_ref ();
185 // Remove the edge from this node to neighbor.
187 node_impl::remove_edge (Supports_Test::Node
* neighbor
)
189 for (unsigned int i
= 0; i
< neighbors_ ().length (); i
++)
190 if (neighbors_ ()[i
] == neighbor
)
192 neighbors_ ()[i
] = neighbors_ ()[neighbors_ ().length () - 1];
193 neighbors_ ().length (neighbors_ ().length () - 1);
194 neighbor
->_remove_ref ();
199 node_impl::change_weight (CORBA::Long new_weight
)
201 weight_ (new_weight
);
207 cout
<< " Name: " << name_ () << endl
;
208 cout
<< " Weight: " << weight_ () << endl
;
209 cout
<< " Degree: " << degree_ () << endl
;
210 cout
<< " Neighbors: " << endl
;
211 for (size_t i
= 0; i
< neighbors_ ().length (); i
++)
212 cout
<< " " << neighbors_ ()[i
]->name_ () << endl
;
215 /* node_init_impl - factory operations */
217 Supports_Test::Node
*
218 node_init_impl::create ()
220 node_impl
* ret_val
= 0;
221 ACE_NEW_RETURN (ret_val
, node_impl
, 0);
226 node_init_impl::create_for_unmarshal ()
228 node_impl
* ret_val
= 0;
229 ACE_NEW_RETURN (ret_val
, node_impl
, 0);