Code

Node tool: special case node duplication for endnodes - select new endnode
[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>
20 #include <cstring>
22 #include "extension/extension.h"
24 namespace Inkscape {
25 namespace Extension {
27 class DB {
28 private:
29     /** A string comparison function to be used in the moduledict
30         to find the different extensions in the hash map. */
31     struct ltstr {
32         bool operator()(const char* s1, const char* s2) const {
33             if ( (s1 == NULL) && (s2 != NULL) ) {
34                 return true;
35             } else if (s1 == NULL || s2 == NULL) {
36                 return false;
37             } else {
38                 return strcmp(s1, s2) < 0;
39             }
40         }
41     };
42     /** This is the actual database.  It has all of the modules in it,
43         indexed by their ids.  It's a hash table for faster lookups */
44     std::map <const char *, Extension *, ltstr> moduledict;
45     /** Maintain an ordered list of modules for generating the extension
46         lists via "foreach" */
47     std::list <Extension *> modulelist;
49     static void foreach_internal (gpointer in_key, gpointer in_value, gpointer in_data);
51 public:
52     DB (void);
53     Extension * get (const gchar *key);
54     void register_ext (Extension *module);
55     void unregister_ext (Extension *module);
56     void foreach (void (*in_func)(Extension * in_plug, gpointer in_data), gpointer in_data);
58 private:
59     static void input_internal (Extension * in_plug, gpointer data);
60     static void output_internal (Extension * in_plug, gpointer data);
61     static void effect_internal (Extension * in_plug, gpointer data);
63 public:
64     typedef std::list<Output *> OutputList;
65     typedef std::list<Input *> InputList;
66     typedef std::list<Effect *> EffectList;
68     InputList  &get_input_list  (InputList &ou_list);
69     OutputList &get_output_list (OutputList &ou_list);
70     EffectList &get_effect_list (EffectList &ou_list);
71 }; /* class DB */
73 extern DB db;
75 } } /* namespace Extension, Inkscape */
77 #endif /* __MODULES_DB_H__ */
79 /*
80   Local Variables:
81   mode:c++
82   c-file-style:"stroustrup"
83   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
84   indent-tabs-mode:nil
85   fill-column:99
86   End:
87 */
88 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :