Version: 9.16.0
SALOMEDSImpl_AttributeTable.hxx
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, OPEN CASCADE
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20// File : SALOMEDSImpl_AttributeTable.hxx
21// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
22//
23#ifndef _SALOMEDSImpl_AttributeTable_HeaderFile
24#define _SALOMEDSImpl_AttributeTable_HeaderFile
25
27
29{
30public:
32 typedef enum {
35 } SortOrder;
36
38 typedef enum {
44 } SortPolicy;
45};
46
47template <class TTable> class TableSorter
48{
49 TTable* myTable;
53 bool myIsRow;
54
55public:
56 TableSorter( TTable* table,
59 int index,
60 bool sortRow)
61 : myTable( table ), mySortOrder( so ), mySortPolicy( sp ),
62 myIndex( index ), myIsRow( sortRow ) {}
63
64 bool operator() ( int idx1, int idx2 )
65 {
66 bool hasValue1 = myIsRow ? myTable->HasValue( myIndex, idx1 ) : myTable->HasValue( idx1, myIndex );
67 bool hasValue2 = myIsRow ? myTable->HasValue( myIndex, idx2 ) : myTable->HasValue( idx2, myIndex );
68 if ( !hasValue1 && !hasValue2 ) {
69 return false;
70 }
71 else if ( !hasValue1 || !hasValue2 ) {
72 switch ( mySortPolicy ) {
74 return (!hasValue1) ?
78 return (!hasValue1) ?
82 return (!hasValue1);
84 return hasValue1;
86 default:
87 // should not go here
88 return false;
89 }
90 }
91 else {
92 if ( myIsRow ) {
94 myTable->GetValue( myIndex, idx1 ) < myTable->GetValue( myIndex, idx2 ) :
95 myTable->GetValue( myIndex, idx2 ) < myTable->GetValue( myIndex, idx1 );
96 }
97 else {
99 myTable->GetValue( idx1, myIndex ) < myTable->GetValue( idx2, myIndex ) :
100 myTable->GetValue( idx2, myIndex ) < myTable->GetValue( idx1, myIndex );
101 }
102 }
103 }
104};
105
106#endif // _SALOMEDSImpl_AttributeTable_HeaderFile
#define SALOMEDSIMPL_EXPORT
Definition: SALOMEDSImpl_Defines.hxx:34
Definition: SALOMEDSImpl_AttributeTable.hxx:29
SortPolicy
Sort policy (specifies how empty cells are taken into account when sorting)
Definition: SALOMEDSImpl_AttributeTable.hxx:38
@ EmptyHighest
Empty cells are considered as highest values.
Definition: SALOMEDSImpl_AttributeTable.hxx:40
@ EmptyLowest
Empty cells are considered as lowest values.
Definition: SALOMEDSImpl_AttributeTable.hxx:39
@ EmptyLast
Empty cells are always last.
Definition: SALOMEDSImpl_AttributeTable.hxx:42
@ EmptyFirst
Empty cells are always first.
Definition: SALOMEDSImpl_AttributeTable.hxx:41
@ EmptyIgnore
Empty cells are ignored (stay at initial positions)
Definition: SALOMEDSImpl_AttributeTable.hxx:43
SortOrder
Sort order.
Definition: SALOMEDSImpl_AttributeTable.hxx:32
@ AscendingOrder
The items are sorted ascending.
Definition: SALOMEDSImpl_AttributeTable.hxx:33
@ DescendingOrder
The items are sorted descending.
Definition: SALOMEDSImpl_AttributeTable.hxx:34
Definition: SALOMEDSImpl_AttributeTable.hxx:48
TTable * myTable
Definition: SALOMEDSImpl_AttributeTable.hxx:49
SALOMEDSImpl_AttributeTable::SortPolicy mySortPolicy
Definition: SALOMEDSImpl_AttributeTable.hxx:51
int myIndex
Definition: SALOMEDSImpl_AttributeTable.hxx:52
bool operator()(int idx1, int idx2)
Definition: SALOMEDSImpl_AttributeTable.hxx:64
bool myIsRow
Definition: SALOMEDSImpl_AttributeTable.hxx:53
SALOMEDSImpl_AttributeTable::SortOrder mySortOrder
Definition: SALOMEDSImpl_AttributeTable.hxx:50
TableSorter(TTable *table, SALOMEDSImpl_AttributeTable::SortOrder so, SALOMEDSImpl_AttributeTable::SortPolicy sp, int index, bool sortRow)
Definition: SALOMEDSImpl_AttributeTable.hxx:56
index
Definition: python_test_driver.py:105