# gdcmSorter.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program: GDCM (Grassroots DICOM). A DICOM library
    00004   Module:  $URL$
    00005
    00006   Copyright (c) 2006-2009 Mathieu Malaterre
    00007   All rights reserved.
    00008   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
    00009
    00010      This software is distributed WITHOUT ANY WARRANTY; without even
    00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00012      PURPOSE.  See the above copyright notice for more information.
    00013
    00014 =========================================================================*/
    00015 #ifndef __gdcmSorter_h
    00016 #define __gdcmSorter_h
    00017
    00018 #include "gdcmDirectory.h"
    00019 #include "gdcmTag.h"
    00020
    00021 #include <vector>
    00022 #include <string>
    00023 #include <map>
    00024
    00025 namespace gdcm
    00026 {
    00027 class DataSet;
    00028
    00039 class GDCM_EXPORT Sorter
    00040 {
    00041   friend std::ostream& operator<<(std::ostream &_os, const Sorter &s);
    00042 public:
    00043   Sorter();
    00044   virtual ~Sorter();
    00045
    00047   virtual bool Sort(std::vector<std::string> const & filenames);
    00048
    00051   const std::vector<std::string> &GetFilenames() const { return Filenames; }
    00052
    00054   void Print(std::ostream &os) const;
    00055
    00057   bool AddSelect( Tag const &tag, const char *value );
    00058
    00060   typedef bool (*SortFunction)(DataSet const &, DataSet const &);
    00061   void SetSortFunction( SortFunction f );
    00062
    00063   virtual bool StableSort(std::vector<std::string> const & filenames);
    00064
    00065 protected:
    00066   std::vector<std::string> Filenames;
    00067   typedef std::map<Tag,std::string> SelectionMap;
    00068   std::map<Tag,std::string> Selection;
    00069   SortFunction SortFunc;
    00070 };
    00071 //-----------------------------------------------------------------------------
    00072 inline std::ostream& operator<<(std::ostream &os, const Sorter &s)
    00073 {
    00074   s.Print( os );
    00075   return os;
    00076 }
    00077
    00078
    00079 } // end namespace gdcm
    00080
    00081 #endif //__gdcmSorter_h