OpenZWave Library 1.6.0
Ref.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2//
3// Ref.h
4//
5// Reference counting for objects.
6//
7// Copyright (c) 2010 Mal Lansell <mal@lansell.org>
8// All rights reserved.
9//
10// SOFTWARE NOTICE AND LICENSE
11//
12// This file is part of OpenZWave.
13//
14// OpenZWave is free software: you can redistribute it and/or modify
15// it under the terms of the GNU Lesser General Public License as published
16// by the Free Software Foundation, either version 3 of the License,
17// or (at your option) any later version.
18//
19// OpenZWave is distributed in the hope that it will be useful,
20// but WITHOUT ANY WARRANTY; without even the implied warranty of
21// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22// GNU Lesser General Public License for more details.
23//
24// You should have received a copy of the GNU Lesser General Public License
25// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
26//
27//-----------------------------------------------------------------------------
28#ifndef _Ref_H
29#define _Ref_H
30
31#pragma once
32
33#include "Defs.h"
34
35namespace OpenZWave
36{
46 class Ref
47 {
48 public:
54 Ref(){ m_refs = 1; }
55
62 void AddRef(){ ++m_refs; }
63
71 {
72 if( 0 >= ( --m_refs ) )
73 {
74 delete this;
75 return 0;
76 }
77 return m_refs;
78 }
79
80 protected:
81 virtual ~Ref(){}
82
83 private:
84 // Reference counting
85 int32 m_refs;
86
87 }; // class Ref
88
89} // namespace OpenZWave
90
91#endif // _Ref_H
92
signed int int32
Definition: Defs.h:94
Definition: Ref.h:47
Ref()
Definition: Ref.h:54
virtual ~Ref()
Definition: Ref.h:81
void AddRef()
Definition: Ref.h:62
int32 Release()
Definition: Ref.h:70
Definition: Bitfield.h:35