/*!
  @header BDBDatabaseConfig
  @abstract Instances of this class are used to configure the database
 
  @availability OS X, GNUstep
  @copyright (C) 2004, 2005, 2006 Oliver Langer
 
  Author: Oliver Langer

  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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

  <pre>
  -------------------------------------------------------------------------
  Modification history

  09.12.2004 ola     initial version
  22.08.2006 ola     license changed
  -------------------------------------------------------------------------
  </pre>
*/

#if !defined(__BDBDatabaseConfig_H)
#define __BDBDatabaseConfig_H

#include <Foundation/Foundation.h>
#include "BDB/BDBObject.h"
#include <db.h>
#include <BDB/BDBConstants.h>

/*!
 * @class BDBDatabaseConfig
 * @abstract This class is used to hand-off a configuration
 * to diverse operations.
 */
@interface BDBDatabaseConfig : BDBObject {
@private
  DB *dbp;
  u_int32_t openFlags;
  u_int32_t generalConfigFlags;

  BDBDatabaseType databaseType;
}


/*!
 * @function init
 * @abstract constructor
 */
- init;


/**
 * @method configureDatabase
 * @abstract For internal usage only
 * @discussion configures the database based on the internal settings
 * @result self
 */
- configureDatabase;


/*!
 * @return the type of the database
 */
- (BDBDatabaseType) databaseType;


/**
 * @return DB structure handle
 */
- (DB*) db;


/**
 * @method generalConfigFlags
 * @abstract NON-API method, for internal purposes only
 * @result flags used for the function DB->set_flags
 */
- (u_int32_t) generalConfigFlags;


/**
 * @return the flags used for creation via bdb
 */
- (u_int32_t) openFlags;


/*!
 * Create database if not existent
 * @param 
 */
- (id) setAllowCreate: (BOOL) enable;


/*!
 * @method setBTreeRecordNumbering
 * @param recordNumbering enables or disables this feature
 * @result self
 * @abstract Configure the Btree to support retrieval by record number.
 * @discuss This method may not be used in conjunction with the usage of
 *   duplicated entries.
 */
- setBTreeRecordNumbering: (BOOL) recordNumbering;


/*!
 * Specify the database type (btree, hash, recno, queue) to be used.
 * @see BDBDatabaseType
 */
- (id) setDatabaseType: (BDBDatabaseType) type;


/*!
 * @method setAllowDuplicates
 * @abstract Configure the database to support duplicate data items.
 * @param sortedDuplicates If true, configure the database to support duplicate 
 *   data items. A value of false is illegal to this method, that is, once set, 
 * the configuration cannot be cleared.
 * @result self
 */
- setAllowDuplicates: (BOOL) duplicatesAllowed;


/*!
 * @method setAllocSortedDuplicates
 * @param allow enables or disables this feature
 * @result self
 * @abstract allow duplicates to be inserted using an automatic sorting 
 *   mechanism
 * @discussion The ordering of duplicates in the database is determined by the 
 * duplicate comparison function.
 */
- setAllocSortedDuplicates: (BOOL) allow;


/*!
 * @method setRecordRenumbering
 * @abstract Set record numbers being mutable
 * @discussion This flag is defind for {@link #BDB_RECNO} only. It causes
 *   logical record numbers to be mutable.
 * @param renumber specify to activate/deactivate renumbering
 */
- setRecordRenumbering: (BOOL) renumber;
@end

#endif
