plugin_init.cpp

来自「ncbi源码」· C++ 代码 · 共 627 行 · 第 1/2 页

CPP
627
字号
//// Create our local data storage connections//void CGBenchPluginInit::x_InitLDS(){    CNcbiApplication* app = CNcbiApplication::Instance();    _ASSERT(app);    const CNcbiRegistry& reg = app->GetConfig();    CRef<CLDS_DatabaseHolder> dbh(new CLDS_DatabaseHolder());    // Discover all LDS_* sections in the application registry    //    list<string> sections;    list<string> lds_sections;    reg.EnumerateSections(&sections);    ITERATE (list<string>, it, sections) {        if (it->find("LDS") == 0) {            lds_sections.push_back(*it);        }    }    vector<string>  plugin_aliases;    ITERATE(list<string>, it, lds_sections) {        string lds_section_name = *it;        string lds_path =             reg.GetString(lds_section_name, "Path", "", CNcbiRegistry::eErrPost);        string lds_alias =             reg.GetString(lds_section_name, "Alias", "Default", CNcbiRegistry::eReturn);        if (lds_path.empty()) {            LOG_POST(Error << "LDS: database " << lds_section_name                            << " " << lds_alias << " ignored. No path.");            continue;        }        // Check if the database already open        {{            CLDS_Database* db1 = dbh->GetDatabase(lds_alias);            if (db1) {                LOG_POST(Error << "LDS: database " << lds_section_name                            << " alias=" << lds_alias                            << " ignored. Alias already exists.");                continue;            }        }}        bool recurse_sub_dir =             reg.GetBool(lds_section_name, "SubDir", true, 0, CNcbiRegistry::eErrPost);        CLDS_Management::ERecurse recurse =             (recurse_sub_dir) ? CLDS_Management::eRecurseSubDirs :                                 CLDS_Management::eDontRecurse;        bool crc32 =             reg.GetBool(lds_section_name, "ControlSum", true, 0, CNcbiRegistry::eErrPost);        // if ControlSum key is true (default), try an laternative "CRC32" key        // (more straightforward synonym for the same setting)        if (crc32) {            crc32 = reg.GetBool(lds_section_name, "CRC32", true, 0, CNcbiRegistry::eErrPost);        }        CLDS_Management::EComputeControlSum control_sum =            (crc32) ? CLDS_Management::eComputeControlSum :                       CLDS_Management::eNoControlSum;        bool is_created;        CLDS_Database *ldb =             CLDS_Management::OpenCreateDB(lds_path, "lds.db",                                           &is_created, recurse,                                           control_sum);        if (!lds_alias.empty()) {            ldb->SetAlias(lds_alias);        }        dbh->AddDatabase(ldb);        if (!is_created) {            CLDS_Management mgmt(*ldb);            mgmt.SyncWithDir(lds_path, recurse, control_sum);        }        plugin_aliases.push_back(lds_alias);          // Adding NON DEFAULT LDS dataloader        // To be activated later in the LDS derived scopes by the dload_basic plugin        try {            string dl_name = string("LDS_dataloader_") + lds_alias;            CRef<CLDS_DataLoader> loader(new CLDS_DataLoader(*ldb, dl_name));            if ( !loader  ) {                NCBI_THROW(CPluginException, eUnknownError,                           "CGBenchPluginInit(): "                           "can't create LDS data loader");            }            CDocManager::GetObjectManager()                .RegisterDataLoader(*(loader.Release()),                                    CObjectManager::eNonDefault, 80);            LOG_POST(Info << "LDS: registered data loader: " << dl_name);        }        catch (CException& e) {            LOG_POST(Error << "error creating LDS data loader: "                            << e.what() << " Alias:" << lds_alias);            string msg("Error creating LDS data loader:\n");            msg += e.GetMsg();            msg += "\nLocal data storage will not be available.";            msg += "Alias: " + lds_alias;            NcbiMessageBox(msg);        }        //break; // TODO: This break is temporary    } // ITERATE    //    // twiddle the plugin registry to handle our aliases    //    if (plugin_aliases.size() > 0) {        CPluginHandle handle = CPluginRegistry::GetPlugin("CLDS_Loader");        if (handle) {            //            // this is a (dangerous!) hack            // DON"T CHANGE THE MENU ITEM!!!!            //            // search for the load data command            CPluginInfo& info = const_cast<CPluginInfo&> (handle.GetInfo());            NON_CONST_ITERATE (CPluginInfo::TCommands::TData, cmd_iter,                               info.SetCommands().SetData()) {                CPluginCommand& cmd = **cmd_iter;                if ( cmd.GetCommand() != eDataCommand_load ) {                    continue;                }                string default_lds_alias = *(plugin_aliases.begin());                //                // found it.  Add an argument for our aliases                //                cmd.AddDefaultArgument("alias", "Directory to load from",                                       CPluginArg::eString, default_lds_alias);                CRef<CPluginValueConstraint> cnst                    (CPluginValueConstraint::CreateSet());                ITERATE(vector<string>, alias, plugin_aliases) {                    *cnst, *alias;                }                cmd.SetConstraint("alias", *cnst);                break;            }        }    }    CDataStore::PutObject("LDS_Database", *dbh);}END_NCBI_SCOPE/* * =========================================================================== * $Log: plugin_init.cpp,v $ * Revision 1000.5  2004/06/01 20:56:32  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.42 * * Revision 1.42  2004/05/21 22:27:47  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.41  2004/05/03 13:04:16  dicuccio * Made log-post message for cache use conflict more user friendly * * Revision 1.40  2004/04/09 20:14:30  dicuccio * Don't add the trace chromatogram loader by default * * Revision 1.39  2004/03/25 14:31:28  dicuccio * Added TRACE chromatogram data loader * * Revision 1.38  2004/02/27 17:33:11  kuznets * Removed CCacheHolder, it now lives in BDB library. * * Revision 1.37  2004/02/27 15:34:34  kuznets * Id1 reader initialization: replaced old local cache with new ICache * implementation (the old one is supposed to be phased out from the toolkit) * * Revision 1.36  2004/02/17 20:35:27  rsmith * moved core/settings.[ch]pp and core/system_path.[ch]pp to config and utils, respectively. * * Revision 1.35  2004/02/17 17:19:57  dicuccio * Moved all LOCAL_CACHE entries into GBLOADER section of registry * * Revision 1.34  2004/01/27 18:42:58  dicuccio * Added flag to diable local cache.  CLeaned up processing of indexed local * directories * * Revision 1.33  2004/01/05 18:09:43  vasilche * Fixed path to genbank loader and readers. * * Revision 1.32  2003/12/09 15:46:54  dicuccio * Use CException::GetMsg() instead of what() * * Revision 1.31  2003/12/02 14:41:42  dicuccio * Restored autorun * * Revision 1.30  2003/11/26 17:16:18  dicuccio * Use the correct class name for registering the initialization plugin * * Revision 1.29  2003/11/24 15:43:12  dicuccio * Added new tip-of-the-day dialog.  Changed CVersion to CPluginVersion * * Revision 1.28  2003/11/04 17:49:23  dicuccio * Changed calling parameters for plugins - pass CPluginMessage instead of paired * CPluginCommand/CPluginReply * * Revision 1.27  2003/10/29 15:10:12  kuznets * Fixed crash on trying to change the lds pluging arguments when gbench.ini does * not have any LDS instances. * * Revision 1.26  2003/10/28 14:22:07  kuznets * Working on support of multiple LDS instances. * * Revision 1.25  2003/10/27 19:58:21  kuznets * Added application registry scan for multiple LDS instances * (not enabled yet) * * Revision 1.24  2003/10/24 12:41:14  kuznets * Added cache locking. Removed explicit local cache directory check * (lives in cache implementation now) * * Revision 1.23  2003/10/23 13:33:57  dicuccio * Modify plugin arguments for LDS loader plugin to add a drop-down box for data * alias * * Revision 1.22  2003/10/21 16:21:22  kuznets * Enabled Id resolution cache for (cached id1 reader) * * Revision 1.21  2003/10/20 18:19:51  kuznets * Changed cache ownership scheme. * Now cache is dumped into a common reusable gbench data store (CDataStore) * (it was owned by the ID1 reader before) * * Revision 1.20  2003/10/16 15:49:49  dicuccio * Properly set the plugin reply status * * Revision 1.19  2003/10/14 16:25:04  dicuccio * Moved GenBank data loader initialization into a separate function - easiter to * follow the code this way * * Revision 1.18  2003/10/09 19:56:47  kuznets * Added registry controlled alias to LDS database * * Revision 1.17  2003/10/08 18:21:26  kuznets * Reflecting changes in LDS library API * * Revision 1.16  2003/10/07 18:28:20  dicuccio * FIxed access to auto_ptr<> after release * * Revision 1.15  2003/10/07 13:40:08  dicuccio * Code clean-up.  Use auto_ptr<> to manage memory locally.  Added default cache * path if no path is found. * * Revision 1.14  2003/10/06 20:22:13  kuznets * Added support for sub directories and option to disable CRC32 for files: *  [LDS] *    SubDir *    ControlSum (alt.name CRC32) * * Revision 1.13  2003/10/06 16:31:21  kuznets * Cache purge re-enabled. * * Revision 1.12  2003/10/06 15:58:05  dicuccio * Various changes: *     - Disabled cache purge (temporarily) *     - Ensure the cache directory exists at app start-up *     - Changed default priority of local data store *     - Changed garbage collection trigger size * * Revision 1.11  2003/10/06 15:15:08  kuznets * Added cache cleaning code (cache keeps objects for 5 days (default value)) * * Revision 1.10  2003/10/06 14:33:32  kuznets * Implemented local cache for the id1 reader * * Revision 1.9  2003/08/19 14:35:20  kuznets * LDS dataloader re-included. Now as a NON DEFAULT dataloader. * (To be later activated in the LDS derived scopes) * * Revision 1.8  2003/08/19 13:44:27  kuznets * LDS dataloader excluded from the list of default loaders. * * Revision 1.7  2003/08/15 19:38:28  dicuccio * Added setting of GenBank data loader settings in .ini file * * Revision 1.6  2003/08/05 15:24:42  kuznets * Redefined default priorities for OM data loaders (GenBank 

⌨️ 快捷键说明

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