NCBI C++ ToolKit
table_data_gbproject.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: table_data_gbproject.cpp 32240 2015-01-22 21:53:03Z katargir $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Roman Katargin
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
34 #include <serial/iterator.hpp>
35 
38 
43 
46 
48 {
49 public:
51 
52  virtual void LoadData() {}
53  virtual ColumnType GetColumnType(size_t col) const;
54  virtual string GetColumnLabel(size_t col) const;
55 
56  virtual size_t GetRowsCount() const;
57  virtual size_t GetColsCount() const;
58 
59  virtual void GetStringValue(size_t row, size_t col, string& value) const;
60 
61  virtual SConstScopedObject GetRowObject(size_t row) const;
62 
64 
65 private:
66  void x_Init();
67 
68  vector<CConstRef<CProjectItem> > m_Items;
69 
72 };
73 
75 {
77  typeid(ITableData).name(),
78  CGBProject_ver2::GetTypeInfo(),
80 }
81 
83 {
84  CTableDataGBProject* table_data = new CTableDataGBProject();
85  table_data->m_Object = object.object;
86  table_data->m_Scope = object.scope;
87  table_data->x_Init();
88  return table_data;
89 }
90 
92 {
93  const CGBProject_ver2& project = dynamic_cast<const CGBProject_ver2&>(*m_Object);
94  for (CTypeConstIterator<CProjectItem> it(project.GetData()); it; ++it) {
95  m_Items.push_back(CConstRef<CProjectItem>(&*it));
96  }
97 }
98 
100 {
101  return m_Items.size();
102 }
103 
105 {
106  return 3;
107 }
108 
110 {
111  if (col == 0 || col == 1 || col == 2)
112  return kString;
113 
114  return kNone;
115 }
116 
117 string CTableDataGBProject::GetColumnLabel(size_t col) const
118 {
119  if (col == 0)
120  return "Item Name";
121  else if (col == 1)
122  return "Item Description";
123  else if (col == 2)
124  return "Folder";
125 
126  return "";
127 }
128 
129 void CTableDataGBProject::GetStringValue(size_t row, size_t col, string& value) const
130 {
131  value.resize(0);
132  if (row >= m_Items.size())
133  return;
134 
135  if (col == 0) {
136  value = m_Items[row]->GetLabel();
137  return;
138  }
139  else if (col == 1) {
140  const list< CRef<CAnnotdesc> >& descr_list = m_Items[row]->GetDescr();
141  CRef<CAnnotdesc> descr;
142  ITERATE( list< CRef<CAnnotdesc> >, descr_itr, descr_list ){
143  if( (**descr_itr).IsComment() ){
144  descr = *descr_itr;
145  }
146  }
147  value = descr.IsNull() ? "" : descr->SetComment();
148  return;
149  }
150  else if (col == 2) {
151  const CGBProject_ver2& project = dynamic_cast<const CGBProject_ver2&>(*m_Object);
152  const CProjectFolder* folder = project.GetData().FindProjectItemFolder(m_Items[row]->GetId());
153  if (folder) {
154  const CFolderInfo& info = folder->GetInfo();
155  value = info.GetTitle();
156  return;
157  }
158  }
159 }
160 
162 {
164 
165  if (row >= m_Items.size())
166  return value;
167 
168  value.object.Reset(m_Items[row]->GetObject());
169  value.scope = m_Scope;
170  return value;
171 }
172 
174 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
const CProjectFolder & GetData() const
retrieve our project's data, in the form of a project folder this may be a contrived entity,...
static void RegisterFactory(const string &interface_name, IInterfaceFactory *factory)
CObject –.
Definition: ncbiobj.hpp:180
const CProjectFolder * FindProjectItemFolder(CProjectItem::TId id) const
vector< CConstRef< CProjectItem > > m_Items
virtual size_t GetRowsCount() const
virtual SConstScopedObject GetRowObject(size_t row) const
virtual size_t GetColsCount() const
CConstRef< CObject > m_Object
virtual string GetColumnLabel(size_t col) const
static CTableDataGBProject * CreateObject(SConstScopedObject &object, ICreateParams *params)
virtual void GetStringValue(size_t row, size_t col, string &value) const
virtual ColumnType GetColumnType(size_t col) const
Template class for iteration on objects of class C (non-medifiable version)
Definition: iterator.hpp:767
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
const CSeq_id & GetId(const CSeq_loc &loc, CScope *scope)
If all CSeq_ids embedded in CSeq_loc refer to the same CBioseq, returns the first CSeq_id found,...
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
Definition: ncbiobj.hpp:735
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
const TInfo & GetInfo(void) const
Get the Info member data.
TComment & SetComment(void)
Select the variant.
Definition: Annotdesc_.hpp:548
static MDB_envinfo info
Definition: mdb_load.c:37
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
#define row(bind, expected)
Definition: string_bind.c:73
USING_SCOPE(objects)
void initCTableGBProject()
Modified on Mon May 20 05:00:29 2024 by modify_doxy.py rev. 669887