automatic commit
[universe.git] / map.h
1
2 ////////////////////////////////////////////////////////////////////////////////
3 // This program is free software; you can redistribute it and/or              //
4 // modify it under the terms of the GNU General Public License                //
5 // version 2 as published by the Free Software Foundation.                    //
6 //                                                                            //
7 // This program is distributed in the hope that it will be useful, but        //
8 // WITHOUT ANY WARRANTY; without even the implied warranty of                 //
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU          //
10 // General Public License for more details.                                   //
11 //                                                                            //
12 // Written and (C) by François Fleuret                                        //
13 // Contact <francois.fleuret@epfl.ch> for comments & bug reports              //
14 ////////////////////////////////////////////////////////////////////////////////
15
16 #ifndef MAP_H
17 #define MAP_H
18
19 #include <iostream>
20 #include <cmath>
21
22 using namespace std;
23
24 #include "misc.h"
25
26 class Map {
27 public:
28   int nb_parameters;
29   scalar_t *parameters;
30   Map();
31   virtual ~Map();
32   virtual void init(int np);
33   virtual void update_map() = 0;
34 };
35
36 // A MapConcatener groups several maps and make them appear as a
37 // single one
38
39 class MapConcatener : public Map {
40   int _nb_max_maps, _nb_maps;
41   Map **_maps;
42 public:
43   MapConcatener(int nb_max_maps);
44   ~MapConcatener();
45   void load(istream &is);
46   void save(ostream &os);
47   void add_map(Map *map);
48   void init();
49   void update_map();
50 };
51
52 // A MapExpander is a map whose parameters are functions of the
53 // parameter of an input map
54
55 class MapExpander : public Map {
56   int _nb_units;
57   scalar_t *_unit_weights, *_state_switch;
58   Map *_input;
59 public:
60   MapExpander(int nb_units);
61   ~MapExpander();
62   void load(istream &is);
63   void save(ostream &os);
64   void set_input(Map *input);
65   void init();
66   void update_map();
67 };
68
69 #endif