Ref.h
Go to the documentation of this file.
//-----------------------------------------------------------------------------
//
// Ref.h
//
// Reference counting for objects.
//
// Copyright (c) 2010 Mal Lansell <mal@lansell.org>
// All rights reserved.
//
// SOFTWARE NOTICE AND LICENSE
//
// This file is part of OpenZWave.
//
// OpenZWave is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// OpenZWave is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
#ifndef _Ref_H
#define _Ref_H
#pragma once
#include "Defs.h"
namespace OpenZWave
{
class Ref
{
public:
Ref(){ m_refs = 1; }
void AddRef(){ ++m_refs; }
int32 Release()
{
if( 0 >= ( --m_refs ) )
{
delete this;
return 0;
}
return m_refs;
}
protected:
virtual ~Ref(){}
private:
// Reference counting
int32 m_refs;
}; // class Ref
} // namespace OpenZWave
#endif // _Ref_H
OpenZWave
Definition: Bitfield.h:34
OpenZWave::Ref::AddRef
void AddRef()
Definition: Ref.h:61
Defs.h
int32
signed int int32
Definition: Defs.h:79
OpenZWave::Ref::~Ref
virtual ~Ref()
Definition: Ref.h:80
OpenZWave::Ref::Release
int32 Release()
Definition: Ref.h:69
OpenZWave::Ref
Definition: Ref.h:45
OpenZWave::Ref::Ref
Ref()
Definition: Ref.h:53