NCBI C++ ToolKit
suc_data.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_EDIT___SUC_DATA__HPP
2 #define GUI_WIDGETS_EDIT___SUC_DATA__HPP
3 
4 /* $Id: suc_data.hpp 41159 2018-06-04 18:32:28Z katargir $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Colleen Bollin
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbistd.hpp>
36 #include <gui/gui_export.h>
37 
39 
40 #include <unordered_map>
41 #include <wx/string.h>
42 
44 
46 {
47 public:
48  CSUCLine (const string& line, const string& accession, const CObject* obj);
49  ~CSUCLine () {};
50 
51  void Add(const string& accession, const CObject* obj);
52  void Print() { cerr << m_Count << "\t" << m_Line << endl; };
53  int Compare(const string& line) { return NStr::Compare(m_Line, line); };
54  size_t GetCount() const { return m_Count; }
55  const string& GetLine() const { return m_Line; }
56 
57  typedef pair<string, CConstRef<CObject> > TRelatedObject;
58  size_t GetRelatedObjectCount() const { return m_RelatedObjects.size(); };
59  CConstRef<CObject> GetRelatedObject(size_t row) const { return m_RelatedObjects[row].second; };
60  const string& GetRelatedObjectAccession(size_t row) const { return m_RelatedObjects[row].first; };
61  const string& GetAccession() {return m_RelatedObjects.empty() ? kEmptyStr : m_RelatedObjects.front().first;}
62 protected:
63  string m_Line;
64  size_t m_Count;
65  vector<TRelatedObject> m_RelatedObjects;
66 };
67 
68 
70 {
71 public:
72  CSUCBlock(objects::CFlatFileConfig::FGenbankBlocks which_block) : m_Block(which_block), m_pos(-1), m_Expanded(false) {}
73  ~CSUCBlock () {}
74 
75  objects::CFlatFileConfig::FGenbankBlocks GetBlockType() const { return m_Block; };
76  void AddBlock(const string& block_text, const string& accession, const CObject* obj);
77  void AddLine(const string& line, const string& accession, const CObject* obj, bool can_split);
78  size_t CountLines() const { return m_Lines.size(); }
79  void Print();
80 
81  CConstRef<CSUCLine> GetLine(size_t pos) const;
82 
83  static const char* GetBlockLabel(objects::CFlatFileConfig::FGenbankBlocks block_type);
84  void SetExpanded(bool val) { m_Expanded = val; }
85  bool GetExpanded() const { return m_Expanded; }
86  void GetText(wxString& text) const;
87 
88  const map<CTempString, CRef<CSUCLine> >& GetLines(void) {return m_Lines;}
89  bool HasSecondLevel(void);
91  size_t CountChar(const string &str, const char c);
92 protected:
93  objects::CFlatFileConfig::FGenbankBlocks m_Block;
94 
97  mutable map<CTempString, CRef<CSUCLine> >::const_iterator m_pos_it;
98  mutable int m_pos;
99  bool m_Expanded;
100  string m_label;
101 };
102 
104 {
105 public:
106  CSUCResults ();
107  ~CSUCResults () {} ;
108 
109  void AddText(string & block_text, objects::CFlatFileConfig::FGenbankBlocks which_block, const string& accession, CConstRef<CObject> obj);
110  size_t CountLines() const;
111  CConstRef<CSUCLine> GetLine(size_t pos) const;
112  objects::CFlatFileConfig::FGenbankBlocks GetBlockType(size_t pos) const;
113  void ExpandBlock(bool val, objects::CFlatFileConfig::FGenbankBlocks which_block);
114  void ExpandAll(bool val);
115  bool GetExpanded(objects::CFlatFileConfig::FGenbankBlocks which_block) const;
116  void GetText(wxString& text);
117 
118  const unordered_map<unsigned int, CRef< CSUCBlock > >& GetBlocks(void) {return m_Blocks;}
119  const vector<objects::CFlatFileConfig::FGenbankBlocks>& GetOrder(void) {return m_order;}
120 protected:
121  unordered_map<unsigned int, CRef< CSUCBlock > > m_Blocks;
122  vector<objects::CFlatFileConfig::FGenbankBlocks> m_order;
123 
124  bool x_GetBlockPos(size_t pos, objects::CFlatFileConfig::FGenbankBlocks& block_type, size_t& block_pos) const;
125 };
126 
128 
129 #endif // GUI_WIDGETS_EDIT___SUC_DATA__HPP
CObject –.
Definition: ncbiobj.hpp:180
CSUCBlock(objects::CFlatFileConfig::FGenbankBlocks which_block)
Definition: suc_data.hpp:72
objects::CFlatFileConfig::FGenbankBlocks GetBlockType() const
Definition: suc_data.hpp:75
string m_label
Definition: suc_data.hpp:100
size_t CountChar(const string &str, const char c)
void SetExpanded(bool val)
Definition: suc_data.hpp:84
map< string, map< CTempString, pair< bool, CRef< CSUCLine > > > > m_SecondLevel
Definition: suc_data.hpp:96
size_t CountLines() const
Definition: suc_data.hpp:78
const map< CTempString, CRef< CSUCLine > > & GetLines(void)
Definition: suc_data.hpp:88
int m_pos
Definition: suc_data.hpp:98
bool GetExpanded() const
Definition: suc_data.hpp:85
~CSUCBlock()
Definition: suc_data.hpp:73
const map< string, map< CTempString, pair< bool, CRef< CSUCLine > > > > & GetSecondLevel(void)
Definition: suc_data.hpp:90
map< CTempString, CRef< CSUCLine > >::const_iterator m_pos_it
Definition: suc_data.hpp:97
map< CTempString, CRef< CSUCLine > > m_Lines
Definition: suc_data.hpp:95
objects::CFlatFileConfig::FGenbankBlocks m_Block
Definition: suc_data.hpp:93
bool m_Expanded
Definition: suc_data.hpp:99
string m_Line
Definition: suc_data.hpp:63
const string & GetLine() const
Definition: suc_data.hpp:55
pair< string, CConstRef< CObject > > TRelatedObject
Definition: suc_data.hpp:57
size_t GetRelatedObjectCount() const
Definition: suc_data.hpp:58
~CSUCLine()
Definition: suc_data.hpp:49
const string & GetAccession()
Definition: suc_data.hpp:61
const string & GetRelatedObjectAccession(size_t row) const
Definition: suc_data.hpp:60
CConstRef< CObject > GetRelatedObject(size_t row) const
Definition: suc_data.hpp:59
void Print()
Definition: suc_data.hpp:52
int Compare(const string &line)
Definition: suc_data.hpp:53
size_t GetCount() const
Definition: suc_data.hpp:54
size_t m_Count
Definition: suc_data.hpp:64
vector< TRelatedObject > m_RelatedObjects
Definition: suc_data.hpp:65
unordered_map< unsigned int, CRef< CSUCBlock > > m_Blocks
Definition: suc_data.hpp:121
const unordered_map< unsigned int, CRef< CSUCBlock > > & GetBlocks(void)
Definition: suc_data.hpp:118
vector< objects::CFlatFileConfig::FGenbankBlocks > m_order
Definition: suc_data.hpp:122
const vector< objects::CFlatFileConfig::FGenbankBlocks > & GetOrder(void)
Definition: suc_data.hpp:119
Definition: map.hpp:338
void Print(const CCompactSAMApplication::AlignInfo &ai)
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define false
Definition: bool.h:36
static const char * str(char *buf, int n)
Definition: stats.c:84
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define kEmptyStr
Definition: ncbistr.hpp:123
static int Compare(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)
Compare of a substring with another string.
Definition: ncbistr.hpp:5297
#define NCBI_GUIWIDGETS_EDIT_EXPORT
Definition: gui_export.h:526
Defines to provide correct exporting from DLLs in Windows.
static void text(MDB_val *v)
Definition: mdb_dump.c:62
#define row(bind, expected)
Definition: string_bind.c:73
static void ExpandAll(wxTreeCtrl &tree, const wxTreeItemId &id, bool shouldExpand, int toLevel)
Modified on Wed Jun 19 17:03:36 2024 by modify_doxy.py rev. 669887