File: Widget_Impl.cpp

package info (click to toggle)
ace 6.0.3%2Bdfsg-0.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 49,368 kB
  • sloc: cpp: 341,826; perl: 30,850; ansic: 20,952; makefile: 10,144; sh: 4,744; python: 828; exp: 787; yacc: 511; xml: 330; lex: 158; lisp: 116; csh: 48; tcl: 5
file content (52 lines) | stat: -rw-r--r-- 1,417 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* -*- C++ -*- */
//=============================================================================
/**
 *  @file    Widget_Impl.cpp
 *
 *  $Id: Widget_Impl.cpp 80826 2008-03-04 14:51:23Z wotte $
 *
 *  @author Christopher Kohlhoff <chris@kohlhoff.com>
 */
//=============================================================================

#include "Widget_Impl.h"
#include "ace/Log_Msg.h"

Widget_Impl::Widget_Impl (void)
{
  ACE_DEBUG ((LM_DEBUG, "Widget_Impl constructor\n"));
}

Widget_Impl::~Widget_Impl (void)
{
  ACE_DEBUG ((LM_DEBUG, "Widget_Impl destructor\n"));
}

void Widget_Impl::add_part (Widget_Part *part)
{
  // Take ownership of the part object using a ACE_Refcounted_Auto_Ptr.
  ACE_Refcounted_Auto_Ptr<Widget_Part, ACE_SYNCH_MUTEX> new_part (part);

  parts_.enqueue_tail (new_part);
}

Widget_Part *Widget_Impl::remove_part (void)
{
  ACE_Refcounted_Auto_Ptr<Widget_Part, ACE_SYNCH_MUTEX> removed_part;
  if (parts_.dequeue_head (removed_part) == -1)
    return 0;

  // Ownership of the part object is released and transferred to the caller.
  return removed_part.release();
}

void Widget_Impl::list_parts (void)
{
  ACE_Unbounded_Queue_Iterator<ACE_Refcounted_Auto_Ptr<Widget_Part, ACE_SYNCH_MUTEX> > iter (parts_);
  ACE_Refcounted_Auto_Ptr<Widget_Part, ACE_SYNCH_MUTEX> *current_part;
  while (iter.next (current_part))
    {
      (*current_part)->print_info ();
      iter.advance ();
    }
}