default smart pointer type switched to intrusive_ptr

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@337 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-05-11 21:34:53 +00:00
parent 3b6743b110
commit 33fd2b5e18
103 changed files with 368 additions and 256 deletions
+7
View File
@@ -9,6 +9,7 @@
#include <data/action/set.hpp>
#include <data/set.hpp>
#include <data/card.hpp>
#include <data/stylesheet.hpp>
#include <util/error.hpp>
// ----------------------------------------------------------------------------- : Add card
@@ -89,6 +90,9 @@ void DisplayChangeAction::perform(bool to_undo) {
}
ChangeCardStyleAction::ChangeCardStyleAction(const CardP& card, const StyleSheetP& stylesheet)
: card(card), stylesheet(stylesheet)
{}
String ChangeCardStyleAction::getName(bool to_undo) const {
return _("Change style");
}
@@ -97,6 +101,9 @@ void ChangeCardStyleAction::perform(bool to_undo) {
}
ChangeSetStyleAction::ChangeSetStyleAction(Set& set, const CardP& card)
: set(set), card(card)
{}
String ChangeSetStyleAction::getName(bool to_undo) const {
return _("Change style (all cards)");
}
+2 -4
View File
@@ -87,8 +87,7 @@ class DisplayChangeAction : public Action {
/// Changing the style of a a card
class ChangeCardStyleAction : public DisplayChangeAction {
public:
ChangeCardStyleAction(const CardP& card, const StyleSheetP& stylesheet)
: card(card), stylesheet(stylesheet) {}
ChangeCardStyleAction(const CardP& card, const StyleSheetP& stylesheet);
virtual String getName(bool to_undo) const;
virtual void perform(bool to_undo);
@@ -101,8 +100,7 @@ class ChangeCardStyleAction : public DisplayChangeAction {
/// Changing the style of a set to that of a card
class ChangeSetStyleAction : public DisplayChangeAction {
public:
ChangeSetStyleAction(Set& set, const CardP& card)
: set(set), card(card) {}
ChangeSetStyleAction(Set& set, const CardP& card);
virtual String getName(bool to_undo) const;
virtual void perform(bool to_undo);
+3 -3
View File
@@ -289,7 +289,7 @@ double ssqrt(double x) {
}
// Remove a single control point
class SinglePointRemoveAction : public Action {
class SinglePointRemoveAction : public Action, public IntrusivePtrBase<SinglePointRemoveAction> {
public:
SinglePointRemoveAction(const SymbolPartP& part, UInt position);
@@ -393,7 +393,7 @@ ControlPointRemoveAction::ControlPointRemoveAction(const SymbolPartP& part, cons
FOR_EACH(point, part->points) {
if (toDelete.find(point) != toDelete.end()) {
// remove this point
removals.push_back(new_shared2<SinglePointRemoveAction>(part, index));
removals.push_back(new_intrusive2<SinglePointRemoveAction>(part, index));
}
++index;
}
@@ -417,7 +417,7 @@ void ControlPointRemoveAction::perform(bool to_undo) {
Action* controlPointRemoveAction(const SymbolPartP& part, const set<ControlPointP>& toDelete) {
if (part->points.size() - toDelete.size() < 2) {
// TODO : remove part?
//new_shared<ControlPointRemoveAllAction>(part);
//new_intrusive<ControlPointRemoveAllAction>(part);
return 0; // no action
} else {
return new ControlPointRemoveAction(part, toDelete);
+1 -1
View File
@@ -36,7 +36,7 @@ inline void swap_value(TextValue& a, TextValue ::ValueType& b
template <typename T, bool ALLOW_MERGE>
class SimpleValueAction : public ValueAction {
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)
{}
+1
View File
@@ -8,6 +8,7 @@
#include <data/card.hpp>
#include <data/game.hpp>
#include <data/stylesheet.hpp>
#include <data/field.hpp>
#include <util/error.hpp>
#include <util/reflect.hpp>
+1 -1
View File
@@ -24,7 +24,7 @@ DECLARE_POINTER_TYPE(StyleSheet);
// ----------------------------------------------------------------------------- : Card
/// A card from a card Set
class Card {
class Card : public IntrusivePtrVirtualBase {
public:
/// Default constructor, uses game_for_new_cards to make the game
Card();
+9 -9
View File
@@ -61,18 +61,18 @@ IMPLEMENT_REFLECTION(Field) {
}
template <>
shared_ptr<Field> read_new<Field>(Reader& reader) {
intrusive_ptr<Field> read_new<Field>(Reader& reader) {
// there must be a type specified
String type;
reader.handle(_("type"), type);
if (type == _("text")) return new_shared<TextField>();
else if (type == _("choice")) return new_shared<ChoiceField>();
else if (type == _("multiple choice")) return new_shared<MultipleChoiceField>();
else if (type == _("boolean")) return new_shared<BooleanField>();
else if (type == _("image")) return new_shared<ImageField>();
else if (type == _("symbol")) return new_shared<SymbolField>();
else if (type == _("color")) return new_shared<ColorField>();
else if (type == _("info")) return new_shared<InfoField>();
if (type == _("text")) return new_intrusive<TextField>();
else if (type == _("choice")) return new_intrusive<ChoiceField>();
else if (type == _("multiple choice")) return new_intrusive<MultipleChoiceField>();
else if (type == _("boolean")) return new_intrusive<BooleanField>();
else if (type == _("image")) return new_intrusive<ImageField>();
else if (type == _("symbol")) return new_intrusive<SymbolField>();
else if (type == _("color")) return new_intrusive<ColorField>();
else if (type == _("info")) return new_intrusive<InfoField>();
else {
throw ParseError(_("Unsupported field type: '") + type + _("'"));
}
+8 -8
View File
@@ -32,7 +32,7 @@ DECLARE_POINTER_TYPE(ValueEditor);
// ----------------------------------------------------------------------------- : Field
/// Information on how to store a value
class Field {
class Field : public IntrusivePtrVirtualBase {
public:
Field();
virtual ~Field();
@@ -71,7 +71,7 @@ class Field {
};
template <>
shared_ptr<Field> read_new<Field>(Reader& reader);
intrusive_ptr<Field> read_new<Field>(Reader& reader);
inline void update_index(FieldP& f, size_t index) {
f->index = index;
}
@@ -79,7 +79,7 @@ inline void update_index(FieldP& f, size_t index) {
// ----------------------------------------------------------------------------- : Style
/// Style information needed to display a Value in a Field.
class Style {
class Style : public IntrusivePtrVirtualBase {
public:
Style(const FieldP&);
virtual ~Style();
@@ -134,7 +134,7 @@ template <> StyleP read_new<Style>(Reader&);
// ----------------------------------------------------------------------------- : StyleListener
/// An object that can respond when a style changes;
class StyleListener {
class StyleListener : public IntrusivePtrVirtualBase {
public:
StyleListener(const StyleP& style);
virtual ~StyleListener();
@@ -148,7 +148,7 @@ class StyleListener {
// ----------------------------------------------------------------------------- : Value
/// A specific value 'in' a Field.
class Value {
class Value : public IntrusivePtrVirtualBase {
public:
inline Value(const FieldP& field) : fieldP(field) {}
virtual ~Value();
@@ -189,14 +189,14 @@ template <> ValueP read_new<Value>(Reader&);
#define IMPLEMENT_FIELD_TYPE(Type) \
StyleP Type ## Field::newStyle(const FieldP& thisP) const { \
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 { \
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 { \
return new_shared1<Type ## Style>(*this); \
return new_intrusive1<Type ## Style>(*this); \
}
#define DECLARE_STYLE_TYPE(Type) \
+2 -2
View File
@@ -11,8 +11,8 @@
// ----------------------------------------------------------------------------- : BooleanField
BooleanField::BooleanField() {
choices->choices.push_back(new_shared1<Choice>(_("yes")));
choices->choices.push_back(new_shared1<Choice>(_("no")));
choices->choices.push_back(new_intrusive1<Choice>(_("yes")));
choices->choices.push_back(new_intrusive1<Choice>(_("no")));
choices->initIds();
}
+2 -2
View File
@@ -30,7 +30,7 @@ class ChoiceField : public Field {
DECLARE_FIELD_TYPE(Choice);
class Choice;
typedef shared_ptr<Choice> ChoiceP;
typedef intrusive_ptr<Choice> ChoiceP;
ChoiceP choices; ///< A choice group of possible choices
OptionalScript script; ///< Script to apply to all values
@@ -47,7 +47,7 @@ class ChoiceField : public Field {
};
/// An item that can be chosen for this field
class ChoiceField::Choice {
class ChoiceField::Choice : public IntrusivePtrBase<ChoiceField::Choice> {
public:
Choice();
Choice(const String& name);
+2 -2
View File
@@ -27,7 +27,7 @@ class ColorField : public Field {
DECLARE_FIELD_TYPE(Color);
class Choice;
typedef shared_ptr<Choice> ChoiceP;
typedef intrusive_ptr<Choice> ChoiceP;
OptionalScript script; ///< Script to apply to all values
OptionalScript default_script; ///< Script that generates the default value
@@ -42,7 +42,7 @@ class ColorField : public Field {
};
/// A color that can be chosen for this field
class ColorField::Choice {
class ColorField::Choice : public IntrusivePtrBase<ColorField::Choice> {
public:
String name; ///< Name of the color
Color color; ///< The actual color
+2 -1
View File
@@ -32,8 +32,9 @@ IMPLEMENT_REFLECTION(SymbolStyle) {
SymbolVariation::SymbolVariation()
: border_radius(0.05)
{}
SymbolVariation::~SymbolVariation() {}
IMPLEMENT_REFLECTION(SymbolVariation) {
IMPLEMENT_REFLECTION_NO_SCRIPT(SymbolVariation) {
REFLECT(name);
REFLECT(border_radius);
REFLECT_NAMELESS(filter);
+2 -1
View File
@@ -47,9 +47,10 @@ class SymbolStyle : public Style {
};
/// Styling for a symbol variation, defines color, border, etc.
class SymbolVariation {
class SymbolVariation : public IntrusivePtrBase<SymbolVariation> {
public:
SymbolVariation();
~SymbolVariation();
String name; ///< Name of this variation
SymbolFilterP filter; ///< Filter to color the symbol
double border_radius; ///< Border radius for the symbol
+1 -1
View File
@@ -48,7 +48,7 @@ class TextField : public Field {
// ----------------------------------------------------------------------------- : TextStyle
/// Background behind text
class TextBackground {
class TextBackground : public IntrusivePtrBase<TextBackground> {
public:
ScriptableImage image; ///< background image, stretched to text size
RealSize displacement;
+1 -1
View File
@@ -79,7 +79,7 @@ wxFont Font::toWxFont(double scale) const {
}
}
IMPLEMENT_REFLECTION(Font) {
IMPLEMENT_REFLECTION_NO_SCRIPT(Font) {
REFLECT(name);
REFLECT(size);
REFLECT(weight);
+1 -1
View File
@@ -19,7 +19,7 @@ DECLARE_POINTER_TYPE(Font);
/// A font for rendering text
/** Contains additional information about scaling, color and shadow */
class Font {
class Font : public IntrusivePtrBase<Font> {
public:
Scriptable<String> name; ///< Name of the font
Scriptable<String> italic_name; ///< Font name for italic text (optional)
+3 -3
View File
@@ -383,7 +383,7 @@ class ApprCardDatabase : public ApprDatabase {
/** Each card has two records, a data record at the top of the file
* and a head record at the bottom
*/
class ApprCardRecord {
class ApprCardRecord : public IntrusivePtrBase<ApprCardRecord> {
public:
String name, sets;
String type, cc, pt, text, flavor;
@@ -536,7 +536,7 @@ void ApprCardDatabase::doRead(wxInputStream& in) {
progress_target->onProgress(0.4f * float(i) / cards.size(),
String(_("reading card ")) << i << _(" of ") << (int)cards.size());
}
card = new_shared<ApprCardRecord>();
card = new_intrusive<ApprCardRecord>();
card->readHead(data);
head_pos = in.TellI();
in.SeekI(card->data_pos);
@@ -751,7 +751,7 @@ bool ApprenticeExportWindow::exportSet() {
cardlist.removeSet(set->apprentice_code);
// add cards from set
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.write();
+1 -1
View File
@@ -20,7 +20,7 @@ DECLARE_POINTER_TYPE(FileFormat);
// ----------------------------------------------------------------------------- : FileFormat
/// A filter for a specific file format
class FileFormat {
class FileFormat : public IntrusivePtrVirtualBase {
public:
virtual ~FileFormat() {}
/// File extension used by this file format
+1 -3
View File
@@ -24,10 +24,8 @@ Bitmap export_bitmap(const SetP& set, const CardP& card) {
DataViewer viewer;
viewer.setSet(set);
viewer.setCard(card);
// style to use
StyleSheetP style = set->stylesheetFor(card);
// size of cards
if (settings.stylesheetSettingsFor(*style).card_normal_export()) {
if (settings.stylesheetSettingsFor(set->stylesheetFor(card)).card_normal_export()) {
// TODO
// viewer.rotation.angle = 0;
// viewer.rotation.zoom = 1.0;
+1 -1
View File
@@ -179,7 +179,7 @@ SymbolPartP read_symbol_part(const ImageData& data) {
}
// 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(y) / data.height
));
+1 -1
View File
@@ -29,7 +29,7 @@ class MSE1FileFormat : public FileFormat {
};
FileFormatP mse1_file_format() {
return new_shared<MSE1FileFormat>();
return new_intrusive<MSE1FileFormat>();
}
// ----------------------------------------------------------------------------- : Importing
+1 -1
View File
@@ -33,5 +33,5 @@ class MSE2FileFormat : public FileFormat {
};
FileFormatP mse2_file_format() {
return new_shared<MSE2FileFormat>();
return new_intrusive<MSE2FileFormat>();
}
+3 -3
View File
@@ -43,7 +43,7 @@ class MtgEditorFileFormat : public FileFormat {
};
FileFormatP mtg_editor_file_format() {
return new_shared<MtgEditorFileFormat>();
return new_intrusive<MtgEditorFileFormat>();
}
// ----------------------------------------------------------------------------- : Importing
@@ -68,7 +68,7 @@ SetP MtgEditorFileFormat::importSet(const String& filename) {
// read file
while (!f.Eof()) {
// 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();
if (line == _("#SET###########")) { // set.title
target = &set->value<TextValue>(_("title")).value;
@@ -103,7 +103,7 @@ SetP MtgEditorFileFormat::importSet(const String& filename) {
set->cards.push_back(current_card);
}
first = false;
current_card = new_shared1<Card>(*set->game);
current_card = new_intrusive1<Card>(*set->game);
target = &current_card->value<TextValue>(_("name")).value;
} else if (line == _("#DATE##########")) { // date
// remember date for generation of illustration filename
+10 -10
View File
@@ -39,20 +39,20 @@ String Game::typeName() const { return _("game"); }
IMPLEMENT_REFLECTION(Game) {
REFLECT_BASE(Packaged);
REFLECT(init_script);
REFLECT(set_fields);
REFLECT_NO_SCRIPT(init_script);
REFLECT_NO_SCRIPT(set_fields);
REFLECT_IF_READING {
default_set_style.init(set_fields);
}
REFLECT(default_set_style);
REFLECT(card_fields);
REFLECT(statistics_dimensions);
REFLECT(statistics_categories);
REFLECT(pack_types);
REFLECT_NO_SCRIPT(default_set_style);
REFLECT_NO_SCRIPT(card_fields);
REFLECT_NO_SCRIPT(statistics_dimensions);
REFLECT_NO_SCRIPT(statistics_categories);
REFLECT_NO_SCRIPT(pack_types);
REFLECT(has_keywords);
REFLECT(keyword_modes);
REFLECT(keyword_parameter_types);
REFLECT(keywords);
REFLECT_NO_SCRIPT(keywords);
// REFLECT(word_lists);
}
@@ -63,7 +63,7 @@ void Game::validate(Version v) {
vector<StatsDimensionP> dims;
FOR_EACH(f, card_fields) {
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
@@ -72,7 +72,7 @@ void Game::validate(Version v) {
{
vector<StatsCategoryP> cats;
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
}
+4 -4
View File
@@ -21,7 +21,7 @@ class KeywordTrie;
// ----------------------------------------------------------------------------- : Keyword parameters
class ParamReferenceType {
class ParamReferenceType : public IntrusivePtrBase<ParamReferenceType> {
public:
String name; ///< Name of the parameter reference type
String description; ///< Description (for status bar)
@@ -31,7 +31,7 @@ class ParamReferenceType {
};
/// Parameter type of keywords
class KeywordParam {
class KeywordParam : public IntrusivePtrBase<KeywordParam> {
public:
KeywordParam();
String name; ///< Name of the parameter type
@@ -49,7 +49,7 @@ class KeywordParam {
// ----------------------------------------------------------------------------- : Keyword mode
/// Information on when and how to use a keyword
class KeywordMode {
class KeywordMode : public IntrusivePtrBase<KeywordMode> {
public:
KeywordMode() : is_default(false) {}
@@ -63,7 +63,7 @@ class KeywordMode {
// ----------------------------------------------------------------------------- : Keyword expansion
/// A keyword for a set or a game
class Keyword {
class Keyword : public IntrusivePtrVirtualBase {
public:
Keyword() : fixed(false), valid(false) {}
+2 -2
View File
@@ -23,7 +23,7 @@ LocaleP Locale::byName(const String& name) {
return packages.open<Locale>(name + _(".mse-locale"));
}
IMPLEMENT_REFLECTION(Locale) {
IMPLEMENT_REFLECTION_NO_SCRIPT(Locale) {
REFLECT_BASE(Packaged);
REFLECT_N("menu", translations[LOCALE_CAT_MENU]);
REFLECT_N("help", translations[LOCALE_CAT_HELP]);
@@ -40,7 +40,7 @@ IMPLEMENT_REFLECTION(Locale) {
REFLECT_N("symbol font", symbol_font_translations);
}
IMPLEMENT_REFLECTION_NAMELESS(SubLocale) {
IMPLEMENT_REFLECTION_NO_GET_MEMBER(SubLocale) {
REFLECT_NAMELESS(translations);
}
+1 -1
View File
@@ -20,7 +20,7 @@ DECLARE_POINTER_TYPE(SubLocale);
// ----------------------------------------------------------------------------- : Locale class
/// Translations of the texts of a game/stylesheet/symbolfont
class SubLocale {
class SubLocale : public IntrusivePtrBase<SubLocale> {
public:
map<String,String> translations;
+2 -2
View File
@@ -20,7 +20,7 @@ class Set;
// ----------------------------------------------------------------------------- : PackType
/// A card pack description for playtesting
class PackType {
class PackType : public IntrusivePtrBase<PackType> {
public:
PackType();
@@ -38,7 +38,7 @@ class PackType {
// ----------------------------------------------------------------------------- : CardType
/// A card type description for playtesting
class CardType {
class CardType : public IntrusivePtrBase<CardType> {
public:
String name; ///< Name of this type of cards
Scriptable<int> amount; ///< Number of cards of this type
+9 -5
View File
@@ -79,7 +79,11 @@ Context& Set::getContextForThumbnails(const StyleSheetP& 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;
else return stylesheet;
}
@@ -122,7 +126,7 @@ void Set::validate(Version file_app_version) {
}
*/ }
// 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
script_manager->updateAll();
}
@@ -187,7 +191,7 @@ int Set::positionOfCard(const CardP& card, const ScriptValueP& order_by) {
values.push_back(*order_by->eval(getContext(c)));
}
// 2. initialize order cache
order.reset(new OrderCache<CardP>(cards, values));
order = new_intrusive2<OrderCache<CardP> >(cards, values);
}
return order->find(card);
}
@@ -199,7 +203,7 @@ void Set::clearOrderCache() {
// Extra set data, for a specific 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:
IndexMap<FieldP, ValueP> data;
String unread_data;
@@ -209,7 +213,7 @@ class Set::Styling {
IndexMap<FieldP, ValueP>& Set::stylingDataFor(const StyleSheet& stylesheet) {
StylingP& styling = styling_data[stylesheet.name()];
if (!styling) {
styling = new_shared<Styling>();
styling = new_intrusive<Styling>();
styling->data.init(stylesheet.styling_fields);
} else if (!styling->unread_data.empty() || (styling->data.empty()) && !stylesheet.styling_fields.empty()) {
// we delayed the reading of the data, read it now
+4 -3
View File
@@ -25,13 +25,13 @@ DECLARE_POINTER_TYPE(Styling);
DECLARE_POINTER_TYPE(Field);
DECLARE_POINTER_TYPE(Value);
DECLARE_POINTER_TYPE(Keyword);
DECLARE_INTRUSIVE_POINTER_TYPE(ScriptValue);
DECLARE_POINTER_TYPE(ScriptValue);
class SetScriptManager;
class SetScriptContext;
class Context;
class Dependency;
template <typename> class OrderCache;
typedef shared_ptr<OrderCache<CardP> > OrderCacheP;
typedef intrusive_ptr<OrderCache<CardP> > OrderCacheP;
// ----------------------------------------------------------------------------- : Set
@@ -80,7 +80,8 @@ class Set : public Packaged {
/// Stylesheet to use for a particular card
/** 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
IndexMap<FieldP, ValueP>& stylingDataFor(const StyleSheet&);
+2 -2
View File
@@ -125,7 +125,7 @@ void Settings::addRecentFile(const String& filename) {
GameSettings& Settings::gameSettingsFor(const Game& game) {
GameSettingsP& gs = game_settings[game.name()];
if (!gs) gs.reset(new GameSettings);
if (!gs) gs = new_intrusive<GameSettings>();
return *gs;
}
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) {
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
return *ss;
}
+2 -2
View File
@@ -49,7 +49,7 @@ class ColumnSettings {
};
/// Settings for a Game
class GameSettings {
class GameSettings : public IntrusivePtrBase<GameSettings> {
public:
GameSettings();
@@ -65,7 +65,7 @@ class GameSettings {
};
/// Settings for a StyleSheet
class StyleSheetSettings {
class StyleSheetSettings : public IntrusivePtrBase<StyleSheetSettings> {
public:
StyleSheetSettings();
+2 -2
View File
@@ -38,7 +38,7 @@ StatsDimension::StatsDimension(const Field& field)
s.addInstruction(I_RET);
}
IMPLEMENT_REFLECTION(StatsDimension) {
IMPLEMENT_REFLECTION_NO_GET_MEMBER(StatsDimension) {
if (!automatic) {
REFLECT(name);
REFLECT(description);
@@ -72,7 +72,7 @@ IMPLEMENT_REFLECTION_ENUM(GraphType) {
VALUE_N("scatter", GRAPH_TYPE_SCATTER);
}
IMPLEMENT_REFLECTION(StatsCategory) {
IMPLEMENT_REFLECTION_NO_GET_MEMBER(StatsCategory) {
if (!automatic) {
REFLECT(name);
REFLECT(description);
+2 -2
View File
@@ -21,7 +21,7 @@ DECLARE_POINTER_TYPE(StatsCategory);
/// A dimension that can be plotted as an axis in a graph
/** Dimensions can be generated automatically based on card fields */
class StatsDimension {
class StatsDimension : public IntrusivePtrBase<StatsDimension> {
public:
StatsDimension();
StatsDimension(const Field&);
@@ -49,7 +49,7 @@ enum GraphType
/// A category for statistics
/** Can be generated automatically based on a dimension */
class StatsCategory {
class StatsCategory : public IntrusivePtrBase<StatsCategory> {
public:
StatsCategory();
StatsCategory(const StatsDimensionP&);
+8 -8
View File
@@ -131,10 +131,10 @@ SymbolPart::SymbolPart()
{}
SymbolPartP SymbolPart::clone() const {
SymbolPartP part = new_shared1<SymbolPart>(*this);
SymbolPartP part = new_intrusive1<SymbolPart>(*this);
// also clone the control points
FOR_EACH(p, part->points) {
p = new_shared1<ControlPoint>(*p);
p = new_intrusive1<ControlPoint>(*p);
}
return part;
}
@@ -166,18 +166,18 @@ IMPLEMENT_REFLECTION(Symbol) {
// A default symbol part, a square, moved by d
SymbolPartP default_symbol_part(double d) {
SymbolPartP part = new_shared<SymbolPart>();
part->points.push_back(new_shared2<ControlPoint>(d + .2, d + .2));
part->points.push_back(new_shared2<ControlPoint>(d + .2, d + .8));
part->points.push_back(new_shared2<ControlPoint>(d + .8, d + .8));
part->points.push_back(new_shared2<ControlPoint>(d + .8, d + .2));
SymbolPartP part = new_intrusive<SymbolPart>();
part->points.push_back(new_intrusive2<ControlPoint>(d + .2, d + .2));
part->points.push_back(new_intrusive2<ControlPoint>(d + .2, d + .8));
part->points.push_back(new_intrusive2<ControlPoint>(d + .8, d + .8));
part->points.push_back(new_intrusive2<ControlPoint>(d + .8, d + .2));
part->name = _("Square");
return part;
}
// A default symbol, a square
SymbolP default_symbol() {
SymbolP symbol = new_shared<Symbol>();
SymbolP symbol = new_intrusive<Symbol>();
symbol->parts.push_back(default_symbol_part(0));
return symbol;
}
+3 -3
View File
@@ -44,7 +44,7 @@ enum WhichHandle
};
/// A control point (corner) of a SymbolPart (polygon/bezier-gon)
class ControlPoint {
class ControlPoint : public IntrusivePtrBase<ControlPoint> {
public:
Vector2D pos; ///< position of the control point itself
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) {
}
/// A single part (polygon/bezier-gon) in a Symbol
class SymbolPart {
class SymbolPart : public IntrusivePtrBase<SymbolPart> {
public:
/// The points of this polygon
vector<ControlPointP> points;
@@ -158,7 +158,7 @@ class SymbolPart {
// ----------------------------------------------------------------------------- : Symbol
/// An editable symbol, consists of any number of SymbolParts
class Symbol {
class Symbol : public IntrusivePtrBase<Symbol> {
public:
/// The parts of this symbol
vector<SymbolPartP> parts;
+1 -1
View File
@@ -70,7 +70,7 @@ IMPLEMENT_REFLECTION(SymbolFont) {
// ----------------------------------------------------------------------------- : SymbolInFont
/// A symbol in a symbol font
class SymbolInFont {
class SymbolInFont : public IntrusivePtrBase<SymbolInFont> {
public:
SymbolInFont();
+1 -1
View File
@@ -111,7 +111,7 @@ enum MenuItemType
};
/// Description of a menu to insert symbols from a symbol font into the text
class InsertSymbolMenu {
class InsertSymbolMenu : public IntrusivePtrBase<InsertSymbolMenu> {
public:
InsertSymbolMenu();