Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / examples / Smart_Pointers / Gadget_Part_Impl.h
blob7acd3e631d1c1adfe81b11acd2c4d543cf50aeca
1 /* -*- C++ -*- */
2 //=============================================================================
3 /**
4 * @file Gadget_Part_Impl.h
6 * @author Christopher Kohlhoff <chris@kohlhoff.com>
7 */
8 //=============================================================================
10 #ifndef GADGET_PART_IMPL_H
11 #define GADGET_PART_IMPL_H
13 #include "Gadget_Part.h"
14 #include "Gadget.h"
16 /**
17 * @class Gadget_Part_Impl
19 * @brief An implementation of the Gadget_Part interface.
21 class Gadget_Part_Impl : public Gadget_Part
23 public:
24 /// Constructor.
25 Gadget_Part_Impl (Gadget_ptr owner, const char* name, int size);
27 /// Destructor.
28 virtual ~Gadget_Part_Impl ();
30 /// Ask the part to print information about itself.
31 virtual void print_info ();
33 /// Ask the part to remove itself from the gadget that contains it.
34 virtual void remove_from_owner ();
36 private:
37 /// The gadget that contains this part.
38 ///
39 /// Some things to note about the choice of ACE_Weak_Bound_Ptr (from the
40 /// typedef for Gadget_ptr):
41 /// - We cannot use an ACE_Strong_Bound_Ptr (Gadget_var) since that would
42 /// result in circular ownership.
43 /// - If we use a raw pointer we have no circular ownership problems, but we
44 /// are unable to guarantee the lifetime of the owner object for the
45 /// duration of the remove_from_owner call. This may not be a problem in
46 /// this limited example, but in multithreaded programs remove_from_owner
47 /// may be called from a different thread to the thread which manages the
48 /// owner's lifetime.
49 /// - ACE_Weak_Bound_Ptr (Gadget_ptr) has no ownership semantics, so we have
50 /// no circular ownership problems. Weak pointers can also be converted
51 /// back into strong ones, so it is possible to guarantee the lifetime of
52 /// the owner object for the duration of the remove_from_owner call.
53 Gadget_ptr owner_;
55 /// The name of this part.
56 char *name_;
58 /// The size of this part.
59 int size_;
62 #endif /* GADGET_PART_IMPL_H */