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"
|
2014-05-08 11:47:54 +00:00
|
|
|
#include "livecellref.hpp"
|
2013-08-16 11:18:48 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-05-25 12:13:07 +00:00
|
|
|
MWWorld::CellRef& MWWorld::Ptr::getCellRef() const
|
2012-03-21 11:29:07 +00:00
|
|
|
{
|
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;
|
2014-05-08 11:47:54 +00:00
|
|
|
}
|
2015-12-17 22:34:52 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
const std::string &MWWorld::ConstPtr::getTypeName() const
|
|
|
|
{
|
|
|
|
if(mRef != 0)
|
|
|
|
return mRef->mClass->getTypeName();
|
|
|
|
throw std::runtime_error("Can't get type name from an empty object.");
|
|
|
|
}
|
|
|
|
|
|
|
|
const MWWorld::LiveCellRefBase *MWWorld::ConstPtr::getBase() const
|
|
|
|
{
|
|
|
|
if (!mRef)
|
|
|
|
throw std::runtime_error ("Can't access cell ref pointed to by null Ptr");
|
|
|
|
|
|
|
|
return mRef;
|
|
|
|
}
|
|
|
|
|
2015-12-18 16:56:48 +00:00
|
|
|
const MWWorld::ContainerStore *MWWorld::ConstPtr::getContainerStore() const
|
|
|
|
{
|
|
|
|
return mContainerStore;
|
|
|
|
}
|
|
|
|
|
2015-12-17 22:34:52 +00:00
|
|
|
MWWorld::ConstPtr::operator const void *()
|
|
|
|
{
|
|
|
|
return mRef;
|
|
|
|
}
|