/*  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_RESTRICT_H
#define H_RELATION_RESTRICT_H

#include <libhrel/relation.h>
#include <libhrel/hash_index.h>

G_BEGIN_DECLS

#define H_TYPE_RELATION_RESTRICT            (h_relation_restrict_get_type ())
#define H_RELATION_RESTRICT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), H_TYPE_RELATION_RESTRICT, HRelationRestrict))
#define H_RELATION_RESTRICT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST    ((klass), H_TYPE_RELATION_RESTRICT, HRelationRestrictClass))
#define H_IS_RELATION_RESTRICT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), H_TYPE_RELATION_RESTRICT))
#define H_IS_RELATION_RESTRICT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE    ((klass), H_TYPE_RELATION_RESTRICT))
#define H_RELATION_RESTRICT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS  ((obj), H_TYPE_RELATION_RESTRICT, HRelationRestrictClass))

typedef struct _HRelationRestrict      HRelationRestrict;
typedef struct _HRelationRestrictClass HRelationRestrictClass;

typedef gboolean (*HTuplePredFunc) (HTuple *tuple, gpointer user_data);

struct _HRelationRestrict
{
  HRelation       relation;

  HRelation      *to_restrict;
  HTuplePredFunc  func;
  gpointer        func_data;
  HHashIndex     *index;
};

struct _HRelationRestrictClass
{
  HRelationClass relation_class;
};

GType      h_relation_restrict_get_type (void);
HRelation *h_relation_restrict          (HRelation      *relation,
                                         HTuplePredFunc  predicate_func,
                                         gpointer        user_data);
HRelation *h_relation_restrict_attrs    (HRelation      *relation,
                                         ...);
HRelation *h_relation_restrict_attrs_l  (HRelation      *relation,
                                         GSList         *list);

G_END_DECLS

#endif /* #ifndef H_RELATION_RESTRICT_H */
