Back to index

salome-kernel  6.5.0
Public Member Functions | Private Attributes
TableSorter< TTable > Class Template Reference

#include <SALOMEDSImpl_AttributeTable.hxx>

List of all members.

Public Member Functions

 TableSorter (TTable *table, SALOMEDSImpl_AttributeTable::SortOrder so, SALOMEDSImpl_AttributeTable::SortPolicy sp, int index, bool sortRow)
bool operator() (int idx1, int idx2)

Private Attributes

TTable * myTable
SALOMEDSImpl_AttributeTable::SortOrder mySortOrder
SALOMEDSImpl_AttributeTable::SortPolicy mySortPolicy
int myIndex
bool myIsRow

Detailed Description

template<class TTable>
class TableSorter< TTable >

Definition at line 47 of file SALOMEDSImpl_AttributeTable.hxx.


Constructor & Destructor Documentation

template<class TTable>
TableSorter< TTable >::TableSorter ( TTable *  table,
SALOMEDSImpl_AttributeTable::SortOrder  so,
SALOMEDSImpl_AttributeTable::SortPolicy  sp,
int  index,
bool  sortRow 
) [inline]

Definition at line 56 of file SALOMEDSImpl_AttributeTable.hxx.

    : myTable( table ), mySortOrder( so ), mySortPolicy( sp ), 
      myIndex( index ), myIsRow( sortRow ) {}

Member Function Documentation

template<class TTable>
bool TableSorter< TTable >::operator() ( int  idx1,
int  idx2 
) [inline]

Definition at line 64 of file SALOMEDSImpl_AttributeTable.hxx.

  {
    bool hasValue1 = myIsRow ? myTable->HasValue( myIndex, idx1 ) : myTable->HasValue( idx1, myIndex );
    bool hasValue2 = myIsRow ? myTable->HasValue( myIndex, idx2 ) : myTable->HasValue( idx2, myIndex );
    if ( !hasValue1 && !hasValue2 ) {
      return false;
    }
    else if ( !hasValue1 || !hasValue2 ) {
      switch ( mySortPolicy ) {
      case SALOMEDSImpl_AttributeTable::EmptyLowest:
       return (!hasValue1) ? 
         (mySortOrder == SALOMEDSImpl_AttributeTable::AscendingOrder) : 
         (mySortOrder == SALOMEDSImpl_AttributeTable::DescendingOrder);
      case SALOMEDSImpl_AttributeTable::EmptyHighest:
       return (!hasValue1) ? 
         (mySortOrder != SALOMEDSImpl_AttributeTable::AscendingOrder) : 
         (mySortOrder != SALOMEDSImpl_AttributeTable::DescendingOrder);
      case SALOMEDSImpl_AttributeTable::EmptyFirst:
       return (!hasValue1);
      case SALOMEDSImpl_AttributeTable::EmptyLast:
       return hasValue1;
      case SALOMEDSImpl_AttributeTable::EmptyIgnore:
      default:
       // should not go here
       return false;
      }
    }
    else {
      if ( myIsRow ) {
       return mySortOrder == SALOMEDSImpl_AttributeTable::AscendingOrder ? 
         myTable->GetValue( myIndex, idx1 ) < myTable->GetValue( myIndex, idx2 ) :
         myTable->GetValue( myIndex, idx2 ) < myTable->GetValue( myIndex, idx1 );
      }
      else {
       return mySortOrder == SALOMEDSImpl_AttributeTable::AscendingOrder ? 
         myTable->GetValue( idx1, myIndex ) < myTable->GetValue( idx2, myIndex ) :
         myTable->GetValue( idx2, myIndex ) < myTable->GetValue( idx1, myIndex );
      }
    }
  }

Member Data Documentation

template<class TTable>
int TableSorter< TTable >::myIndex [private]

Definition at line 52 of file SALOMEDSImpl_AttributeTable.hxx.

template<class TTable>
bool TableSorter< TTable >::myIsRow [private]

Definition at line 53 of file SALOMEDSImpl_AttributeTable.hxx.

template<class TTable>
SALOMEDSImpl_AttributeTable::SortOrder TableSorter< TTable >::mySortOrder [private]

Definition at line 50 of file SALOMEDSImpl_AttributeTable.hxx.

template<class TTable>
SALOMEDSImpl_AttributeTable::SortPolicy TableSorter< TTable >::mySortPolicy [private]

Definition at line 51 of file SALOMEDSImpl_AttributeTable.hxx.

template<class TTable>
TTable* TableSorter< TTable >::myTable [private]

Definition at line 49 of file SALOMEDSImpl_AttributeTable.hxx.


The documentation for this class was generated from the following file: