📄 hxclreg.cpp
字号:
/* ***** BEGIN LICENSE BLOCK *****
* Version: RCSL 1.0/RPSL 1.0
*
* Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved.
*
* The contents of this file, and the files included with this file, are
* subject to the current version of the RealNetworks Public Source License
* Version 1.0 (the "RPSL") available at
* http://www.helixcommunity.org/content/rpsl unless you have licensed
* the file under the RealNetworks Community Source License Version 1.0
* (the "RCSL") available at http://www.helixcommunity.org/content/rcsl,
* in which case the RCSL will apply. You may also obtain the license terms
* directly from RealNetworks. You may not use this file except in
* compliance with the RPSL or, if you have a valid RCSL with RealNetworks
* applicable to this file, the RCSL. Please see the applicable RPSL or
* RCSL for the rights, obligations and limitations governing use of the
* contents of the file.
*
* This file is part of the Helix DNA Technology. RealNetworks is the
* developer of the Original Code and owns the copyrights in the portions
* it created.
*
* This file, and the files included with this file, is distributed and made
* available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
*
* Technology Compatibility Kit Test Suite(s) Location:
* http://www.helixcommunity.org/content/tck
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** */
#include "hlxclib/stdio.h"
#include "hlxclib/string.h"
#include "hxtypes.h"
#include "hxcom.h"
#include "ihxpckts.h"
#include "hxmon.h"
#include "watchlst.h"
#include "property.h"
#include "db_dict.h"
#include "commreg.h"
#include "hxpropwclnt.h"
#include "hxclreg.h"
#include "hxheap.h"
#ifdef _DEBUG
#undef HX_THIS_FILE
static const char HX_THIS_FILE[] = __FILE__;
#endif
HXClientRegistry::HXClientRegistry() :
m_lRefCount(0)
,m_pPropDB(NULL)
,m_pContext(NULL)
{
m_pPropDB = new CommonRegistry;
}
HXClientRegistry::~HXClientRegistry()
{
Close();
}
/////////////////////////////////////////////////////////////////////////
// Method:
// HXRegistry::QueryInterface
// Purpose:
// Implement this to export the interfaces supported by your
// object.
//
STDMETHODIMP
HXClientRegistry::QueryInterface(REFIID riid, void** ppvObj)
{
QInterfaceList qiList[] =
{
{ GET_IIDHANDLE(IID_IHXRegistry), (IHXRegistry*)this },
{ GET_IIDHANDLE(IID_IUnknown), (IUnknown*)(IHXRegistry*)this },
};
return ::QIFind(qiList, QILISTSIZE(qiList), riid, ppvObj);
}
/////////////////////////////////////////////////////////////////////////
// Method:
// HXRegistry::AddRef
// Purpose:
// Everyone usually implements this the same... feel free to use
// this implementation.
//
STDMETHODIMP_(ULONG32)
HXClientRegistry::AddRef()
{
return InterlockedIncrement(&m_lRefCount);
}
/////////////////////////////////////////////////////////////////////////
// Method:
// HXRegistry::Release
// Purpose:
// Everyone usually implements this the same... feel free to use
// this implementation.
//
STDMETHODIMP_(ULONG32)
HXClientRegistry::Release()
{
if (InterlockedDecrement(&m_lRefCount) > 0)
{
return m_lRefCount;
}
delete this;
return 0;
}
/*
* Users of this class should call Init and the context should
* expose IHXInterruptState and IHXScheduler if they want to
* ensure that watches are fired ONLY at non-interrupt time.
*
* Currently, this functionality is ONLY used by the client core
* since it is multi-threaded and needs to deal with
* top level clients which are not thread-safe.
*/
void
HXClientRegistry::Init(IUnknown* pContext)
{
m_pContext = pContext;
m_pContext->AddRef();
}
void
HXClientRegistry::Close(void)
{
HX_DELETE(m_pPropDB);
HX_RELEASE(m_pContext);
}
/************************************************************************
* Method:
* IHXRegistry::CreatePropWatch
* Purpose:
* Create a new IHXPropWatch object which can then be queried for the
* right kind of IHXPropWatch object.
*/
STDMETHODIMP
HXClientRegistry::CreatePropWatch(IHXPropWatch*& ppObj)
{
if (!m_pPropDB)
{
return HXR_FAIL;
}
ppObj = (IHXPropWatch *)new HXClientPropWatch(m_pPropDB, m_pContext);
if (ppObj)
{
ppObj->AddRef();
return HXR_OK;
}
return HXR_OUTOFMEMORY;
}
/************************************************************************
* Method:
* IHXRegistry::AddComp
* Purpose:
* Add a COMPOSITE property to the registry and return its hash
* key value if successful. It returns ZERO (0) if an error occured
* during the operation.
*/
STDMETHODIMP_(UINT32)
HXClientRegistry::AddComp(const char * new_prop)
{
// if the return value is ZERO then the operation failed
return m_pPropDB->AddComp(new_prop);
}
/************************************************************************
* Method:
* IHXRegistry::AddInt
* Purpose:
* Add an INTEGER property with name in "pName" and value in
* "iValue" to the registry. The return value is the id to
* the newly added Property or ZERO if there was an error.
*/
STDMETHODIMP_(UINT32)
HXClientRegistry::AddInt(const char* new_prop, const INT32 val)
{
// if the return value is ZERO then the operation failed
return m_pPropDB->AddInt(new_prop, val);
}
/************************************************************************
* Method:
* IHXRegistry::GetInt
* Purpose:
* Retreive an INTEGER value from the registry given its Property
* name "pcName" or by its id "id". If the Property
* is found, it will return HXR_OK, otherwise it returns HXR_FAIL.
*/
STDMETHODIMP
HXClientRegistry::GetIntByName(const char* prop_name, INT32& val) const
{
return m_pPropDB->GetInt(prop_name, &val);
}
/************************************************************************
* Method:
* IHXRegistry::GetInt
* Purpose:
* Retreive an INTEGER value from the registry given its Property
* name "pcName" or by its id "id". If the Property
* is found, it will return HXR_OK, otherwise it returns HXR_FAIL.
*/
STDMETHODIMP
HXClientRegistry::GetIntById(const UINT32 hash_key, INT32& val) const
{
return m_pPropDB->GetInt(hash_key, &val);
}
/************************************************************************
* Method:
* IHXRegistry::SetIntByXYZ
* Purpose:
* Modify a Property's INTEGER value in the registry given the
* Property's name "pcName" or its id "id". If the value
* was set, it will return HXR_OK, otherwise it returns HXR_FAIL.
*/
STDMETHODIMP
HXClientRegistry::SetIntByName(const char* prop_name, const INT32 val)
{
return m_pPropDB->SetInt(prop_name, val);
}
/************************************************************************
* Method:
* IHXRegistry::SetIntByXYZ
* Purpose:
* Modify a Property's INTEGER value in the registry given the
* Property's name "pcName" or its id "id". If the value
* was set, it will return HXR_OK, otherwise it returns HXR_FAIL.
*/
STDMETHODIMP
HXClientRegistry::SetIntById(const UINT32 hash_key, const INT32 val)
{
return m_pPropDB->SetInt(hash_key, val);
}
/************************************************************************
* Method:
* IHXRegistry::AddStr
* Purpose:
* Add an STRING property with name in "pcName" and value in
* "pcValue" to the registry.
*/
STDMETHODIMP_(UINT32)
HXClientRegistry::AddStr(const char* new_prop, IHXBuffer* val)
{
// if the return value is ZERO then the operation failed
return m_pPropDB->AddStr(new_prop, val);
}
/************************************************************************
* Method:
* IHXRegistry::GetStrByXYZ
* Purpose:
* Retreive an STRING value from the registry given its Property
* name "pcName" or by its id "id". If the Property
* is found, it will return HXR_OK, otherwise it returns HXR_FAIL.
*/
STDMETHODIMP
HXClientRegistry::GetStrByName(const char* prop_name, REF(IHXBuffer*) val) const
{
val = NULL;
return m_pPropDB->GetStr(prop_name, val);
}
/************************************************************************
* Method:
* IHXRegistry::GetStrByXYZ
* Purpose:
* Retreive an STRING value from the registry given its Property
* name "pcName" or by its id "id". If the Property
* is found, it will return HXR_OK, otherwise it returns HXR_FAIL.
*/
STDMETHODIMP
HXClientRegistry::GetStrById(const UINT32 hash_key, REF(IHXBuffer*) val) const
{
val = NULL;
return m_pPropDB->GetStr(hash_key, val);
}
/************************************************************************
* Method:
* IHXRegistry::SetStrByXYZ
* Purpose:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -