]> git.jsancho.org Git - dungeon-master.git/blob - src/generators.cpp
register scene generators
[dungeon-master.git] / src / generators.cpp
1 /* Dungeon Master --- RPG Adventure Generator
2    Copyright © 2019 Javier Sancho <jsf@jsancho.org>
3
4    Dungeon Master is free software; you can redistribute it and/or modify it
5    under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 3 of the License, or
7    (at your option) any later version.
8
9    Dungeon Master is distributed in the hope that it will be useful, but
10    WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with Dungeon Master. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <libguile.h>
19 #include <list>
20 #include <map>
21 #include "generators.h"
22
23 struct compare_strings
24 {
25   bool operator() (const char* a, const char* b) const
26   {
27     return strcmp (a, b) < 0;
28   }
29 };
30
31 std::map<char*,
32          std::list<SceneGenerator*>,
33          compare_strings> registered_generators;
34
35 SceneGenerator*
36 register_generator (char* name,
37                     char* type,
38                     SCM proc)
39 {
40   SceneGenerator* generator = (SceneGenerator*) malloc (sizeof (SceneGenerator));
41   generator->name = name;
42   generator->type = type;
43   generator->proc = proc;
44
45   registered_generators[type].push_back (generator);
46
47   return generator;
48 }