2 //=============================================================================
4 * @file Gadget_Part_Impl.h
6 * @author Christopher Kohlhoff <chris@kohlhoff.com>
8 //=============================================================================
10 #ifndef GADGET_PART_IMPL_H
11 #define GADGET_PART_IMPL_H
13 #include "Gadget_Part.h"
17 * @class Gadget_Part_Impl
19 * @brief An implementation of the Gadget_Part interface.
21 class Gadget_Part_Impl
: public Gadget_Part
25 Gadget_Part_Impl (Gadget_ptr owner
, const char* name
, int size
);
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 ();
37 /// The gadget that contains this part.
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
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.
55 /// The name of this part.
58 /// The size of this part.
62 #endif /* GADGET_PART_IMPL_H */