From 11ee3ba6de191d0f1b48f9b7f982ca7c3e6e42e4 Mon Sep 17 00:00:00 2001 From: MenTaLguY Date: Sat, 29 Apr 2006 19:21:13 +0000 Subject: make Debug::SimpleEvent more convenient (bzr r629) --- src/debug/event.h | 1 + src/debug/logger.cpp | 1 + src/debug/simple-event.h | 87 ++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 86 insertions(+), 3 deletions(-) (limited to 'src/debug') diff --git a/src/debug/event.h b/src/debug/event.h index fdc50f225..54ac31476 100644 --- a/src/debug/event.h +++ b/src/debug/event.h @@ -30,6 +30,7 @@ public: DOCUMENT, REFCOUNT, EXTENSION, + FINALIZERS, OTHER }; enum { N_CATEGORIES=OTHER+1 }; diff --git a/src/debug/logger.cpp b/src/debug/logger.cpp index f28d1526b..fc83e89df 100644 --- a/src/debug/logger.cpp +++ b/src/debug/logger.cpp @@ -104,6 +104,7 @@ static void set_category_mask(bool * const mask, char const *filter) { { "DOCUMENT", Event::DOCUMENT }, { "REFCOUNT", Event::REFCOUNT }, { "EXTENSION", Event::EXTENSION }, + { "FINALIZERS", Event::FINALIZERS }, { "OTHER", Event::OTHER }, { NULL, Event::OTHER } }; diff --git a/src/debug/simple-event.h b/src/debug/simple-event.h index 3695eaa6a..cb4e85016 100644 --- a/src/debug/simple-event.h +++ b/src/debug/simple-event.h @@ -12,6 +12,8 @@ #ifndef SEEN_INKSCAPE_DEBUG_SIMPLE_EVENT_H #define SEEN_INKSCAPE_DEBUG_SIMPLE_EVENT_H +#include +#include "gc-alloc.h" #include "debug/event.h" namespace Inkscape { @@ -21,17 +23,96 @@ namespace Debug { template class SimpleEvent : public Event { public: - SimpleEvent(Util::ptr_shared name) : _name(name) {} SimpleEvent(char const *name) : _name(Util::share_string(name)) {} static Category category() { return C; } Util::ptr_shared name() const { return _name; } - unsigned propertyCount() const { return 0; } - PropertyPair property(unsigned property) const { return PropertyPair(); } + unsigned propertyCount() const { return _properties.size(); } + PropertyPair property(unsigned property) const { + return _properties[property]; + } + +protected: + SimpleEvent(char const *name, + char const *attr0, char const *value0) + : _name(Util::share_string(name)) + { + _addProperty(attr0, value0); + } + + SimpleEvent(char const *name, + char const *attr0, char const *value0, + char const *attr1, char const *value1) + : _name(Util::share_string(name)) + { + _addProperty(attr0, value0); + _addProperty(attr1, value1); + } + + SimpleEvent(char const *name, + char const *attr0, char const *value0, + char const *attr1, char const *value1, + char const *attr2, char const *value2) + : _name(Util::share_string(name)) + { + _addProperty(attr0, value0); + _addProperty(attr1, value1); + _addProperty(attr2, value2); + } + + SimpleEvent(char const *name, + char const *attr0, char const *value0, + char const *attr1, char const *value1, + char const *attr2, char const *value2, + char const *attr3, char const *value3) + : _name(Util::share_string(name)) + { + _addProperty(attr0, value0); + _addProperty(attr1, value1); + _addProperty(attr2, value2); + _addProperty(attr3, value3); + } + + SimpleEvent(char const *name, + char const *attr0, char const *value0, + char const *attr1, char const *value1, + char const *attr2, char const *value2, + char const *attr3, char const *value3, + char const *attr4, char const *value4) + : _name(Util::share_string(name)) + { + _addProperty(attr0, value0); + _addProperty(attr1, value1); + _addProperty(attr2, value2); + _addProperty(attr3, value3); + _addProperty(attr4, value4); + } + + SimpleEvent(char const *name, + char const *attr0, char const *value0, + char const *attr1, char const *value1, + char const *attr2, char const *value2, + char const *attr3, char const *value3, + char const *attr4, char const *value4, + char const *attr5, char const *value5) + : _name(Util::share_string(name)) + { + _addProperty(attr0, value0); + _addProperty(attr1, value1); + _addProperty(attr2, value2); + _addProperty(attr3, value3); + _addProperty(attr4, value4); + _addProperty(attr5, value5); + } + + void _addProperty(char const *name, char const *value) { + _properties.push_back(PropertyPair(name, value)); + } private: Util::ptr_shared _name; + std::vector > _properties; }; } -- cgit v1.2.3