#include "rpl4.h"
#pragma hdrstop

#include "rpl4mode.h"

#if defined(DEBUG)
#	define Test_Tell(n) DEBUG_STREAM << n
#else
#	define Test_Tell(n)
#endif

struct ModeLookup
{
	const char *name;
	ModeMask modeMask;
};

static ModeLookup mode_lookup[] =
{
	{"ModeNonConfig",   RPL4ModeManager::ModeNonConfig},
	{"ModeConfigReady", RPL4ModeManager::ModeConfigReady},
	{"ModeConfigOn",    RPL4ModeManager::ModeConfigOn},
	{"ModePreset1",     RPL4ModeManager::ModePreset1},
	{"ModePreset2",     RPL4ModeManager::ModePreset2},
	{"ModePreset3",     RPL4ModeManager::ModePreset3},
	{"ModePreset4",     RPL4ModeManager::ModePreset4},
	{"ModePreset5",     RPL4ModeManager::ModePreset5},
	{"ModePreset6",     RPL4ModeManager::ModePreset6},
	{"ModeBasic",       RPL4ModeManager::ModeBasic},
	{"ModeStandard",    RPL4ModeManager::ModeStandard},
	{"ModeIntercom",    RPL4ModeManager::ModeIntercom},
	{"ModeConfiguring", RPL4ModeManager::ModeConfiguring},
	{ NULL, (ModeMask)0}
};

Logical RPL4ModeManager::ModeStringLookup(const char *name, ModeMask *returned_value)
{
	Check(this);
	Check_Pointer(name); 
	Check_Pointer(returned_value); 
	//----------------------------------------
	// Search table for match
	//----------------------------------------
	ModeLookup *lookup;

	for(lookup=mode_lookup; lookup->name!=NULL; ++lookup)
	{
		if (stricmp(name, lookup->name) == 0)
		{
			*returned_value = lookup->modeMask;
			Check_Fpu();
			return True;
		}
	}
	//----------------------------------------
	// Not found here, check next level down.
	//----------------------------------------
	Check_Fpu();
	return ModeManager::ModeStringLookup(name, returned_value);
}
