// -*- C++ -*- //

/* datamodelarray.h
 *
 * Copyright 2003 libgdamm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <glibmm/object.h>
#include <libgdamm/datamodel.h>
#include <libgdamm/row.h>

_DEFS(libgdamm,libgda)
_PINCLUDE(glibmm/private/object_p.h)

namespace Gnome
{

namespace Gda
{

/** An implementation of DataModel based on an array.
 *
 * The Gda::DataModelArray object is a data model which internally uses a GArray to index all its rows (represented as Gda::Row objects).
 * In this data model, all the data is stored in memory, which can be a memory limitation if the number of rows is huge.
 * This type of data model is easy to use to store some temporary data, and has a random access mode (any value can be accessed at 
 * any time without the need for an iterator). 
 *
 * @ingroup DataModels
 */
class DataModelArray
 : public Glib::Object,
   public DataModel
{
  _CLASS_GOBJECT(DataModelArray, GdaDataModelArray, GDA_DATA_MODEL_ARRAY, Glib::Object, GObject)
  _IMPLEMENTS_INTERFACE(DataModel)
protected:
  explicit DataModelArray(int cols);

public:
  _WRAP_CREATE(int cols)

  //This is an equivalent for gda_data_model_array_new_with_g_types().
  void set_column_g_type(int col, GType type);
  _IGNORE(gda_data_model_array_new_with_g_types)

  _WRAP_METHOD(void set_n_columns(int cols), gda_data_model_array_set_n_columns)
  _WRAP_METHOD(void clear(), gda_data_model_array_clear)

  _WRAP_METHOD(Glib::RefPtr<Row> get_row(int row), gda_data_model_array_get_row, errthrow)
  _WRAP_METHOD(Glib::RefPtr<const Row> get_row(int row) const, gda_data_model_array_get_row, errthrow)
    
  _WRAP_PROPERTY("n-columns", guint)
};

} // namespace Gda
} // namespace Gnome

