source: branches/1.6/src/core/RpPtr.cc @ 6131

Last change on this file since 6131 was 5679, checked in by ldelgass, 9 years ago

Full merge 1.3 branch to uq branch to sync. Fixed partial subdirectory merge
by removing mergeinfo from lang/python/Rappture directory.

  • Property svn:eol-style set to native
File size: 913 bytes
Line 
1/*
2 * ======================================================================
3 *  Rappture::Ptr<type>
4 *
5 *  AUTHOR:  Michael McLennan, Purdue University
6 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
7 * ----------------------------------------------------------------------
8 *  See the file "license.terms" for information on usage and
9 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10 * ======================================================================
11 */
12
13#include <stdlib.h>
14#include <RpPtr.h>
15#include <assert.h>
16
17using namespace Rappture;
18
19PtrCore::PtrCore(void* ptr)
20  : _ptr(ptr),
21    _refcount(1)
22{
23}
24
25PtrCore::~PtrCore()
26{
27    assert(_refcount <= 0);
28}
29
30void*
31PtrCore::pointer() const
32{
33    return _ptr;
34}
35
36void
37PtrCore::attach()
38{
39    _refcount++;
40}
41
42void*
43PtrCore::detach()
44{
45    if (--_refcount <= 0 && _ptr != NULL) {
46        return _ptr;
47    }
48    return NULL;
49}
Note: See TracBrowser for help on using the repository browser.