Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
db.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Functions to keep a listing of all modules in the system. Has its
4 * own file mostly for abstraction reasons, but is pretty simple
5 * otherwise.
6 *
7 * Authors:
8 * Ted Gould <ted@gould.cx>
9 * Lauris Kaplinski <lauris@kaplinski.com>
10 *
11 * Copyright (C) 2002-2004 Authors
12 *
13 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
14 */
15
16#ifndef SEEN_MODULES_DB_H
17#define SEEN_MODULES_DB_H
18
19#include <string>
20#include <memory>
21#include <unordered_map>
22#include <vector>
23
24#include <glib.h>
25
26#include "extension.h"
27
28namespace Inkscape::Extension {
29
30class Template; // New
31class Input; // Load
32class Output; // Save
33class Effect; // Modify
34
35class DB {
36private:
39 std::unordered_map<std::string, std::unique_ptr<Extension>> moduledict;
40
41public:
42 DB() = default;
43 DB(DB &&) = delete; // Database is non-movable, hence also non-copyable.
44 DB &operator=(DB &&) = delete;
45
46 Extension *get(const gchar *key) const;
47 void take_ownership(std::unique_ptr<Extension> module);
48 void foreach(void (*in_func)(Extension * in_plug, gpointer in_data), gpointer in_data);
49
50private:
51 static void template_internal(Extension *in_plug, gpointer data);
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);
55
56public:
57 typedef std::list<Template *> TemplateList;
58 typedef std::list<Output *> OutputList;
59 typedef std::list<Input *> InputList;
60 typedef std::list<Effect *> EffectList;
61
65
66 std::vector<Effect*> get_effect_list();
67}; /* class DB */
68
69extern DB db;
70
71} // namespace Inkscape::Extension
72
73#endif // SEEN_MODULES_DB_H
74
75/*
76 Local Variables:
77 mode:c++
78 c-file-style:"stroustrup"
79 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
80 indent-tabs-mode:nil
81 fill-column:99
82 End:
83*/
84// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
std::list< Output * > OutputList
Definition db.h:58
std::list< Effect * > EffectList
Definition db.h:60
static void output_internal(Extension *in_plug, gpointer data)
The function to look at each module and see if it is an output module, then add it to the list.
Definition db.cpp:182
void take_ownership(std::unique_ptr< Extension > module)
Take the ownership of an extension to ensure that it is freed on program exit.
Definition db.cpp:86
std::vector< Effect * > get_effect_list()
Creates a list of all the Effect extensions.
Definition db.cpp:266
DB & operator=(DB &&)=delete
OutputList & get_output_list(OutputList &ou_list)
Creates a list of all the Output extensions.
Definition db.cpp:256
TemplateList & get_template_list(TemplateList &ou_list)
Create a list of all the Template extensions.
Definition db.cpp:228
std::unordered_map< std::string, std::unique_ptr< Extension > > moduledict
This is the actual database.
Definition db.h:39
std::list< Input * > InputList
Definition db.h:59
static void effect_internal(Extension *in_plug, gpointer data)
The function to look at each module and see if it is an effect module, then add it to the list.
Definition db.cpp:208
std::list< Template * > TemplateList
Definition db.h:57
Extension * get(const gchar *key) const
This function looks up a Inkscape::Extension::Extension by using its unique id. It then returns a ref...
Definition db.cpp:101
InputList & get_input_list(InputList &ou_list)
Creates a list of all the Input extensions.
Definition db.cpp:242
static void input_internal(Extension *in_plug, gpointer data)
The function to look at each module and see if it is an input module, then add it to the list.
Definition db.cpp:162
static void template_internal(Extension *in_plug, gpointer data)
The function to look at each module and see if it is a template module, then add it to the list.
Definition db.cpp:142
The object that is the basis for the Extension system.
Definition extension.h:133
Inkscape::Extension::Extension: Frontend to certain, possibly pluggable, actions.
Extension support.
DB db
This is the actual database object.
Definition db.cpp:32
static cairo_user_data_key_t key
static const Point data[]