Fixed quiescence-futility pruning. Code changes because of tests.
[rattatechess.git] / commands.h
blobc1408353ff40255787686eb107f0e544470e7e85
1 /***************************************************************************
2 commands.h - description
3 -------------------
4 begin : mer ott 23 2002
5 copyright : (C) 2007 by Maurizio Monge
6 email : monge@linuz.sns.it
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #ifndef __COMMANDS_H__
19 #define __COMMANDS_H__
21 #include "engine.h"
23 /* class to store information about a command */
24 class Engine::Cmd
26 private:
27 typedef void (Engine::*CmdFunc)(int argc, char *argv[]);
29 CmdFunc m_func;
30 int m_min;
31 int m_max;
32 const char *m_desc;
34 public:
35 Cmd()
36 { }
38 Cmd(CmdFunc f, const char *d = NULL)
39 : m_func(f)
40 , m_min(0)
41 , m_max(0)
42 , m_desc(d)
43 { }
45 Cmd(CmdFunc f, int n, const char *d = NULL)
46 : m_func(f)
47 , m_min(n)
48 , m_max(n)
49 , m_desc(d)
50 { }
52 Cmd(CmdFunc f, int n, int x, const char *d = NULL)
53 : m_func(f)
54 , m_min(n)
55 , m_max(x)
56 , m_desc(d)
57 { }
59 int min() const { return m_min; }
60 int max() const { return m_max; }
61 const char* desc() const { return m_desc; }
63 void run(int argc, char *argv[]);
66 class Engine::Variable
68 public:
69 typedef void (Engine::*VarSetFunc)(void* d, const char* value);
70 typedef char* (Engine::*VarGetFunc)(void* d, char* value);
72 enum Type
74 Integer,
75 String,
76 Custom
79 int m_type;
80 const char* m_desc;
82 union
84 struct
86 int (Engine::*m_int_var);
87 int m_range_min;
88 int m_range_max;
90 char* (Engine::*m_string_var);
91 struct
93 void *m_custom_data;
94 VarSetFunc m_custom_set;
95 VarGetFunc m_custom_get;
99 Variable()
102 Variable(int (Engine::*ivar), int def_val, const char *d = NULL);
103 Variable(int (Engine::*ivar), int def_val, int min, int max, const char *d = NULL);
104 Variable(char* (Engine::*svar), const char* def_val, const char *d = NULL);
105 Variable(VarSetFunc set, VarGetFunc get, const char *d = NULL);
106 Variable(VarSetFunc set, VarGetFunc get, void* data, const char *d = NULL);
108 void from_string(const char *s);
109 const char* to_string(char* buf64);
110 const char* desc() { return m_desc; }
113 #endif //__COMMANDS_H__