3 //=============================================================================
7 * @author Christopher Kohlhoff <chris@kohlhoff.com>
9 //=============================================================================
15 #include "Widget_Part.h"
17 #include "ace/Unbounded_Queue.h"
18 #include "ace/Refcounted_Auto_Ptr.h"
19 #include "ace/Synch_Traits.h"
20 #include "ace/Thread_Mutex.h"
25 * @brief An implementation of the Widget interface.
27 class Widget_Impl
: public Widget
34 virtual ~Widget_Impl ();
36 /// Add a new part to the widget. The widget takes ownership of the part
38 virtual void add_part (Widget_Part
*part
);
40 /// Remove a random part from the widget. Ownership of the part is returned
42 virtual Widget_Part
*remove_part ();
44 /// Ask the widget to print information about the parts that it contains.
45 virtual void list_parts ();
48 /// The parts which make up this widget. The set actually contains instances
49 /// of ACE_Refcounted_Auto_Ptr to automatically manage the lifetimes of the
50 /// constituent parts.
52 /// Some things to note about the choice of ACE_Refcounted_Auto_Ptr:
53 /// - We cannot use auto_ptr to manage the objects, since auto_ptr does not
54 /// support the copying and assignment semantics necessary for storage in
56 /// - The ACE_Strong_Bound_Ptr reference counted pointer could be used to
57 /// store objects in a container, however (for reasons of safety) it
58 /// provides no way to release ownership of the object from the smart
59 /// pointer. We need to be able to release ownership to implement the
60 /// remove_part method.
61 /// - ACE_Refcounted_Ptr can both be stored in containers and allows us to
62 /// release ownership of the pointer that it contains.
63 ACE_Unbounded_Queue
<ACE_Refcounted_Auto_Ptr
<Widget_Part
, ACE_SYNCH_MUTEX
> > parts_
;
66 #endif /* WIDGET_IMPL_H */