📄 pluginconfigvalues.hpp
字号:
/* * =========================================================================== * PRODUCTION $Log: PluginConfigValues.hpp,v $ * PRODUCTION Revision 1000.2 2004/06/01 19:46:12 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.4 * PRODUCTION * =========================================================================== *//* $Id: PluginConfigValues.hpp,v 1000.2 2004/06/01 19:46:12 gouriano Exp $ * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * =========================================================================== * * Author: Robert G. Smith * * File Description: * CPluginConfigValues represents one named set of key/value pairs * used to configure a plugin. It is identified by its 'item' and 'style' strings. * It is intended that 'item' would refer to the type of the data and 'style' * to particular saved data values. i.e. all those CPluginConfigValues that have * the same 'item' would have the same 'key's and structure in their 'keyvals'. * * * Remark: * This code was originally generated by application DATATOOL * using specifications from the data definition file * 'plugin.asn'. */#ifndef GUI_PLUGIN_PLUGINCONFIGVALUES_HPP#define GUI_PLUGIN_PLUGINCONFIGVALUES_HPP// generated includes#include <gui/config/PluginConfigValues_.hpp>#include <gui/config/KeyValue.hpp>#include <gui/config/PluginConfigID.hpp>// generated classesBEGIN_NCBI_SCOPEBEGIN_objects_SCOPE // namespace ncbi::objects::class NCBI_GUICONFIG_EXPORT CPluginConfigValues : public CPluginConfigValues_Base{ typedef CPluginConfigValues_Base Tparent;public: // constructor CPluginConfigValues(void); CPluginConfigValues(const string& item, const string& style); // destructor ~CPluginConfigValues(void); // merge the other_pcv with this one, over writing values in this one // when the key is the same. CPluginConfigValues& Merge(const CPluginConfigValues& other_pcv); // accessors // Check these 'Can' methods before calling 'Get' methods bool CanGetByKey() const; bool CanGetByType() const; // search multiple levels with keys like: "label1|label2|label3" const CKeyValue& GetKeyvalueByKey(const string & key, const string& delim = "|") const; const string& GetStringByKey(const string & key, const string& delim = "|") const; // Normally use this. /// Return a list of all the keys in this PCC. /// use delim to separate parts of a hierachical key void GetAllKeys(CKeyValue::TKeyList& key_list, const string& delim = "|") const; // only single level keys (type) since recursion on multiple levels // must be done by CPluginConfigCache. const CPluginConfigID& GetPCIdByType(const string& type) const; const string& GetStyleByType(const string& type) const; // mutators // We always can add/set data. // But call these if you want to make sure the other kind of data // wasn't added before because you will lose it otherwise. bool CanAddKeys() const; bool CanAddPCId() const; // search and add multiple levels with keys like: "label1|label2|label3" CKeyValue& AddKey(const string& key, const string& delim = "|"); CKeyValue& AddKeyString(const string& key, const string& value, const string& delim = "|"); // only single level keys (type) since recursion on multiple levels // must be done by CPluginConfigCache. CPluginConfigID& AddPCId(const string& type, const string& style); CPluginConfigID& AddPCId(const CPluginConfigID& pcid); // delete key value pairs. bool DelKeyval(const string & key, const string& delim = "|"); // comparisons bool TypeMatches(string item) const; bool StyleMatches(string style) const;private: // Prohibit copy constructor and assignment operator CPluginConfigValues(const CPluginConfigValues& value); CPluginConfigValues& operator=(const CPluginConfigValues& value);};/////////////////// CPluginConfigValues inline methods// constructorinlineCPluginConfigValues::CPluginConfigValues(void){}inlineCPluginConfigValues::CPluginConfigValues(const string& item, const string& style){ CRef<TId> pId(new TId(item, style)); // or would auto_ptr be better? SetId(*pId);}// comparisonsinlinebool CPluginConfigValues::TypeMatches(string type) const{ if (CanGetId()) { return (GetId().TypeMatches(type)); } return false;}inlinebool CPluginConfigValues::StyleMatches(string style) const{ if (CanGetId()) { return (GetId().StyleMatches(style)); } return false;}// accessorsinlinebool CPluginConfigValues::CanGetByKey() const{ return CanGetData() && GetData().IsKeyvals();}inlinebool CPluginConfigValues::CanGetByType() const{ return CanGetData() && GetData().IsInclude();}inlineconst string& CPluginConfigValues::GetStringByKey(const string & key, const string& delim) const{ return GetKeyvalueByKey(key, delim).GetVal().GetStr();}inlineconst string& CPluginConfigValues::GetStyleByType(const string& type) const{ return GetPCIdByType(type).GetStyle();}// mutator (Set) methods inlinebool CPluginConfigValues::CanAddKeys() const{ return !IsSetData() || (CanGetData() && ! GetData().IsInclude());}inlinebool CPluginConfigValues::CanAddPCId() const{ return !IsSetData() || (CanGetData() && ! GetData().IsKeyvals());}inlineCKeyValue& CPluginConfigValues::AddKeyString(const string& key, const string& val, const string& delim){ CKeyValue& kv = AddKey(key, delim); kv.SetVal().SetStr(val); return kv;}inlineCPluginConfigID& CPluginConfigValues::AddPCId(const CPluginConfigID& pcid){ _ASSERT(pcid.CanGetType() && pcid.CanGetStyle()); return AddPCId(pcid.GetType(), pcid.GetStyle());}/////////////////// end of CPluginConfigValues inline methodsEND_objects_SCOPE // namespace ncbi::objects::END_NCBI_SCOPE/** ===========================================================================** $Log: PluginConfigValues.hpp,v $* Revision 1000.2 2004/06/01 19:46:12 gouriano* PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.4** Revision 1.4 2004/04/20 14:06:19 rsmith* add GetAllKeys method.** Revision 1.3 2003/11/21 12:48:32 rsmith* Add ability to delete entries by key.** Revision 1.2 2003/10/10 19:35:31 dicuccio* Added export specifiers** Revision 1.1 2003/10/10 17:41:23 rsmith* moved from gui/plugin to gui/config** Revision 1.4 2003/08/19 18:12:05 rsmith* can always add anything. CanAddKeys() and CanAddPCId() only advisory.** Revision 1.3 2003/08/13 20:24:20 rsmith* Merge method and get rid of FindIf** Revision 1.2 2003/08/05 19:01:34 rsmith* change members used in mem_fun to satisfy certain compilers.** Revision 1.1 2003/08/05 17:37:38 rsmith* Classes to allow saving of plugins configuration values as ASN.1.*** ===========================================================================*/#endif // GUI_PLUGIN_PLUGINCONFIGVALUES_HPP/* Original file checksum: lines: 93, chars: 2532, CRC32: 1662a326 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -