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