eb68f40b6af2b3771b28944fb391e50cda5edf59
1 /**
2 * Inkscape::Whiteboard::KeyNodeTable - structure for lookup of values from keys
3 * and vice versa
4 *
5 * Authors:
6 * Bob Jamison
7 *
8 * Copyright (c) 2005 Authors
9 */
10 #ifndef __KEY_NODE_H__
11 #define __KEY_NODE_H__
13 #include <glibmm.h>
15 #include <vector>
17 #include "xml/node.h"
20 namespace Inkscape
21 {
22 namespace Whiteboard
23 {
26 class KeyNodePair
27 {
28 public:
29 KeyNodePair(const Glib::ustring &keyArg, const XML::Node *nodeArg)
30 {
31 key = keyArg;
32 node = (XML::Node *)nodeArg;
33 }
34 KeyNodePair(const KeyNodePair &other)
35 {
36 key = other.key;
37 node = other.node;
38 }
39 virtual ~KeyNodePair()
40 {}
41 Glib::ustring key;
42 XML::Node *node;
43 };
45 class KeyNodeTable
46 {
47 public:
49 KeyNodeTable()
50 {}
52 KeyNodeTable(const KeyNodeTable &other)
53 {
54 items = other.items;
55 }
57 virtual ~KeyNodeTable()
58 {}
60 virtual void clear();
62 virtual void append(const KeyNodeTable &other);
64 virtual void put(const KeyNodePair &pair);
66 virtual void put(const Glib::ustring &key, const XML::Node *node);
68 virtual XML::Node * get(const Glib::ustring &key) const;
70 virtual void remove(const Glib::ustring &key);
72 virtual Glib::ustring get(XML::Node *node) const;
74 virtual void remove(XML::Node *node);
76 virtual unsigned int size() const;
78 virtual KeyNodePair item(unsigned int index) const;
80 virtual Glib::ustring generateKey(Glib::ustring);
82 private:
84 std::vector<KeyNodePair> items;
86 unsigned int counter;
88 };
92 } // namespace Whiteboard
94 } // namespace Inkscape
97 #endif /* __KEY_NODE_H__ */