/*  libhrel - Holyrel library

    Copyright (C) 2005 Chong Kai Xiong <descender@phreaker.net>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA  02111-1307  USA.
*/

#ifndef H_RELATION_SORT_H
#define H_RELATION_SORT_H

#include <libhrel/relation.h>

G_BEGIN_DECLS

#define H_TYPE_RELATION_SORT            (h_relation_sort_get_type ())
#define H_RELATION_SORT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), H_TYPE_RELATION_SORT, HRelationSort))
#define H_RELATION_SORT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST    ((klass), H_TYPE_RELATION_SORT, HRelationSortClass))
#define H_IS_RELATION_SORT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), H_TYPE_RELATION_SORT))
#define H_IS_RELATION_SORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE    ((klass), H_TYPE_RELATION_SORT))
#define H_RELATION_SORT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS  ((obj), H_TYPE_RELATION_SORT, HRelationSortClass))

typedef struct _HRelationSort      HRelationSort;
typedef struct _HRelationSortClass HRelationSortClass;

struct _HRelationSort
{
  HRelation         relation;

  HRelation        *to_sort;
  GCompareDataFunc  compare_func;
  gpointer          compare_func_data;
  GTree            *index;
};

struct _HRelationSortClass
{
  HRelationClass relation_class;
};

GType      h_relation_sort_get_type   (void);
HRelation *h_relation_sort            (HRelation        *relation,
                                       GCompareDataFunc  compare_func,
                                       gpointer          user_data);
HRelation *h_relation_sort_by_attrs   (HRelation        *relation,
                                       ...);
HRelation *h_relation_sort_by_attrs_l (HRelation        *relation,
                                       GSList           *list);

G_END_DECLS

#endif /* #ifndef H_RELATION_SORT_H */
