/******************************************************************************
* NOMAD -  Nonlinear Optimization for Mixed vAriables and Derivatives.        *
* Copyright (C) 2001-2004  Gilles Couture - Ecole Polytechnique,              *
*                          Charles Audet - Ecole Polytechnique,               *
*		           John Dennis - Rice University.                     *
*                                                                             *
* Author: Gilles Couture                                                      *
* École Polytechnique de Montréal - GERAD                                     *
* C.P. 6079, Succ. Centre-ville, Montréal (Québec) H3C 3A7 Canada             *
* Tel:  (514) 340-6053 x6928                                                  *
* Email: Gilles.Couture@gerad.ca                                              *
* Fax: (514) 340-5665                                                         *
*                                                                             *
* This program is free software; you can redistribute it and/or               *
* modify it under the terms of the GNU General Public License                 *
* as published by the Free Software Foundation. You can find the              *
* GNU General Public License at:                                              *
*             http://www.gnu.org/copyleft/gpl.html                            *
*                                                                             *
* This program 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 General Public License for more details.                                *
*                                                                             *
* You should have received a copy of the GNU General Public License           *
* along with this program; if not, write to the Free Software                 *
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. *
*                                                                             *
* You can find information on the NOMAD software at:                          *
*             http://www.gerad.ca/NOMAD/                                      *
******************************************************************************/

// database.h -- class definition for Database, a virtual class from which all
// database classes are derived (BerkeleyDb, StlCache).
#ifndef _DATABASE_H
#define _DATABASE_H
#include "augmentedpoint.h"
#include "point.h"

enum DatabaseOpState {FOUND, NOTFOUND, ERROR};

class Database
{
public:
  Database(const char * name, const int dim, const int out_dim);
  virtual ~Database() {}
  virtual bool find(AugmentedPoint & ap, const double * key) = 0;
  virtual void insert(double * inp, double * utp) = 0;

private:
  // Database has the following data:
  // - a string variable, the database file name.
  // - "key_size" is the problem dimension.
  // - "data_size" is the number of outputs.
protected:
  const char * file_name;
  const int key_size;
  const int data_size;
};

// Constructor. The parameters received are the name of the database file,
// "keySize" is the problem dimension (also the number of real numbers in a
// point's coordinates), "datSize" is the number of outputs.
inline Database::Database(const char * name, const int dim, const int out_dim)
  : file_name(name), key_size(dim), data_size(out_dim)
{}

#endif
