2012-03-21 11:20:19 +00:00
|
|
|
|
|
|
|
#include "ptr.hpp"
|
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
|
2012-03-21 11:48:05 +00:00
|
|
|
#include "containerstore.hpp"
|
2013-08-16 11:18:48 +00:00
|
|
|
#include "class.hpp"
|
2012-03-21 11:48:05 +00:00
|
|
|
|
2013-08-13 13:42:02 +00:00
|
|
|
|
2013-08-16 11:18:48 +00:00
|
|
|
/* This shouldn't really be here. */
|
|
|
|
MWWorld::LiveCellRefBase::LiveCellRefBase(std::string type, const ESM::CellRef &cref)
|
|
|
|
: mClass(&Class::get(type)), mRef(cref), mData(mRef)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const std::string& MWWorld::Ptr::getTypeName() const
|
|
|
|
{
|
|
|
|
if(mRef != 0)
|
|
|
|
return mRef->mClass->getTypeName();
|
|
|
|
throw std::runtime_error("Can't get type name from an empty object.");
|
|
|
|
}
|
|
|
|
|
2014-01-31 12:25:32 +00:00
|
|
|
MWWorld::LiveCellRefBase *MWWorld::Ptr::getBase() const
|
|
|
|
{
|
|
|
|
if (!mRef)
|
|
|
|
throw std::runtime_error ("Can't access cell ref pointed to by null Ptr");
|
|
|
|
|
|
|
|
return mRef;
|
|
|
|
}
|
|
|
|
|
2012-03-21 11:29:07 +00:00
|
|
|
ESM::CellRef& MWWorld::Ptr::getCellRef() const
|
|
|
|
{
|
2013-08-15 00:05:42 +00:00
|
|
|
assert(mRef);
|
2012-03-21 11:48:05 +00:00
|
|
|
|
2013-08-15 00:05:42 +00:00
|
|
|
return mRef->mRef;
|
2012-03-21 11:29:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MWWorld::RefData& MWWorld::Ptr::getRefData() const
|
|
|
|
{
|
2013-08-15 00:05:42 +00:00
|
|
|
assert(mRef);
|
2012-03-21 11:48:05 +00:00
|
|
|
|
2013-08-15 00:05:42 +00:00
|
|
|
return mRef->mData;
|
2012-03-21 11:29:07 +00:00
|
|
|
}
|
|
|
|
|
2012-03-21 11:20:19 +00:00
|
|
|
void MWWorld::Ptr::setContainerStore (ContainerStore *store)
|
|
|
|
{
|
|
|
|
assert (store);
|
|
|
|
assert (!mCell);
|
|
|
|
|
|
|
|
mContainerStore = store;
|
|
|
|
}
|
|
|
|
|
|
|
|
MWWorld::ContainerStore *MWWorld::Ptr::getContainerStore() const
|
|
|
|
{
|
|
|
|
return mContainerStore;
|
|
|
|
}
|
2014-02-23 17:17:41 +00:00
|
|
|
|
|
|
|
MWWorld::Ptr::operator const void *()
|
|
|
|
{
|
|
|
|
return mRef;
|
|
|
|
}
|