Code

moving trunk for module inkscape
[inkscape.git] / src / extension / db.h
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             return strcmp(s1, s2) < 0;
33         }
34     };
35     /** This is the actual database.  It has all of the modules in it,
36         indexed by their ids.  It's a hash table for faster lookups */
37     std::map <const char *, Extension *, ltstr> moduledict;
38     /** Maintain an ordered list of modules for generating the extension
39         lists via "foreach" */
40     std::list <Extension *> modulelist;
42     static void foreach_internal (gpointer in_key, gpointer in_value, gpointer in_data);
44 public:
45     DB (void);
46     Extension * get (const gchar *key);
47     void register_ext (Extension *module);
48     void unregister_ext (Extension *module);
49     void foreach (void (*in_func)(Extension * in_plug, gpointer in_data), gpointer in_data);
51 private:
52     static void input_internal (Extension * in_plug, gpointer data);
53     static void output_internal (Extension * in_plug, gpointer data);
54     static void effect_internal (Extension * in_plug, gpointer data);
56 public:
57     typedef std::list<Output *> OutputList;
58     typedef std::list<Input *> InputList;
59     typedef std::list<Effect *> EffectList;
61     InputList  &get_input_list (InputList &ou_list);
62     OutputList &get_output_list (OutputList &ou_list);
63     EffectList &get_effect_list (EffectList &ou_list);
64 }; /* class DB */
66 extern DB db;
68 } } /* namespace Extension, Inkscape */
70 #endif /* __MODULES_DB_H__ */
72 /*
73   Local Variables:
74   mode:c++
75   c-file-style:"stroustrup"
76   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
77   indent-tabs-mode:nil
78   fill-column:99
79   End:
80 */
81 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :