1 #ifndef __CLength_HPP__
2 #define __CLength_HPP__
3 
4 /* "Species" - a CoreWars evolver.  Copyright (C) 2003 'Varfar'
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the Free
8  * Software Foundation; either version 1, or (at your option) any later
9  * version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20 
21 #include "ini.hpp"
22 #include <iostream>
23 
24 class CLength { /* manages the lengths of a warrior that is allowed */
25 	public:
26 		void read_ini(INIFile &ini); /* loads length values; values are REQUIRED */
27 		CLength *read_override_ini(INIFile &ini); /* loads length values; if any length values are
28 			specified, then a copy of this length will be made; all unspecified values in the new
29 			class will be "inherited" from this one, and any specified values will be overriden.  If nothing
30 			is specified, then this will be returned */
31 		void write_ini(std::ostream &os);
32 		void write_override_ini(std::ostream &os,const CLength *parent);
min() const33 		int min() const { return _min; }
max() const34 		int max() const { return _max; }
ok(const int size) const35 		bool ok(const int size) const { return ((min() <= size) && (size <= max())); }
36 		int rnd() const; // returns a random length that is ok()
37 	protected:
38 		int _min, _max;
39 };
40 
41 #endif // __CLength_HPP__
42