~valavanisalex/ubuntu/precise/inkscape/fix-943984

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/extension/db.h

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 */
 
14
 
 
15
#ifndef __MODULES_DB_H__
 
16
#define __MODULES_DB_H__
 
17
 
 
18
#include <map>
 
19
#include <list>
 
20
#include <cstring>
 
21
 
 
22
#include "extension/extension.h"
 
23
 
 
24
namespace Inkscape {
 
25
namespace Extension {
 
26
 
 
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;
 
48
 
 
49
    static void foreach_internal (gpointer in_key, gpointer in_value, gpointer in_data);
 
50
 
 
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);
 
57
 
 
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);
 
62
 
 
63
public:
 
64
    typedef std::list<Output *> OutputList;
 
65
    typedef std::list<Input *> InputList;
 
66
    typedef std::list<Effect *> EffectList;
 
67
 
 
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 */
 
72
 
 
73
extern DB db;
 
74
 
 
75
} } /* namespace Extension, Inkscape */
 
76
 
 
77
#endif /* __MODULES_DB_H__ */
 
78
 
 
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:encoding=utf-8:textwidth=99 :