HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TS_Resource.h
Go to the documentation of this file.
1 /* Resource.h
2  *
3  * Copyright 1992 by Algorithmic Arts, Inc.
4  * All Rights Reserved. Use, disclosure or reproduction of this software
5  * is prohibited without prior express written consent of Algorithmic Arts.
6  *
7  * $XRevision: 1.1.1.1 $
8  *
9  */
10 
11 #ifndef TESSERA_RESOURCE_H
12 #define TESSERA_RESOURCE_H
13 
14 #include "TS_API.h"
15 #include <SYS/SYS_AtomicInt.h>
16 
17 // Base class for reference counted objects.
19 {
20 public:
21  TS_Resource() : myCount(0) { }
22  virtual ~TS_Resource();
23  void ref() { myCount.add(1); }
24  void unref() { if (!myCount.add(-1)) delete this; }
25  int refCount() const { return myCount.load(); }
26 private:
27  SYS_AtomicInt32 myCount;
28 };
29 
30 #endif // TESSERA_RESOURCE_H
void unref()
Definition: TS_Resource.h:24
#define TS_API
Definition: api.h:41
int refCount() const
Definition: TS_Resource.h:25
void ref()
Definition: TS_Resource.h:23