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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_CONTROLS___ROW_MODEL__HPP
2 #define GUI_WIDGETS_CONTROLS___ROW_MODEL__HPP
3 
4 /* $Id: row_model.hpp 43775 2019-08-29 18:56:30Z 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: Yury Voronov
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbistd.hpp>
36 #include <wx/variant.h>
37 
38 //#include <gui/widgets/controls/anytype.hpp>
39 //#include <gui/widgets/controls/anyref.hpp>
40 
42 
43 
45 {
46 /****** PUBLIC DEFINITION SECTION ******/
47 public:
48  virtual ~IwxRowModel() {}
49 
50  virtual int GetNumColumns() const = 0;
51 
52  virtual wxVariant GetValueAtColumn( int col ) const = 0;
53 };
55 
57 {
58 /****** PUBLIC DEFINITION SECTION ******/
59 public:
60  virtual ~IRowSorter() {}
61 
62  virtual bool operator()( const IwxRowModel& aRow, const IwxRowModel& bRow ) const = 0;
63 };
64 
66  : public CObject, public IRowSorter
67 {
68  /****** PRIVATE DATA SECTION ******/
69 private:
70 
72 
73  /****** PUBLIC DEFINITION SECTION ******/
74 public:
75 
77  : m_Sorter( aSorter )
78  {
79  }
80 
81  virtual bool operator()( const IwxRowModel& aRow, const IwxRowModel& bRow ) const
82  {
83  return (*m_Sorter)( bRow, aRow );
84  }
85 };
86 
88  : public CObject, public IRowSorter
89 {
90 /****** PRIVATE DATA SECTION ******/
91 private:
92 
95 
96 /****** PUBLIC DEFINITION SECTION ******/
97 public:
98 
100  : m_SorterOne( aSorter )
101  , m_SorterTwo( bSorter )
102  {
103  }
104 
105  virtual bool operator()( const IwxRowModel& aRow, const IwxRowModel& bRow ) const
106  {
107  bool rv =(*m_SorterOne)( aRow, bRow );
108  if( rv ){
109  return rv;
110  }
111 
112  rv = (*m_SorterOne)( bRow, aRow );
113  if( rv ){
114  return !rv;
115  }
116 
117  return (*m_SorterTwo)( aRow, bRow );
118  }
119 };
120 
122 {
123 /****** PUBLIC DEFINITION SECTION ******/
124 public:
125  virtual ~IwxVariantSorter() {}
126 
127  virtual bool operator()( const wxVariant& aAny, const wxVariant& bAny ) const = 0;
128 };
129 
130 
132  : public CObject, public IRowSorter
133 {
135  int m_Column;
136 
137 /****** PUBLIC DEFINITION SECTION ******/
138 public:
139 
140  CSorterByColumn( IwxVariantSorter* aSorter, int aColumn )
141  : m_Sorter( aSorter )
142  , m_Column( aColumn )
143  {
144  }
145 
146  void SetColumn( int aColumn ){ m_Column = aColumn; }
147 
148  virtual bool operator()(const IwxRowModel& aRow, const IwxRowModel& bRow) const
149  {
150  return (*m_Sorter)(aRow.GetValueAtColumn(m_Column), bRow.GetValueAtColumn(m_Column));
151  }
152 };
153 
155  : public CObject, public IRowSorter
156 {
157  vector<CSorterByColumn*> m_ColSorters;
158 
159  /****** PUBLIC DEFINITION SECTION ******/
160 public:
161 
162  CSorterByMultiCols( vector<CSorterByColumn*> aSorters )
163  : m_ColSorters( aSorters )
164  {
165  }
166 
167  virtual bool operator()( const IwxRowModel& aRow, const IwxRowModel& bRow ) const
168  {
169  ITERATE( vector<CSorterByColumn*>, sort_itr, m_ColSorters ){
170  CSorterByColumn* sorter = *sort_itr;
171 
172  int cmp = (*sorter)( aRow, bRow );
173 
174  if( cmp != 0 ){
175  return cmp;
176  }
177  }
178 
179  return 0;
180  }
181 };
182 
184 {
185 /****** PUBLIC DEFINITION SECTION ******/
186 public:
187  virtual ~IRowFilter() {}
188 
189  virtual bool operator()( const IwxRowModel& aRow ) const = 0;
190 };
191 
192 
194 
195 #endif // GUI_WIDGETS_CONTROLS___ROW_MODEL__HPP
CObject –.
Definition: ncbiobj.hpp:180
virtual bool operator()(const IwxRowModel &aRow, const IwxRowModel &bRow) const
Definition: row_model.hpp:81
CReverseSorter(CIRef< IRowSorter > aSorter)
Definition: row_model.hpp:76
CIRef< IRowSorter > m_Sorter
Definition: row_model.hpp:71
CSorterByColumn(IwxVariantSorter *aSorter, int aColumn)
Definition: row_model.hpp:140
IwxVariantSorter * m_Sorter
Definition: row_model.hpp:134
void SetColumn(int aColumn)
Definition: row_model.hpp:146
virtual bool operator()(const IwxRowModel &aRow, const IwxRowModel &bRow) const
Definition: row_model.hpp:148
CSorterByMultiCols(vector< CSorterByColumn * > aSorters)
Definition: row_model.hpp:162
virtual bool operator()(const IwxRowModel &aRow, const IwxRowModel &bRow) const
Definition: row_model.hpp:167
vector< CSorterByColumn * > m_ColSorters
Definition: row_model.hpp:157
CIRef< IRowSorter > m_SorterOne
Definition: row_model.hpp:93
CIRef< IRowSorter > m_SorterTwo
Definition: row_model.hpp:94
virtual bool operator()(const IwxRowModel &aRow, const IwxRowModel &bRow) const
Definition: row_model.hpp:105
CTandemSorter(CIRef< IRowSorter > aSorter, CIRef< IRowSorter > bSorter)
Definition: row_model.hpp:99
virtual bool operator()(const IwxRowModel &aRow) const =0
virtual ~IRowFilter()
Definition: row_model.hpp:187
virtual bool operator()(const IwxRowModel &aRow, const IwxRowModel &bRow) const =0
virtual ~IRowSorter()
Definition: row_model.hpp:60
virtual ~IwxRowModel()
Definition: row_model.hpp:48
virtual int GetNumColumns() const =0
virtual wxVariant GetValueAtColumn(int col) const =0
virtual bool operator()(const wxVariant &aAny, const wxVariant &bAny) const =0
virtual ~IwxVariantSorter()
Definition: row_model.hpp:125
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#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_WX_EXPORT
Definition: gui_export.h:543
IwxRowModel IRowModel
Definition: row_model.hpp:54
Modified on Mon Feb 26 04:00:03 2024 by modify_doxy.py rev. 669887