From 33fd2b5e1889347c1d89df515e81c4460ccfc789 Mon Sep 17 00:00:00 2001 From: twanvl Date: Fri, 11 May 2007 21:34:53 +0000 Subject: [PATCH] default smart pointer type switched to intrusive_ptr git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@337 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/data/action/set.cpp | 7 +++ src/data/action/set.hpp | 6 +- src/data/action/symbol_part.cpp | 6 +- src/data/action/value.cpp | 2 +- src/data/card.cpp | 1 + src/data/card.hpp | 2 +- src/data/field.cpp | 18 +++--- src/data/field.hpp | 16 +++--- src/data/field/boolean.cpp | 4 +- src/data/field/choice.hpp | 4 +- src/data/field/color.hpp | 4 +- src/data/field/symbol.cpp | 3 +- src/data/field/symbol.hpp | 3 +- src/data/field/text.hpp | 2 +- src/data/font.cpp | 2 +- src/data/font.hpp | 2 +- src/data/format/apprentice.cpp | 6 +- src/data/format/formats.hpp | 2 +- src/data/format/image.cpp | 4 +- src/data/format/image_to_symbol.cpp | 2 +- src/data/format/mse1.cpp | 2 +- src/data/format/mse2.cpp | 2 +- src/data/format/mtg_editor.cpp | 6 +- src/data/game.cpp | 20 +++---- src/data/keyword.hpp | 8 +-- src/data/locale.cpp | 4 +- src/data/locale.hpp | 2 +- src/data/pack.hpp | 4 +- src/data/set.cpp | 14 +++-- src/data/set.hpp | 7 ++- src/data/settings.cpp | 4 +- src/data/settings.hpp | 4 +- src/data/statistics.cpp | 4 +- src/data/statistics.hpp | 4 +- src/data/symbol.cpp | 16 +++--- src/data/symbol.hpp | 6 +- src/data/symbol_font.cpp | 2 +- src/data/symbol_font.hpp | 2 +- src/gfx/generated_image.cpp | 5 ++ src/gfx/generated_image.hpp | 8 +-- src/gfx/gfx.hpp | 2 +- src/gui/control/card_editor.cpp | 2 +- src/gui/control/card_list.hpp | 4 +- src/gui/control/filtered_card_list.hpp | 2 +- src/gui/control/graph.cpp | 16 +++--- src/gui/control/graph.hpp | 11 ++-- src/gui/control/image_card_list.cpp | 2 +- src/gui/control/item_list.hpp | 2 +- src/gui/control/package_list.hpp | 4 +- src/gui/control/select_card_list.cpp | 2 + src/gui/control/select_card_list.hpp | 1 + src/gui/control/text_ctrl.cpp | 3 +- src/gui/control/text_ctrl.hpp | 1 + src/gui/new_window.cpp | 2 +- src/gui/print_window.cpp | 13 +++-- src/gui/print_window.hpp | 2 +- src/gui/set/cards_panel.cpp | 4 +- src/gui/set/keywords_panel.cpp | 8 +-- src/gui/set/panel.cpp | 5 ++ src/gui/set/panel.hpp | 4 +- src/gui/set/stats_panel.cpp | 4 +- src/gui/set/style_panel.cpp | 14 ++--- src/gui/set/window.cpp | 2 +- src/gui/symbol/basic_shape_editor.cpp | 24 ++++---- src/gui/symbol/control.cpp | 16 +++--- src/gui/symbol/editor.hpp | 2 +- src/gui/thumbnail_thread.cpp | 2 +- src/gui/thumbnail_thread.hpp | 2 +- src/gui/update_checker.cpp | 4 +- src/gui/value/choice.cpp | 2 +- src/gui/value/choice.hpp | 2 +- src/gui/value/color.hpp | 2 +- src/gui/value/image.cpp | 2 +- src/gui/welcome_window.cpp | 4 +- src/render/card/viewer.cpp | 7 ++- src/render/card/viewer.hpp | 5 +- src/render/symbol/filter.cpp | 12 ++-- src/render/symbol/filter.hpp | 4 +- src/render/text/element.cpp | 4 +- src/render/text/element.hpp | 3 +- src/render/text/viewer.cpp | 2 +- src/render/value/color.cpp | 2 +- src/render/value/image.cpp | 2 +- src/render/value/viewer.hpp | 2 +- src/resource/msw/mse.rc | 6 +- src/script/functions/basic.cpp | 1 + src/script/functions/image.cpp | 3 +- src/script/script.hpp | 2 +- src/script/script_manager.cpp | 10 ++-- src/script/script_manager.hpp | 2 +- src/script/scriptable.hpp | 2 +- src/script/to_value.hpp | 2 +- src/script/value.hpp | 4 +- src/util/io/get_member.hpp | 10 +++- src/util/io/package.cpp | 4 +- src/util/io/package.hpp | 4 +- src/util/io/package_manager.cpp | 12 ++-- src/util/io/package_manager.hpp | 6 +- src/util/io/reader.hpp | 14 +++-- src/util/io/writer.hpp | 10 +++- src/util/order_cache.hpp | 2 +- src/util/reflect.hpp | 18 +++++- src/util/smart_ptr.hpp | 77 +++++++++++++++++++++----- 103 files changed, 368 insertions(+), 256 deletions(-) diff --git a/src/data/action/set.cpp b/src/data/action/set.cpp index 7b06a499..1f91ea8c 100644 --- a/src/data/action/set.cpp +++ b/src/data/action/set.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include // ----------------------------------------------------------------------------- : Add card @@ -89,6 +90,9 @@ void DisplayChangeAction::perform(bool to_undo) { } +ChangeCardStyleAction::ChangeCardStyleAction(const CardP& card, const StyleSheetP& stylesheet) + : card(card), stylesheet(stylesheet) +{} String ChangeCardStyleAction::getName(bool to_undo) const { return _("Change style"); } @@ -97,6 +101,9 @@ void ChangeCardStyleAction::perform(bool to_undo) { } +ChangeSetStyleAction::ChangeSetStyleAction(Set& set, const CardP& card) + : set(set), card(card) +{} String ChangeSetStyleAction::getName(bool to_undo) const { return _("Change style (all cards)"); } diff --git a/src/data/action/set.hpp b/src/data/action/set.hpp index 7c36110a..2811655e 100644 --- a/src/data/action/set.hpp +++ b/src/data/action/set.hpp @@ -87,8 +87,7 @@ class DisplayChangeAction : public Action { /// Changing the style of a a card class ChangeCardStyleAction : public DisplayChangeAction { public: - ChangeCardStyleAction(const CardP& card, const StyleSheetP& stylesheet) - : card(card), stylesheet(stylesheet) {} + ChangeCardStyleAction(const CardP& card, const StyleSheetP& stylesheet); virtual String getName(bool to_undo) const; virtual void perform(bool to_undo); @@ -101,8 +100,7 @@ class ChangeCardStyleAction : public DisplayChangeAction { /// Changing the style of a set to that of a card class ChangeSetStyleAction : public DisplayChangeAction { public: - ChangeSetStyleAction(Set& set, const CardP& card) - : set(set), card(card) {} + ChangeSetStyleAction(Set& set, const CardP& card); virtual String getName(bool to_undo) const; virtual void perform(bool to_undo); diff --git a/src/data/action/symbol_part.cpp b/src/data/action/symbol_part.cpp index 8999d778..e612dc66 100644 --- a/src/data/action/symbol_part.cpp +++ b/src/data/action/symbol_part.cpp @@ -289,7 +289,7 @@ double ssqrt(double x) { } // Remove a single control point -class SinglePointRemoveAction : public Action { +class SinglePointRemoveAction : public Action, public IntrusivePtrBase { public: SinglePointRemoveAction(const SymbolPartP& part, UInt position); @@ -393,7 +393,7 @@ ControlPointRemoveAction::ControlPointRemoveAction(const SymbolPartP& part, cons FOR_EACH(point, part->points) { if (toDelete.find(point) != toDelete.end()) { // remove this point - removals.push_back(new_shared2(part, index)); + removals.push_back(new_intrusive2(part, index)); } ++index; } @@ -417,7 +417,7 @@ void ControlPointRemoveAction::perform(bool to_undo) { Action* controlPointRemoveAction(const SymbolPartP& part, const set& toDelete) { if (part->points.size() - toDelete.size() < 2) { // TODO : remove part? - //new_shared(part); + //new_intrusive(part); return 0; // no action } else { return new ControlPointRemoveAction(part, toDelete); diff --git a/src/data/action/value.cpp b/src/data/action/value.cpp index 62769352..5be3361b 100644 --- a/src/data/action/value.cpp +++ b/src/data/action/value.cpp @@ -36,7 +36,7 @@ inline void swap_value(TextValue& a, TextValue ::ValueType& b template class SimpleValueAction : public ValueAction { public: - inline SimpleValueAction(const shared_ptr& value, const typename T::ValueType& new_value) + inline SimpleValueAction(const intrusive_ptr& value, const typename T::ValueType& new_value) : ValueAction(value), new_value(new_value) {} diff --git a/src/data/card.cpp b/src/data/card.cpp index d6824356..c9882286 100644 --- a/src/data/card.cpp +++ b/src/data/card.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include diff --git a/src/data/card.hpp b/src/data/card.hpp index 287438ba..6076cbc9 100644 --- a/src/data/card.hpp +++ b/src/data/card.hpp @@ -24,7 +24,7 @@ DECLARE_POINTER_TYPE(StyleSheet); // ----------------------------------------------------------------------------- : Card /// A card from a card Set -class Card { +class Card : public IntrusivePtrVirtualBase { public: /// Default constructor, uses game_for_new_cards to make the game Card(); diff --git a/src/data/field.cpp b/src/data/field.cpp index c1a41791..eb09cf6c 100644 --- a/src/data/field.cpp +++ b/src/data/field.cpp @@ -61,18 +61,18 @@ IMPLEMENT_REFLECTION(Field) { } template <> -shared_ptr read_new(Reader& reader) { +intrusive_ptr read_new(Reader& reader) { // there must be a type specified String type; reader.handle(_("type"), type); - if (type == _("text")) return new_shared(); - else if (type == _("choice")) return new_shared(); - else if (type == _("multiple choice")) return new_shared(); - else if (type == _("boolean")) return new_shared(); - else if (type == _("image")) return new_shared(); - else if (type == _("symbol")) return new_shared(); - else if (type == _("color")) return new_shared(); - else if (type == _("info")) return new_shared(); + if (type == _("text")) return new_intrusive(); + else if (type == _("choice")) return new_intrusive(); + else if (type == _("multiple choice")) return new_intrusive(); + else if (type == _("boolean")) return new_intrusive(); + else if (type == _("image")) return new_intrusive(); + else if (type == _("symbol")) return new_intrusive(); + else if (type == _("color")) return new_intrusive(); + else if (type == _("info")) return new_intrusive(); else { throw ParseError(_("Unsupported field type: '") + type + _("'")); } diff --git a/src/data/field.hpp b/src/data/field.hpp index 096a1049..97a6ad8b 100644 --- a/src/data/field.hpp +++ b/src/data/field.hpp @@ -32,7 +32,7 @@ DECLARE_POINTER_TYPE(ValueEditor); // ----------------------------------------------------------------------------- : Field /// Information on how to store a value -class Field { +class Field : public IntrusivePtrVirtualBase { public: Field(); virtual ~Field(); @@ -71,7 +71,7 @@ class Field { }; template <> -shared_ptr read_new(Reader& reader); +intrusive_ptr read_new(Reader& reader); inline void update_index(FieldP& f, size_t index) { f->index = index; } @@ -79,7 +79,7 @@ inline void update_index(FieldP& f, size_t index) { // ----------------------------------------------------------------------------- : Style /// Style information needed to display a Value in a Field. -class Style { +class Style : public IntrusivePtrVirtualBase { public: Style(const FieldP&); virtual ~Style(); @@ -134,7 +134,7 @@ template <> StyleP read_new