#pragma once

#include "core/types.h"
#include "core/string.h"
#include <vector>
#include <map>

class BitParameter
{
protected:
	String paramName;
	i32 *paramPtr;
	i32 paramValue;
	i32 paramMin;
	i32 paramMax;
public:
	BitParameter( const char *name, i32 *ptr, i32 defaultValue_, i32 minv_, i32 maxv_ );

	String getName() const;
	i32 getDefaultValue() const;
	i32 getMinValue() const;
	i32 getMaxValue() const;
	i32 getValue() const;
	i32 setValue(i32 newValue);
	// set to default
	void reset();
};

class AutoBitParameter : public BitParameter
{
public:
	AutoBitParameter( const char *name, i32 *ptr, i32 minv_, i32 maxv_ );
};

class BitPersonality
{
protected:
	std::map< String, BitParameter * > parMap;
	std::vector< BitParameter * > params;
	static BitPersonality *globalPers;
public:
	~BitPersonality();

	static BitPersonality *get();
	bool add( const BitParameter &par );
	BitParameter *find( const String &parName ) const;
	void getParameters( std::vector< BitParameter * > &params );

	bool save( const String &fnm ) const;
	bool load( const String &fnm );
	// reset all params to default
	void reset();
};
