Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / examples / Smart_Pointers / gadget_test.cpp
blob32890ae311290a687a47f4c61719a7c41d234aa7
1 /* -*- C++ -*- */
2 //=============================================================================
3 /**
4 * @file gadget_test.cpp
6 * @author Christopher Kohlhoff <chris@kohlhoff.com>
7 */
8 //=============================================================================
10 #include "ace/Refcounted_Auto_Ptr.h"
11 #include "ace/Unbounded_Queue.h"
12 #include "Gadget.h"
13 #include "Gadget_Factory.h"
14 #include "Gadget_Part.h"
15 #include "Gadget_Part_Factory.h"
16 #include <memory>
18 int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
20 ACE_UNUSED_ARG (argc);
21 ACE_UNUSED_ARG (argv);
23 Gadget_var g1 = Gadget_Factory::create_gadget ();
24 g1->add_part (Gadget_Part_Factory::create_gadget_part (g1, "part1", 1));
25 g1->add_part (Gadget_Part_Factory::create_gadget_part (g1, "part2", 2));
26 g1->add_part (Gadget_Part_Factory::create_gadget_part (g1, "part3", 3));
28 g1->list_parts ();
30 Gadget_Part_var p1 = g1->remove_part ();
31 p1->print_info ();
33 // Oops, we forgot to collect the return value! No worries, the temporary
34 // Gadget_var returned by the function call will clean it up automatically.
35 g1->remove_part ();
37 g1->list_parts ();
39 Gadget_var g2 = Gadget_Factory::create_gadget ();
40 g2->add_part (Gadget_Part_Factory::create_gadget_part (g2, "part4", 4));
41 Gadget_Part_var p2 = Gadget_Part_Factory::create_gadget_part (g2, "part5", 5);
42 g2->add_part (p2);
43 p2->remove_from_owner ();
45 g2->list_parts ();
47 return 0;