Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / examples / Smart_Pointers / widget_test.cpp
blob98bfe7efef9d41ed28a4bed59f1ebf2e132c1a6c
1 /* -*- C++ -*- */
2 //=============================================================================
3 /**
4 * @file widget_test.cpp
6 * @author Christopher Kohlhoff <chris@kohlhoff.com>
7 */
8 //=============================================================================
10 #include "ace/OS_main.h"
11 #include "Widget.h"
12 #include "Widget_Factory.h"
13 #include "Widget_Part.h"
14 #include "Widget_Part_Factory.h"
15 #include <memory>
17 int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
19 ACE_UNUSED_ARG (argc);
20 ACE_UNUSED_ARG (argv);
22 std::unique_ptr<Widget> w1 (Widget_Factory::create_widget ());
23 w1->add_part (Widget_Part_Factory::create_widget_part (w1.get(), "part1", 1));
24 w1->add_part (Widget_Part_Factory::create_widget_part (w1.get(), "part2", 2));
25 w1->add_part (Widget_Part_Factory::create_widget_part (w1.get(), "part3", 3));
27 w1->list_parts ();
29 std::unique_ptr<Widget_Part> p1 (w1->remove_part ());
30 p1->print_info ();
31 std::unique_ptr<Widget_Part> p2 (w1->remove_part ());
33 w1->list_parts ();
35 std::unique_ptr<Widget> w2 (Widget_Factory::create_widget ());
36 w2->add_part (Widget_Part_Factory::create_widget_part (w2.get(), "part4", 4));
37 Widget_Part *p3 = Widget_Part_Factory::create_widget_part (w2.get(), "part5", 5);
38 w2->add_part (p3);
39 p3->remove_from_owner ();
41 w2->list_parts ();
43 return 0;