turned ContainerStore from a template into a simple struct

This commit is contained in:
Marc Zinnschlag 2012-01-28 11:45:55 +01:00
parent 8de6761a79
commit f2972b1ca0
35 changed files with 54 additions and 58 deletions

View file

@ -60,7 +60,7 @@ namespace MWClass
}
void Apparatus::insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const
MWWorld::ContainerStore& containerStore) const
{
insertIntoContainerStore (ptr, containerStore.appas);
}

View file

@ -23,7 +23,7 @@ namespace MWClass
///< Generate action for activation
virtual void insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const;
MWWorld::ContainerStore& containerStore) const;
///< Insert into a containe
virtual std::string getScript (const MWWorld::Ptr& ptr) const;

View file

@ -72,7 +72,7 @@ namespace MWClass
}
void Armor::insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const
MWWorld::ContainerStore& containerStore) const
{
insertIntoContainerStore (ptr, containerStore.armors);
}

View file

@ -29,7 +29,7 @@ namespace MWClass
///< Return item max health or throw an exception, if class does not have item health
virtual void insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const;
MWWorld::ContainerStore& containerStore) const;
///< Insert into a containe
virtual std::string getScript (const MWWorld::Ptr& ptr) const;

View file

@ -62,7 +62,7 @@ namespace MWClass
}
void Book::insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const
MWWorld::ContainerStore& containerStore) const
{
insertIntoContainerStore (ptr, containerStore.books);
}

View file

@ -23,7 +23,7 @@ namespace MWClass
///< Generate action for activation
virtual void insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const;
MWWorld::ContainerStore& containerStore) const;
///< Insert into a containe
virtual std::string getScript (const MWWorld::Ptr& ptr) const;

View file

@ -60,7 +60,7 @@ namespace MWClass
}
void Clothing::insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const
MWWorld::ContainerStore& containerStore) const
{
insertIntoContainerStore (ptr, containerStore.clothes);
}

View file

@ -23,7 +23,7 @@ namespace MWClass
///< Generate action for activation
virtual void insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const;
MWWorld::ContainerStore& containerStore) const;
///< Insert into a containe
virtual std::string getScript (const MWWorld::Ptr& ptr) const;

View file

@ -15,7 +15,7 @@ namespace
{
struct CustomData : public MWWorld::CustomData
{
MWWorld::ContainerStore<MWWorld::RefData> mContainerStore;
MWWorld::ContainerStore mContainerStore;
virtual MWWorld::CustomData *clone() const;
};
@ -79,7 +79,7 @@ namespace MWClass
return ref->base->name;
}
MWWorld::ContainerStore<MWWorld::RefData>& Container::getContainerStore (const MWWorld::Ptr& ptr)
MWWorld::ContainerStore& Container::getContainerStore (const MWWorld::Ptr& ptr)
const
{
ensureCustomData (ptr);

View file

@ -20,8 +20,7 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual MWWorld::ContainerStore<MWWorld::RefData>& getContainerStore (
const MWWorld::Ptr& ptr) const;
virtual MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const;
///< Return container store
virtual std::string getScript (const MWWorld::Ptr& ptr) const;

View file

@ -17,7 +17,7 @@ namespace
struct CustomData : public MWWorld::CustomData
{
MWMechanics::CreatureStats mCreatureStats;
MWWorld::ContainerStore<MWWorld::RefData> mContainerStore;
MWWorld::ContainerStore mContainerStore;
virtual MWWorld::CustomData *clone() const;
};
@ -118,7 +118,7 @@ namespace MWClass
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionTalk (ptr));
}
MWWorld::ContainerStore<MWWorld::RefData>& Creature::getContainerStore (const MWWorld::Ptr& ptr)
MWWorld::ContainerStore& Creature::getContainerStore (const MWWorld::Ptr& ptr)
const
{
ensureCustomData (ptr);

View file

@ -39,7 +39,7 @@ namespace MWClass
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
///< Generate action for activation
virtual MWWorld::ContainerStore<MWWorld::RefData>& getContainerStore (
virtual MWWorld::ContainerStore& getContainerStore (
const MWWorld::Ptr& ptr) const;
///< Return container store

View file

@ -58,7 +58,7 @@ namespace MWClass
}
void Ingredient::insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const
MWWorld::ContainerStore& containerStore) const
{
insertIntoContainerStore (ptr, containerStore.ingreds);
}

View file

@ -23,7 +23,7 @@ namespace MWClass
///< Generate action for activation
virtual void insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const;
MWWorld::ContainerStore& containerStore) const;
///< Insert into a containe
virtual std::string getScript (const MWWorld::Ptr& ptr) const;

View file

@ -90,7 +90,7 @@ namespace MWClass
}
void Light::insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const
MWWorld::ContainerStore& containerStore) const
{
insertIntoContainerStore (ptr, containerStore.lights);
}

View file

@ -28,7 +28,7 @@ namespace MWClass
///< Generate action for activation
virtual void insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const;
MWWorld::ContainerStore& containerStore) const;
///< Insert into a containe
virtual std::string getScript (const MWWorld::Ptr& ptr) const;

View file

@ -61,7 +61,7 @@ namespace MWClass
}
void Lockpick::insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const
MWWorld::ContainerStore& containerStore) const
{
insertIntoContainerStore (ptr, containerStore.lockpicks);
}

View file

@ -23,7 +23,7 @@ namespace MWClass
///< Generate action for activation
virtual void insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const;
MWWorld::ContainerStore& containerStore) const;
///< Insert into a containe
virtual std::string getScript (const MWWorld::Ptr& ptr) const;

View file

@ -60,7 +60,7 @@ namespace MWClass
}
void Miscellaneous::insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const
MWWorld::ContainerStore& containerStore) const
{
insertIntoContainerStore (ptr, containerStore.miscItems);
}

View file

@ -23,7 +23,7 @@ namespace MWClass
///< Generate action for activation
virtual void insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const;
MWWorld::ContainerStore& containerStore) const;
///< Insert into a containe
virtual std::string getScript (const MWWorld::Ptr& ptr) const;

View file

@ -29,7 +29,7 @@ namespace
MWMechanics::NpcStats mNpcStats;
MWMechanics::CreatureStats mCreatureStats;
MWMechanics::Movement mMovement;
MWWorld::ContainerStore<MWWorld::RefData> mContainerStore;
MWWorld::ContainerStore mContainerStore;
virtual MWWorld::CustomData *clone() const;
};
@ -156,7 +156,7 @@ namespace MWClass
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionTalk (ptr));
}
MWWorld::ContainerStore<MWWorld::RefData>& Npc::getContainerStore (const MWWorld::Ptr& ptr)
MWWorld::ContainerStore& Npc::getContainerStore (const MWWorld::Ptr& ptr)
const
{
ensureCustomData (ptr);

View file

@ -35,8 +35,7 @@ namespace MWClass
virtual MWMechanics::NpcStats& getNpcStats (const MWWorld::Ptr& ptr) const;
///< Return NPC stats
virtual MWWorld::ContainerStore<MWWorld::RefData>& getContainerStore (
const MWWorld::Ptr& ptr) const;
virtual MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const;
///< Return container store
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,

View file

@ -60,7 +60,7 @@ namespace MWClass
}
void Potion::insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const
MWWorld::ContainerStore& containerStore) const
{
insertIntoContainerStore (ptr, containerStore.potions);
}

View file

@ -23,7 +23,7 @@ namespace MWClass
///< Generate action for activation
virtual void insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const;
MWWorld::ContainerStore& containerStore) const;
///< Insert into a containe
virtual std::string getScript (const MWWorld::Ptr& ptr) const;

View file

@ -20,7 +20,7 @@ namespace MWClass
assert (ref->base != NULL);
const std::string &model = ref->base->model;
if (!model.empty())
{
MWRender::Objects& objects = renderingInterface.getObjects();
@ -59,7 +59,7 @@ namespace MWClass
}
void Probe::insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const
MWWorld::ContainerStore& containerStore) const
{
insertIntoContainerStore (ptr, containerStore.probes);
}

View file

@ -23,7 +23,7 @@ namespace MWClass
///< Generate action for activation
virtual void insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const;
MWWorld::ContainerStore& containerStore) const;
///< Insert into a containe
virtual std::string getScript (const MWWorld::Ptr& ptr) const;

View file

@ -60,7 +60,7 @@ namespace MWClass
}
void Repair::insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const
MWWorld::ContainerStore& containerStore) const
{
insertIntoContainerStore (ptr, containerStore.repairs);
}

View file

@ -23,7 +23,7 @@ namespace MWClass
///< Generate action for activation
virtual void insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const;
MWWorld::ContainerStore& containerStore) const;
///< Insert into a containe
virtual std::string getScript (const MWWorld::Ptr& ptr) const;

View file

@ -73,7 +73,7 @@ namespace MWClass
}
void Weapon::insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const
MWWorld::ContainerStore& containerStore) const
{
insertIntoContainerStore (ptr, containerStore.weapons);
}

View file

