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

Go to the SVN repository for this file.

1 #ifndef GUI_CORE___TABLE_IMPORT_COLUMN__HPP
2 #define GUI_CORE___TABLE_IMPORT_COLUMN__HPP
3 
4 /* $Id: table_import_column.hpp 45881 2021-01-05 03:10:02Z rudnev $
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: Bob Falk
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbistl.hpp>
36 #include <corelib/ncbiobj.hpp>
37 
39 
41 
42 #include <gui/gui_export.h>
43 
44 
46 
48 
49 ///////////////////////////////////////////////////////////////////////////////
50 /// CTableImportColumn -
51 ///
52 /// This class holds meta-data for the columns in the tabular data. The size
53 /// and number of columns is automatically updated when the delimiter info
54 /// is changed.
55 ///
57 public:
58  enum eColumnType { eSeqIdColumn=0, eNumberColumn, eRealNumberColumn,
59  eTextColumn, eSkippedColumn, eTypeUndefined };
60 
61  enum eDataType {
62  eLocationID = 0,
69  eGenotype, // Encodes a variation, e.g. "CT" or "G" (x,y or MT on human)
76  eUnspecifiedReal, // Real Number
82  eLastType
83  };
84 
85  static const char* m_TypeNameList[];
86  static const char* m_ShortTypeNameList[];
87 
88 public:
90  : m_ColumnWidth(8)
91  , m_ColumnType(eTextColumn)
92  , m_OneBased(true)
93  , m_Match(false)
94  , m_DataType(eUndefined)
95  , m_IsCurrent(false) {}
96 
97  void SetWidth(int w) { m_ColumnWidth = w; }
98  int GetWidth() const { return m_ColumnWidth; }
99 
100  void SetType(eColumnType t) { m_ColumnType = t; }
101  eColumnType GetType() const { return m_ColumnType; }
102 
103  void SetOneBased(bool b) { m_OneBased = b; }
104  bool GetOneBased() const { return m_OneBased; }
105 
106  /// For attribute table import we need to specify a column
107  /// as the column to use in matching the table against to entry
108  void SetMatchColumn(bool b) { m_Match = b; }
109  bool GetMatchColumn() const { return m_Match; }
110 
111  /// Get set bio-type info for the column
112  void SetDataType(eDataType t) { m_DataType = t; }
113  eDataType GetDataType() const { return m_DataType; }
114  string GetDataTypeString() const { return GetStringFromDataType(m_DataType); }
115  string GetShortDataTypeString() const { return GetShortStringFromDataType(m_DataType); }
116 
117  /// Return a string version of a data-type (e.g. "Length" for eLength)
118  static string GetStringFromDataType(eDataType t);
119  /// Return a short string of a data-type, and blank for 'undefined' types
120  static string GetShortStringFromDataType(eDataType t);
121  /// Return enum data-type from string
122  static eDataType GetDataTypeFromString(const string& s);
123  static vector<eDataType> GetMatchingDataTypes(eColumnType c);
124 
125 
126  void SetName(const string& n);
127  string GetName() const { return m_ColumnName; }
128  string GetNameEx() const { return GetSkipped() ? "" : m_ColumnName; }
129 
130  void SetAssembly(const CMapAssemblyParams& a) { m_Assembly = a; }
131  CMapAssemblyParams GetAssembly() const { return m_Assembly; }
132 
133  bool GetSkipped() const { return (m_ColumnType == eSkippedColumn); }
134 
135  void SetIsCurrent(bool b) { m_IsCurrent = b; }
136  bool GetIsCurrent() const { return m_IsCurrent; }
137 
138  void SetQualifier(const string& q) { m_Qualifier = q; }
139  string GetQualifier() const { return m_Qualifier; }
140 
141  void SetQualifierType(const string& q) { m_QualifierType = q; }
142  string GetQualifierType() const { return m_QualifierType; }
143 
144  /// Log column parameters
145  void LogColumnInfo() const;
146 
147  /// Export column info in ASN user-object format
148  void SaveAsn(CUser_field& user_field) const;
149  /// Import column info from ASN user-object format
150  void LoadAsn(CUser_field& user_field);
151 
152  /// Add/update a column property
153  void SetProperty(const string& prop_name, const string& prop_value) { m_Properties[prop_name] = prop_value; }
154  bool HasProperty(const string& prop_name) { return (m_Properties.count(prop_name) > 0); }
155  string GetProperty(const string& prop_name) { return (HasProperty(prop_name) ? m_Properties[prop_name] : ""); }
156  map<string,string>& GetPropertyValues() { return m_Properties; }
157 
158 protected:
159  /// width in chracters
161 
162  /// Column name
163  string m_ColumnName;
164 
165  /// Matching Assembly for column identifier
167 
168  /// column type
170 
171  /// If integer, is it one based or 0 based?
173 
174  /// (For attribute table loading) Is this the match column
175  bool m_Match;
176 
177  /// The semantic meaning of the column, e.g. id, start pos, stop pos, strand
179 
180  /// If true, this is the current column for editing purposes
181  /// (for views that allow you to edit column type info)
183 
184  /// For table import in sequence editor - the qualifier field name
185  string m_Qualifier;
186 
187  /// Also for sequence editor import - text version of
188  /// CFieldNamePanel::EFieldType
190 
191  /// Any properties (text only) user wants to set for the column. When
192  /// converted to seq-annot, we add these to user data as &propname=prop_value
194 };
195 
196 
198 
199 
200 #endif // GUI_CORE___TABLE_IMPORT_COLUMN__HPP
CTableImportColumn -.
CMapAssemblyParams m_Assembly
Matching Assembly for column identifier.
string GetShortDataTypeString() const
eColumnType GetType() const
bool m_OneBased
If integer, is it one based or 0 based?
map< string, string > & GetPropertyValues()
void SetDataType(eDataType t)
Get set bio-type info for the column.
string m_ColumnName
Column name.
bool HasProperty(const string &prop_name)
void SetQualifierType(const string &q)
void SetType(eColumnType t)
string GetProperty(const string &prop_name)
void SetAssembly(const CMapAssemblyParams &a)
void SetMatchColumn(bool b)
For attribute table import we need to specify a column as the column to use in matching the table aga...
eColumnType m_ColumnType
column type
string GetQualifierType() const
string m_Qualifier
For table import in sequence editor - the qualifier field name.
void SetQualifier(const string &q)
bool m_Match
(For attribute table loading) Is this the match column
string GetDataTypeString() const
eDataType GetDataType() const
int m_ColumnWidth
width in chracters
CMapAssemblyParams GetAssembly() const
string m_QualifierType
Also for sequence editor import - text version of CFieldNamePanel::EFieldType.
map< string, string > m_Properties
Any properties (text only) user wants to set for the column.
void SetProperty(const string &prop_name, const string &prop_value)
Add/update a column property.
bool m_IsCurrent
If true, this is the current column for editing purposes (for views that allow you to edit column typ...
eDataType m_DataType
The semantic meaning of the column, e.g. id, start pos, stop pos, strand.
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
#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 NCBI_GUIWIDGETS_LOADERS_EXPORT
Definition: gui_export.h:525
Defines to provide correct exporting from DLLs in Windows.
yy_size_t n
unsigned int a
Definition: ncbi_localip.c:102
EIPRangeType t
Definition: ncbi_localip.c:101
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
The NCBI C++/STL use hints.
USING_SCOPE(objects)
Modified on Fri Sep 20 14:57:02 2024 by modify_doxy.py rev. 669887