Code

simplify the SimpleEvent API more
[inkscape.git] / src / debug / simple-event.h
1 /*
2  * Inkscape::Debug::SimpleEvent - trivial implementation of Debug::Event
3  *
4  * Authors:
5  *   MenTaLguY <mental@rydia.net>
6  *
7  * Copyright (C) 2005 MenTaLguY
8  *
9  * Released under GNU GPL, read the file 'COPYING' for more information
10  */
12 #ifndef SEEN_INKSCAPE_DEBUG_SIMPLE_EVENT_H
13 #define SEEN_INKSCAPE_DEBUG_SIMPLE_EVENT_H
15 #include <vector>
16 #include "gc-alloc.h"
17 #include "debug/event.h"
19 namespace Inkscape {
21 namespace Debug {
23 template <Event::Category C=Event::OTHER>
24 class SimpleEvent : public Event {
25 public:
26     explicit SimpleEvent(Util::ptr_shared<char> name) : _name(name) {}
27     explicit SimpleEvent(char const *name) : _name(Util::share_string(name)) {}
29     // default copy
30     // default assign
32     static Category category() { return C; }
34     Util::ptr_shared<char> name() const { return _name; }
35     unsigned propertyCount() const { return _properties.size(); }
36     PropertyPair property(unsigned property) const {
37         return _properties[property];
38     }
40 protected:
41     void _addProperty(Util::ptr_shared<char> name,
42                       Util::ptr_shared<char> value)
43     {
44         _properties.push_back(PropertyPair(name, value));
45     }
46     void _addProperty(Util::ptr_shared<char> name, char const *value) {
47         _addProperty(name, Util::share_string(value));
48     }
49     void _addProperty(char const *name, Util::ptr_shared<char> value) {
50         _addProperty(Util::share_string(name), value);
51     }
52     void _addProperty(char const *name, char const *value) {
53         _addProperty(Util::share_string(name), Util::share_string(value));
54     }
56 private:
57     Util::ptr_shared<char> _name;
58     std::vector<PropertyPair, GC::Alloc<PropertyPair, GC::AUTO> > _properties;
59 };
61 }
63 }
65 #endif
66 /*
67   Local Variables:
68   mode:c++
69   c-file-style:"stroustrup"
70   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
71   indent-tabs-mode:nil
72   fill-column:99
73   End:
74 */
75 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :