Artec 3D Scanning SDK 1.0
Main Page
Namespaces
Classes
Files
Examples
File List
File Members
artec
sdk
base
RefBase.h
Go to the documentation of this file.
1
/********************************************************************
2
*
3
* Project Artec 3D Scanning SDK
4
*
5
* Purpose: Ref counter declaration
6
*
7
* Copyright: Artec Group
8
*
9
********************************************************************/
10
11
#ifndef _REF_H_
12
#define _REF_H_
13
14
#ifdef WIN32
15
#include <intrin.h>
16
#endif
17
18
#define IMPLEMENT_IREF \
19
virtual int addRef() const \
20
{ \
21
return ref_.addRef(); \
22
} \
23
virtual int release() const \
24
{ \
25
long refCount = ref_.release(); \
26
if (refCount == 0) \
27
delete this; \
28
\
29
return refCount; \
30
} \
31
private: \
32
artec::sdk::base::details::RefCounter ref_; \
33
public:
34
35
namespace
artec
{
namespace
sdk {
namespace
base
36
{
37
namespace
details
38
{
39
40
class
RefCounter
41
{
42
public
:
43
RefCounter
() : refCount_(1) {}
44
45
int
addRef
()
const
46
{
47
#ifdef WIN32
48
return
_InterlockedIncrement((
volatile
long
*)&refCount_);
49
#else
50
// we assume linux or osx here
51
return
__sync_add_and_fetch(&refCount_, 1);
52
#endif
53
}
54
55
int
release
()
const
56
{
57
#ifdef WIN32
58
return
_InterlockedDecrement((
volatile
long
*)&refCount_);
59
#else
60
// we assume linux or osx here
61
return
__sync_sub_and_fetch(&refCount_, 1);
62
#endif
63
}
64
65
private
:
66
mutable
volatile
int
refCount_;
67
};
68
69
}
// namespace details
70
71
template
<
class
Interface>
class
RefBase
:
public
Interface
72
{
73
public
:
74
IMPLEMENT_IREF
;
75
virtual
~RefBase
() {}
76
};
77
78
} } }
// namespace artec::sdk::base
79
80
#endif // _REF_H_
artec::sdk::base::RefBase::IMPLEMENT_IREF
IMPLEMENT_IREF
Definition:
RefBase.h:74
artec::sdk::base::RefBase::~RefBase
virtual ~RefBase()
Definition:
RefBase.h:75
artec
Definition:
AlgorithmWorkset.h:17
artec::sdk::base::details::RefCounter::RefCounter
RefCounter()
Definition:
RefBase.h:43
artec::sdk::base::details::RefCounter::release
int release() const
Definition:
RefBase.h:55
artec::sdk::base::details::RefCounter::addRef
int addRef() const
Definition:
RefBase.h:45
artec::sdk::base::details::RefCounter
Definition:
RefBase.h:40
artec::sdk::base::RefBase
Definition:
RefBase.h:71
Generated on Wed Dec 30 2015 18:59:17 for Artec 3D Scanning SDK by
1.8.10