⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commreg.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 4 页
字号:
 *  	delete a property (DB_node too) from the database given *  the key string. */UINT32CommonRegistry::Del(const UINT32 hash_key){    DB_node* d = 0;    Property* p = 0;    DB_implem* ldb = _logdb_imp;    d = (DB_node *)_ids->get(hash_key);    if (!d)    {	DPRINTF(D_REGISTRY, ("%lu -- was NOT FOUND\n", hash_key));	return 0;    }    p = d->get_data();    if (!p)    {	DPRINTF(D_REGISTRY, ("%lu -- has NO DATA\n", hash_key));	return 0;    }    if (p->is_read_only())    {	DPRINTF(D_REGISTRY, ("%lu -- is READ ONLY\n", hash_key));        return 0;    }    // find the DB that contains this node    ldb = d->get_db();    if (!ldb)    {	DPRINTF(D_REGISTRY, ("%lu -- has NO IMPLEMENTATION\n", hash_key));        return 0;    }    // here the response method doesn't exactly end this method    DeleteDone(ldb, d, p);    if (p->m_lWatchCount)    {	/*	 * Wait for the clear watches to delete the node	 */	p->set_deleted(ldb, d, hash_key);	return hash_key;    }    return _Del(ldb, d, p, hash_key);}UINT32CommonRegistry::_Del(DB_implem* ldb, DB_node* d, Property* p, UINT32 h){    if (p->get_type() == PT_COMPOSITE)    {	DB_implem* temp_ldb;	p->get_db_val(&temp_ldb);	if (_del(temp_ldb) == HXR_FAIL)	    return 0;    }    _ids->destroy(h);    ldb->del(d);    _count--;    return h;}UINT32CommonRegistry::SetWatch(PropWatch* pPropWatch){    /*     * XXXAAK -- need to do some checking to disallow duplicate watchpoints     * per process     */    WListElem* wle = new WListElem;    wle->data = pPropWatch;    m_pWatchList->insert(wle);    m_lWatchCount++;    return 1;}UINT32CommonRegistry::SetWatch(const char* prop_name, PropWatch* pPropWatch){    DB_node*  d = 0;    Property* p = 0;    if (_find(&d, &p, prop_name) == HXR_OK)    {	WListElem* wle = new WListElem;	wle->data = pPropWatch;	p->m_pWatchList->insert(wle);	p->m_lWatchCount++;	return d->get_id();    }    return 0;}UINT32CommonRegistry::SetWatch(const UINT32 hash_key, PropWatch* pPropWatch){    DB_node*  d = 0;    Property* p = 0;    d = (DB_node *)_ids->get(hash_key);    if (!d)	return 0;    p = (Property *)d->get_data();    if (p)    {	WListElem* wle = new WListElem;	wle->data = pPropWatch;	p->m_pWatchList->insert(wle);	p->m_lWatchCount++;	return hash_key;    }    return 0;}/* *  Function Name:  	SetTrickleWatch *  Input Params:   	const char* par_prop_name, const char* target_name, *                      PropWatch* cb *  Return Value:   	UINT32 *  Description: *  	this method does kinda a watch for a Property that will be added *  in the future. when the "target_name" Property gets added somewhere *  under the hierarchy of the parent Property "par_prop_name" the watch *  will be TRICKLED down the hierarchy until it reaches its target and *  set it for the target. if the target never gets added the callback *  will NOT be triggered. */HX_RESULTCommonRegistry::SetTrickleWatch(const char* par_prop_name,                                 const char* target_name,			        PropWatch* cb){    // not supported!!!    return HXR_NOTIMPL; }/* *  Function Name:  	CommonRegistry::ClearWatch *  Input Params:   	int proc_num *  Return Value:   	HX_RESULT *  Description: *  	clear a watchpoint from the global watchlist at the highgest  *  level of the database hierarchy. */HX_RESULTCommonRegistry::ClearWatch(IHXPropWatchResponse* pResonse){    return _clearWatch(pResonse);}HX_RESULTCommonRegistry::ClearWatch(const char* prop_name, IHXPropWatchResponse* pResonse){    DB_node*  d = 0;    Property* p = 0;    if (_find(&d, &p, prop_name) != HXR_OK)	return HXR_FAIL;    return _clearWatch(p, pResonse);}HX_RESULTCommonRegistry::ClearWatch(const UINT32 hash_key, IHXPropWatchResponse* pResonse){    DB_node*  d = 0;    Property* p = 0;    d = (DB_node *)_ids->get(hash_key);    if (!d)    {	return HXR_FAIL;    }    p = d->get_data();    return _clearWatch(p, pResonse);}HX_RESULTCommonRegistry::AddDone(DB_implem* db_level, DB_node* new_node,	                DB_node* parent_node, Property* parent_prop){    _dispatchParentCallbacks(db_level, new_node, DBE_ADDED);        return HXR_OK;}HX_RESULTCommonRegistry::SetDone(DB_node* new_node, Property* new_prop){    _dispatchCallbacks(new_node, new_prop, DBE_MODIFIED);    return HXR_OK;}HX_RESULTCommonRegistry::DeleteDone(DB_implem* db_level, DB_node* node,			   Property* prop){    _dispatchCallbacks(node, prop, DBE_DELETED);    _dispatchParentCallbacks(db_level, node, DBE_DELETED);       return HXR_OK;}DB_node*CommonRegistry::_addComp(Key* k, char* key_str, DB_implem* ldb){    DPRINTF(D_REGISTRY, ("CommonRegistry::_addComp()\n"));    Property* new_p = new Property(k, PT_COMPOSITE);    if( !new_p )    {        return NULL;    }    DB_node* new_d = ldb->add(key_str, new_p);    if( !new_d )    {	delete new_p;	return NULL;    }    DB_dict* pNewDb = new DB_dict(new_d);    if( !pNewDb )    {	delete new_p;	delete new_d;	return NULL;    }    new_p->db_val(pNewDb);    UINT32 id = _ids->create((void *)new_d);    new_d->id(id);    _count++;    return new_d;}DB_node*CommonRegistry::_addInt(Key* k, char* key_str, INT32 val, DB_implem* ldb){    DPRINTF(D_REGISTRY, ("CommonRegistry::_addInt()\n"));    Property* new_p = new Property(k, PT_INTEGER);    if(!new_p)    {        return NULL;    }    new_p->int_val(val);    DB_node* new_d = ldb->add(key_str, new_p);    if (!new_d)    {	delete new_p;	return 0;    }    UINT32 id = _ids->create((void *)new_d);    new_d->id(id);    _count++;    return new_d;}DB_node*CommonRegistry::_addBuf(Key* k, char* key_str, IHXBuffer* buf, DB_implem* ldb,                        HXPropType val_type){    DPRINTF(D_REGISTRY, ("CommonRegistry::_addBuf()\n"));    Property* new_p = new Property(k, val_type);    if(!new_p)    {        return NULL;    }    // AddRef gets called within the buf_val() method    new_p->buf_val(buf, val_type);    DB_node* new_d = ldb->add(key_str, new_p);    if (!new_d)    {	delete new_p;	return 0;    }    UINT32 id = _ids->create((void *)new_d);    new_d->id(id);    _count++;    return new_d;}DB_node*CommonRegistry::_addIntRef(Key* k, char* key_str, INT32* val, DB_implem* ldb){    DPRINTF(D_REGISTRY, ("CommonRegistry::_addIntRef()\n"));    Property* new_p = new Property(k, PT_INTREF);    new_p->int_ref_val(val);    DB_node* new_d = ldb->add(key_str, new_p);    if (!new_d)    {	delete new_p;	return 0;    }    UINT32 id = _ids->create((void *)new_d);    new_d->id(id);    _count++;    return new_d;}/* *  Function Name:  	_dispatchParentCallbacks *  Input Params:   	DB_implem* db, DB_node* currNode, DB_Event e *  Return Value:   	void *  Description: *      fires off the callbacks of the Parent of the *  Property in "currNode". it is used only when a Property gets *  added or deleted. */voidCommonRegistry::_dispatchParentCallbacks(DB_implem* db, DB_node* currNode,                                          DB_Event e){    DB_node*	    parNode = 0;		// parent's node    Property*	    parProp = 0;		// parent's property    UINT32 	    par_hash_key = 0;    if (_logdb_imp == db)    {	if (!m_pWatchList || m_pWatchList->empty())	    return;	PropWatch* 	pPropWatch = NULL;	UINT32 hash_key = currNode->get_id();	DPRINTF(D_REGISTRY, ("_dPC -- before root loop\n"));	for (WatchList_iterator wli(m_pWatchList); *wli != 0; ++wli)	{	    WListElem* wle = *wli;	    pPropWatch = (PropWatch *)wle->data;	    switch (e)	    {	    case DBE_ADDED:		pPropWatch->m_pResponse->AddedProp(hash_key, PT_UNKNOWN, 0);		break;	    case DBE_MODIFIED:		pPropWatch->m_pResponse->ModifiedProp(hash_key, PT_UNKNOWN, 0);		break;	    case DBE_DELETED:		pPropWatch->m_pResponse->DeletedProp(hash_key, 0);		break;	    default:		break;	    }	}    }    else    {	// find the node that owns this DB	parNode = db->owner_node();	if (parNode)	{	    par_hash_key = parNode->get_id();	    // get the parent's Property	    parProp = parNode->get_data();	    if (!parProp)	    {		DPRINTF(D_REGISTRY, ("%s has an INVALID parent Property\n",		                     currNode->get_data()->get_key_str()));		return;	    }	}	else	{	    DPRINTF(D_REGISTRY, ("%s has an INVALID parent DB_node\n",	                         currNode->get_data()->get_key_str()));	    return;	}	if (!parProp->m_pWatchList || parProp->m_pWatchList->empty())	    return;	UINT32 hash_key = currNode->get_id();	for (WatchList_iterator wli(parProp->m_pWatchList); *wli != 0; ++wli)	{	    WListElem* wle = *wli;	    PropWatch* pPropWatch = (PropWatch *)wle->data;	    switch (e)	    {	    case DBE_ADDED:		pPropWatch->m_pResponse->AddedProp(hash_key, PT_UNKNOWN, 						   par_hash_key);		break;	    case DBE_MODIFIED:		pPropWatch->m_pResponse->ModifiedProp(hash_key, PT_UNKNOWN,						      par_hash_key);		break;	    case DBE_DELETED:		pPropWatch->m_pResponse->DeletedProp(hash_key, par_hash_key);		break;	    default:		break;	    }	}    }}/* *  Function Name:  	_dispatchCallbacks *  Input Params:   	UINT32 hash_key, Property* p, DB_Event e *  Return Value:   	void *  Description: *  	it fires off the watch callbacks of the Property "p" whenever *  it gets modified or deleted. */voidCommonRegistry::_dispatchCallbacks(DB_node* d, Property* p, DB_Event e){    if (p->m_lWatchCount <= 0)	return;    UINT32 hash_key = d->get_id();    UINT32 par_id = 0;    // find the DB that contains this node    DB_implem* ldb = d->get_db();    if (ldb)    {	// find the node that owns the DB	DB_node* par_node = ldb->owner_node();	if (par_node)	    par_id = par_node->get_id();    }    for (WatchList_iterator wli(p->m_pWatchList); *wli != 0; ++wli)    {	WListElem* wle = *wli;	PropWatch* pPropWatch = (PropWatch *)wle->data;	switch (e)	{	case DBE_ADDED:	    pPropWatch->m_pResponse->AddedProp(hash_key, PT_UNKNOWN, par_id);	    break;	case DBE_MODIFIED:	    pPropWatch->m_pResponse->ModifiedProp(hash_key, PT_UNKNOWN, par_id);	    break;	case DBE_DELETED:	    pPropWatch->m_pResponse->DeletedProp(hash_key, par_id);	    break;	default:	    break;	}    }}/* *  Function Name:  	CommonRegistry::_clearWatch *  Input Params:   	int proc_num *  Return Value:   	HX_RESULT *  Description: *  	clear watch at the root level of the registry. */HX_RESULTCommonRegistry::_clearWatch(IHXPropWatchResponse* pResonse){    for (WatchList_iterator wli(m_pWatchList); *wli != 0; ++wli)    {	WListElem* wle = *wli;	PropWatch* pPropWatch = (PropWatch *)wle->data;    // Delete the entry that contains pResonse if one was supplied.    // If pResponse is NULL, blindly delete the first entry in the watch list.    if ((pPropWatch && pResonse && pPropWatch->m_pResponse == pResonse) ||        !pResonse)    {        m_pWatchList->removeElem(wle);	    delete wle;	    delete pPropWatch;	    m_lWatchCount--;    }    }        return HXR_OK;}/* *  Function Name:  	_clearWatch *  Input Params:   	Property* p *  Return Value:   	HX_RESULT *  Description: *  	clears a watch callback (watchpoint) from a Property based on  *  the process number. if the Property is not specified, then the *  watchpoints at the highgest level are cleared. */HX_RESULTCommonRegistry::_clearWatch(Property* p, IHXPropWatchResponse* pResonse){    if (p)    {	for (WatchList_iterator wli(p->m_pWatchList); *wli != 0; ++wli)	{	    WListElem* wle = *wli;	    PropWatch* pPropWatch = (PropWatch *)wle->data;	            // Delete the entry that contains pResonse if one was supplied.        // If pResponse is NULL, blindly delete the first entry in the watch list.        if ((pPropWatch && pResonse && pPropWatch->m_pResponse == pResonse) ||            !pResonse)        {            delete pPropWatch;	        return DeleteWatch(p, wle);        }	}    }    return HXR_OK;}HX_RESULTCommonRegistry::DeleteWatch(Property* p, WListElem* wle){    p->m_pWatchList->removeElem(wle);    delete wle;    p->m_lWatchCount--;    if (p->is_deleted() && !p->m_lWatchCount)    {	_Del(p->_owner_db, p->_owner_node, p, p->_id);    }    return HXR_OK;}/* *  Function Name:  	GetType *  Input Params:   	const char* prop_name *  Return Value:   	HXPropType *  Description: *      returns the Datatype of the Property. */HXPropTypeCommonRegistry::GetType(const char* prop_name) const{    DB_node*  d = 0;    Property* p = 0;    if (_find(&d, &p, prop_name) == HXR_OK)	if (p)	    return p->get_type();    return PT_UNKNOWN;}/* *  Function Name:  	GetType *  Input Params:   	const UINT32 hash_key *  Return Value:   	HXPropType *  Description: *      returns the Datatype of the Property. */HXPropTypeCommonRegistry::GetType(const UINT32 hash_key) const{    DB_node*  d = 0;    Property* p = 0;    UINT32    h = hash_key;    d = (DB_node *)_ids->get(hash_key);    if (!d)    {	DPRINTF(D_REGISTRY, ("Get Type (%lu) failed\n", hash_key));	return PT_UNKNOWN;    }    p = d->get_data();    if (p)	return p->get_type();    return PT_UNKNOWN;}/* *  Function Name:  	CommonRegistry::GetPropList const *  Input Params:	IHXValues*& pValues *  Return Value:   	HX_RESULT *  Description: *  	it returns back a list of triples one for each property under  *  highest level of the database. each of these properties consists of  *  name, type and the hash key * *  XXXAAK -- return a list of hash keys if the list element is PT_COMPOSITE. */HX_RESULTCommonRegistry::GetPropList(IHXValues*& pValues) const{    return _getPropList(_logdb_imp, pValues);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -