added FieldP to values and styles, implemented reflection for IndexMap

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@36 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-10-19 18:44:27 +00:00
parent 46a6ed39dc
commit ff96f1522a
30 changed files with 290 additions and 122 deletions
+24 -9
View File
@@ -9,6 +9,7 @@
#include <data/field.hpp>
#include <data/field/text.hpp>
#include <data/field/choice.hpp>
#include <data/field/multiple_choice.hpp>
#include <data/field/boolean.hpp>
#include <data/field/image.hpp>
#include <data/field/symbol.hpp>
@@ -56,21 +57,29 @@ shared_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 == _("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>();
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 {
throw ParseError(_("Unsupported field type: '") + type + _("'"));
}
}
// ----------------------------------------------------------------------------- : Style
Style::Style(const FieldP& field)
: fieldP(field)
, z_index(0)
, left(0), width (1)
, top (0), height(1)
, visible(true)
{}
Style::~Style() {}
IMPLEMENT_REFLECTION(Style) {
@@ -82,9 +91,12 @@ IMPLEMENT_REFLECTION(Style) {
REFLECT(visible);
}
void initObject(const FieldP& field, StyleP& style) {
void init_object(const FieldP& field, StyleP& style) {
style = field->newStyle(field);
}
template <> StyleP read_new<Style>(Reader&) {
throw InternalError(_("IndexMap contains nullptr StyleP the application should have crashed already"));
}
// ----------------------------------------------------------------------------- : Value
@@ -93,7 +105,10 @@ Value::~Value() {}
IMPLEMENT_REFLECTION_NAMELESS(Value) {
}
void initObject(const FieldP& field, ValueP& value) {
void init_object(const FieldP& field, ValueP& value) {
value = field->newValue(field);
}
template <> ValueP read_new<Value>(Reader&) {
throw InternalError(_("IndexMap contains nullptr ValueP the application should have crashed already"));
}