Initial 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 // $Id: map.h,v 1.5 2006-07-26 06:53:19 fleuret Exp $
17
18 #ifndef MAP_H
19 #define MAP_H
20
21 #include <iostream>
22 #include <cmath>
23
24 using namespace std;
25
26 #include "misc.h"
27
28 class Map {
29 public:
30   int nb_parameters;
31   scalar_t *parameters;
32   Map();
33   virtual ~Map();
34   virtual void init(int np);
35   virtual void update_map() = 0;
36 };
37
38 // A MapConcatener groups several maps and make them appear as a
39 // single one
40
41 class MapConcatener : public Map {
42   int _nb_max_maps, _nb_maps;
43   Map **_maps;
44 public:
45   MapConcatener(int nb_max_maps);
46   ~MapConcatener();
47   void load(istream &is);
48   void save(ostream &os);
49   void add_map(Map *map);
50   void init();
51   void update_map();
52 };
53
54 // A MapExpander is a map whose parameters are functions of the
55 // parameter of an input map
56
57 class MapExpander : public Map {
58   int _nb_units;
59   scalar_t *_unit_weights, *_state_switch;
60   Map *_input;
61 public:
62   MapExpander(int nb_units);
63   ~MapExpander();
64   void load(istream &is);
65   void save(ostream &os);
66   void set_input(Map *input);
67   void init();
68   void update_map();
69 };
70
71 #endif