1 /*
2 * Functions to keep a listing of all modules in the system. Has its
3 * own file mostly for abstraction reasons, but is pretty simple
4 * otherwise.
5 *
6 * Authors:
7 * Ted Gould <ted@gould.cx>
8 * Lauris Kaplinski <lauris@kaplinski.com>
9 *
10 * Copyright (C) 2002-2004 Authors
11 *
12 * Released under GNU GPL, read the file 'COPYING' for more information
13 */
15 #ifndef __MODULES_DB_H__
16 #define __MODULES_DB_H__
18 #include <map>
19 #include <list>
21 #include "extension/extension.h"
23 namespace Inkscape {
24 namespace Extension {
26 class DB {
27 private:
28 /** A string comparison function to be used in the moduledict
29 to find the different extensions in the hash map. */
30 struct ltstr {
31 bool operator()(const char* s1, const char* s2) const {
32 if ( (s1 == NULL) && (s2 != NULL) ) {
33 return true;
34 } else if (s1 == NULL || s2 == NULL) {
35 return false;
36 } else {
37 return strcmp(s1, s2) < 0;
38 }
39 }
40 };
41 /** This is the actual database. It has all of the modules in it,
42 indexed by their ids. It's a hash table for faster lookups */
43 std::map <const char *, Extension *, ltstr> moduledict;
44 /** Maintain an ordered list of modules for generating the extension
45 lists via "foreach" */
46 std::list <Extension *> modulelist;
48 static void foreach_internal (gpointer in_key, gpointer in_value, gpointer in_data);
50 public:
51 DB (void);
52 Extension * get (const gchar *key);
53 void register_ext (Extension *module);
54 void unregister_ext (Extension *module);
55 void foreach (void (*in_func)(Extension * in_plug, gpointer in_data), gpointer in_data);
57 private:
58 static void input_internal (Extension * in_plug, gpointer data);
59 static void output_internal (Extension * in_plug, gpointer data);
60 static void effect_internal (Extension * in_plug, gpointer data);
62 public:
63 typedef std::list<Output *> OutputList;
64 typedef std::list<Input *> InputList;
65 typedef std::list<Effect *> EffectList;
67 InputList &get_input_list (InputList &ou_list);
68 OutputList &get_output_list (OutputList &ou_list);
69 EffectList &get_effect_list (EffectList &ou_list);
70 }; /* class DB */
72 extern DB db;
74 } } /* namespace Extension, Inkscape */
76 #endif /* __MODULES_DB_H__ */
78 /*
79 Local Variables:
80 mode:c++
81 c-file-style:"stroustrup"
82 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
83 indent-tabs-mode:nil
84 fill-column:99
85 End:
86 */
87 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :