Commit 7df019db authored by twanvl's avatar twanvl

default smart pointer type switched to intrusive_ptr

parent 42e66d0d
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <data/action/set.hpp> #include <data/action/set.hpp>
#include <data/set.hpp> #include <data/set.hpp>
#include <data/card.hpp> #include <data/card.hpp>
#include <data/stylesheet.hpp>
#include <util/error.hpp> #include <util/error.hpp>
// ----------------------------------------------------------------------------- : Add card // ----------------------------------------------------------------------------- : Add card
...@@ -89,6 +90,9 @@ void DisplayChangeAction::perform(bool to_undo) { ...@@ -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 { String ChangeCardStyleAction::getName(bool to_undo) const {
return _("Change style"); return _("Change style");
} }
...@@ -97,6 +101,9 @@ void ChangeCardStyleAction::perform(bool to_undo) { ...@@ -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 { String ChangeSetStyleAction::getName(bool to_undo) const {
return _("Change style (all cards)"); return _("Change style (all cards)");
} }
......
...@@ -87,8 +87,7 @@ class DisplayChangeAction : public Action { ...@@ -87,8 +87,7 @@ class DisplayChangeAction : public Action {
/// Changing the style of a a card /// Changing the style of a a card
class ChangeCardStyleAction : public DisplayChangeAction { class ChangeCardStyleAction : public DisplayChangeAction {
public: public:
ChangeCardStyleAction(const CardP& card, const StyleSheetP& stylesheet) ChangeCardStyleAction(const CardP& card, const StyleSheetP& stylesheet);
: card(card), stylesheet(stylesheet) {}
virtual String getName(bool to_undo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool to_undo); virtual void perform(bool to_undo);
...@@ -101,8 +100,7 @@ class ChangeCardStyleAction : public DisplayChangeAction { ...@@ -101,8 +100,7 @@ class ChangeCardStyleAction : public DisplayChangeAction {
/// Changing the style of a set to that of a card /// Changing the style of a set to that of a card
class ChangeSetStyleAction : public DisplayChangeAction { class ChangeSetStyleAction : public DisplayChangeAction {
public: public:
ChangeSetStyleAction(Set& set, const CardP& card) ChangeSetStyleAction(Set& set, const CardP& card);
: set(set), card(card) {}
virtual String getName(bool to_undo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool to_undo); virtual void perform(bool to_undo);
......
...@@ -289,7 +289,7 @@ double ssqrt(double x) { ...@@ -289,7 +289,7 @@ double ssqrt(double x) {
} }
// Remove a single control point // Remove a single control point
class SinglePointRemoveAction : public Action { class SinglePointRemoveAction : public Action, public IntrusivePtrBase<SinglePointRemoveAction> {
public: public:
SinglePointRemoveAction(const SymbolPartP& part, UInt position); SinglePointRemoveAction(const SymbolPartP& part, UInt position);
...@@ -393,7 +393,7 @@ ControlPointRemoveAction::ControlPointRemoveAction(const SymbolPartP& part, cons ...@@ -393,7 +393,7 @@ ControlPointRemoveAction::ControlPointRemoveAction(const SymbolPartP& part, cons
FOR_EACH(point, part->points) { FOR_EACH(point, part->points) {
if (toDelete.find(point) != toDelete.end()) { if (toDelete.find(point) != toDelete.end()) {
// remove this point // remove this point
removals.push_back(new_shared2<SinglePointRemoveAction>(part, index)); removals.push_back(new_intrusive2<SinglePointRemoveAction>(part, index));
} }
++index; ++index;
} }
...@@ -417,7 +417,7 @@ void ControlPointRemoveAction::perform(bool to_undo) { ...@@ -417,7 +417,7 @@ void ControlPointRemoveAction::perform(bool to_undo) {
Action* controlPointRemoveAction(const SymbolPartP& part, const set<ControlPointP>& toDelete) { Action* controlPointRemoveAction(const SymbolPartP& part, const set<ControlPointP>& toDelete) {
if (part->points.size() - toDelete.size() < 2) { if (part->points.size() - toDelete.size() < 2) {
// TODO : remove part? // TODO : remove part?
//new_shared<ControlPointRemoveAllAction>(part); //new_intrusive<ControlPointRemoveAllAction>(part);
return 0; // no action return 0; // no action
} else { } else {
return new ControlPointRemoveAction(part, toDelete); return new ControlPointRemoveAction(part, toDelete);
......
...@@ -36,7 +36,7 @@ inline void swap_value(TextValue& a, TextValue ::ValueType& b ...@@ -36,7 +36,7 @@ inline void swap_value(TextValue& a, TextValue ::ValueType& b
template <typename T, bool ALLOW_MERGE> template <typename T, bool ALLOW_MERGE>
class SimpleValueAction : public ValueAction { class SimpleValueAction : public ValueAction {
public: public:
inline SimpleValueAction(const shared_ptr<T>& value, const typename T::ValueType& new_value) inline SimpleValueAction(const intrusive_ptr<T>& value, const typename T::ValueType& new_value)
: ValueAction(value), new_value(new_value) : ValueAction(value), new_value(new_value)
{} {}
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <data/card.hpp> #include <data/card.hpp>
#include <data/game.hpp> #include <data/game.hpp>
#include <data/stylesheet.hpp>
#include <data/field.hpp> #include <data/field.hpp>
#include <util/error.hpp> #include <util/error.hpp>
#include <util/reflect.hpp> #include <util/reflect.hpp>
......
...@@ -24,7 +24,7 @@ DECLARE_POINTER_TYPE(StyleSheet); ...@@ -24,7 +24,7 @@ DECLARE_POINTER_TYPE(StyleSheet);
// ----------------------------------------------------------------------------- : Card // ----------------------------------------------------------------------------- : Card
/// A card from a card Set /// A card from a card Set
class Card { class Card : public IntrusivePtrVirtualBase {
public: public:
/// Default constructor, uses game_for_new_cards to make the game /// Default constructor, uses game_for_new_cards to make the game
Card(); Card();
......
...@@ -61,18 +61,18 @@ IMPLEMENT_REFLECTION(Field) { ...@@ -61,18 +61,18 @@ IMPLEMENT_REFLECTION(Field) {
} }
template <> template <>
shared_ptr<Field> read_new<Field>(Reader& reader) { intrusive_ptr<Field> read_new<Field>(Reader& reader) {
// there must be a type specified // there must be a type specified
String type; String type;
reader.handle(_("type"), type); reader.handle(_("type"), type);
if (type == _("text")) return new_shared<TextField>(); if (type == _("text")) return new_intrusive<TextField>();
else if (type == _("choice")) return new_shared<ChoiceField>(); else if (type == _("choice")) return new_intrusive<ChoiceField>();
else if (type == _("multiple choice")) return new_shared<MultipleChoiceField>(); else if (type == _("multiple choice")) return new_intrusive<MultipleChoiceField>();
else if (type == _("boolean")) return new_shared<BooleanField>(); else if (type == _("boolean")) return new_intrusive<BooleanField>();
else if (type == _("image")) return new_shared<ImageField>(); else if (type == _("image")) return new_intrusive<ImageField>();
else if (type == _("symbol")) return new_shared<SymbolField>(); else if (type == _("symbol")) return new_intrusive<SymbolField>();
else if (type == _("color")) return new_shared<ColorField>(); else if (type == _("color")) return new_intrusive<ColorField>();
else if (type == _("info")) return new_shared<InfoField>(); else if (type == _("info")) return new_intrusive<InfoField>();
else { else {
throw ParseError(_("Unsupported field type: '") + type + _("'")); throw ParseError(_("Unsupported field type: '") + type + _("'"));
} }
......
...@@ -32,7 +32,7 @@ DECLARE_POINTER_TYPE(ValueEditor); ...@@ -32,7 +32,7 @@ DECLARE_POINTER_TYPE(ValueEditor);
// ----------------------------------------------------------------------------- : Field // ----------------------------------------------------------------------------- : Field
/// Information on how to store a value /// Information on how to store a value
class Field { class Field : public IntrusivePtrVirtualBase {
public: public:
Field(); Field();
virtual ~Field(); virtual ~Field();
...@@ -71,7 +71,7 @@ class Field { ...@@ -71,7 +71,7 @@ class Field {
}; };
template <> template <>
shared_ptr<Field> read_new<Field>(Reader& reader); intrusive_ptr<Field> read_new<Field>(Reader& reader);
inline void update_index(FieldP& f, size_t index) { inline void update_index(FieldP& f, size_t index) {
f->index = index; f->index = index;
} }
...@@ -79,7 +79,7 @@ inline void update_index(FieldP& f, size_t index) { ...@@ -79,7 +79,7 @@ inline void update_index(FieldP& f, size_t index) {
// ----------------------------------------------------------------------------- : Style // ----------------------------------------------------------------------------- : Style
/// Style information needed to display a Value in a Field. /// Style information needed to display a Value in a Field.
class Style { class Style : public IntrusivePtrVirtualBase {
public: public:
Style(const FieldP&); Style(const FieldP&);
virtual ~Style(); virtual ~Style();
...@@ -134,7 +134,7 @@ template <> StyleP read_new<Style>(Reader&); ...@@ -134,7 +134,7 @@ template <> StyleP read_new<Style>(Reader&);
// ----------------------------------------------------------------------------- : StyleListener // ----------------------------------------------------------------------------- : StyleListener
/// An object that can respond when a style changes; /// An object that can respond when a style changes;
class StyleListener { class StyleListener : public IntrusivePtrVirtualBase {
public: public:
StyleListener(const StyleP& style); StyleListener(const StyleP& style);
virtual ~StyleListener(); virtual ~StyleListener();
...@@ -148,7 +148,7 @@ class StyleListener { ...@@ -148,7 +148,7 @@ class StyleListener {
// ----------------------------------------------------------------------------- : Value // ----------------------------------------------------------------------------- : Value
/// A specific value 'in' a Field. /// A specific value 'in' a Field.
class Value { class Value : public IntrusivePtrVirtualBase {
public: public:
inline Value(const FieldP& field) : fieldP(field) {} inline Value(const FieldP& field) : fieldP(field) {}
virtual ~Value(); virtual ~Value();
...@@ -189,14 +189,14 @@ template <> ValueP read_new<Value>(Reader&); ...@@ -189,14 +189,14 @@ template <> ValueP read_new<Value>(Reader&);
#define IMPLEMENT_FIELD_TYPE(Type) \ #define IMPLEMENT_FIELD_TYPE(Type) \
StyleP Type ## Field::newStyle(const FieldP& thisP) const { \ StyleP Type ## Field::newStyle(const FieldP& thisP) const { \
assert(thisP.get() == this); \ assert(thisP.get() == this); \
return new_shared1<Type ## Style>(static_pointer_cast<Type ## Field>(thisP)); \ return new_intrusive1<Type ## Style>(static_pointer_cast<Type ## Field>(thisP));\
} \ } \
ValueP Type ## Field::newValue(const FieldP& thisP) const { \ ValueP Type ## Field::newValue(const FieldP& thisP) const { \
assert(thisP.get() == this); \ assert(thisP.get() == this); \
return new_shared1<Type ## Value>(static_pointer_cast<Type ## Field>(thisP)); \ return new_intrusive1<Type ## Value>(static_pointer_cast<Type ## Field>(thisP));\
} \ } \
StyleP Type ## Style::clone() const { \ StyleP Type ## Style::clone() const { \
return new_shared1<Type ## Style>(*this); \ return new_intrusive1<Type ## Style>(*this); \
} }
#define DECLARE_STYLE_TYPE(Type) \ #define DECLARE_STYLE_TYPE(Type) \
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
// ----------------------------------------------------------------------------- : BooleanField // ----------------------------------------------------------------------------- : BooleanField
BooleanField::BooleanField() { BooleanField::BooleanField() {
choices->choices.push_back(new_shared1<Choice>(_("yes"))); choices->choices.push_back(new_intrusive1<Choice>(_("yes")));
choices->choices.push_back(new_shared1<Choice>(_("no"))); choices->choices.push_back(new_intrusive1<Choice>(_("no")));
choices->initIds(); choices->initIds();
} }
......
...@@ -30,7 +30,7 @@ class ChoiceField : public Field { ...@@ -30,7 +30,7 @@ class ChoiceField : public Field {
DECLARE_FIELD_TYPE(Choice); DECLARE_FIELD_TYPE(Choice);
class Choice; class Choice;
typedef shared_ptr<Choice> ChoiceP; typedef intrusive_ptr<Choice> ChoiceP;
ChoiceP choices; ///< A choice group of possible choices ChoiceP choices; ///< A choice group of possible choices
OptionalScript script; ///< Script to apply to all values OptionalScript script; ///< Script to apply to all values
...@@ -47,7 +47,7 @@ class ChoiceField : public Field { ...@@ -47,7 +47,7 @@ class ChoiceField : public Field {
}; };
/// An item that can be chosen for this field /// An item that can be chosen for this field
class ChoiceField::Choice { class ChoiceField::Choice : public IntrusivePtrBase<ChoiceField::Choice> {
public: public:
Choice(); Choice();
Choice(const String& name); Choice(const String& name);
......
...@@ -27,7 +27,7 @@ class ColorField : public Field { ...@@ -27,7 +27,7 @@ class ColorField : public Field {
DECLARE_FIELD_TYPE(Color); DECLARE_FIELD_TYPE(Color);
class Choice; class Choice;
typedef shared_ptr<Choice> ChoiceP; typedef intrusive_ptr<Choice> ChoiceP;
OptionalScript script; ///< Script to apply to all values OptionalScript script; ///< Script to apply to all values
OptionalScript default_script; ///< Script that generates the default value OptionalScript default_script; ///< Script that generates the default value
...@@ -42,7 +42,7 @@ class ColorField : public Field { ...@@ -42,7 +42,7 @@ class ColorField : public Field {
}; };
/// A color that can be chosen for this field /// A color that can be chosen for this field
class ColorField::Choice { class ColorField::Choice : public IntrusivePtrBase<ColorField::Choice> {
public: public:
String name; ///< Name of the color String name; ///< Name of the color
Color color; ///< The actual color Color color; ///< The actual color
......
...@@ -32,8 +32,9 @@ IMPLEMENT_REFLECTION(SymbolStyle) { ...@@ -32,8 +32,9 @@ IMPLEMENT_REFLECTION(SymbolStyle) {
SymbolVariation::SymbolVariation() SymbolVariation::SymbolVariation()
: border_radius(0.05) : border_radius(0.05)
{} {}
SymbolVariation::~SymbolVariation() {}
IMPLEMENT_REFLECTION(SymbolVariation) { IMPLEMENT_REFLECTION_NO_SCRIPT(SymbolVariation) {
REFLECT(name); REFLECT(name);
REFLECT(border_radius); REFLECT(border_radius);
REFLECT_NAMELESS(filter); REFLECT_NAMELESS(filter);
......
...@@ -47,9 +47,10 @@ class SymbolStyle : public Style { ...@@ -47,9 +47,10 @@ class SymbolStyle : public Style {
}; };
/// Styling for a symbol variation, defines color, border, etc. /// Styling for a symbol variation, defines color, border, etc.
class SymbolVariation { class SymbolVariation : public IntrusivePtrBase<SymbolVariation> {
public: public:
SymbolVariation(); SymbolVariation();
~SymbolVariation();
String name; ///< Name of this variation String name; ///< Name of this variation
SymbolFilterP filter; ///< Filter to color the symbol SymbolFilterP filter; ///< Filter to color the symbol
double border_radius; ///< Border radius for the symbol double border_radius; ///< Border radius for the symbol
......
...@@ -48,7 +48,7 @@ class TextField : public Field { ...@@ -48,7 +48,7 @@ class TextField : public Field {
// ----------------------------------------------------------------------------- : TextStyle // ----------------------------------------------------------------------------- : TextStyle
/// Background behind text /// Background behind text
class TextBackground { class TextBackground : public IntrusivePtrBase<TextBackground> {
public: public:
ScriptableImage image; ///< background image, stretched to text size ScriptableImage image; ///< background image, stretched to text size
RealSize displacement; RealSize displacement;
......
...@@ -79,7 +79,7 @@ wxFont Font::toWxFont(double scale) const { ...@@ -79,7 +79,7 @@ wxFont Font::toWxFont(double scale) const {
} }
} }
IMPLEMENT_REFLECTION(Font) { IMPLEMENT_REFLECTION_NO_SCRIPT(Font) {
REFLECT(name); REFLECT(name);
REFLECT(size); REFLECT(size);
REFLECT(weight); REFLECT(weight);
......
...@@ -19,7 +19,7 @@ DECLARE_POINTER_TYPE(Font); ...@@ -19,7 +19,7 @@ DECLARE_POINTER_TYPE(Font);
/// A font for rendering text /// A font for rendering text
/** Contains additional information about scaling, color and shadow */ /** Contains additional information about scaling, color and shadow */
class Font { class Font : public IntrusivePtrBase<Font> {
public: public:
Scriptable<String> name; ///< Name of the font Scriptable<String> name; ///< Name of the font
Scriptable<String> italic_name; ///< Font name for italic text (optional) Scriptable<String> italic_name; ///< Font name for italic text (optional)
......
...@@ -383,7 +383,7 @@ class ApprCardDatabase : public ApprDatabase { ...@@ -383,7 +383,7 @@ class ApprCardDatabase : public ApprDatabase {
/** Each card has two records, a data record at the top of the file /** Each card has two records, a data record at the top of the file
* and a head record at the bottom * and a head record at the bottom
*/ */
class ApprCardRecord { class ApprCardRecord : public IntrusivePtrBase<ApprCardRecord> {
public: public:
String name, sets; String name, sets;
String type, cc, pt, text, flavor; String type, cc, pt, text, flavor;
...@@ -536,7 +536,7 @@ void ApprCardDatabase::doRead(wxInputStream& in) { ...@@ -536,7 +536,7 @@ void ApprCardDatabase::doRead(wxInputStream& in) {
progress_target->onProgress(0.4f * float(i) / cards.size(), progress_target->onProgress(0.4f * float(i) / cards.size(),
String(_("reading card ")) << i << _(" of ") << (int)cards.size()); String(_("reading card ")) << i << _(" of ") << (int)cards.size());
} }
card = new_shared<ApprCardRecord>(); card = new_intrusive<ApprCardRecord>();
card->readHead(data); card->readHead(data);
head_pos = in.TellI(); head_pos = in.TellI();
in.SeekI(card->data_pos); in.SeekI(card->data_pos);
...@@ -751,7 +751,7 @@ bool ApprenticeExportWindow::exportSet() { ...@@ -751,7 +751,7 @@ bool ApprenticeExportWindow::exportSet() {
cardlist.removeSet(set->apprentice_code); cardlist.removeSet(set->apprentice_code);
// add cards from set // add cards from set
FOR_EACH(card, set->cards) { FOR_EACH(card, set->cards) {
ApprCardRecordP rec = new_shared2<ApprCardRecord>(*card, set->apprentice_code); ApprCardRecordP rec = new_intrusive2<ApprCardRecord>(*card, set->apprentice_code);
cardlist.cards.push_back(rec); cardlist.cards.push_back(rec);
} }
cardlist.write(); cardlist.write();
......
...@@ -20,7 +20,7 @@ DECLARE_POINTER_TYPE(FileFormat); ...@@ -20,7 +20,7 @@ DECLARE_POINTER_TYPE(FileFormat);
// ----------------------------------------------------------------------------- : FileFormat // ----------------------------------------------------------------------------- : FileFormat
/// A filter for a specific file format /// A filter for a specific file format
class FileFormat { class FileFormat : public IntrusivePtrVirtualBase {
public: public:
virtual ~FileFormat() {} virtual ~FileFormat() {}
/// File extension used by this file format /// File extension used by this file format
......
...@@ -24,10 +24,8 @@ Bitmap export_bitmap(const SetP& set, const CardP& card) { ...@@ -24,10 +24,8 @@ Bitmap export_bitmap(const SetP& set, const CardP& card) {
DataViewer viewer; DataViewer viewer;
viewer.setSet(set); viewer.setSet(set);
viewer.setCard(card); viewer.setCard(card);
// style to use
StyleSheetP style = set->stylesheetFor(card);
// size of cards // size of cards
if (settings.stylesheetSettingsFor(*style).card_normal_export()) { if (settings.stylesheetSettingsFor(set->stylesheetFor(card)).card_normal_export()) {
// TODO // TODO
// viewer.rotation.angle = 0; // viewer.rotation.angle = 0;
// viewer.rotation.zoom = 1.0; // viewer.rotation.zoom = 1.0;
......
...@@ -179,7 +179,7 @@ SymbolPartP read_symbol_part(const ImageData& data) { ...@@ -179,7 +179,7 @@ SymbolPartP read_symbol_part(const ImageData& data) {
} }
// add to part and place a mark // add to part and place a mark
part->points.push_back(new_shared2<ControlPoint>( part->points.push_back(new_intrusive2<ControlPoint>(
double(x) / data.width, double(x) / data.width,
double(y) / data.height double(y) / data.height
)); ));
......
...@@ -29,7 +29,7 @@ class MSE1FileFormat : public FileFormat { ...@@ -29,7 +29,7 @@ class MSE1FileFormat : public FileFormat {
}; };
FileFormatP mse1_file_format() { FileFormatP mse1_file_format() {
return new_shared<MSE1FileFormat>(); return new_intrusive<MSE1FileFormat>();
} }
// ----------------------------------------------------------------------------- : Importing // ----------------------------------------------------------------------------- : Importing
......
...@@ -33,5 +33,5 @@ class MSE2FileFormat : public FileFormat { ...@@ -33,5 +33,5 @@ class MSE2FileFormat : public FileFormat {
}; };
FileFormatP mse2_file_format() { FileFormatP mse2_file_format() {
return new_shared<MSE2FileFormat>(); return new_intrusive<MSE2FileFormat>();
} }
...@@ -43,7 +43,7 @@ class MtgEditorFileFormat : public FileFormat { ...@@ -43,7 +43,7 @@ class MtgEditorFileFormat : public FileFormat {
}; };
FileFormatP mtg_editor_file_format() { FileFormatP mtg_editor_file_format() {
return new_shared<MtgEditorFileFormat>(); return new_intrusive<MtgEditorFileFormat>();
} }
// ----------------------------------------------------------------------------- : Importing // ----------------------------------------------------------------------------- : Importing
...@@ -68,7 +68,7 @@ SetP MtgEditorFileFormat::importSet(const String& filename) { ...@@ -68,7 +68,7 @@ SetP MtgEditorFileFormat::importSet(const String& filename) {
// read file // read file
while (!f.Eof()) { while (!f.Eof()) {
// read a line // read a line
if (!current_card) current_card = new_shared1<Card>(*set->game); if (!current_card) current_card = new_intrusive1<Card>(*set->game);
String line = file.ReadLine(); String line = file.ReadLine();
if (line == _("#SET###########")) { // set.title if (line == _("#SET###########")) { // set.title
target = &set->value<TextValue>(_("title")).value; target = &set->value<TextValue>(_("title")).value;
...@@ -103,7 +103,7 @@ SetP MtgEditorFileFormat::importSet(const String& filename) { ...@@ -103,7 +103,7 @@ SetP MtgEditorFileFormat::importSet(const String& filename) {
set->cards.push_back(current_card); set->cards.push_back(current_card);
} }
first = false; first = false;
current_card = new_shared1<Card>(*set->game); current_card = new_intrusive1<Card>(*set->game);
target = &current_card->value<TextValue>(_("name")).value; target = &current_card->value<TextValue>(_("name")).value;
} else if (line == _("#DATE##########")) { // date } else if (line == _("#DATE##########")) { // date
// remember date for generation of illustration filename // remember date for generation of illustration filename
......
...@@ -39,20 +39,20 @@ String Game::typeName() const { return _("game"); } ...@@ -39,20 +39,20 @@ String Game::typeName() const { return _("game"); }
IMPLEMENT_REFLECTION(Game) { IMPLEMENT_REFLECTION(Game) {
REFLECT_BASE(Packaged); REFLECT_BASE(Packaged);
REFLECT(init_script); REFLECT_NO_SCRIPT(init_script);
REFLECT(set_fields); REFLECT_NO_SCRIPT(set_fields);
REFLECT_IF_READING { REFLECT_IF_READING {
default_set_style.init(set_fields); default_set_style.init(set_fields);
} }
REFLECT(default_set_style); REFLECT_NO_SCRIPT(default_set_style);
REFLECT(card_fields); REFLECT_NO_SCRIPT(card_fields);
REFLECT(statistics_dimensions); REFLECT_NO_SCRIPT(statistics_dimensions);
REFLECT(statistics_categories); REFLECT_NO_SCRIPT(statistics_categories);
REFLECT(pack_types); REFLECT_NO_SCRIPT(pack_types);
REFLECT(has_keywords); REFLECT(has_keywords);
REFLECT(keyword_modes); REFLECT(keyword_modes);
REFLECT(keyword_parameter_types); REFLECT(keyword_parameter_types);
REFLECT(keywords); REFLECT_NO_SCRIPT(keywords);
// REFLECT(word_lists); // REFLECT(word_lists);
} }
...@@ -63,7 +63,7 @@ void Game::validate(Version v) { ...@@ -63,7 +63,7 @@ void Game::validate(Version v) {
vector<StatsDimensionP> dims; vector<StatsDimensionP> dims;
FOR_EACH(f, card_fields) { FOR_EACH(f, card_fields) {
if (f->show_statistics) { if (f->show_statistics) {
dims.push_back(new_shared1<StatsDimension>(*f)); dims.push_back(new_intrusive1<StatsDimension>(*f));
} }
} }
statistics_dimensions.insert(statistics_dimensions.begin(), dims.begin(), dims.end()); // push front statistics_dimensions.insert(statistics_dimensions.begin(), dims.begin(), dims.end()); // push front
...@@ -72,7 +72,7 @@ void Game::validate(Version v) { ...@@ -72,7 +72,7 @@ void Game::validate(Version v) {
{ {
vector<StatsCategoryP> cats; vector<StatsCategoryP> cats;
FOR_EACH(dim, statistics_dimensions) { FOR_EACH(dim, statistics_dimensions) {
cats.push_back(new_shared1<StatsCategory>(dim)); cats.push_back(new_intrusive1<StatsCategory>(dim));
} }
statistics_categories.insert(statistics_categories.begin(), cats.begin(), cats.end()); // push front statistics_categories.insert(statistics_categories.begin(), cats.begin(), cats.end()); // push front
} }
......
...@@ -21,7 +21,7 @@ class KeywordTrie; ...@@ -21,7 +21,7 @@ class KeywordTrie;
// ----------------------------------------------------------------------------- : Keyword parameters // ----------------------------------------------------------------------------- : Keyword parameters
class ParamReferenceType { class ParamReferenceType : public IntrusivePtrBase<ParamReferenceType> {
public: public:
String name; ///< Name of the parameter reference type String name; ///< Name of the parameter reference type
String description; ///< Description (for status bar) String description; ///< Description (for status bar)
...@@ -31,7 +31,7 @@ class ParamReferenceType { ...@@ -31,7 +31,7 @@ class ParamReferenceType {
}; };
/// Parameter type of keywords /// Parameter type of keywords
class KeywordParam { class KeywordParam : public IntrusivePtrBase<KeywordParam> {
public: public:
KeywordParam(); KeywordParam();
String name; ///< Name of the parameter type String name; ///< Name of the parameter type
...@@ -49,7 +49,7 @@ class KeywordParam { ...@@ -49,7 +49,7 @@ class KeywordParam {
// ----------------------------------------------------------------------------- : Keyword mode // ----------------------------------------------------------------------------- : Keyword mode
/// Information on when and how to use a keyword /// Information on when and how to use a keyword
class KeywordMode { class KeywordMode : public IntrusivePtrBase<KeywordMode> {
public: public:
KeywordMode() : is_default(false) {} KeywordMode() : is_default(false) {}
...@@ -63,7 +63,7 @@ class KeywordMode { ...@@ -63,7 +63,7 @@ class KeywordMode {
// ----------------------------------------------------------------------------- : Keyword expansion // ----------------------------------------------------------------------------- : Keyword expansion
/// A keyword for a set or a game /// A keyword for a set or a game
class Keyword { class Keyword : public IntrusivePtrVirtualBase {
public: public:
Keyword() : fixed(false), valid(false) {} Keyword() : fixed(false), valid(false) {}
......
...@@ -23,7 +23,7 @@ LocaleP Locale::byName(const String& name) { ...@@ -23,7 +23,7 @@ LocaleP Locale::byName(const String& name) {
return packages.open<Locale>(name + _(".mse-locale")); return packages.open<Locale>(name + _(".mse-locale"));
} }
IMPLEMENT_REFLECTION(Locale) { IMPLEMENT_REFLECTION_NO_SCRIPT(Locale) {
REFLECT_BASE(Packaged); REFLECT_BASE(Packaged);
REFLECT_N("menu", translations[LOCALE_CAT_MENU]); REFLECT_N("menu", translations[LOCALE_CAT_MENU]);
REFLECT_N("help", translations[LOCALE_CAT_HELP]); REFLECT_N("help", translations[LOCALE_CAT_HELP]);
...@@ -40,7 +40,7 @@ IMPLEMENT_REFLECTION(Locale) { ...@@ -40,7 +40,7 @@ IMPLEMENT_REFLECTION(Locale) {
REFLECT_N("symbol font", symbol_font_translations); REFLECT_N("symbol font", symbol_font_translations);
} }
IMPLEMENT_REFLECTION_NAMELESS(SubLocale) { IMPLEMENT_REFLECTION_NO_GET_MEMBER(SubLocale) {
REFLECT_NAMELESS(translations); REFLECT_NAMELESS(translations);
} }
......
...@@ -20,7 +20,7 @@ DECLARE_POINTER_TYPE(SubLocale); ...@@ -20,7 +20,7 @@ DECLARE_POINTER_TYPE(SubLocale);
// ----------------------------------------------------------------------------- : Locale class // ----------------------------------------------------------------------------- : Locale class
/// Translations of the texts of a game/stylesheet/symbolfont /// Translations of the texts of a game/stylesheet/symbolfont
class SubLocale { class SubLocale : public IntrusivePtrBase<SubLocale> {
public: public:
map<String,String> translations; map<String,String> translations;
......
...@@ -20,7 +20,7 @@ class Set; ...@@ -20,7 +20,7 @@ class Set;
// ----------------------------------------------------------------------------- : PackType // ----------------------------------------------------------------------------- : PackType
/// A card pack description for playtesting /// A card pack description for playtesting
class PackType { class PackType : public IntrusivePtrBase<PackType> {
public: public:
PackType(); PackType();
...@@ -38,7 +38,7 @@ class PackType { ...@@ -38,7 +38,7 @@ class PackType {
// ----------------------------------------------------------------------------- : CardType // ----------------------------------------------------------------------------- : CardType
/// A card type description for playtesting /// A card type description for playtesting
class CardType { class CardType : public IntrusivePtrBase<CardType> {
public: public:
String name; ///< Name of this type of cards String name; ///< Name of this type of cards
Scriptable<int> amount; ///< Number of cards of this type Scriptable<int> amount; ///< Number of cards of this type
......
...@@ -79,7 +79,11 @@ Context& Set::getContextForThumbnails(const StyleSheetP& stylesheet) { ...@@ -79,7 +79,11 @@ Context& Set::getContextForThumbnails(const StyleSheetP& stylesheet) {
return thumbnail_script_context->getContext(stylesheet); return thumbnail_script_context->getContext(stylesheet);
} }
StyleSheetP Set::stylesheetFor(const CardP& card) { const StyleSheet& Set::stylesheetFor(const CardP& card) {
if (card && card->stylesheet) return *card->stylesheet;
else return *stylesheet;
}
StyleSheetP Set::stylesheetForP(const CardP& card) {
if (card && card->stylesheet) return card->stylesheet; if (card && card->stylesheet) return card->stylesheet;
else return stylesheet; else return stylesheet;
} }
...@@ -122,7 +126,7 @@ void Set::validate(Version file_app_version) { ...@@ -122,7 +126,7 @@ void Set::validate(Version file_app_version) {
} }
*/ } */ }
// we want at least one card // we want at least one card
if (cards.empty()) cards.push_back(new_shared1<Card>(*game)); if (cards.empty()) cards.push_back(new_intrusive1<Card>(*game));
// update scripts // update scripts
script_manager->updateAll(); script_manager->updateAll();
} }
...@@ -187,7 +191,7 @@ int Set::positionOfCard(const CardP& card, const ScriptValueP& order_by) { ...@@ -187,7 +191,7 @@ int Set::positionOfCard(const CardP& card, const ScriptValueP& order_by) {
values.push_back(*order_by->eval(getContext(c))); values.push_back(*order_by->eval(getContext(c)));
} }
// 2. initialize order cache // 2. initialize order cache
order.reset(new OrderCache<CardP>(cards, values)); order = new_intrusive2<OrderCache<CardP> >(cards, values);
} }
return order->find(card); return order->find(card);
} }
...@@ -199,7 +203,7 @@ void Set::clearOrderCache() { ...@@ -199,7 +203,7 @@ void Set::clearOrderCache() {
// Extra set data, for a specific stylesheet // Extra set data, for a specific stylesheet
/* The data is not read immediatly, because we do not know the stylesheet */ /* The data is not read immediatly, because we do not know the stylesheet */
class Set::Styling { class Set::Styling : public IntrusivePtrBase<Set::Styling> {
public: public:
IndexMap<FieldP, ValueP> data; IndexMap<FieldP, ValueP> data;
String unread_data; String unread_data;
...@@ -209,7 +213,7 @@ class Set::Styling { ...@@ -209,7 +213,7 @@ class Set::Styling {
IndexMap<FieldP, ValueP>& Set::stylingDataFor(const StyleSheet& stylesheet) { IndexMap<FieldP, ValueP>& Set::stylingDataFor(const StyleSheet& stylesheet) {
StylingP& styling = styling_data[stylesheet.name()]; StylingP& styling = styling_data[stylesheet.name()];
if (!styling) { if (!styling) {
styling = new_shared<Styling>(); styling = new_intrusive<Styling>();
styling->data.init(stylesheet.styling_fields); styling->data.init(stylesheet.styling_fields);
} else if (!styling->unread_data.empty() || (styling->data.empty()) && !stylesheet.styling_fields.empty()) { } else if (!styling->unread_data.empty() || (styling->data.empty()) && !stylesheet.styling_fields.empty()) {
// we delayed the reading of the data, read it now // we delayed the reading of the data, read it now
......
...@@ -25,13 +25,13 @@ DECLARE_POINTER_TYPE(Styling); ...@@ -25,13 +25,13 @@ DECLARE_POINTER_TYPE(Styling);
DECLARE_POINTER_TYPE(Field); DECLARE_POINTER_TYPE(Field);
DECLARE_POINTER_TYPE(Value); DECLARE_POINTER_TYPE(Value);
DECLARE_POINTER_TYPE(Keyword); DECLARE_POINTER_TYPE(Keyword);
DECLARE_INTRUSIVE_POINTER_TYPE(ScriptValue); DECLARE_POINTER_TYPE(ScriptValue);
class SetScriptManager; class SetScriptManager;
class SetScriptContext; class SetScriptContext;
class Context; class Context;
class Dependency; class Dependency;
template <typename> class OrderCache; template <typename> class OrderCache;
typedef shared_ptr<OrderCache<CardP> > OrderCacheP; typedef intrusive_ptr<OrderCache<CardP> > OrderCacheP;
// ----------------------------------------------------------------------------- : Set // ----------------------------------------------------------------------------- : Set
...@@ -80,7 +80,8 @@ class Set : public Packaged { ...@@ -80,7 +80,8 @@ class Set : public Packaged {
/// Stylesheet to use for a particular card /// Stylesheet to use for a particular card
/** card may be null */ /** card may be null */
StyleSheetP stylesheetFor(const CardP& card); const StyleSheet& stylesheetFor (const CardP& card);
StyleSheetP stylesheetForP(const CardP& card);
/// Styling information for a particular stylesheet /// Styling information for a particular stylesheet
IndexMap<FieldP, ValueP>& stylingDataFor(const StyleSheet&); IndexMap<FieldP, ValueP>& stylingDataFor(const StyleSheet&);
......
...@@ -125,7 +125,7 @@ void Settings::addRecentFile(const String& filename) { ...@@ -125,7 +125,7 @@ void Settings::addRecentFile(const String& filename) {
GameSettings& Settings::gameSettingsFor(const Game& game) { GameSettings& Settings::gameSettingsFor(const Game& game) {
GameSettingsP& gs = game_settings[game.name()]; GameSettingsP& gs = game_settings[game.name()];
if (!gs) gs.reset(new GameSettings); if (!gs) gs = new_intrusive<GameSettings>();
return *gs; return *gs;
} }
ColumnSettings& Settings::columnSettingsFor(const Game& game, const Field& field) { ColumnSettings& Settings::columnSettingsFor(const Game& game, const Field& field) {
...@@ -143,7 +143,7 @@ ColumnSettings& Settings::columnSettingsFor(const Game& game, const Field& field ...@@ -143,7 +143,7 @@ ColumnSettings& Settings::columnSettingsFor(const Game& game, const Field& field
} }
StyleSheetSettings& Settings::stylesheetSettingsFor(const StyleSheet& stylesheet) { StyleSheetSettings& Settings::stylesheetSettingsFor(const StyleSheet& stylesheet) {
StyleSheetSettingsP& ss = stylesheet_settings[stylesheet.name()]; StyleSheetSettingsP& ss = stylesheet_settings[stylesheet.name()];
if (!ss) ss.reset(new StyleSheetSettings); if (!ss) ss = new_intrusive<StyleSheetSettings>();
ss->useDefault(default_stylesheet_settings); // update default settings ss->useDefault(default_stylesheet_settings); // update default settings
return *ss; return *ss;
} }
......
...@@ -49,7 +49,7 @@ class ColumnSettings { ...@@ -49,7 +49,7 @@ class ColumnSettings {
}; };
/// Settings for a Game /// Settings for a Game
class GameSettings { class GameSettings : public IntrusivePtrBase<GameSettings> {
public: public:
GameSettings(); GameSettings();
...@@ -65,7 +65,7 @@ class GameSettings { ...@@ -65,7 +65,7 @@ class GameSettings {
}; };
/// Settings for a StyleSheet /// Settings for a StyleSheet
class StyleSheetSettings { class StyleSheetSettings : public IntrusivePtrBase<StyleSheetSettings> {
public: public:
StyleSheetSettings(); StyleSheetSettings();
......
...@@ -38,7 +38,7 @@ StatsDimension::StatsDimension(const Field& field) ...@@ -38,7 +38,7 @@ StatsDimension::StatsDimension(const Field& field)
s.addInstruction(I_RET); s.addInstruction(I_RET);
} }
IMPLEMENT_REFLECTION(StatsDimension) { IMPLEMENT_REFLECTION_NO_GET_MEMBER(StatsDimension) {
if (!automatic) { if (!automatic) {
REFLECT(name); REFLECT(name);
REFLECT(description); REFLECT(description);
...@@ -72,7 +72,7 @@ IMPLEMENT_REFLECTION_ENUM(GraphType) { ...@@ -72,7 +72,7 @@ IMPLEMENT_REFLECTION_ENUM(GraphType) {
VALUE_N("scatter", GRAPH_TYPE_SCATTER); VALUE_N("scatter", GRAPH_TYPE_SCATTER);
} }
IMPLEMENT_REFLECTION(StatsCategory) { IMPLEMENT_REFLECTION_NO_GET_MEMBER(StatsCategory) {
if (!automatic) { if (!automatic) {
REFLECT(name); REFLECT(name);
REFLECT(description); REFLECT(description);
......
...@@ -21,7 +21,7 @@ DECLARE_POINTER_TYPE(StatsCategory); ...@@ -21,7 +21,7 @@ DECLARE_POINTER_TYPE(StatsCategory);
/// A dimension that can be plotted as an axis in a graph /// A dimension that can be plotted as an axis in a graph
/** Dimensions can be generated automatically based on card fields */ /** Dimensions can be generated automatically based on card fields */
class StatsDimension { class StatsDimension : public IntrusivePtrBase<StatsDimension> {
public: public:
StatsDimension(); StatsDimension();
StatsDimension(const Field&); StatsDimension(const Field&);
...@@ -49,7 +49,7 @@ enum GraphType ...@@ -49,7 +49,7 @@ enum GraphType
/// A category for statistics /// A category for statistics
/** Can be generated automatically based on a dimension */ /** Can be generated automatically based on a dimension */
class StatsCategory { class StatsCategory : public IntrusivePtrBase<StatsCategory> {
public: public:
StatsCategory(); StatsCategory();
StatsCategory(const StatsDimensionP&); StatsCategory(const StatsDimensionP&);
......
...@@ -131,10 +131,10 @@ SymbolPart::SymbolPart() ...@@ -131,10 +131,10 @@ SymbolPart::SymbolPart()
{} {}
SymbolPartP SymbolPart::clone() const { SymbolPartP SymbolPart::clone() const {
SymbolPartP part = new_shared1<SymbolPart>(*this); SymbolPartP part = new_intrusive1<SymbolPart>(*this);
// also clone the control points // also clone the control points
FOR_EACH(p, part->points) { FOR_EACH(p, part->points) {
p = new_shared1<ControlPoint>(*p); p = new_intrusive1<ControlPoint>(*p);
} }
return part; return part;
} }
...@@ -166,18 +166,18 @@ IMPLEMENT_REFLECTION(Symbol) { ...@@ -166,18 +166,18 @@ IMPLEMENT_REFLECTION(Symbol) {
// A default symbol part, a square, moved by d // A default symbol part, a square, moved by d
SymbolPartP default_symbol_part(double d) { SymbolPartP default_symbol_part(double d) {
SymbolPartP part = new_shared<SymbolPart>(); SymbolPartP part = new_intrusive<SymbolPart>();
part->points.push_back(new_shared2<ControlPoint>(d + .2, d + .2)); part->points.push_back(new_intrusive2<ControlPoint>(d + .2, d + .2));
part->points.push_back(new_shared2<ControlPoint>(d + .2, d + .8)); part->points.push_back(new_intrusive2<ControlPoint>(d + .2, d + .8));
part->points.push_back(new_shared2<ControlPoint>(d + .8, d + .8)); part->points.push_back(new_intrusive2<ControlPoint>(d + .8, d + .8));
part->points.push_back(new_shared2<ControlPoint>(d + .8, d + .2)); part->points.push_back(new_intrusive2<ControlPoint>(d + .8, d + .2));
part->name = _("Square"); part->name = _("Square");
return part; return part;
} }
// A default symbol, a square // A default symbol, a square
SymbolP default_symbol() { SymbolP default_symbol() {
SymbolP symbol = new_shared<Symbol>(); SymbolP symbol = new_intrusive<Symbol>();
symbol->parts.push_back(default_symbol_part(0)); symbol->parts.push_back(default_symbol_part(0));
return symbol; return symbol;
} }
......
...@@ -44,7 +44,7 @@ enum WhichHandle ...@@ -44,7 +44,7 @@ enum WhichHandle
}; };
/// A control point (corner) of a SymbolPart (polygon/bezier-gon) /// A control point (corner) of a SymbolPart (polygon/bezier-gon)
class ControlPoint { class ControlPoint : public IntrusivePtrBase<ControlPoint> {
public: public:
Vector2D pos; ///< position of the control point itself Vector2D pos; ///< position of the control point itself
Vector2D delta_before; ///< delta to bezier control point, for curve before point Vector2D delta_before; ///< delta to bezier control point, for curve before point
...@@ -121,7 +121,7 @@ inline size_t mod(int a, size_t size) { ...@@ -121,7 +121,7 @@ inline size_t mod(int a, size_t size) {
} }
/// A single part (polygon/bezier-gon) in a Symbol /// A single part (polygon/bezier-gon) in a Symbol
class SymbolPart { class SymbolPart : public IntrusivePtrBase<SymbolPart> {
public: public:
/// The points of this polygon /// The points of this polygon
vector<ControlPointP> points; vector<ControlPointP> points;
...@@ -158,7 +158,7 @@ class SymbolPart { ...@@ -158,7 +158,7 @@ class SymbolPart {
// ----------------------------------------------------------------------------- : Symbol // ----------------------------------------------------------------------------- : Symbol
/// An editable symbol, consists of any number of SymbolParts /// An editable symbol, consists of any number of SymbolParts
class Symbol { class Symbol : public IntrusivePtrBase<Symbol> {
public: public:
/// The parts of this symbol /// The parts of this symbol
vector<SymbolPartP> parts; vector<SymbolPartP> parts;
......
...@@ -70,7 +70,7 @@ IMPLEMENT_REFLECTION(SymbolFont) { ...@@ -70,7 +70,7 @@ IMPLEMENT_REFLECTION(SymbolFont) {
// ----------------------------------------------------------------------------- : SymbolInFont // ----------------------------------------------------------------------------- : SymbolInFont
/// A symbol in a symbol font /// A symbol in a symbol font
class SymbolInFont { class SymbolInFont : public IntrusivePtrBase<SymbolInFont> {
public: public:
SymbolInFont(); SymbolInFont();
......
...@@ -111,7 +111,7 @@ enum MenuItemType ...@@ -111,7 +111,7 @@ enum MenuItemType
}; };
/// Description of a menu to insert symbols from a symbol font into the text /// Description of a menu to insert symbols from a symbol font into the text
class InsertSymbolMenu { class InsertSymbolMenu : public IntrusivePtrBase<InsertSymbolMenu> {
public: public:
InsertSymbolMenu(); InsertSymbolMenu();
......
...@@ -138,6 +138,11 @@ bool BuiltInImage::operator == (const GeneratedImage& that) const { ...@@ -138,6 +138,11 @@ bool BuiltInImage::operator == (const GeneratedImage& that) const {
// ----------------------------------------------------------------------------- : SymbolToImage // ----------------------------------------------------------------------------- : SymbolToImage
SymbolToImage::SymbolToImage(const String& filename, Age age, const SymbolVariationP& variation)
: filename(filename), age(age), variation(variation)
{}
SymbolToImage::~SymbolToImage() {}
Image SymbolToImage::generate(const Options& opt) const { Image SymbolToImage::generate(const Options& opt) const {
// TODO : use opt.width and opt.height? // TODO : use opt.width and opt.height?
if (!opt.symbol_package) throw ScriptError(_("Can only load images in a context where an image is expected")); if (!opt.symbol_package) throw ScriptError(_("Can only load images in a context where an image is expected"));
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <gfx/gfx.hpp> #include <gfx/gfx.hpp>
#include <script/value.hpp> #include <script/value.hpp>
DECLARE_INTRUSIVE_POINTER_TYPE(GeneratedImage); DECLARE_POINTER_TYPE(GeneratedImage);
DECLARE_POINTER_TYPE(SymbolVariation); DECLARE_POINTER_TYPE(SymbolVariation);
class Package; class Package;
...@@ -161,12 +161,12 @@ class BuiltInImage : public GeneratedImage { ...@@ -161,12 +161,12 @@ class BuiltInImage : public GeneratedImage {
/// Use a symbol as an image /// Use a symbol as an image
class SymbolToImage : public GeneratedImage { class SymbolToImage : public GeneratedImage {
public: public:
inline SymbolToImage(const String& filename, Age age, const SymbolVariationP& variation) SymbolToImage(const String& filename, Age age, const SymbolVariationP& variation);
: filename(filename), age(age), variation(variation) ~SymbolToImage();
{}
virtual Image generate(const Options& opt) const; virtual Image generate(const Options& opt) const;
virtual bool operator == (const GeneratedImage& that) const; virtual bool operator == (const GeneratedImage& that) const;
private: private:
SymbolToImage(const SymbolToImage&); // copy ctor
String filename; String filename;
Age age; ///< Age the symbol was last updated Age age; ///< Age the symbol was last updated
SymbolVariationP variation; SymbolVariationP variation;
......
...@@ -127,7 +127,7 @@ void set_alpha(Image& img, const Image& img_alpha); ...@@ -127,7 +127,7 @@ void set_alpha(Image& img, const Image& img_alpha);
/// An alpha mask is an alpha channel that can be copied to another image /// An alpha mask is an alpha channel that can be copied to another image
/** It is created by treating black in the source image as transparent and white (red) as opaque /** It is created by treating black in the source image as transparent and white (red) as opaque
*/ */
class AlphaMask { class AlphaMask : public IntrusivePtrBase<AlphaMask> {
public: public:
AlphaMask(const Image& mask); AlphaMask(const Image& mask);
~AlphaMask(); ~AlphaMask();
......
...@@ -37,7 +37,7 @@ ValueViewerP DataEditor::makeViewer(const StyleP& style) { ...@@ -37,7 +37,7 @@ ValueViewerP DataEditor::makeViewer(const StyleP& style) {
bool DataEditor::drawBorders() const { bool DataEditor::drawBorders() const {
return !nativeLook() && return !nativeLook() &&
settings.stylesheetSettingsFor(*set->stylesheetFor(card)).card_borders(); settings.stylesheetSettingsFor(set->stylesheetFor(card)).card_borders();
} }
bool DataEditor::drawEditing() const { bool DataEditor::drawEditing() const {
return true; return true;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <util/prec.hpp> #include <util/prec.hpp>
#include <gui/control/item_list.hpp> #include <gui/control/item_list.hpp>
#include <data/card.hpp>
#include <data/set.hpp> #include <data/set.hpp>
DECLARE_POINTER_TYPE(ChoiceField); DECLARE_POINTER_TYPE(ChoiceField);
...@@ -27,10 +28,11 @@ DECLARE_EVENT_TYPE(EVENT_CARD_SELECT, <not used>) ...@@ -27,10 +28,11 @@ DECLARE_EVENT_TYPE(EVENT_CARD_SELECT, <not used>)
/// The event of selecting a card /// The event of selecting a card
struct CardSelectEvent : public wxCommandEvent { struct CardSelectEvent : public wxCommandEvent {
CardP card; ///< The selected card
inline CardSelectEvent(const CardP& card) inline CardSelectEvent(const CardP& card)
: wxCommandEvent(EVENT_CARD_SELECT), card(card) : wxCommandEvent(EVENT_CARD_SELECT), card(card)
{} {}
CardP card; ///< The selected card
}; };
// ----------------------------------------------------------------------------- : CardListBase // ----------------------------------------------------------------------------- : CardListBase
......
...@@ -17,7 +17,7 @@ DECLARE_POINTER_TYPE(CardListFilter); ...@@ -17,7 +17,7 @@ DECLARE_POINTER_TYPE(CardListFilter);
// ----------------------------------------------------------------------------- : CardListFilter // ----------------------------------------------------------------------------- : CardListFilter
/// A filter function to determine which items are shown in a card list /// A filter function to determine which items are shown in a card list
class CardListFilter { class CardListFilter : public IntrusivePtrVirtualBase {
public: public:
virtual ~CardListFilter() {} virtual ~CardListFilter() {}
/// Should a card be shown in the list? /// Should a card be shown in the list?
......
...@@ -367,19 +367,19 @@ GraphControl::GraphControl(Window* parent, int id) ...@@ -367,19 +367,19 @@ GraphControl::GraphControl(Window* parent, int id)
: wxControl(parent, id) : wxControl(parent, id)
{ {
//* //*
shared_ptr<GraphContainer> combined(new GraphContainer()); intrusive_ptr<GraphContainer> combined(new GraphContainer());
combined->add(new_shared1<GraphValueAxis>(0)); combined->add(new_intrusive1<GraphValueAxis>(0));
combined->add(new_shared1<BarGraph>(0)); combined->add(new_intrusive1<BarGraph>(0));
graph = new_shared6<GraphWithMargins>(combined, 23,8,7,20, true); graph = new_intrusive6<GraphWithMargins>(combined, 23,8,7,20, true);
/*/ /*/
shared_ptr<GraphContainer> combined(new GraphContainer()); intrusive_ptr<GraphContainer> combined(new GraphContainer());
combined->add(new_shared1<PieGraph>(0)); combined->add(new_intrusive1<PieGraph>(0));
graph = new_shared6<GraphWithMargins>(combined, 20,20,20,20, false); graph = new_intrusive6<GraphWithMargins>(combined, 20,20,20,20, false);
//*/ //*/
} }
void GraphControl::setData(const GraphDataPre& data) { void GraphControl::setData(const GraphDataPre& data) {
setData(new_shared1<GraphData>(data)); setData(new_intrusive1<GraphData>(data));
} }
void GraphControl::setData(const GraphDataP& data) { void GraphControl::setData(const GraphDataP& data) {
if (graph) { if (graph) {
......
...@@ -28,7 +28,7 @@ DECLARE_EVENT_TYPE(EVENT_GRAPH_SELECT, <not used>) ...@@ -28,7 +28,7 @@ DECLARE_EVENT_TYPE(EVENT_GRAPH_SELECT, <not used>)
/// A group in a table or graph /// A group in a table or graph
/** A group is rendered as a single bar or pie slice */ /** A group is rendered as a single bar or pie slice */
class GraphGroup { class GraphGroup : public IntrusivePtrBase<GraphGroup> {
public: public:
GraphGroup(const String& name, UInt size, const Color& color = *wxBLACK) GraphGroup(const String& name, UInt size, const Color& color = *wxBLACK)
: name(name), color(color), size(size) : name(name), color(color), size(size)
...@@ -48,7 +48,7 @@ enum AutoColor ...@@ -48,7 +48,7 @@ enum AutoColor
/// An axis in a graph, consists of a list of groups /// An axis in a graph, consists of a list of groups
/** The sum of groups.sum = sum of all elements in the data */ /** The sum of groups.sum = sum of all elements in the data */
class GraphAxis { class GraphAxis : public IntrusivePtrBase<GraphAxis> {
public: public:
GraphAxis(const String& name, AutoColor auto_color = AUTO_COLOR_EVEN, bool numeric = false, const map<String,Color>* colors = nullptr) GraphAxis(const String& name, AutoColor auto_color = AUTO_COLOR_EVEN, bool numeric = false, const map<String,Color>* colors = nullptr)
: name(name) : name(name)
...@@ -69,7 +69,7 @@ class GraphAxis { ...@@ -69,7 +69,7 @@ class GraphAxis {
}; };
/// A single data point of a graph /// A single data point of a graph
class GraphElement { class GraphElement : public IntrusivePtrBase<GraphElement> {
public: public:
GraphElement() {} GraphElement() {}
GraphElement(const String& v1); GraphElement(const String& v1);
...@@ -86,7 +86,7 @@ class GraphDataPre { ...@@ -86,7 +86,7 @@ class GraphDataPre {
}; };
/// Data to be displayed in a graph /// Data to be displayed in a graph
class GraphData { class GraphData : public IntrusivePtrBase<GraphData> {
public: public:
GraphData(const GraphDataPre&); GraphData(const GraphDataPre&);
...@@ -108,9 +108,8 @@ enum DrawLayer ...@@ -108,9 +108,8 @@ enum DrawLayer
/// A type of graph /// A type of graph
/** It is rendered into a sub-rectangle of the screen */ /** It is rendered into a sub-rectangle of the screen */
class Graph { class Graph : public IntrusivePtrVirtualBase {
public: public:
virtual ~Graph() {}
/// Draw this graph, filling the internalRect() of the dc. /// Draw this graph, filling the internalRect() of the dc.
virtual void draw(RotatedDC& dc, const vector<int>& current, DrawLayer layer) const = 0; virtual void draw(RotatedDC& dc, const vector<int>& current, DrawLayer layer) const = 0;
/// Find the item at the given position, the rectangle gives the screen size /// Find the item at the given position, the rectangle gives the screen size
......
...@@ -98,7 +98,7 @@ int ImageCardList::OnGetItemImage(long pos) const { ...@@ -98,7 +98,7 @@ int ImageCardList::OnGetItemImage(long pos) const {
return it->second; return it->second;
} else { } else {
// request a thumbnail // request a thumbnail
thumbnail_thread.request(new_shared2<CardThumbnailRequest>(const_cast<ImageCardList*>(this), val.filename)); thumbnail_thread.request(new_intrusive2<CardThumbnailRequest>(const_cast<ImageCardList*>(this), val.filename));
} }
} }
return -1; return -1;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <util/prec.hpp> #include <util/prec.hpp>
#include <wx/listctrl.h> #include <wx/listctrl.h>
typedef shared_ptr<void> VoidP; typedef intrusive_ptr<IntrusivePtrVirtualBase> VoidP;
// ----------------------------------------------------------------------------- : ItemList // ----------------------------------------------------------------------------- : ItemList
......
...@@ -38,8 +38,8 @@ class PackageList : public GalleryList { ...@@ -38,8 +38,8 @@ class PackageList : public GalleryList {
/** @pre hasSelection() /** @pre hasSelection()
* Throws if the selection is not of type T */ * Throws if the selection is not of type T */
template <typename T> template <typename T>
shared_ptr<T> getSelection() const { intrusive_ptr<T> getSelection() const {
shared_ptr<T> ret = dynamic_pointer_cast<T>(packages.at(selection).package); intrusive_ptr<T> ret = dynamic_pointer_cast<T>(packages.at(selection).package);
if (!ret) throw InternalError(_("PackageList: Selected package has the wrong type")); if (!ret) throw InternalError(_("PackageList: Selected package has the wrong type"));
ret->loadFully(); ret->loadFully();
return ret; return ret;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <gui/control/select_card_list.hpp> #include <gui/control/select_card_list.hpp>
#include <gui/util.hpp> #include <gui/util.hpp>
#include <data/card.hpp>
DECLARE_TYPEOF_COLLECTION(CardP); DECLARE_TYPEOF_COLLECTION(CardP);
...@@ -24,6 +25,7 @@ SelectCardList::SelectCardList(Window* parent, int id, long additional_style) ...@@ -24,6 +25,7 @@ SelectCardList::SelectCardList(Window* parent, int id, long additional_style)
il->Add(load_resource_image(_("selected"))); il->Add(load_resource_image(_("selected")));
AssignImageList(il, wxIMAGE_LIST_SMALL); AssignImageList(il, wxIMAGE_LIST_SMALL);
} }
SelectCardList::~SelectCardList() {}
void SelectCardList::selectAll() { void SelectCardList::selectAll() {
FOR_EACH_CONST(c, set->cards) { FOR_EACH_CONST(c, set->cards) {
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
class SelectCardList : public CardListBase { class SelectCardList : public CardListBase {
public: public:
SelectCardList(Window* parent, int id, long additional_style = 0); SelectCardList(Window* parent, int id, long additional_style = 0);
~SelectCardList();
/// Select all cards /// Select all cards
void selectAll(); void selectAll();
/// Deselect all cards /// Deselect all cards
......
...@@ -21,6 +21,7 @@ TextCtrl::TextCtrl(Window* parent, int id, bool multi_line, long style) ...@@ -21,6 +21,7 @@ TextCtrl::TextCtrl(Window* parent, int id, bool multi_line, long style)
, value(nullptr) , value(nullptr)
, multi_line(multi_line) , multi_line(multi_line)
{} {}
TextCtrl::~TextCtrl() {}
Rotation TextCtrl::getRotation() const { Rotation TextCtrl::getRotation() const {
return Rotation(0, RealRect(RealPoint(0,0),GetClientSize())); return Rotation(0, RealRect(RealPoint(0,0),GetClientSize()));
...@@ -57,7 +58,7 @@ void TextCtrl::updateSize() { ...@@ -57,7 +58,7 @@ void TextCtrl::updateSize() {
} }
void TextCtrl::setValue(String* value, bool untagged) { void TextCtrl::setValue(String* value, bool untagged) {
setValue(new_shared4<FakeTextValue>(getFieldP(), value, true, untagged)); setValue(new_intrusive4<FakeTextValue>(getFieldP(), value, true, untagged));
} }
void TextCtrl::setValue(const FakeTextValueP& value) { void TextCtrl::setValue(const FakeTextValueP& value) {
value->retrieve(); value->retrieve();
......
...@@ -30,6 +30,7 @@ DECLARE_POINTER_TYPE(FakeTextValue); ...@@ -30,6 +30,7 @@ DECLARE_POINTER_TYPE(FakeTextValue);
class TextCtrl : public DataEditor { class TextCtrl : public DataEditor {
public: public:
TextCtrl(Window* parent, int id, bool multi_line, long style = 0); TextCtrl(Window* parent, int id, bool multi_line, long style = 0);
~TextCtrl();
/// Set the value that is being edited /// Set the value that is being edited
/** value can be a nullptr*/ /** value can be a nullptr*/
......
...@@ -92,7 +92,7 @@ void NewSetWindow::OnOK(wxCommandEvent&) { ...@@ -92,7 +92,7 @@ void NewSetWindow::OnOK(wxCommandEvent&) {
void NewSetWindow::done() { void NewSetWindow::done() {
StyleSheetP stylesheet = stylesheet_list->getSelection<StyleSheet>(); StyleSheetP stylesheet = stylesheet_list->getSelection<StyleSheet>();
set = new_shared1<Set>(stylesheet); set = new_intrusive1<Set>(stylesheet);
set->validate(); set->validate();
EndModal(wxID_OK); EndModal(wxID_OK);
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <gui/card_select_window.hpp> #include <gui/card_select_window.hpp>
#include <gui/util.hpp> #include <gui/util.hpp>
#include <data/set.hpp> #include <data/set.hpp>
#include <data/card.hpp>
#include <data/stylesheet.hpp> #include <data/stylesheet.hpp>
#include <render/card/viewer.hpp> #include <render/card/viewer.hpp>
#include <wx/print.h> #include <wx/print.h>
...@@ -44,7 +45,7 @@ class TextBufferDC : public wxMemoryDC { ...@@ -44,7 +45,7 @@ class TextBufferDC : public wxMemoryDC {
private: private:
// A call to DrawText // A call to DrawText
struct TextDraw { struct TextDraw : public IntrusivePtrBase<TextDraw> {
wxFont font; wxFont font;
Color color; Color color;
int x, y; int x, y;
...@@ -57,7 +58,7 @@ class TextBufferDC : public wxMemoryDC { ...@@ -57,7 +58,7 @@ class TextBufferDC : public wxMemoryDC {
{} {}
}; };
public: public:
typedef shared_ptr<TextDraw> TextDrawP; typedef intrusive_ptr<TextDraw> TextDrawP;
private: private:
vector<TextDrawP> text; vector<TextDrawP> text;
Bitmap buffer; Bitmap buffer;
...@@ -73,12 +74,12 @@ TextBufferDC::TextBufferDC(int width, int height) ...@@ -73,12 +74,12 @@ TextBufferDC::TextBufferDC(int width, int height)
void TextBufferDC::DoDrawText(const String& str, int x, int y) { void TextBufferDC::DoDrawText(const String& str, int x, int y) {
double usx,usy; double usx,usy;
GetUserScale(&usx, &usy); GetUserScale(&usx, &usy);
text.push_back( new_shared7<TextDraw>(GetFont(), GetTextForeground(), usx, usy, x, y, str) ); text.push_back( new_intrusive7<TextDraw>(GetFont(), GetTextForeground(), usx, usy, x, y, str) );
} }
void TextBufferDC::DoDrawRotatedText(const String& str, int x, int y, double angle) { void TextBufferDC::DoDrawRotatedText(const String& str, int x, int y, double angle) {
double usx,usy; double usx,usy;
GetUserScale(&usx, &usy); GetUserScale(&usx, &usy);
text.push_back( new_shared8<TextDraw>(GetFont(), GetTextForeground(), usx, usy, x, y, str, angle) ); text.push_back( new_intrusive8<TextDraw>(GetFont(), GetTextForeground(), usx, usy, x, y, str, angle) );
} }
DECLARE_TYPEOF_COLLECTION(TextBufferDC::TextDrawP); DECLARE_TYPEOF_COLLECTION(TextBufferDC::TextDrawP);
...@@ -171,7 +172,7 @@ void CardsPrintout::OnPreparePrinting() { ...@@ -171,7 +172,7 @@ void CardsPrintout::OnPreparePrinting() {
int pw_mm, ph_mm; int pw_mm, ph_mm;
GetPageSizeMM(&pw_mm, &ph_mm); GetPageSizeMM(&pw_mm, &ph_mm);
if (!layout) { if (!layout) {
layout = new_shared2<PageLayout>(*set->stylesheet, RealSize(pw_mm, ph_mm)); layout = new_intrusive2<PageLayout>(*set->stylesheet, RealSize(pw_mm, ph_mm));
} }
} }
...@@ -201,7 +202,7 @@ void CardsPrintout::drawCard(DC& dc, const CardP& card, int card_nr) { ...@@ -201,7 +202,7 @@ void CardsPrintout::drawCard(DC& dc, const CardP& card, int card_nr) {
RealPoint pos( layout->margin_left + (layout->card_size.width + layout->card_spacing.width) * col RealPoint pos( layout->margin_left + (layout->card_size.width + layout->card_spacing.width) * col
, layout->margin_top + (layout->card_size.height + layout->card_spacing.height) * row); , layout->margin_top + (layout->card_size.height + layout->card_spacing.height) * row);
// determine rotation // determine rotation
StyleSheet& stylesheet = *set->stylesheetFor(card); const StyleSheet& stylesheet = set->stylesheetFor(card);
int rotation = 0; int rotation = 0;
if ((stylesheet.card_width > stylesheet.card_height) != layout->card_landscape) { if ((stylesheet.card_width > stylesheet.card_height) != layout->card_landscape) {
rotation = 90 - rotation; rotation = 90 - rotation;
......
...@@ -27,7 +27,7 @@ void print_set(Window* parent, const SetP& set); ...@@ -27,7 +27,7 @@ void print_set(Window* parent, const SetP& set);
// ----------------------------------------------------------------------------- : Layout // ----------------------------------------------------------------------------- : Layout
/// Layout of a page of cards /// Layout of a page of cards
class PageLayout { class PageLayout : public IntrusivePtrBase<PageLayout> {
public: public:
PageLayout(); PageLayout();
PageLayout(const StyleSheet& stylesheet, const RealSize& page_size); PageLayout(const StyleSheet& stylesheet, const RealSize& page_size);
......
...@@ -150,7 +150,7 @@ void CardsPanel::onUpdateUI(wxUpdateUIEvent& ev) { ...@@ -150,7 +150,7 @@ void CardsPanel::onUpdateUI(wxUpdateUIEvent& ev) {
case ID_CARD_PREV: ev.Enable(card_list->canSelectPrevious()); break; case ID_CARD_PREV: ev.Enable(card_list->canSelectPrevious()); break;
case ID_CARD_NEXT: ev.Enable(card_list->canSelectNext()); break; case ID_CARD_NEXT: ev.Enable(card_list->canSelectNext()); break;
case ID_CARD_ROTATE_0: case ID_CARD_ROTATE_90: case ID_CARD_ROTATE_180: case ID_CARD_ROTATE_270: { case ID_CARD_ROTATE_0: case ID_CARD_ROTATE_90: case ID_CARD_ROTATE_180: case ID_CARD_ROTATE_270: {
StyleSheetSettings& ss = settings.stylesheetSettingsFor(*set->stylesheetFor(card_list->getCard())); StyleSheetSettings& ss = settings.stylesheetSettingsFor(set->stylesheetFor(card_list->getCard()));
int a = ev.GetId() == ID_CARD_ROTATE_0 ? 0 int a = ev.GetId() == ID_CARD_ROTATE_0 ? 0
: ev.GetId() == ID_CARD_ROTATE_90 ? 90 : ev.GetId() == ID_CARD_ROTATE_90 ? 90
: ev.GetId() == ID_CARD_ROTATE_180 ? 180 : ev.GetId() == ID_CARD_ROTATE_180 ? 180
...@@ -203,7 +203,7 @@ void CardsPanel::onCommand(int id) { ...@@ -203,7 +203,7 @@ void CardsPanel::onCommand(int id) {
break; break;
case ID_CARD_ROTATE: case ID_CARD_ROTATE:
case ID_CARD_ROTATE_0: case ID_CARD_ROTATE_90: case ID_CARD_ROTATE_180: case ID_CARD_ROTATE_270: { case ID_CARD_ROTATE_0: case ID_CARD_ROTATE_90: case ID_CARD_ROTATE_180: case ID_CARD_ROTATE_270: {
StyleSheetSettings& ss = settings.stylesheetSettingsFor(*set->stylesheetFor(card_list->getCard())); StyleSheetSettings& ss = settings.stylesheetSettingsFor(set->stylesheetFor(card_list->getCard()));
ss.card_angle.assign( ss.card_angle.assign(
id == ID_CARD_ROTATE ? (ss.card_angle() + 90) % 360 id == ID_CARD_ROTATE ? (ss.card_angle() + 90) % 360
: id == ID_CARD_ROTATE_0 ? 0 : id == ID_CARD_ROTATE_0 ? 0
......
...@@ -305,10 +305,10 @@ void KeywordsPanel::onKeywordSelect(KeywordSelectEvent& ev) { ...@@ -305,10 +305,10 @@ void KeywordsPanel::onKeywordSelect(KeywordSelectEvent& ev) {
if (ev.keyword) { if (ev.keyword) {
Keyword& kw = *ev.keyword; Keyword& kw = *ev.keyword;
sp->Show(fixed, kw.fixed); sp->Show(fixed, kw.fixed);
keyword ->setValue(new_shared5<KeywordTextValue> (keyword->getFieldP(), &kw, &kw.keyword, !kw.fixed, true)); keyword ->setValue(new_intrusive5<KeywordTextValue> (keyword->getFieldP(), &kw, &kw.keyword, !kw.fixed, true));
match ->setValue(new_shared4<KeywordTextValue> (match->getFieldP(), &kw, &kw.match, !kw.fixed)); match ->setValue(new_intrusive4<KeywordTextValue> (match->getFieldP(), &kw, &kw.match, !kw.fixed));
rules ->setValue(new_shared4<KeywordTextValue> (rules->getFieldP(), &kw, &kw.rules, !kw.fixed)); rules ->setValue(new_intrusive4<KeywordTextValue> (rules->getFieldP(), &kw, &kw.rules, !kw.fixed));
shared_ptr<KeywordReminderTextValue> reminder_value(new KeywordReminderTextValue(reminder->getFieldP(), &kw, !kw.fixed)); intrusive_ptr<KeywordReminderTextValue> reminder_value(new KeywordReminderTextValue(reminder->getFieldP(), &kw, !kw.fixed));
reminder->setValue(reminder_value); reminder->setValue(reminder_value);
errors->SetLabel(reminder_value->errors); errors->SetLabel(reminder_value->errors);
add_param->Enable(!kw.fixed && !set->game->keyword_parameter_types.empty()); add_param->Enable(!kw.fixed && !set->game->keyword_parameter_types.empty());
......
...@@ -7,9 +7,14 @@ ...@@ -7,9 +7,14 @@
// ----------------------------------------------------------------------------- : Includes // ----------------------------------------------------------------------------- : Includes
#include <gui/set/panel.hpp> #include <gui/set/panel.hpp>
#include <data/card.hpp>
// ----------------------------------------------------------------------------- : SetWindowPanel // ----------------------------------------------------------------------------- : SetWindowPanel
SetWindowPanel::SetWindowPanel(Window* parent, int id, bool autoTabbing) SetWindowPanel::SetWindowPanel(Window* parent, int id, bool autoTabbing)
: wxPanel(parent, id, wxDefaultPosition, wxDefaultSize, autoTabbing ? wxTAB_TRAVERSAL : 0) : wxPanel(parent, id, wxDefaultPosition, wxDefaultSize, autoTabbing ? wxTAB_TRAVERSAL : 0)
{} {}
CardP SetWindowPanel::selectedCard() const {
return CardP();
}
...@@ -22,7 +22,7 @@ class wxFindReplaceData; ...@@ -22,7 +22,7 @@ class wxFindReplaceData;
class SetWindowPanel : public wxPanel, public SetView { class SetWindowPanel : public wxPanel, public SetView {
public: public:
SetWindowPanel(Window* parent, int id, bool autoTabbing = false); SetWindowPanel(Window* parent, int id, bool autoTabbing = false);
/// We will probably want to respond to set changes /// We will probably want to respond to set changes
virtual void onSetChange() {} virtual void onSetChange() {}
...@@ -66,7 +66,7 @@ class SetWindowPanel : public wxPanel, public SetView { ...@@ -66,7 +66,7 @@ class SetWindowPanel : public wxPanel, public SetView {
virtual bool doReplaceAll(wxFindReplaceData&) { return false; } ///< Replace all matches virtual bool doReplaceAll(wxFindReplaceData&) { return false; } ///< Replace all matches
// --------------------------------------------------- : Selection // --------------------------------------------------- : Selection
virtual CardP selectedCard() const { return CardP(); } ///< Return the currently selected card, or CardP() virtual CardP selectedCard() const; ///< Return the currently selected card, or CardP()
virtual void selectCard(const CardP& card) {} ///< Switch the view to another card virtual void selectCard(const CardP& card) {} ///< Switch the view to another card
virtual void selectFirstCard() {} ///< Switch the view to the first card virtual void selectFirstCard() {} ///< Switch the view to the first card
}; };
......
...@@ -148,7 +148,7 @@ void StatsPanel::onCategorySelect() { ...@@ -148,7 +148,7 @@ void StatsPanel::onCategorySelect() {
StatsCategory& cat = categories->getSelection(); StatsCategory& cat = categories->getSelection();
GraphDataPre d; GraphDataPre d;
FOR_EACH(dim, cat.dimensions) { FOR_EACH(dim, cat.dimensions) {
d.axes.push_back(new_shared4<GraphAxis>( d.axes.push_back(new_intrusive4<GraphAxis>(
dim->name, dim->name,
dim->colors.empty() ? AUTO_COLOR_EVEN : AUTO_COLOR_NO, dim->colors.empty() ? AUTO_COLOR_EVEN : AUTO_COLOR_NO,
dim->numeric, dim->numeric,
...@@ -183,7 +183,7 @@ void StatsPanel::onGraphSelect(wxCommandEvent&) { ...@@ -183,7 +183,7 @@ void StatsPanel::onGraphSelect(wxCommandEvent&) {
void StatsPanel::filterCards() { void StatsPanel::filterCards() {
if (!categories->hasSelection()) return; if (!categories->hasSelection()) return;
shared_ptr<StatsFilter> filter(new StatsFilter(*set)); intrusive_ptr<StatsFilter> filter(new StatsFilter(*set));
StatsCategory& cat = categories->getSelection(); StatsCategory& cat = categories->getSelection();
vector<pair<StatsDimensionP, String> > values; vector<pair<StatsDimensionP, String> > values;
int i = 0; int i = 0;
......
...@@ -46,19 +46,19 @@ void StylePanel::onChangeSet() { ...@@ -46,19 +46,19 @@ void StylePanel::onChangeSet() {
list->select(set->stylesheet->name(), false); list->select(set->stylesheet->name(), false);
editor->setSet(set); editor->setSet(set);
preview->setSet(set); preview->setSet(set);
card.reset(); card = CardP();
use_for_all->Enable(false); use_for_all->Enable(false);
} }
void StylePanel::onAction(const Action& action, bool undone) { void StylePanel::onAction(const Action& action, bool undone) {
TYPE_CASE_(action, ChangeSetStyleAction) { TYPE_CASE_(action, ChangeSetStyleAction) {
list->select(set->stylesheetFor(card)->name(), false); list->select(set->stylesheetFor(card).name(), false);
editor->showStylesheet(set->stylesheetFor(card)); editor->showStylesheet(set->stylesheetForP(card));
} }
TYPE_CASE(action, ChangeCardStyleAction) { TYPE_CASE(action, ChangeCardStyleAction) {
if (action.card == card) { if (action.card == card) {
list->select(set->stylesheetFor(card)->name(), false); list->select(set->stylesheetFor(card).name(), false);
editor->showStylesheet(set->stylesheetFor(card)); editor->showStylesheet(set->stylesheetForP(card));
} }
} }
use_for_all->Enable(card && card->stylesheet); use_for_all->Enable(card && card->stylesheet);
...@@ -69,8 +69,8 @@ void StylePanel::onAction(const Action& action, bool undone) { ...@@ -69,8 +69,8 @@ void StylePanel::onAction(const Action& action, bool undone) {
void StylePanel::selectCard(const CardP& card) { void StylePanel::selectCard(const CardP& card) {
this->card = card; this->card = card;
preview->setCard(card); preview->setCard(card);
editor->showStylesheet(set->stylesheetFor(card)); editor->showStylesheet(set->stylesheetForP(card));
list->select(set->stylesheetFor(card)->name(), false); list->select(set->stylesheetFor(card).name(), false);
use_for_all->Enable(card && card->stylesheet); use_for_all->Enable(card && card->stylesheet);
} }
......
...@@ -233,7 +233,7 @@ bool SetWindow::isOnlyWithSet() { ...@@ -233,7 +233,7 @@ bool SetWindow::isOnlyWithSet() {
void SetWindow::onChangeSet() { void SetWindow::onChangeSet() {
// make sure there is always at least one card // make sure there is always at least one card
// some things need this // some things need this
if (set->cards.empty()) set->cards.push_back(new_shared1<Card>(*set->game)); if (set->cards.empty()) set->cards.push_back(new_intrusive1<Card>(*set->game));
// all panels view the same set // all panels view the same set
FOR_EACH(p, panels) { FOR_EACH(p, panels) {
p->setSet(set); p->setSet(set);
......
...@@ -178,7 +178,7 @@ void SymbolBasicShapeEditor::makeShape(const Vector2D& a, const Vector2D& b, boo ...@@ -178,7 +178,7 @@ void SymbolBasicShapeEditor::makeShape(const Vector2D& a, const Vector2D& b, boo
// TODO : Move out of this class // TODO : Move out of this class
void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bool constrained) { void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bool constrained) {
shape = new_shared<SymbolPart>(); shape = new_intrusive<SymbolPart>();
// What shape to make? // What shape to make?
switch (mode) { switch (mode) {
case ID_SHAPE_CIRCLE: { case ID_SHAPE_CIRCLE: {
...@@ -191,10 +191,10 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo ...@@ -191,10 +191,10 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo
// a circle has 4 control points, the first is: (x+r, y) db(0, kr) da(0, -kr) // a circle has 4 control points, the first is: (x+r, y) db(0, kr) da(0, -kr)
// kr is a magic constant // kr is a magic constant
const double kr = 0.5522847498f; // = 4/3 * (sqrt(2) - 1) const double kr = 0.5522847498f; // = 4/3 * (sqrt(2) - 1)
shape->points.push_back(new_shared7<ControlPoint>(c.x + r.x, c.y, 0, kr * r.y, 0, -kr * r.y, LOCK_SIZE)); shape->points.push_back(new_intrusive7<ControlPoint>(c.x + r.x, c.y, 0, kr * r.y, 0, -kr * r.y, LOCK_SIZE));
shape->points.push_back(new_shared7<ControlPoint>(c.x, c.y - r.y, kr * r.x, 0, -kr * r.x, 0, LOCK_SIZE)); shape->points.push_back(new_intrusive7<ControlPoint>(c.x, c.y - r.y, kr * r.x, 0, -kr * r.x, 0, LOCK_SIZE));
shape->points.push_back(new_shared7<ControlPoint>(c.x - r.x, c.y, 0, -kr * r.y, 0, kr * r.y, LOCK_SIZE)); shape->points.push_back(new_intrusive7<ControlPoint>(c.x - r.x, c.y, 0, -kr * r.y, 0, kr * r.y, LOCK_SIZE));
shape->points.push_back(new_shared7<ControlPoint>(c.x, c.y + r.y, -kr * r.x, 0, kr * r.x, 0, LOCK_SIZE)); shape->points.push_back(new_intrusive7<ControlPoint>(c.x, c.y + r.y, -kr * r.x, 0, kr * r.x, 0, LOCK_SIZE));
break; break;
} case ID_SHAPE_RECTANGLE: { } case ID_SHAPE_RECTANGLE: {
// A rectangle / square // A rectangle / square
...@@ -204,10 +204,10 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo ...@@ -204,10 +204,10 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo
shape->name = capitalize(_TYPE_("rectangle")); shape->name = capitalize(_TYPE_("rectangle"));
} }
// a rectangle just has four corners // a rectangle just has four corners
shape->points.push_back(new_shared2<ControlPoint>(c.x - r.x, c.y - r.y)); shape->points.push_back(new_intrusive2<ControlPoint>(c.x - r.x, c.y - r.y));
shape->points.push_back(new_shared2<ControlPoint>(c.x + r.x, c.y - r.y)); shape->points.push_back(new_intrusive2<ControlPoint>(c.x + r.x, c.y - r.y));
shape->points.push_back(new_shared2<ControlPoint>(c.x + r.x, c.y + r.y)); shape->points.push_back(new_intrusive2<ControlPoint>(c.x + r.x, c.y + r.y));
shape->points.push_back(new_shared2<ControlPoint>(c.x - r.x, c.y + r.y)); shape->points.push_back(new_intrusive2<ControlPoint>(c.x - r.x, c.y + r.y));
break; break;
} default: { } default: {
// A polygon or star // A polygon or star
...@@ -250,7 +250,7 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo ...@@ -250,7 +250,7 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo
// we can generate points // we can generate points
for(int i = 0 ; i < n ; ++i) { for(int i = 0 ; i < n ; ++i) {
double theta = alpha * i; double theta = alpha * i;
shape->points.push_back(new_shared2<ControlPoint>( shape->points.push_back(new_intrusive2<ControlPoint>(
c.x + ra * r.x * sin(theta), c.x + ra * r.x * sin(theta),
y - ra * r.y * cos(theta) y - ra * r.y * cos(theta)
)); ));
...@@ -272,13 +272,13 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo ...@@ -272,13 +272,13 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo
for(int i = 0 ; i < n ; ++i) { for(int i = 0 ; i < n ; ++i) {
double theta = alpha * i; double theta = alpha * i;
// from a // from a
shape->points.push_back(new_shared2<ControlPoint>( shape->points.push_back(new_intrusive2<ControlPoint>(
c.x + ra * r.x * sin(theta), c.x + ra * r.x * sin(theta),
y - ra * r.y * cos(theta) y - ra * r.y * cos(theta)
)); ));
// from b // from b
theta = alpha * (i + 0.5); theta = alpha * (i + 0.5);
shape->points.push_back(new_shared2<ControlPoint>( shape->points.push_back(new_intrusive2<ControlPoint>(
c.x + rb * r.x * sin(theta), c.x + rb * r.x * sin(theta),
y - rb * r.y * cos(theta) y - rb * r.y * cos(theta)
)); ));
......
...@@ -37,22 +37,22 @@ void SymbolControl::switchEditor(const SymbolEditorBaseP& e) { ...@@ -37,22 +37,22 @@ void SymbolControl::switchEditor(const SymbolEditorBaseP& e) {
void SymbolControl::onChangeSymbol() { void SymbolControl::onChangeSymbol() {
selected_parts.clear(); selected_parts.clear();
switchEditor(new_shared2<SymbolSelectEditor>(this, false)); switchEditor(new_intrusive2<SymbolSelectEditor>(this, false));
Refresh(false); Refresh(false);
} }
void SymbolControl::onModeChange(wxCommandEvent& ev) { void SymbolControl::onModeChange(wxCommandEvent& ev) {
switch (ev.GetId()) { switch (ev.GetId()) {
case ID_MODE_SELECT: case ID_MODE_SELECT:
switchEditor(new_shared2<SymbolSelectEditor>(this, false)); switchEditor(new_intrusive2<SymbolSelectEditor>(this, false));
break; break;
case ID_MODE_ROTATE: case ID_MODE_ROTATE:
switchEditor(new_shared2<SymbolSelectEditor>(this, true)); switchEditor(new_intrusive2<SymbolSelectEditor>(this, true));
break; break;
case ID_MODE_POINTS: case ID_MODE_POINTS:
if (selected_parts.size() == 1) { if (selected_parts.size() == 1) {
single_selection = *selected_parts.begin(); single_selection = *selected_parts.begin();
switchEditor(new_shared2<SymbolPointEditor>(this, single_selection)); switchEditor(new_intrusive2<SymbolPointEditor>(this, single_selection));
} }
break; break;
case ID_MODE_SHAPES: case ID_MODE_SHAPES:
...@@ -60,7 +60,7 @@ void SymbolControl::onModeChange(wxCommandEvent& ev) { ...@@ -60,7 +60,7 @@ void SymbolControl::onModeChange(wxCommandEvent& ev) {
selected_parts.clear(); selected_parts.clear();
signalSelectionChange(); signalSelectionChange();
} }
switchEditor(new_shared1<SymbolBasicShapeEditor>(this)); switchEditor(new_intrusive1<SymbolBasicShapeEditor>(this));
break; break;
} }
} }
...@@ -102,7 +102,7 @@ void SymbolControl::onUpdateSelection() { ...@@ -102,7 +102,7 @@ void SymbolControl::onUpdateSelection() {
if (single_selection != *selected_parts.begin()) { if (single_selection != *selected_parts.begin()) {
// begin editing another part // begin editing another part
single_selection = *selected_parts.begin(); single_selection = *selected_parts.begin();
editor = new_shared2<SymbolPointEditor>(this, single_selection); editor = new_intrusive2<SymbolPointEditor>(this, single_selection);
Refresh(false); Refresh(false);
} }
break; break;
...@@ -122,14 +122,14 @@ void SymbolControl::onUpdateSelection() { ...@@ -122,14 +122,14 @@ void SymbolControl::onUpdateSelection() {
void SymbolControl::selectPart(const SymbolPartP& part) { void SymbolControl::selectPart(const SymbolPartP& part) {
selected_parts.clear(); selected_parts.clear();
selected_parts.insert(part); selected_parts.insert(part);
switchEditor(new_shared2<SymbolSelectEditor>(this, false)); switchEditor(new_intrusive2<SymbolSelectEditor>(this, false));
signalSelectionChange(); signalSelectionChange();
} }
void SymbolControl::activatePart(const SymbolPartP& part) { void SymbolControl::activatePart(const SymbolPartP& part) {
selected_parts.clear(); selected_parts.clear();
selected_parts.insert(part); selected_parts.insert(part);
switchEditor(new_shared2<SymbolPointEditor>(this, part)); switchEditor(new_intrusive2<SymbolPointEditor>(this, part));
} }
void SymbolControl::signalSelectionChange() { void SymbolControl::signalSelectionChange() {
......
...@@ -22,7 +22,7 @@ class SymbolControl; ...@@ -22,7 +22,7 @@ class SymbolControl;
* Differrent SymbolEditors represent different tools. * Differrent SymbolEditors represent different tools.
* NOTE : Do not confuse with SymbolEditor (a FieldEditor) * NOTE : Do not confuse with SymbolEditor (a FieldEditor)
*/ */
class SymbolEditorBase { class SymbolEditorBase : public IntrusivePtrVirtualBase {
protected: protected:
/// The control for which we are editing /// The control for which we are editing
SymbolControl& control; SymbolControl& control;
......
...@@ -84,7 +84,7 @@ wxThread::ExitCode ThumbnailThreadWorker::Entry() { ...@@ -84,7 +84,7 @@ wxThread::ExitCode ThumbnailThreadWorker::Entry() {
{ {
wxMutexLocker lock(parent->mutex); wxMutexLocker lock(parent->mutex);
parent->closed_requests.push_back(make_pair(current,img)); parent->closed_requests.push_back(make_pair(current,img));
current.reset(); current = ThumbnailRequestP();
parent->completed.Signal(); parent->completed.Signal();
} }
} }
......
...@@ -20,7 +20,7 @@ class ThumbnailThreadWorker; ...@@ -20,7 +20,7 @@ class ThumbnailThreadWorker;
// ----------------------------------------------------------------------------- : ThumbnailRequest // ----------------------------------------------------------------------------- : ThumbnailRequest
/// A request for some kind of thumbnail /// A request for some kind of thumbnail
class ThumbnailRequest { class ThumbnailRequest : public IntrusivePtrVirtualBase {
public: public:
ThumbnailRequest(void* owner, const String& cache_name, const wxDateTime& modified) ThumbnailRequest(void* owner, const String& cache_name, const wxDateTime& modified)
: owner(owner), cache_name(cache_name), modified(modified) {} : owner(owner), cache_name(cache_name), modified(modified) {}
......
...@@ -21,7 +21,7 @@ DECLARE_POINTER_TYPE(VersionData); ...@@ -21,7 +21,7 @@ DECLARE_POINTER_TYPE(VersionData);
// ----------------------------------------------------------------------------- : Update data // ----------------------------------------------------------------------------- : Update data
/// Information on available packages /// Information on available packages
class PackageVersionData { class PackageVersionData : public IntrusivePtrBase<PackageVersionData> {
public: public:
PackageVersionData() : is_installer(true) {} PackageVersionData() : is_installer(true) {}
...@@ -34,7 +34,7 @@ class PackageVersionData { ...@@ -34,7 +34,7 @@ class PackageVersionData {
}; };
/// Information on the latest availible version /// Information on the latest availible version
class VersionData { class VersionData : public IntrusivePtrBase<VersionData> {
public: public:
Version version; ///< Latest version number of MSE Version version; ///< Latest version number of MSE
String description; ///< html description of the latest MSE release String description; ///< html description of the latest MSE release
......
...@@ -163,7 +163,7 @@ void DropDownChoiceListBase::generateThumbnailImages() { ...@@ -163,7 +163,7 @@ void DropDownChoiceListBase::generateThumbnailImages() {
ThumbnailStatus status = style().thumbnails_status[i]; ThumbnailStatus status = style().thumbnails_status[i];
if (i >= image_count || status != THUMB_OK) { if (i >= image_count || status != THUMB_OK) {
// request this thumbnail // request this thumbnail
thumbnail_thread.request( new_shared3<ChoiceThumbnailRequest>(&cve, i, status == THUMB_NOT_MADE) ); thumbnail_thread.request( new_intrusive3<ChoiceThumbnailRequest>(&cve, i, status == THUMB_NOT_MADE) );
} }
} }
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <gui/drop_down_list.hpp> #include <gui/drop_down_list.hpp>
#include <render/value/choice.hpp> #include <render/value/choice.hpp>
DECLARE_POINTER_TYPE(DropDownList); DECLARE_SHARED_POINTER_TYPE(DropDownList);
// ----------------------------------------------------------------------------- : ChoiceValueEditor // ----------------------------------------------------------------------------- : ChoiceValueEditor
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <gui/value/editor.hpp> #include <gui/value/editor.hpp>
#include <render/value/color.hpp> #include <render/value/color.hpp>
DECLARE_POINTER_TYPE(DropDownList); DECLARE_SHARED_POINTER_TYPE(DropDownList);
// ----------------------------------------------------------------------------- : ColorValueEditor // ----------------------------------------------------------------------------- : ColorValueEditor
......
...@@ -37,7 +37,7 @@ void ImageValueEditor::sliceImage(const Image& image) { ...@@ -37,7 +37,7 @@ void ImageValueEditor::sliceImage(const Image& image) {
if (mask_image.LoadFile(*image_file)) { if (mask_image.LoadFile(*image_file)) {
Image resampled(style().width, style().height); Image resampled(style().width, style().height);
resample(mask_image, resampled); resample(mask_image, resampled);
mask = new_shared1<AlphaMask>(resampled); mask = new_intrusive1<AlphaMask>(resampled);
} }
} }
// slice // slice
......
...@@ -89,8 +89,8 @@ void WelcomeWindow::onNewSet(wxCommandEvent&) { ...@@ -89,8 +89,8 @@ void WelcomeWindow::onNewSet(wxCommandEvent&) {
// TODO: MOVEME // TODO: MOVEME
template <typename T> template <typename T>
shared_ptr<T> open_package(const String& filename) { intrusive_ptr<T> open_package(const String& filename) {
shared_ptr<T> package(new T); intrusive_ptr<T> package(new T);
package->open(filename); package->open(filename);
return package; return package;
} }
......
...@@ -22,6 +22,8 @@ DECLARE_TYPEOF_NO_REV(IndexMap<FieldP COMMA StyleP>); ...@@ -22,6 +22,8 @@ DECLARE_TYPEOF_NO_REV(IndexMap<FieldP COMMA StyleP>);
// ----------------------------------------------------------------------------- : DataViewer // ----------------------------------------------------------------------------- : DataViewer
DataViewer::DataViewer() : drawing(false) {}
DataViewer::~DataViewer() {}
// ----------------------------------------------------------------------------- : Drawing // ----------------------------------------------------------------------------- : Drawing
...@@ -84,10 +86,11 @@ Rotation DataViewer::getRotation() const { ...@@ -84,10 +86,11 @@ Rotation DataViewer::getRotation() const {
void DataViewer::setCard(const CardP& card, bool refresh) { void DataViewer::setCard(const CardP& card, bool refresh) {
if (!card) return; // TODO: clear viewer? if (!card) return; // TODO: clear viewer?
if (!refresh && this->card == card && this->stylesheet == set->stylesheetFor(card)) return; // already set StyleSheetP new_stylesheet = set->stylesheetForP(card);
if (!refresh && this->card == card && this->stylesheet == new_stylesheet) return; // already set
assert(set); assert(set);
this->card = card; this->card = card;
stylesheet = set->stylesheetFor(card); stylesheet = new_stylesheet;
setStyles(stylesheet, stylesheet->card_style); setStyles(stylesheet, stylesheet->card_style);
setData(card->data); setData(card->data);
onChangeSize(); onChangeSize();
......
...@@ -22,7 +22,8 @@ class Context; ...@@ -22,7 +22,8 @@ class Context;
/// A viewer can generate an image of some values, usually a card. /// A viewer can generate an image of some values, usually a card.
class DataViewer : public SetView { class DataViewer : public SetView {
public: public:
DataViewer() : drawing(false) {} DataViewer();
~DataViewer();
// --------------------------------------------------- : Drawing // --------------------------------------------------- : Drawing
...@@ -57,7 +58,7 @@ class DataViewer : public SetView { ...@@ -57,7 +58,7 @@ class DataViewer : public SetView {
/// The rotation to use /// The rotation to use
virtual Rotation getRotation() const; virtual Rotation getRotation() const;
/// The card we are viewing /// The card we are viewing
inline CardP getCard() const { return card; } inline const CardP& getCard() const { return card; }
/// Invalidate and redraw (the area of) a single value viewer /// Invalidate and redraw (the area of) a single value viewer
virtual void redraw(const ValueViewer&) {} virtual void redraw(const ValueViewer&) {}
......
...@@ -53,24 +53,24 @@ Image render_symbol(const SymbolP& symbol, const SymbolFilter& filter, double bo ...@@ -53,24 +53,24 @@ Image render_symbol(const SymbolP& symbol, const SymbolFilter& filter, double bo
// ----------------------------------------------------------------------------- : SymbolFilter // ----------------------------------------------------------------------------- : SymbolFilter
IMPLEMENT_REFLECTION(SymbolFilter) { IMPLEMENT_REFLECTION_NO_SCRIPT(SymbolFilter) {
REFLECT_IF_NOT_READING { REFLECT_IF_NOT_READING {
String fill_type = fillType(); String fill_type = fillType();
REFLECT(fill_type); REFLECT(fill_type);
} }
} }
template <> void GetMember::handle(const shared_ptr<SymbolFilter>& f) { template <> void GetMember::handle(const intrusive_ptr<SymbolFilter>& f) {
handle(*f); handle(*f);
} }
template <> template <>
shared_ptr<SymbolFilter> read_new<SymbolFilter>(Reader& reader) { intrusive_ptr<SymbolFilter> read_new<SymbolFilter>(Reader& reader) {
// there must be a fill type specified // there must be a fill type specified
String fill_type; String fill_type;
reader.handle(_("fill type"), fill_type); reader.handle(_("fill type"), fill_type);
if (fill_type == _("solid")) return new_shared<SolidFillSymbolFilter>(); if (fill_type == _("solid")) return new_intrusive<SolidFillSymbolFilter>();
else if (fill_type == _("linear gradient")) return new_shared<LinearGradientSymbolFilter>(); else if (fill_type == _("linear gradient")) return new_intrusive<LinearGradientSymbolFilter>();
else if (fill_type == _("radial gradient")) return new_shared<RadialGradientSymbolFilter>(); else if (fill_type == _("radial gradient")) return new_intrusive<RadialGradientSymbolFilter>();
else { else {
throw ParseError(_ERROR_1_("unsupported fill type", fill_type)); throw ParseError(_ERROR_1_("unsupported fill type", fill_type));
} }
......
...@@ -46,7 +46,7 @@ enum SymbolSet ...@@ -46,7 +46,7 @@ enum SymbolSet
// ----------------------------------------------------------------------------- : SymbolFilter // ----------------------------------------------------------------------------- : SymbolFilter
/// Base class for symbol filters /// Base class for symbol filters
class SymbolFilter { class SymbolFilter : public IntrusivePtrVirtualBase {
public: public:
virtual ~SymbolFilter() {} virtual ~SymbolFilter() {}
/// What color should the symbol have at location (x, y)? /// What color should the symbol have at location (x, y)?
...@@ -59,7 +59,7 @@ class SymbolFilter { ...@@ -59,7 +59,7 @@ class SymbolFilter {
}; };
template <> template <>
shared_ptr<SymbolFilter> read_new<SymbolFilter>(Reader& reader); intrusive_ptr<SymbolFilter> read_new<SymbolFilter>(Reader& reader);
// ----------------------------------------------------------------------------- : SymbolFilter types // ----------------------------------------------------------------------------- : SymbolFilter types
......
...@@ -128,14 +128,14 @@ struct TextElementsFromString { ...@@ -128,14 +128,14 @@ struct TextElementsFromString {
else if (is_substr(text, tag_start, _("<atom"))) { else if (is_substr(text, tag_start, _("<atom"))) {
// 'atomic' indicator // 'atomic' indicator
size_t end_tag = min(end, match_close_tag(text, tag_start)); size_t end_tag = min(end, match_close_tag(text, tag_start));
shared_ptr<AtomTextElement> e(new AtomTextElement(text, pos, end_tag)); intrusive_ptr<AtomTextElement> e(new AtomTextElement(text, pos, end_tag));
fromString(e->elements, text, pos, end_tag, style, ctx); fromString(e->elements, text, pos, end_tag, style, ctx);
te.elements.push_back(e); te.elements.push_back(e);
pos = skip_tag(text, end_tag); pos = skip_tag(text, end_tag);
} else if (is_substr(text, tag_start, _( "<error"))) { } else if (is_substr(text, tag_start, _( "<error"))) {
// error indicator // error indicator
size_t end_tag = min(end, match_close_tag(text, tag_start)); size_t end_tag = min(end, match_close_tag(text, tag_start));
shared_ptr<ErrorTextElement> e(new ErrorTextElement(text, pos, end_tag)); intrusive_ptr<ErrorTextElement> e(new ErrorTextElement(text, pos, end_tag));
fromString(e->elements, text, pos, end_tag, style, ctx); fromString(e->elements, text, pos, end_tag, style, ctx);
te.elements.push_back(e); te.elements.push_back(e);
pos = skip_tag(text, end_tag); pos = skip_tag(text, end_tag);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <util/prec.hpp> #include <util/prec.hpp>
#include <util/rotation.hpp> #include <util/rotation.hpp>
#include <util/real_point.hpp> #include <util/real_point.hpp>
#include <data/font.hpp>
DECLARE_POINTER_TYPE(TextElement); DECLARE_POINTER_TYPE(TextElement);
DECLARE_POINTER_TYPE(Font); DECLARE_POINTER_TYPE(Font);
...@@ -47,7 +48,7 @@ struct CharInfo { ...@@ -47,7 +48,7 @@ struct CharInfo {
}; };
/// A section of text that can be rendered using a TextViewer /// A section of text that can be rendered using a TextViewer
class TextElement { class TextElement : public IntrusivePtrBase<TextElement> {
public: public:
/// The text of which a subsection is drawn /// The text of which a subsection is drawn
String text; String text;
......
...@@ -303,7 +303,7 @@ void TextViewer::setExactScrollPosition(double pos) { ...@@ -303,7 +303,7 @@ void TextViewer::setExactScrollPosition(double pos) {
void TextViewer::prepareElements(const String& text, const TextStyle& style, Context& ctx) { void TextViewer::prepareElements(const String& text, const TextStyle& style, Context& ctx) {
if (style.always_symbol) { if (style.always_symbol) {
elements.elements.clear(); elements.elements.clear();
elements.elements.push_back(new_shared5<SymbolTextElement>(text, 0, text.size(), style.symbol_font, &ctx)); elements.elements.push_back(new_intrusive5<SymbolTextElement>(text, 0, text.size(), style.symbol_font, &ctx));
} else { } else {
elements.fromString(text, 0, text.size(), style, ctx); elements.fromString(text, 0, text.size(), style, ctx);
} }
......
...@@ -101,6 +101,6 @@ void ColorValueViewer::loadMask(const Rotation& rot) const { ...@@ -101,6 +101,6 @@ void ColorValueViewer::loadMask(const Rotation& rot) const {
if (image.LoadFile(*image_file)) { if (image.LoadFile(*image_file)) {
Image resampled(w,h); Image resampled(w,h);
resample(image, resampled); resample(image, resampled);
alpha_mask = new_shared1<AlphaMask>(resampled); alpha_mask = new_intrusive1<AlphaMask>(resampled);
} }
} }
...@@ -93,7 +93,7 @@ void ImageValueViewer::loadMask(const Rotation& rot) const { ...@@ -93,7 +93,7 @@ void ImageValueViewer::loadMask(const Rotation& rot) const {
if (image.LoadFile(*image_file)) { if (image.LoadFile(*image_file)) {
Image resampled(w,h); Image resampled(w,h);
resample(image, resampled); resample(image, resampled);
alpha_mask = new_shared1<AlphaMask>(resampled); alpha_mask = new_intrusive1<AlphaMask>(resampled);
} }
} }
......
...@@ -24,7 +24,7 @@ DECLARE_POINTER_TYPE(Value); ...@@ -24,7 +24,7 @@ DECLARE_POINTER_TYPE(Value);
/// The virtual viewer control for a single field on a card (or in the set data) /// The virtual viewer control for a single field on a card (or in the set data)
/** A viewer can only display a value, not edit it, ValueEditor is used for that */ /** A viewer can only display a value, not edit it, ValueEditor is used for that */
class ValueViewer : public StyleListener{ class ValueViewer : public StyleListener {
public: public:
/// Construct a ValueViewer, set the value at a later time /// Construct a ValueViewer, set the value at a later time
ValueViewer(DataViewer& parent, const StyleP& style); ValueViewer(DataViewer& parent, const StyleP& style);
......
...@@ -148,15 +148,15 @@ WXCURSOR_HAND CURSOR DISCARDABLE "wx/msw/hand.cur" ...@@ -148,15 +148,15 @@ WXCURSOR_HAND CURSOR DISCARDABLE "wx/msw/hand.cur"
// -------------------------------------------------------- : Version info // -------------------------------------------------------- : Version info
1 VERSIONINFO 1 VERSIONINFO
FILEVERSION 0,3,1 FILEVERSION 0,3,2
PRODUCTVERSION 0,3,1 PRODUCTVERSION 0,3,2
FILETYPE VFT_APP FILETYPE VFT_APP
{ {
BLOCK "StringFileInfo" BLOCK "StringFileInfo"
{ {
BLOCK "040904E4" BLOCK "040904E4"
{ {
VALUE "FileVersion", "0.3.1" VALUE "FileVersion", "0.3.2"
VALUE "License", "GNU General Public License 2 or later; This is free software, and you are welcome to redistribute it under certain conditions; See the help file for details" VALUE "License", "GNU General Public License 2 or later; This is free software, and you are welcome to redistribute it under certain conditions; See the help file for details"
VALUE "FileDescription", "Magic Set Editor" VALUE "FileDescription", "Magic Set Editor"
VALUE "InternalName", "mse2/8" VALUE "InternalName", "mse2/8"
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <script/functions/util.hpp> #include <script/functions/util.hpp>
#include <util/tagged_string.hpp> #include <util/tagged_string.hpp>
#include <data/set.hpp> #include <data/set.hpp>
#include <data/card.hpp>
#include <data/game.hpp> #include <data/game.hpp>
DECLARE_TYPEOF_COLLECTION(pair<String COMMA ScriptValueP>); DECLARE_TYPEOF_COLLECTION(pair<String COMMA ScriptValueP>);
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <script/image.hpp> #include <script/image.hpp>
// used by the functions // used by the functions
#include <data/set.hpp> #include <data/set.hpp>
#include <data/card.hpp>
#include <data/stylesheet.hpp> #include <data/stylesheet.hpp>
#include <data/symbol.hpp> #include <data/symbol.hpp>
#include <data/field/symbol.hpp> #include <data/field/symbol.hpp>
...@@ -78,7 +79,7 @@ SCRIPT_FUNCTION(symbol_variation) { ...@@ -78,7 +79,7 @@ SCRIPT_FUNCTION(symbol_variation) {
// find style // find style
SCRIPT_PARAM(Set*, set); SCRIPT_PARAM(Set*, set);
SCRIPT_OPTIONAL_PARAM_(CardP, card); SCRIPT_OPTIONAL_PARAM_(CardP, card);
SymbolStyleP style = dynamic_pointer_cast<SymbolStyle>(set->stylesheetFor(card)->styleFor(value->fieldP)); SymbolStyleP style = dynamic_pointer_cast<SymbolStyle>(set->stylesheetForP(card)->styleFor(value->fieldP));
if (!style) throw InternalError(_("Symbol value has a style of the wrong type")); if (!style) throw InternalError(_("Symbol value has a style of the wrong type"));
// find variation // find variation
FOR_EACH(v, style->variations) { FOR_EACH(v, style->variations) {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <util/prec.hpp> #include <util/prec.hpp>
#include <script/value.hpp> #include <script/value.hpp>
DECLARE_INTRUSIVE_POINTER_TYPE(Script); DECLARE_POINTER_TYPE(Script);
// ----------------------------------------------------------------------------- : Instructions // ----------------------------------------------------------------------------- : Instructions
......
...@@ -71,7 +71,7 @@ Context& SetScriptContext::getContext(const StyleSheetP& stylesheet) { ...@@ -71,7 +71,7 @@ Context& SetScriptContext::getContext(const StyleSheetP& stylesheet) {
} }
} }
Context& SetScriptContext::getContext(const CardP& card) { Context& SetScriptContext::getContext(const CardP& card) {
Context& ctx = getContext(set.stylesheetFor(card)); Context& ctx = getContext(set.stylesheetForP(card));
if (card) { if (card) {
ctx.setVariable(_("card"), to_script(card)); ctx.setVariable(_("card"), to_script(card));
} else { } else {
...@@ -185,15 +185,13 @@ void SetScriptManager::onAction(const Action& action, bool undone) { ...@@ -185,15 +185,13 @@ void SetScriptManager::onAction(const Action& action, bool undone) {
void SetScriptManager::updateStyles(const CardP& card) { void SetScriptManager::updateStyles(const CardP& card) {
// lastUpdatedCard = card; // lastUpdatedCard = card;
StyleSheetP stylesheet = set.stylesheetFor(card); const StyleSheet& stylesheet = set.stylesheetFor(card);
Context& ctx = getContext(card); Context& ctx = getContext(card);
// update all styles // update all styles
FOR_EACH(s, stylesheet->card_style) { FOR_EACH_CONST(s, stylesheet.card_style) {
if (s->update(ctx)) { if (s->update(ctx)) {
s->tellListeners();
// style has changed, tell listeners // style has changed, tell listeners
//%% ScriptStyleEvent change(stylesheet.get(), s.get()); s->tellListeners();
// set->actions.tellListeners(change);
} }
} }
} }
......
...@@ -50,7 +50,7 @@ class SetScriptContext { ...@@ -50,7 +50,7 @@ class SetScriptContext {
/** Whenever there is an action all necessary scripts are executed. /** Whenever there is an action all necessary scripts are executed.
* Executes both Value scripts and Style scriptables. * Executes both Value scripts and Style scriptables.
* *
* The context contains a normal pointer to the set, not a shared_ptr, because the set * The context contains a normal pointer to the set, not a shared/intrusive_ptr, because the set
* itself owns this object. * itself owns this object.
*/ */
class SetScriptManager : public SetScriptContext, public ActionListener { class SetScriptManager : public SetScriptContext, public ActionListener {
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <script/parser.hpp> #include <script/parser.hpp>
#include <script/to_value.hpp> #include <script/to_value.hpp>
DECLARE_INTRUSIVE_POINTER_TYPE(Script); DECLARE_POINTER_TYPE(Script);
// ----------------------------------------------------------------------------- : Store // ----------------------------------------------------------------------------- : Store
......
...@@ -219,7 +219,7 @@ inline ScriptValueP to_script(const map<K,V>* v) { return new_intrusive1<Sc ...@@ -219,7 +219,7 @@ inline ScriptValueP to_script(const map<K,V>* v) { return new_intrusive1<Sc
template <typename K, typename V> template <typename K, typename V>
inline ScriptValueP to_script(const IndexMap<K,V>* v) { return new_intrusive1<ScriptMap<IndexMap<K,V> > >(v); } inline ScriptValueP to_script(const IndexMap<K,V>* v) { return new_intrusive1<ScriptMap<IndexMap<K,V> > >(v); }
template <typename T> template <typename T>
inline ScriptValueP to_script(const shared_ptr<T>& v) { return new_intrusive1<ScriptObject<shared_ptr<T> > >(v); } inline ScriptValueP to_script(const intrusive_ptr<T>& v) { return new_intrusive1<ScriptObject<intrusive_ptr<T> > >(v); }
template <typename T> template <typename T>
inline ScriptValueP to_script(const Defaultable<T>& v) { return to_script(v()); } inline ScriptValueP to_script(const Defaultable<T>& v) { return to_script(v()); }
......
...@@ -15,7 +15,7 @@ class Dependency; ...@@ -15,7 +15,7 @@ class Dependency;
// ----------------------------------------------------------------------------- : ScriptValue // ----------------------------------------------------------------------------- : ScriptValue
DECLARE_INTRUSIVE_POINTER_TYPE(ScriptValue); DECLARE_POINTER_TYPE(ScriptValue);
enum ScriptType enum ScriptType
{ SCRIPT_NIL { SCRIPT_NIL
...@@ -33,7 +33,7 @@ enum ScriptType ...@@ -33,7 +33,7 @@ enum ScriptType
/// A value that can be handled by the scripting engine. /// A value that can be handled by the scripting engine.
/// Actual values are derived types /// Actual values are derived types
class ScriptValue : public IntrusivePtrBase { class ScriptValue : public IntrusivePtrBaseWithDelete {
public: public:
virtual ~ScriptValue() {} virtual ~ScriptValue() {}
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <script/value.hpp> #include <script/value.hpp>
class Script; class Script;
DECLARE_INTRUSIVE_POINTER_TYPE(Script); DECLARE_POINTER_TYPE(Script);
template <typename T> class Defaultable; template <typename T> class Defaultable;
template <typename T> class Scriptable; template <typename T> class Scriptable;
...@@ -39,6 +39,9 @@ class GetDefaultMember { ...@@ -39,6 +39,9 @@ class GetDefaultMember {
/// Handle an object: we don't match things with a name /// Handle an object: we don't match things with a name
template <typename T> template <typename T>
void handle(const Char* name, const T& object) {} void handle(const Char* name, const T& object) {}
/// Don't handle a value
template <typename T>
inline void handleNoScript(const Char* name, T& value) {}
/// Handle an object: investigate children, or store it if we know how /// Handle an object: investigate children, or store it if we know how
void handle(const Char *); void handle(const Char *);
...@@ -50,7 +53,7 @@ class GetDefaultMember { ...@@ -50,7 +53,7 @@ class GetDefaultMember {
template <typename T> void handle(const vector<T>& c) { value = to_script(&c); } template <typename T> void handle(const vector<T>& c) { value = to_script(&c); }
template <typename K, typename V> void handle(const map<K,V>& c) { value = to_script(&c); } template <typename K, typename V> void handle(const map<K,V>& c) { value = to_script(&c); }
template <typename K, typename V> void handle(const IndexMap<K,V>& c) { value = to_script(&c); } template <typename K, typename V> void handle(const IndexMap<K,V>& c) { value = to_script(&c); }
template <typename T> void handle(const shared_ptr<T>& p) { value = to_script(p); } template <typename T> void handle(const intrusive_ptr<T>& p) { value = to_script(p); }
void handle(const ScriptValueP&); void handle(const ScriptValueP&);
void handle(const ScriptP&); void handle(const ScriptP&);
private: private:
...@@ -85,6 +88,9 @@ class GetMember : private GetDefaultMember { ...@@ -85,6 +88,9 @@ class GetMember : private GetDefaultMember {
gdm.handle(object); gdm.handle(object);
} }
} }
/// Don't handle a value
template <typename T>
inline void handleNoScript(const Char* name, T& value) {}
/// Handle an object: investigate children /// Handle an object: investigate children
template <typename T> void handle(const T&); template <typename T> void handle(const T&);
/// Handle an index map: invistigate keys /// Handle an index map: invistigate keys
......
...@@ -412,9 +412,9 @@ IMPLEMENT_REFLECTION(Packaged) { ...@@ -412,9 +412,9 @@ IMPLEMENT_REFLECTION(Packaged) {
REFLECT(short_name); REFLECT(short_name);
REFLECT(full_name); REFLECT(full_name);
REFLECT_N("icon", icon_filename); REFLECT_N("icon", icon_filename);
REFLECT(position_hint); REFLECT_NO_SCRIPT(position_hint);
REFLECT(version); REFLECT(version);
REFLECT_N("depends ons", dependencies); // hack for singular_form REFLECT_NO_SCRIPT_N("depends ons", dependencies); // hack for singular_form
} }
Packaged::Packaged() Packaged::Packaged()
......
...@@ -45,7 +45,7 @@ DECLARE_DYNAMIC_ARG(Package*, clipboard_package); ...@@ -45,7 +45,7 @@ DECLARE_DYNAMIC_ARG(Package*, clipboard_package);
* *
* TODO: maybe support sub packages (a package inside another package)? * TODO: maybe support sub packages (a package inside another package)?
*/ */
class Package { class Package : public IntrusivePtrVirtualBase {
public: public:
// --------------------------------------------------- : Managing the outside of the package // --------------------------------------------------- : Managing the outside of the package
...@@ -177,7 +177,7 @@ class Package { ...@@ -177,7 +177,7 @@ class Package {
// ----------------------------------------------------------------------------- : Packaged // ----------------------------------------------------------------------------- : Packaged
/// Dependencies of a package /// Dependencies of a package
class PackageDependency { class PackageDependency : public IntrusivePtrBase<PackageDependency> {
public: public:
String package; ///< Name of the package someone depends on String package; ///< Name of the package someone depends on
Version version; ///< Minimal required version of that package Version version; ///< Minimal required version of that package
......
...@@ -65,12 +65,12 @@ PackagedP PackageManager::openAny(const String& name, bool just_header) { ...@@ -65,12 +65,12 @@ PackagedP PackageManager::openAny(const String& name, bool just_header) {
return p; return p;
} else { } else {
// load with the right type, based on extension // load with the right type, based on extension
if (fn.GetExt() == _("mse-game")) p = new_shared<Game>(); if (fn.GetExt() == _("mse-game")) p = new_intrusive<Game>();
else if (fn.GetExt() == _("mse-style")) p = new_shared<StyleSheet>(); else if (fn.GetExt() == _("mse-style")) p = new_intrusive<StyleSheet>();
else if (fn.GetExt() == _("mse-locale")) p = new_shared<Locale>(); else if (fn.GetExt() == _("mse-locale")) p = new_intrusive<Locale>();
else if (fn.GetExt() == _("mse-include")) p = new_shared<IncludePackage>(); else if (fn.GetExt() == _("mse-include")) p = new_intrusive<IncludePackage>();
else if (fn.GetExt() == _("mse-symbol-font")) p = new_shared<SymbolFont>(); else if (fn.GetExt() == _("mse-symbol-font")) p = new_intrusive<SymbolFont>();
else if (fn.GetExt() == _("mse-export-template")) p = new_shared<ExportTemplate>(); else if (fn.GetExt() == _("mse-export-template")) p = new_intrusive<ExportTemplate>();
else { else {
throw PackageError(_("Unrecognized package type: '") + fn.GetExt() + _("'\nwhile trying to open: ") + name); throw PackageError(_("Unrecognized package type: '") + fn.GetExt() + _("'\nwhile trying to open: ") + name);
} }
......
...@@ -33,19 +33,19 @@ class PackageManager { ...@@ -33,19 +33,19 @@ class PackageManager {
/// Open a package with the specified name (including extension) /// Open a package with the specified name (including extension)
template <typename T> template <typename T>
shared_ptr<T> open(const String& name) { intrusive_ptr<T> open(const String& name) {
wxFileName fn(data_directory + _("/") + name); wxFileName fn(data_directory + _("/") + name);
fn.Normalize(); fn.Normalize();
String filename = fn.GetFullPath(); String filename = fn.GetFullPath();
// Is this package already loaded? // Is this package already loaded?
PackagedP& p = loaded_packages[filename]; PackagedP& p = loaded_packages[filename];
shared_ptr<T> typedP = dynamic_pointer_cast<T>(p); intrusive_ptr<T> typedP = dynamic_pointer_cast<T>(p);
if (typedP) { if (typedP) {
typedP->loadFully(); typedP->loadFully();
return typedP; return typedP;
} else { } else {
// not loaded, or loaded with wrong type (i.e. with just_header) // not loaded, or loaded with wrong type (i.e. with just_header)
p = typedP = new_shared<T>(); p = typedP = new_intrusive<T>();
typedP->open(filename); typedP->open(filename);
return typedP; return typedP;
} }
......
...@@ -82,14 +82,18 @@ class Reader { ...@@ -82,14 +82,18 @@ class Reader {
exitBlock(); exitBlock();
} }
} }
/// Handle a value
template <typename T>
inline void handleNoScript(const Char* name, T& value) { handle(name,value); }
/// Reads a vector from the input stream /// Reads a vector from the input stream
template <typename T> template <typename T>
void handle(const Char* name, vector<T>& vector); void handle(const Char* name, vector<T>& vector);
/// Reads an object of type T from the input stream /// Reads an object of type T from the input stream
template <typename T> void handle(T& object); template <typename T> void handle(T& object);
/// Reads a shared_ptr from the input stream /// Reads a intrusive_ptr from the input stream
template <typename T> void handle(shared_ptr<T>& pointer); template <typename T> void handle(intrusive_ptr<T>& pointer);
/// Reads a map from the input stream /// Reads a map from the input stream
template <typename V> void handle(map<String,V>& m); template <typename V> void handle(map<String,V>& m);
/// Reads an IndexMap from the input stream, reads only keys that already exist in the map /// Reads an IndexMap from the input stream, reads only keys that already exist in the map
...@@ -178,8 +182,8 @@ class Reader { ...@@ -178,8 +182,8 @@ class Reader {
* This function can be overloaded to provide different behaviour * This function can be overloaded to provide different behaviour
*/ */
template <typename T> template <typename T>
shared_ptr<T> read_new(Reader& reader) { intrusive_ptr<T> read_new(Reader& reader) {
return new_shared<T>(); return new_intrusive<T>();
} }
/// Update the 'index' member of a value for use by IndexMap /// Update the 'index' member of a value for use by IndexMap
...@@ -197,7 +201,7 @@ void Reader::handle(const Char* name, vector<T>& vector) { ...@@ -197,7 +201,7 @@ void Reader::handle(const Char* name, vector<T>& vector) {
} }
template <typename T> template <typename T>
void Reader::handle(shared_ptr<T>& pointer) { void Reader::handle(intrusive_ptr<T>& pointer) {
if (!pointer) pointer = read_new<T>(*this); if (!pointer) pointer = read_new<T>(*this);
handle(*pointer); handle(*pointer);
} }
......
...@@ -45,6 +45,10 @@ class Writer { ...@@ -45,6 +45,10 @@ class Writer {
handle(object); handle(object);
exitBlock(); exitBlock();
} }
/// Handle a value
template <typename T>
inline void handleNoScript(const Char* name, T& value) { handle(name,value); }
/// Write a vector to the output stream /// Write a vector to the output stream
template <typename T> template <typename T>
void handle(const Char* name, const vector<T>& vector); void handle(const Char* name, const vector<T>& vector);
...@@ -55,8 +59,8 @@ class Writer { ...@@ -55,8 +59,8 @@ class Writer {
/// Write an object of type T to the output stream /// Write an object of type T to the output stream
template <typename T> void handle(const T& object); template <typename T> void handle(const T& object);
/// Write a shared_ptr to the output stream /// Write a intrusive_ptr to the output stream
template <typename T> void handle(const shared_ptr<T>& pointer); template <typename T> void handle(const intrusive_ptr<T>& pointer);
/// Write a map to the output stream /// Write a map to the output stream
template <typename K, typename V> void handle(const map<K,V>& map); template <typename K, typename V> void handle(const map<K,V>& map);
/// Write an IndexMap to the output stream /// Write an IndexMap to the output stream
...@@ -107,7 +111,7 @@ void Writer::handle(const Char* name, const vector<T>& vec) { ...@@ -107,7 +111,7 @@ void Writer::handle(const Char* name, const vector<T>& vec) {
} }
template <typename T> template <typename T>
void Writer::handle(const shared_ptr<T>& pointer) { void Writer::handle(const intrusive_ptr<T>& pointer) {
if (pointer) handle(*pointer); if (pointer) handle(*pointer);
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment