2012-03-21 12:20:19 +01:00
|
|
|
#include "ptr.hpp"
|
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
|
2012-03-21 12:48:05 +01:00
|
|
|
#include "containerstore.hpp"
|
2013-08-16 04:18:48 -07:00
|
|
|
#include "class.hpp"
|
2014-05-08 13:47:54 +02:00
|
|
|
#include "livecellref.hpp"
|
2013-08-16 04:18:48 -07:00
|
|
|
|
|
|
|
const std::string& MWWorld::Ptr::getTypeName() const
|
|
|
|
{
|
2020-11-13 11:39:47 +04:00
|
|
|
if(mRef != nullptr)
|
2013-08-16 04:18:48 -07:00
|
|
|
return mRef->mClass->getTypeName();
|
|
|
|
throw std::runtime_error("Can't get type name from an empty object.");
|
|
|
|
}
|
|
|
|
|
2014-01-31 13:25:32 +01: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 14:13:07 +02:00
|
|
|
MWWorld::CellRef& MWWorld::Ptr::getCellRef() const
|
2012-03-21 12:29:07 +01:00
|
|
|
{
|
2013-08-14 17:05:42 -07:00
|
|
|
assert(mRef);
|
2012-03-21 12:48:05 +01:00
|
|
|
|
2013-08-14 17:05:42 -07:00
|
|
|
return mRef->mRef;
|
2012-03-21 12:29:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
MWWorld::RefData& MWWorld::Ptr::getRefData() const
|
|
|
|
{
|
2013-08-14 17:05:42 -07:00
|
|
|
assert(mRef);
|
2012-03-21 12:48:05 +01:00
|
|
|
|
2013-08-14 17:05:42 -07:00
|
|
|
return mRef->mData;
|
2012-03-21 12:29:07 +01:00
|
|
|
}
|
|
|
|
|
2012-03-21 12:20:19 +01:00
|
|
|
void MWWorld::Ptr::setContainerStore (ContainerStore *store)
|
|
|
|
{
|
|
|
|
assert (store);
|
|
|
|
assert (!mCell);
|
|
|
|
|
|
|
|
mContainerStore = store;
|
|
|
|
}
|
|
|
|
|
|
|
|
MWWorld::ContainerStore *MWWorld::Ptr::getContainerStore() const
|
|
|
|
{
|
|
|
|
return mContainerStore;
|
|
|
|
}
|
2014-02-23 18:17:41 +01:00
|
|
|
|
|
|
|
MWWorld::Ptr::operator const void *()
|
|
|
|
{
|
|
|
|
return mRef;
|
2014-05-08 13:47:54 +02:00
|
|
|
}
|
2015-12-17 23:34:52 +01:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
const std::string &MWWorld::ConstPtr::getTypeName() const
|
|
|
|
{
|
2020-11-13 11:39:47 +04:00
|
|
|
if(mRef != nullptr)
|
2015-12-17 23:34:52 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-02-14 19:34:54 +00:00
|
|
|
void MWWorld::ConstPtr::setContainerStore (const ContainerStore *store)
|
|
|
|
{
|
|
|
|
assert (store);
|
|
|
|
assert (!mCell);
|
|
|
|
|
|
|
|
mContainerStore = store;
|
|
|
|
}
|
|
|
|
|
2015-12-18 17:56:48 +01:00
|
|
|
const MWWorld::ContainerStore *MWWorld::ConstPtr::getContainerStore() const
|
|
|
|
{
|
|
|
|
return mContainerStore;
|
|
|
|
}
|
|
|
|
|
2015-12-17 23:34:52 +01:00
|
|
|
MWWorld::ConstPtr::operator const void *()
|
|
|
|
{
|
|
|
|
return mRef;
|
|
|
|
}
|