Mercurial > ~dholland > hg > ag > index.cgi
comparison anagram/support/agref.cpp @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 /********************************************************** | |
2 | |
3 The AnaGram Class Library | |
4 | |
5 The AgReference Class | |
6 Copyright 1997 Parsifal Software. All Rights Reserved. | |
7 See the file COPYING for license and usage terms. | |
8 | |
9 ***********************************************************/ | |
10 | |
11 #include "agref.h" | |
12 | |
13 void AgReferenceBase::doAssignmentLocks(const AgReferenceBase &r) { | |
14 if (object!=0 && object->unlock()) { | |
15 delete object; | |
16 } | |
17 object = r.object; | |
18 if (object != 0) { | |
19 object->lock(); | |
20 } | |
21 } | |
22 | |
23 AgReferenceBase::AgReferenceBase() : object(0) {} | |
24 | |
25 AgReferenceBase::AgReferenceBase(AgReferenceCount* object_) | |
26 : object(object_) | |
27 { | |
28 if (object != 0) { | |
29 object->lock(); | |
30 } | |
31 } | |
32 | |
33 AgReferenceBase::AgReferenceBase(const AgReferenceBase &r) | |
34 : object(r.object) | |
35 { | |
36 if (object!= 0) { | |
37 object->lock(); | |
38 } | |
39 } | |
40 | |
41 AgReferenceBase::~AgReferenceBase() { | |
42 if (object!= 0 && object->unlock()) { | |
43 delete object; | |
44 } | |
45 } | |
46 | |
47 int AgReferenceBase::exists() const { | |
48 return object != 0; | |
49 } | |
50 | |
51 void AgReferenceBase::discardData() { | |
52 if (object && object->unlock()) { | |
53 delete object; | |
54 } | |
55 object = 0; | |
56 } | |
57 |