2009-03-28 20:02:34 +00:00
|
|
|
/**
|
|
|
|
* The common library
|
|
|
|
* @file param_config.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PARAM_CONFIG_H__
|
|
|
|
#define __PARAM_CONFIG_H__ 1
|
|
|
|
|
|
|
|
#include "wx/confbase.h"
|
|
|
|
#include "wx/fileconf.h"
|
2009-05-21 17:42:42 +00:00
|
|
|
#include <boost/ptr_container/ptr_vector.hpp>
|
2009-03-28 20:02:34 +00:00
|
|
|
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
/** Type of parameter in the configuration file */
|
|
|
|
enum paramcfg_id
|
2009-03-28 20:02:34 +00:00
|
|
|
{
|
|
|
|
PARAM_INT,
|
|
|
|
PARAM_SETCOLOR,
|
|
|
|
PARAM_DOUBLE,
|
|
|
|
PARAM_BOOL,
|
|
|
|
PARAM_LIBNAME_LIST,
|
|
|
|
PARAM_WXSTRING,
|
2010-06-17 16:30:10 +00:00
|
|
|
PARAM_COMMAND_ERASE,
|
2010-10-04 12:58:07 +00:00
|
|
|
PARAM_FIELDNAME_LIST
|
2009-03-28 20:02:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define MAX_COLOR 0x8001F
|
2009-04-29 17:09:00 +00:00
|
|
|
#define IS_VALID_COLOR( c ) ( ( c >= 0 ) && ( c <= 0x8001F ) )
|
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
#define INT_MINVAL 0x80000000
|
|
|
|
#define INT_MAXVAL 0x7FFFFFFF
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class PARAM_CFG_BASE
|
|
|
|
* is a base class which establishes the virtual functions ReadParam and SaveParam,
|
|
|
|
* which are re-implemented by a number of base classes, and these function's
|
|
|
|
* doxygen comments are inherited also.
|
|
|
|
*/
|
2009-03-28 20:02:34 +00:00
|
|
|
class PARAM_CFG_BASE
|
|
|
|
{
|
|
|
|
public:
|
2010-06-17 16:30:10 +00:00
|
|
|
const wxChar* m_Ident; ///< Keyword in config data
|
|
|
|
paramcfg_id m_Type; ///< Type of parameter
|
|
|
|
const wxChar* m_Group; ///< Group name (this is like a path in the config data)
|
|
|
|
bool m_Setup; ///< Install or Project based parameter, true == install
|
2009-03-28 20:02:34 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
PARAM_CFG_BASE( const wxChar* ident, const paramcfg_id type, const wxChar* group = NULL );
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
/**
|
|
|
|
* Function ReadParam
|
|
|
|
* reads the value of the parameter stored in aConfig
|
|
|
|
* @param aConfig = the wxConfigBase that holds the parameter
|
2009-03-28 20:02:34 +00:00
|
|
|
*/
|
|
|
|
virtual void ReadParam( wxConfigBase* aConfig ) {};
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
/**
|
|
|
|
* Function SaveParam
|
|
|
|
* saves the value of the parameter stored in aConfig
|
2009-03-28 20:02:34 +00:00
|
|
|
* @param aConfig = the wxConfigBase that can store the parameter
|
|
|
|
*/
|
|
|
|
virtual void SaveParam( wxConfigBase* aConfig ) {};
|
|
|
|
};
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Configuration parameter - Integer Class
|
|
|
|
*
|
|
|
|
*/
|
2009-03-28 20:02:34 +00:00
|
|
|
class PARAM_CFG_INT : public PARAM_CFG_BASE
|
|
|
|
{
|
|
|
|
public:
|
2010-06-17 16:30:10 +00:00
|
|
|
int* m_Pt_param; ///< Pointer to the parameter value
|
|
|
|
int m_Min, m_Max; ///< Minimum and maximum values of the param type
|
|
|
|
int m_Default; ///< The default value of the parameter
|
2009-03-28 20:02:34 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
PARAM_CFG_INT( const wxChar* ident, int* ptparam,
|
|
|
|
int default_val = 0, int min = INT_MINVAL, int max = INT_MAXVAL,
|
|
|
|
const wxChar* group = NULL );
|
|
|
|
PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam,
|
|
|
|
int default_val = 0, int min = INT_MINVAL, int max = INT_MAXVAL,
|
|
|
|
const wxChar* group = NULL );
|
|
|
|
|
|
|
|
virtual void ReadParam( wxConfigBase* aConfig );
|
|
|
|
virtual void SaveParam( wxConfigBase* aConfig );
|
|
|
|
};
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Configuration parameter - SetColor Class
|
|
|
|
*
|
|
|
|
*/
|
2009-03-28 20:02:34 +00:00
|
|
|
class PARAM_CFG_SETCOLOR : public PARAM_CFG_BASE
|
|
|
|
{
|
|
|
|
public:
|
2010-06-17 16:30:10 +00:00
|
|
|
int* m_Pt_param; ///< Pointer to the parameter value
|
|
|
|
int m_Default; ///< The default value of the parameter
|
2009-03-28 20:02:34 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
PARAM_CFG_SETCOLOR( const wxChar* ident, int* ptparam,
|
|
|
|
int default_val, const wxChar* group = NULL );
|
|
|
|
PARAM_CFG_SETCOLOR( bool Insetup, const wxChar* ident, int* ptparam,
|
|
|
|
int default_val, const wxChar* group = NULL );
|
|
|
|
|
|
|
|
virtual void ReadParam( wxConfigBase* aConfig );
|
|
|
|
virtual void SaveParam( wxConfigBase* aConfig );
|
|
|
|
};
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Configuration parameter - Double Precision Class
|
|
|
|
*
|
|
|
|
*/
|
2009-03-28 20:02:34 +00:00
|
|
|
class PARAM_CFG_DOUBLE : public PARAM_CFG_BASE
|
|
|
|
{
|
|
|
|
public:
|
2010-06-17 16:30:10 +00:00
|
|
|
double* m_Pt_param; ///< Pointer to the parameter value
|
|
|
|
double m_Default; ///< The default value of the parameter
|
|
|
|
double m_Min, m_Max; ///< Minimum and maximum values of the param type
|
2009-03-28 20:02:34 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
PARAM_CFG_DOUBLE( const wxChar* ident, double* ptparam,
|
|
|
|
double default_val = 0.0, double min = 0.0, double max = 10000.0,
|
|
|
|
const wxChar* group = NULL );
|
|
|
|
PARAM_CFG_DOUBLE( bool Insetup, const wxChar* ident, double* ptparam,
|
|
|
|
double default_val = 0.0, double min = 0.0, double max = 10000.0,
|
|
|
|
const wxChar* group = NULL );
|
|
|
|
|
|
|
|
virtual void ReadParam( wxConfigBase* aConfig );
|
|
|
|
virtual void SaveParam( wxConfigBase* aConfig );
|
|
|
|
};
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Configuration parameter - Boolean Class
|
|
|
|
*
|
|
|
|
*/
|
2009-03-28 20:02:34 +00:00
|
|
|
class PARAM_CFG_BOOL : public PARAM_CFG_BASE
|
|
|
|
{
|
|
|
|
public:
|
2010-06-17 16:30:10 +00:00
|
|
|
bool* m_Pt_param; ///< Pointer to the parameter value
|
|
|
|
int m_Default; ///< The default value of the parameter
|
2009-03-28 20:02:34 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
PARAM_CFG_BOOL( const wxChar* ident, bool* ptparam,
|
|
|
|
int default_val = FALSE, const wxChar* group = NULL );
|
|
|
|
PARAM_CFG_BOOL( bool Insetup, const wxChar* ident, bool* ptparam,
|
|
|
|
int default_val = FALSE, const wxChar* group = NULL );
|
|
|
|
|
|
|
|
virtual void ReadParam( wxConfigBase* aConfig );
|
|
|
|
virtual void SaveParam( wxConfigBase* aConfig );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
/**
|
|
|
|
* Configuration parameter - wxString Class
|
|
|
|
*
|
|
|
|
*/
|
2009-03-28 20:02:34 +00:00
|
|
|
class PARAM_CFG_WXSTRING : public PARAM_CFG_BASE
|
|
|
|
{
|
|
|
|
public:
|
2010-06-17 16:30:10 +00:00
|
|
|
wxString* m_Pt_param; ///< Pointer to the parameter value
|
2009-03-28 20:02:34 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
PARAM_CFG_WXSTRING( const wxChar* ident, wxString* ptparam, const wxChar* group = NULL );
|
|
|
|
PARAM_CFG_WXSTRING( bool Insetup,
|
|
|
|
const wxChar* ident,
|
|
|
|
wxString* ptparam,
|
|
|
|
const wxChar* group = NULL );
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
virtual void ReadParam( wxConfigBase* aConfig );
|
2009-03-28 20:02:34 +00:00
|
|
|
virtual void SaveParam( wxConfigBase* aConfig );
|
|
|
|
};
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
class PARAM_CFG_LIBNAME_LIST : public PARAM_CFG_BASE
|
|
|
|
{
|
|
|
|
public:
|
2010-06-17 16:30:10 +00:00
|
|
|
wxArrayString* m_Pt_param; ///< Pointer to the parameter value
|
2009-03-28 20:02:34 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
PARAM_CFG_LIBNAME_LIST( const wxChar* ident,
|
|
|
|
wxArrayString* ptparam,
|
|
|
|
const wxChar* group = NULL );
|
|
|
|
|
|
|
|
virtual void ReadParam( wxConfigBase* aConfig );
|
|
|
|
virtual void SaveParam( wxConfigBase* aConfig );
|
|
|
|
};
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
/** A list of parameters type */
|
2009-05-21 17:42:42 +00:00
|
|
|
typedef boost::ptr_vector< PARAM_CFG_BASE > PARAM_CFG_ARRAY;
|
2009-03-28 20:02:34 +00:00
|
|
|
|
|
|
|
#endif /* __PARAM_CONFIG_H__ */
|