/*!
  @header FTConfig
  @abstract Module of FT
 
  @availability OS X, GNUstep
  @copyright 2004, 2005, 2006 Free Software Foundation, 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.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

  01.12.05 ola     initial version
  06.06.06 ola     ClassObjectFactory, RegisterClassObject added
  23.08.06 ola     license changed
  -------------------------------------------------------------------------
  </pre>
*/

#if !defined(__FTConfig_H)
#define __FTConfig_H

#include <Foundation/Foundation.h>
#include <Encore/Encore.h>
#include <FT/FTObject.h>
#include <FT/FTServiceLoader.h>

@class FTConfigDatabaseNames;
@class FTConfigServices;
@class FTClassObjectFactory;


/*!
 * @class FTConfig
 * @abstract Used by the xml configuration mechanism. It encapsulates all 
 *   configuration settings given in the ft config.xml file.
 * @discussion All methos of this interface are called through reflection by
 *   {@link ECXMLControl}.
 */
@interface FTConfig : FTObject {
  @private
    FTConfigDatabaseNames *databaseNames;
    FTConfigServices *services;
    FTClassObjectFactory *classObjectFactory;

    NSString *baseDataDir;
}

- init;
- (void) dealloc;


- (NSString *) baseDataDir;
- (FTClassObjectFactory *) classObjectFactory;
- (FTConfigDatabaseNames *) databaseNames;
- (FTConfigServices *) services;

- setBaseDataDir: (NSString *) theBaseDir;
- setDatabaseNames: (FTConfigDatabaseNames *) theDatabaseNames;
- setFTClassObjectFactory: (FTClassObjectFactory *) aClassObjectFactory;
- setServices: (FTConfigServices *) theServices;
@end


// --------------------------------------- FTConfigDatabaseNames

@class FTConfigDatabaseName;
/*!
 * @class FTDatabaseNames
 * @abstract This class maps entries to database names
 * @discussion All methos of this interface are called through reflection by
 *   {@link ECXMLControl}.
 */
@interface FTConfigDatabaseNames : FTObject {
  @private
    NSMutableDictionary *entryToDatabaseName;
}

- init;
- (void) dealloc;

- addDatabaseName: (FTConfigDatabaseName *) dbNameToAdd;
- (id <ECIterator>) allDatabaseNames;
- (NSString *) databaseNameForEntry: (NSString *) anEntry;
@end


// --------------------------------------- FTConfigDatabaseName 
/*!
 * @class FTDatabaseName
 * @abstract Represents a database name or a schema for formulating database
 *   names
 * @discussion All methods of this interface are called through reflection by
 *   {@link ECXMLControl}.
 */
@interface FTConfigDatabaseName : FTObject {
  @private
    NSString *entry;
    NSString *databaseName;
}

- init;
- (void) dealloc;

- (NSString *) databaseName;
- (NSString *) entry;


- setDatabaseName: (NSString *) aDatabaseName;
- setEntry: (NSString *) anEntry;
@end


// --------------------------------------- FTConfigServices
@class FTConfigServiceLoaders;


/*!
 * @class FTConfigServices
 * @abstract Contains settings for the configuration of services
 * @discussion Most of the methods of this interface are called through 
 *   reflection by {@link ECXMLControl}.
 */
@interface FTConfigServices : ECObject {
  @private 
    NSMutableDictionary *serviceLoaders;
}

- init;
- (void) dealloc;

- setServiceLoaders: (FTConfigServiceLoaders *) serviceLoadersToSet;
- (NSMutableDictionary *) serviceLoaders;
@end


// --------------------------------------- FTConfigServices

/*!
 * @class FTConfigServiceLoaders
 * @abstract Contains settings for the configuration of service loaders
 * @discussion Most of the methods of this interface are called through 
 *   reflection by {@link ECXMLControl}.
 */
@interface FTConfigServiceLoaders : ECObject {
  @private 
    NSMutableDictionary *serviceLoaders;
}

- init;
- (void) dealloc;

- addServiceLoader: (id <FTServiceLoader>) serviceLoader;
- (NSMutableDictionary *) serviceLoaders;
@end


// --------------------------------------- FTClassObjectFactory
/*!
 * @class FTRegisterClassObject
 * @abstract This class is used to register a class name under a certain key
 */
@interface FTRegisterClassObject : FTObject {
  @private
    NSString *classObject;
    NSString *key;
}

- init;
- (void) dealloc;


/*!
 * @method classObject
 * @result name of class object
 */
- (NSString *) classObject;


/*!
 * @method key
 * @result key for the class object
 */
- (NSString *) key;

/*!
 * @method setClassObject
 * @param aClassObject name of class object
 * @result self
 */
- setClassObject: (NSString *) aClassObject;


/*!
 * @method setKey
 * @param aKey key to use for the class object
 * @result self
 */
- setKey: (NSString *) aKey;
@end


// --------------------------------------- FTClassObjectFactory

/*!
 * @class FTClassObjectFactory
 * @abstract Maps keys to class objects.
 */
@interface FTClassObjectFactory : FTObject {
  @private 
    NSMutableDictionary *keyToClassObject;
}

- init;
- (void) dealloc;

- addFTRegisterClassObject: (FTRegisterClassObject *) toRegister;
- (Class) classObjectForKey: (NSString *) key;
@end

#endif

