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

📄 reg_table.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 2 页
字号:
            delete tt;        }    }    catch (...)    {        // Just ignore them. The worst that can happen is that we have a        // memory leak.    }}// insert optimized for simplicity, not speedBoolean reg_table_rep::_insert(const reg_table_record& rec){    // ipc synchronization    AutoMutex monitor(_mutex);    type_table* tt = 0;    if (false ==  _table.lookup(rec.namespace_name.getString(), tt))    {        AutoPtr<type_table> temp(new type_table());        _table.insert(rec.namespace_name.getString(), temp.get());        temp.release();        if (false ==  _table.lookup(rec.namespace_name.getString(), tt))            return false;    }    routing_table* rt = 0;    // if not found in type_table, insert new entry.    if (false == tt->lookup(rec.type, rt))    {        AutoPtr<routing_table> temp(new routing_table());        tt->insert(rec.type, temp.get());        temp.release();        if (false == tt->lookup(rec.type, rt))            return false;    }    Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,        "reg_table_rep::_insert - Inserting provider $0 into the provider "            "reqistration table,",        rec.class_name.getString());    // Insert the new record into the routing table    return rt->insert(rec.class_name.getString(), new reg_table_record(rec));}const reg_table_record* reg_table_rep::find(const reg_table_record& rec){    return _find(rec, FIND);}void reg_table_rep::find(    const reg_table_record& rec,    Array<reg_table_record*>* results){    _find(rec, (FIND | MULTIPLE), results);}void reg_table_rep::destroy(const reg_table_record& rec){    _find(rec, (FIND | REMOVE | DESTROY));}void reg_table_rep::destroy_all(){    reg_table_record rec;    _find(rec, (FIND | REMOVE | DESTROY | MULTIPLE ));}reg_table_record* reg_table_rep::_find(    const reg_table_record& rec,    Uint32 flags,    Array<reg_table_record*>* arr_ptr){    // ipc synchronization    AutoMutex monitor(_mutex);    type_table* tt = 0;    Boolean try_again = true;    if (flags & MULTIPLE)    {        _enumerate(rec, flags, arr_ptr);        return 0;    }    else    {        // find the type entry        if (true == _table.lookup(rec.namespace_name.getString(), tt))        {try_again_wild_namespace:            routing_table* rt;            if (true == tt->lookup(rec.type, rt))            {                reg_table_record* record;                while (true == rt->lookup(rec.class_name.getString(), record))                {                    // flags value of all foxes always matches                    if (rec.flags != 0xffffffff)                    if (record->flags != rec.flags)                        continue;                    if (flags & REMOVE || flags & DESTROY)                    {                        rt->remove(rec.class_name.getString());                        if (flags & DESTROY)                        {                            delete record;                            record = 0;                        }                    }                    return record;                }            }        }    }    // now try again using the special wildcard namespace table    CIMNamespaceName _wild;    _wild.clear();    if (true == try_again && true == _table.lookup(_wild.getString(), tt))    {        try_again = false;        goto try_again_wild_namespace;    }    return 0;}// do not call directly - does not lock the reg table mutex !!void reg_table_rep::_enumerate(    const reg_table_record& rec,    Uint32 flags,    Array<reg_table_record*>* results){_enumerate_start:    if (flags & MULTIPLE)    {        if (results == 0 && ! (flags & DESTROY))            return;        for (namespace_table::Iterator i = _table.start(); i; i++)        {            // null namespace_name is a wildcard            if (false == rec.namespace_name.isNull())            {                if (rec.namespace_name.getString() != i.key())                    continue;            }            for (type_table::Iterator y = i.value()->start(); y != 0 ; y++)            {                // type of -1 is a wildcard                if (rec.type != 0xffffffff)                {                    if (rec.type != y.key())                        continue;                }                for (routing_table::Iterator x = y.value()->start();                     x != 0; x++)                {                    // null class_name is a wildcard                    if (false == rec.class_name.isNull())                    {                        if (!rec.class_name.equal(x.value()->class_name))                            continue;                    }                    reg_table_record* tmp = x.value();                    // flags value of all foxes always matches                    if (rec.flags != 0xffffffff)                        if (tmp->flags != rec.flags)                            continue;                    if (flags & SERVICE)                    {                        if (rec.service != tmp->service)                            continue;                    }                    if (flags & REMOVE || flags & DESTROY)                    {                        y.value()->remove(x.key());                        if (flags & DESTROY)                        {                            delete tmp;                        }                        goto _enumerate_start;                    }                    else                    {                        results->append(tmp);                    }                }            }        }    }}void reg_table_rep::_dump_table(){    PEGASUS_STD(cout) << "******** Dumping Reg Table ********" <<        PEGASUS_STD(endl);    AutoMutex monitor(_mutex);    for (namespace_table::Iterator i = _table.start(); i; i++)    {        PEGASUS_STD(cout) << "Namespace: "  << i.key() << PEGASUS_STD(endl);        for (type_table::Iterator y = i.value()->start(); y != 0 ; y++)        {            PEGASUS_STD(cout) << "Type: " << y.key()  << PEGASUS_STD(endl);            for (routing_table::Iterator x = y.value()->start(); x != 0; x++)            {                reg_table_record* tmp = x.value();                tmp->dump();            }        }    }}const Uint32 DynamicRoutingTable:: INTERNAL       = 0x00000001;const Uint32 DynamicRoutingTable:: INSTANCE       = 0x00000002;const Uint32 DynamicRoutingTable:: CLASS          = 0x00000003;const Uint32 DynamicRoutingTable:: METHOD         = 0x00000004;DynamicRoutingTable::DynamicRoutingTable(){    _rep = new reg_table_rep();}DynamicRoutingTable::~DynamicRoutingTable(){    Dec(_rep);}DynamicRoutingTable::DynamicRoutingTable(const DynamicRoutingTable& table){    if (this != &table)    {        Inc(_rep = table._rep);    }}DynamicRoutingTable& DynamicRoutingTable::operator=(    const DynamicRoutingTable& table){    if (this != &table)    {        // De-allocate the _rep we have internally        Dec(_rep);        Inc(_rep = table._rep);    }    return *this;}DynamicRoutingTable DynamicRoutingTable::get_rw_routing_table(){    return DynamicRoutingTable(_internal_routing_table);}MessageQueueService* DynamicRoutingTable::get_routing(    const CIMName& classname,    const CIMNamespaceName& ns,    Uint32 type,    Uint32 flags,    String& provider,    String& module) const{    reg_table_record rec(classname, ns, type, flags, 0, provider, module);    const reg_table_record* ret = _rep->find(rec);    if (ret)    {        provider = ret->provider_name;        module = ret->module_name;        return ret->service;    }    return 0;}Boolean DynamicRoutingTable::insert_record(    const CIMName& classname,    const CIMNamespaceName& ns,    Uint32 type,    Uint32 flags,    MessageQueueService* svce){    reg_table_record rec(classname, ns, type, flags, svce);    return _rep->_insert(rec);}Boolean DynamicRoutingTable::insert_record(    const CIMName& classname,    const CIMNamespaceName& ns,    Uint32 type,    Uint32 flags,    MessageQueueService* svce,    const String& provider,    const String& module){    reg_table_record rec(classname, ns, type, flags, svce, provider, module);    return _rep->_insert(rec);}void DynamicRoutingTable::dump_table(){    _rep->_dump_table();}PEGASUS_NAMESPACE_END

⌨️ 快捷键说明

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