#ifndef INSTRUMENTCONFIG_H
#define INSTRUMENTCONFIG_H

#include "callback.h"
#include "ostime.h"
#include "types.h"
#include "configfile.h"


/*-----------------------------------------------------------------------
CLASS
	InstrumentCfg

FILE
	instrumentcfg.h

DESCRIPTION	
	InstrumentCfg contains an instrument configuration(s) file(s)
	and handles updating a config item when it changes. 

AUTHOR
	Danelle Cline. Copyright 1998 MBARI.			
LOG:
	Modifier 	Date    		Change
	--------   	----    		--------
	D. Cline	10/05/98		Charlie prototype

-----------------------------------------------------------------------*/
class InstrumentCfg 
{
public:
	// Initializes members.
	InstrumentCfg();

	virtual ~InstrumentCfg();

	// Parent class can call this to initialize a config file. If
	// cfgfile = NULL, trys to open default cfg file <Instrument::id()>.cfg
	// Opens, and parses <cfgfile>.  
	// Stores all string token pairs in ConfigFileManager 
	// vector configItems
	virtual void initialize(const char *cfgfile = NULL);

	// Saves instrument configuration items to disk. Replaces the existing
	// .cfg file with the current state of the instrument. The .cal file
	// is not replaced - it is READ only
	virtual void saveConfigItems(CallbackObject *);

	// Searches config (.cfg) file for a ConfigItem with <name>. If item with <name>
	// found returns the  ConfigItemWrapper <item> containing a COPY of the config item,
	// and OK status, else returns ERROR.
	virtual MBool searchForConfigItem(const char * name, ConfigItemWrapper &item);
	
	// Searches config file for a ConfigItem with same name as 
	// item contained in <item>, and replaces if found.
	// This is generally when a calling class has changed an item, 
	// and wants the change reflected in the contained config file managed in
	// InstrumentCfg
	virtual void replaceConfigItem(const ConfigItemWrapper item);


	// Create configuration item with <name> and a single argument 
	// string <argvs>. For example createCfgItem("LOAD.MACRO1", "testmacro.txt");
	virtual MBool createCfgItem(const char *name, const char *argvs);
	

private:
	ConfigFile _configFile;
};

#endif 
