1 #ifndef __OPERAND_DISTRIBUTION_HPP_
2 #define __OPERAND_DISTRIBUTION_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 /* to implement a generator:
22  * 1) derive publically from COperand
23  * 1) give it an identifier in the EImpl enumeration
24  * 2) make the constructor set the _type member
25  * 3) make COperand factories understand this new implementation and how to identify it
26  * 4) implement the read_ini/write_ini functionality
27  */
28 
29 #include "operand.hpp"
30 #include "distribution.hpp"
31 
32 class COperandDistribution: public COperand, protected CDistribution {
33 	public:
34 		COperandDistribution(const field_t coresize); /* constructor creates default values */
35 		// actual query point
36 		virtual void rnd(insn_t &instruction,const Field field);
37 		// and saving
38 		virtual void write_ini(std::ostream &os);
39 		virtual void write_override_ini(std::ostream &os,const COperand *parent);
40 	protected:
41 		// from COperand
42 		virtual void read_ini_impl(INIFile &ini);
43 		virtual COperand *read_override_ini_impl(INIFile &ini); /* loads freq values; if any freq values are
44 			specified, then a copy of this freq will be made; all unspecified values in the new
45 			class will be "inherited" from this one, and any specified values will be overriden.  If nothing
46 			is specified, then this will be returned */
47 	private:
48 		COperandDistribution(const CDistribution &copy);
49 		static CDistribution *ImplFactory(const CDistribution &copy);
50 };
51 
52 #endif // ifndef __OPERAND_DISTRIBUTION_HPP_
53