/*  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_BASE_H
#define H_RELATION_BASE_H

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

G_BEGIN_DECLS

#define H_TYPE_RELATION_BASE            (h_relation_base_get_type ())
#define H_RELATION_BASE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), H_TYPE_RELATION_BASE, HRelationBase))
#define H_RELATION_BASE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST    ((klass), H_TYPE_RELATION_BASE, HRelationBaseClass))
#define H_IS_RELATION_BASE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), H_TYPE_RELATION_BASE))
#define H_IS_RELATION_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE    ((klass), H_TYPE_RELATION_BASE))
#define H_RELATION_BASE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS  ((obj), H_TYPE_RELATION_BASE, HRelationBaseClass))

typedef struct _HRelationBase      HRelationBase;
typedef struct _HRelationBaseClass HRelationBaseClass;

struct _HRelationBase
{
  HRelation   relation;
  HAttrMap   *attrs;
  HHashIndex *tuples;
  GSList     *primary_key;
};

struct _HRelationBaseClass
{
  HRelationClass relation_class;
};

GType      h_relation_base_get_type        (void);
HRelation *h_relation_base_new             (const gchar   *name,
                                            const gchar   *description,
                                            ...);
gboolean   h_relation_base_insert_tuple    (HRelationBase *relation,
                                            HTuple        *tuple);
gboolean   h_relation_base_insert_tuplev   (HRelationBase *relation,
                                            ...);
gboolean   h_relation_base_delete_tuple    (HRelationBase *relation,
                                            HTuple        *key);
gboolean   h_relation_base_delete_tuplev   (HRelationBase *relation,
                                            ...);
HTuple    *h_relation_base_get_tuple       (HRelationBase *relation,
                                            HTuple        *key);
HTuple    *h_relation_base_get_tuplev      (HRelationBase *relation,
                                            ...);
GSList    *h_relation_base_get_primary_key (HRelationBase *relation);

G_END_DECLS

#endif /* #ifndef H_RELATION_BASE_H */
