/* 
 * © 2007-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
 *
 * 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 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., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */
#ifndef _QUERY_RECORDSET_H_
#define _QUERY_RECORDSET_H_


#include "wbpublic_public_interface.h"
#include "grt/tree_model.h"
#include <string>

class Recordset_data_storage;


class WBPUBLICBACKEND_PUBLIC_FUNC Recordset : public bec::ListModel
{
public:
  Recordset();
  virtual ~Recordset();

  Recordset_data_storage * data_storage() { return _data_storage; }
  void data_storage(Recordset_data_storage *data_storage) { _data_storage= data_storage; }

  void commit(Recordset_data_storage *data_storage);
  void reset(Recordset_data_storage *data_storage);
  void commit();
  void reset();

  void refresh();
  int count();

  bool set_field(const bec::NodeId &node, int column, const std::string &value);
  bool set_field(const bec::NodeId &node, int column, int value);

  int field_count();
  std::string field_name(int index);

private:
  Recordset_data_storage *_data_storage;
  std::vector<std::string> _rs;
  std::vector<std::string> _field_names;

protected:
  // for internal use only
  virtual bool get_field_grt(const bec::NodeId &node, int column, grt::ValueRef &value);
};

#pragma make_public(Recordset)


#endif /* _QUERY_RECORDSET_H_ */
