📄 reference_counter.h
字号:
/******************************************************************************
*******************************************************************************
** **
** Copyright (c) 2006 Videon Central, Inc. **
** All rights reserved. **
** **
** The computer program contained herein contains proprietary information **
** which is the property of Videon Central, Inc. The program may be used **
** and/or copied only with the written permission of Videon Central, Inc. **
** or in accordance with the terms and conditions stipulated in the **
** agreement/contract under which the programs have been supplied. **
** **
*******************************************************************************
******************************************************************************/
/**
* @file reference_counter.h
*
* $Revision: 1.3 $
*
* Base class for objects that require reference counting
*
*/
#ifndef __REFERENCE_COUNTER_H
#define __REFERENCE_COUNTER_H
#include "mutex.h"
#include "vcitypes.h"
#include "error.h"
/**
*******************************************************************************
* ReferenceChecker class provides a simple mechanism to check if object is
* created and destroyed properly
*
*******************************************************************************/
class ReferenceChecker
{
protected:
uint32 m_referenceCount;
public:
ReferenceChecker ( void );
~ReferenceChecker ( void );
virtual VDVD_ERROR Create ( void );
virtual VDVD_ERROR Destroy ( void );
BOOLEAN IsReferenced ( void );
};
/**
*******************************************************************************
* ReferenceCounter class provides mechanism to automatically construct or
* destruct an object(allocate/free resources) depending on if it is being
* used (referenced) or not. This is used to greatly simplify teardown
* sequences for objects that are shared and should not be destructed until
* last user delete's it's reference.
*
*******************************************************************************/
class ReferenceCounter : public ReferenceChecker
{
private:
Mutex m_mutex;
virtual VDVD_ERROR Construct ( void )=0;
virtual VDVD_ERROR Destruct ( void )=0;
public:
virtual VDVD_ERROR AddReference ( void );
virtual VDVD_ERROR DeleteReference ( void );
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -