diff options
author | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-04-10 19:59:37 +0000 |
---|---|---|
committer | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-04-10 19:59:37 +0000 |
commit | 3df4acfa816441fc28a95dee6d0191a927145d95 (patch) | |
tree | b5ae7ca44662cfd8e5c95f1826e4406021a606f5 /examples/Smart_Pointers/Gadget_Part_Impl.cpp | |
parent | 60a5612b83d856fc0adc52b9f39fac9960ec9818 (diff) | |
download | ATCD-pre-subset.tar.gz |
This commit was manufactured by cvs2svn to create tag 'pre-subset'.pre-subset
Diffstat (limited to 'examples/Smart_Pointers/Gadget_Part_Impl.cpp')
-rw-r--r-- | examples/Smart_Pointers/Gadget_Part_Impl.cpp | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/examples/Smart_Pointers/Gadget_Part_Impl.cpp b/examples/Smart_Pointers/Gadget_Part_Impl.cpp deleted file mode 100644 index aeda00711bb..00000000000 --- a/examples/Smart_Pointers/Gadget_Part_Impl.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- C++ -*- */ -//============================================================================= -/** - * @file Gadget_Part_Impl.cpp - * - * $Id$ - * - * @author Christopher Kohlhoff <chris@kohlhoff.com> - */ -//============================================================================= - -#include "Gadget_Part_Impl.h" -#include "ace/ACE.h" -#include "ace/Log_Msg.h" -#include "ace/Unbounded_Queue.h" - -Gadget_Part_Impl::Gadget_Part_Impl (Gadget_ptr owner, - const char* name, - int size) - : owner_ (owner), - name_ (ACE::strnew (name)), - size_ (size) -{ - ACE_DEBUG ((LM_DEBUG, "Gadget_Part_Impl constructor\n")); -} - -Gadget_Part_Impl::~Gadget_Part_Impl (void) -{ - ACE_DEBUG ((LM_DEBUG, "Gadget_Part_Impl destructor\n")); - - delete [] name_; -} - -void Gadget_Part_Impl::print_info (void) -{ - ACE_DEBUG ((LM_INFO, "Gadget part: name=%s size=%d\n", name_, size_)); -} - -void Gadget_Part_Impl::remove_from_owner (void) -{ - // Need to guarantee the existence of the owner for the duration of this call. - Gadget_var owner = owner_; - - // Weak pointers are automatically set to NULL if the object they refer to - // is deleted. We can use this fact to check that our owner still exists. - if (owner == 0) - return; - - // Take all existing parts from the owner and build up a temporary list. If - // we find ourselves then we won't add ourselves to the list. - ACE_Unbounded_Queue<Gadget_Part_var> parts; - for (;;) - { - Gadget_Part_var part = owner->remove_part (); - if (part == 0) - break; - if (part != this) - parts.enqueue_tail (part); - } - - // Add the remaining parts back to the gadget. - while (!parts.is_empty ()) - { - Gadget_Part_var part; - parts.dequeue_head (part); - owner->add_part (part); - } -} |