xref: /onnv-gate/usr/src/cmd/man/src/util/nsgmls.src/include/Resource.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate // Copyright (c) 1994 James Clark
2*0Sstevel@tonic-gate // See the file COPYING for copying permission.
3*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
4*0Sstevel@tonic-gate 
5*0Sstevel@tonic-gate #ifndef Resource_INCLUDED
6*0Sstevel@tonic-gate #define Resource_INCLUDED 1
7*0Sstevel@tonic-gate 
8*0Sstevel@tonic-gate #ifdef SP_NAMESPACE
9*0Sstevel@tonic-gate namespace SP_NAMESPACE {
10*0Sstevel@tonic-gate #endif
11*0Sstevel@tonic-gate 
12*0Sstevel@tonic-gate class SP_API Resource {
13*0Sstevel@tonic-gate public:
14*0Sstevel@tonic-gate   Resource();
15*0Sstevel@tonic-gate   Resource(const Resource &);
16*0Sstevel@tonic-gate   int unref();			// return 1 if it should be deleted
17*0Sstevel@tonic-gate   void ref();
18*0Sstevel@tonic-gate   int count() const;
19*0Sstevel@tonic-gate private:
20*0Sstevel@tonic-gate   int count_;
21*0Sstevel@tonic-gate };
22*0Sstevel@tonic-gate 
23*0Sstevel@tonic-gate inline
Resource()24*0Sstevel@tonic-gate Resource::Resource()
25*0Sstevel@tonic-gate : count_(0)
26*0Sstevel@tonic-gate {
27*0Sstevel@tonic-gate }
28*0Sstevel@tonic-gate 
29*0Sstevel@tonic-gate inline
Resource(const Resource &)30*0Sstevel@tonic-gate Resource::Resource(const Resource &)
31*0Sstevel@tonic-gate : count_(0)
32*0Sstevel@tonic-gate {
33*0Sstevel@tonic-gate }
34*0Sstevel@tonic-gate 
35*0Sstevel@tonic-gate inline
count()36*0Sstevel@tonic-gate int Resource::count() const
37*0Sstevel@tonic-gate {
38*0Sstevel@tonic-gate   return count_;
39*0Sstevel@tonic-gate }
40*0Sstevel@tonic-gate 
41*0Sstevel@tonic-gate inline
unref()42*0Sstevel@tonic-gate int Resource::unref()
43*0Sstevel@tonic-gate {
44*0Sstevel@tonic-gate   return --count_ <= 0;
45*0Sstevel@tonic-gate }
46*0Sstevel@tonic-gate 
47*0Sstevel@tonic-gate inline
ref()48*0Sstevel@tonic-gate void Resource::ref()
49*0Sstevel@tonic-gate {
50*0Sstevel@tonic-gate   ++count_;
51*0Sstevel@tonic-gate }
52*0Sstevel@tonic-gate 
53*0Sstevel@tonic-gate #ifdef SP_NAMESPACE
54*0Sstevel@tonic-gate }
55*0Sstevel@tonic-gate #endif
56*0Sstevel@tonic-gate 
57*0Sstevel@tonic-gate #endif /* not Resource_INCLUDED */
58