added getValue function to Class hierarchy

This commit is contained in:
Marc Zinnschlag 2012-04-07 19:53:49 +02:00
parent 751e7d2199
commit d5a7d418dd
26 changed files with 141 additions and 0 deletions

View file

@ -70,6 +70,14 @@ namespace MWClass
return ref->base->script; return ref->base->script;
} }
int Apparatus::getValue (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
ptr.get<ESM::Apparatus>();
return ref->base->data.value;
}
void Apparatus::registerSelf() void Apparatus::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Apparatus); boost::shared_ptr<Class> instance (new Apparatus);

View file

@ -25,6 +25,9 @@ namespace MWClass
virtual std::string getScript (const MWWorld::Ptr& ptr) const; virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;

View file

@ -160,6 +160,14 @@ namespace MWClass
return ESM::Skill::HeavyArmor; return ESM::Skill::HeavyArmor;
} }
int Armor::getValue (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
ptr.get<ESM::Armor>();
return ref->base->data.value;
}
void Armor::registerSelf() void Armor::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Armor); boost::shared_ptr<Class> instance (new Armor);

View file

@ -40,6 +40,9 @@ namespace MWClass
/// Return the index of the skill this item corresponds to when equiopped or -1, if there is /// Return the index of the skill this item corresponds to when equiopped or -1, if there is
/// no such skill. /// no such skill.
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;

View file

@ -72,6 +72,14 @@ namespace MWClass
return ref->base->script; return ref->base->script;
} }
int Book::getValue (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
ptr.get<ESM::Book>();
return ref->base->data.value;
}
void Book::registerSelf() void Book::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Book); boost::shared_ptr<Class> instance (new Book);

View file

@ -25,6 +25,9 @@ namespace MWClass
virtual std::string getScript (const MWWorld::Ptr& ptr) const; virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;

View file

@ -123,6 +123,14 @@ namespace MWClass
return -1; return -1;
} }
int Clothing::getValue (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
ptr.get<ESM::Clothing>();
return ref->base->data.value;
}
void Clothing::registerSelf() void Clothing::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Clothing); boost::shared_ptr<Class> instance (new Clothing);

View file

@ -34,6 +34,9 @@ namespace MWClass
/// Return the index of the skill this item corresponds to when equiopped or -1, if there is /// Return the index of the skill this item corresponds to when equiopped or -1, if there is
/// no such skill. /// no such skill.
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;

View file

@ -68,6 +68,14 @@ namespace MWClass
return ref->base->script; return ref->base->script;
} }
int Ingredient::getValue (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
ptr.get<ESM::Ingredient>();
return ref->base->data.value;
}
void Ingredient::registerSelf() void Ingredient::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Ingredient); boost::shared_ptr<Class> instance (new Ingredient);

View file

@ -25,6 +25,9 @@ namespace MWClass
virtual std::string getScript (const MWWorld::Ptr& ptr) const; virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;

View file

@ -110,6 +110,14 @@ namespace MWClass
return std::make_pair (slots, false); return std::make_pair (slots, false);
} }
int Light::getValue (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
ptr.get<ESM::Light>();
return ref->base->data.value;
}
void Light::registerSelf() void Light::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Light); boost::shared_ptr<Class> instance (new Light);

View file

@ -34,6 +34,9 @@ namespace MWClass
///< \return first: Return IDs of the slot this object can be equipped in; second: can object ///< \return first: Return IDs of the slot this object can be equipped in; second: can object
/// stay stacked when equipped? /// stay stacked when equipped?
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;

View file

@ -81,6 +81,14 @@ namespace MWClass
return std::make_pair (slots, false); return std::make_pair (slots, false);
} }
int Lockpick::getValue (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
ptr.get<ESM::Tool>();
return ref->base->data.value;
}
void Lockpick::registerSelf() void Lockpick::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Lockpick); boost::shared_ptr<Class> instance (new Lockpick);

View file

@ -29,6 +29,9 @@ namespace MWClass
///< \return first: Return IDs of the slot this object can be equipped in; second: can object ///< \return first: Return IDs of the slot this object can be equipped in; second: can object
/// stay stacked when equipped? /// stay stacked when equipped?
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;

View file

@ -70,6 +70,14 @@ namespace MWClass
return ref->base->script; return ref->base->script;
} }
int Miscellaneous::getValue (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
ptr.get<ESM::Miscellaneous>();
return ref->base->data.value;
}
void Miscellaneous::registerSelf() void Miscellaneous::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Miscellaneous); boost::shared_ptr<Class> instance (new Miscellaneous);

View file

@ -25,6 +25,9 @@ namespace MWClass
virtual std::string getScript (const MWWorld::Ptr& ptr) const; virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;

View file

@ -70,6 +70,14 @@ namespace MWClass
return ref->base->script; return ref->base->script;
} }
int Potion::getValue (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
ptr.get<ESM::Potion>();
return ref->base->data.value;
}
void Potion::registerSelf() void Potion::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Potion); boost::shared_ptr<Class> instance (new Potion);

View file

@ -25,6 +25,9 @@ namespace MWClass
virtual std::string getScript (const MWWorld::Ptr& ptr) const; virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;

View file

@ -80,6 +80,14 @@ namespace MWClass
return std::make_pair (slots, false); return std::make_pair (slots, false);
} }
int Probe::getValue (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
ptr.get<ESM::Probe>();
return ref->base->data.value;
}
void Probe::registerSelf() void Probe::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Probe); boost::shared_ptr<Class> instance (new Probe);

View file

@ -29,6 +29,9 @@ namespace MWClass
///< \return first: Return IDs of the slot this object can be equipped in; second: can object ///< \return first: Return IDs of the slot this object can be equipped in; second: can object
/// stay stacked when equipped? /// stay stacked when equipped?
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;

View file

@ -70,6 +70,14 @@ namespace MWClass
return ref->base->script; return ref->base->script;
} }
int Repair::getValue (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
ptr.get<ESM::Repair>();
return ref->base->data.value;
}
void Repair::registerSelf() void Repair::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Repair); boost::shared_ptr<Class> instance (new Repair);

View file

@ -25,6 +25,9 @@ namespace MWClass
virtual std::string getScript (const MWWorld::Ptr& ptr) const; virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;

View file

@ -139,6 +139,14 @@ namespace MWClass
return -1; return -1;
} }
int Weapon::getValue (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
ptr.get<ESM::Weapon>();
return ref->base->data.value;
}
void Weapon::registerSelf() void Weapon::registerSelf()
{ {
boost::shared_ptr<Class> instance (new Weapon); boost::shared_ptr<Class> instance (new Weapon);

View file

@ -40,6 +40,9 @@ namespace MWClass
/// Return the index of the skill this item corresponds to when equiopped or -1, if there is /// Return the index of the skill this item corresponds to when equiopped or -1, if there is
/// no such skill. /// no such skill.
virtual int getValue (const MWWorld::Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;

View file

@ -137,6 +137,11 @@ namespace MWWorld
return -1; return -1;
} }
int Class::getValue (const Ptr& ptr) const
{
throw std::logic_error ("value not supported by this class");
}
const Class& Class::get (const std::string& key) const Class& Class::get (const std::string& key)
{ {
std::map<std::string, boost::shared_ptr<Class> >::const_iterator iter = sClasses.find (key); std::map<std::string, boost::shared_ptr<Class> >::const_iterator iter = sClasses.find (key);

View file

@ -155,6 +155,10 @@ namespace MWWorld
/// no such skill. /// no such skill.
/// (default implementation: return -1) /// (default implementation: return -1)
virtual int getValue (const Ptr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
/// (default implementation: throws an exception)
static const Class& get (const std::string& key); static const Class& get (const std::string& key);
///< If there is no class for this \a key, an exception is thrown. ///< If there is no class for this \a key, an exception is thrown.