@ -29,7 +29,7 @@ namespace MWClass
///< Return item max health or throw an exception, if class does not have item health
virtual void insertIntoContainer (const MWWorld::Ptr& ptr,
MWWorld::ContainerStore<MWWorld::RefData>& containerStore) const;
MWWorld::ContainerStore& containerStore) const;
///< Insert into a containe
virtual std::string getScript (const MWWorld::Ptr& ptr) const;

View file

@ -71,12 +71,12 @@ namespace MWWorld
return boost::shared_ptr<Action> (new NullAction);
}
ContainerStore<RefData>& Class::getContainerStore (const Ptr& ptr) const
ContainerStore& Class::getContainerStore (const Ptr& ptr) const
{
throw std::runtime_error ("class does not have a container store");
}
void Class::insertIntoContainer (const Ptr& ptr, ContainerStore<RefData>& containerStore) const
void Class::insertIntoContainer (const Ptr& ptr, ContainerStore& containerStore) const
{
throw std::runtime_error ("class does not support inserting into a container");
}

View file

@ -61,8 +61,6 @@ namespace MWWorld
///< Return ID of \a ptr or throw an exception, if class does not support ID retrieval
/// (default implementation: throw an exception)
virtual void insertObjectRendering (const Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
virtual void insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const;
///< Add reference into a cell for rendering (default implementation: don't render anything).
@ -105,11 +103,11 @@ namespace MWWorld
///< Generate action for using via inventory menu (default implementation: return a
/// null action).
virtual ContainerStore<RefData>& getContainerStore (const Ptr& ptr) const;
virtual ContainerStore& getContainerStore (const Ptr& ptr) const;
///< Return container store or throw an exception, if class does not have a
/// container store (default implementation: throw an exceoption)
virtual void insertIntoContainer (const Ptr& ptr, ContainerStore<RefData>& containerStore)
virtual void insertIntoContainer (const Ptr& ptr, ContainerStore& containerStore)
const;
///< Insert into a container or throw an exception, if class does not support inserting into
/// a container.

View file

@ -3,23 +3,24 @@
#include <components/esm_store/cell_store.hpp>
#include "refdata.hpp"
namespace MWWorld
{
template<typename D>
struct ContainerStore
{
ESMS::CellRefList<ESM::Potion, D> potions;
ESMS::CellRefList<ESM::Apparatus, D> appas;
ESMS::CellRefList<ESM::Armor, D> armors;
ESMS::CellRefList<ESM::Book, D> books;
ESMS::CellRefList<ESM::Clothing, D> clothes;
ESMS::CellRefList<ESM::Ingredient, D> ingreds;
ESMS::CellRefList<ESM::Light, D> lights;
ESMS::CellRefList<ESM::Tool, D> lockpicks;
ESMS::CellRefList<ESM::Miscellaneous, D> miscItems;
ESMS::CellRefList<ESM::Probe, D> probes;
ESMS::CellRefList<ESM::Repair, D> repairs;
ESMS::CellRefList<ESM::Weapon, D> weapons;
ESMS::CellRefList<ESM::Potion, RefData> potions;
ESMS::CellRefList<ESM::Apparatus, RefData> appas;
ESMS::CellRefList<ESM::Armor, RefData> armors;
ESMS::CellRefList<ESM::Book, RefData> books;
ESMS::CellRefList<ESM::Clothing, RefData> clothes;
ESMS::CellRefList<ESM::Ingredient, RefData> ingreds;
ESMS::CellRefList<ESM::Light, RefData> lights;
ESMS::CellRefList<ESM::Tool, RefData> lockpicks;
ESMS::CellRefList<ESM::Miscellaneous, RefData> miscItems;
ESMS::CellRefList<ESM::Probe, RefData> probes;
ESMS::CellRefList<ESM::Repair, RefData> repairs;
ESMS::CellRefList<ESM::Weapon, RefData> weapons;
};
}

View file

@ -24,7 +24,7 @@ namespace
namespace MWWorld
{
void listItemsInContainer (const std::string& id,
ContainerStore<MWWorld::RefData>& containerStore,
ContainerStore& containerStore,
const ESMS::ESMStore& store, std::vector<Ptr>& list)
{
listItemsInContainerImp (id, containerStore.potions, store.potions, list);

View file

@ -8,11 +8,10 @@
#include "containerstore.hpp"
#include "ptr.hpp"
#include "refdata.hpp"
namespace MWWorld
{
void listItemsInContainer (const std::string& id, ContainerStore<MWWorld::RefData>& containerStore,
void listItemsInContainer (const std::string& id, ContainerStore& containerStore,
const ESMS::ESMStore& store, std::vector<Ptr>& list);
///< append all references with the given id to list.
}