2010-07-03 15:46:55 +00:00
|
|
|
#ifndef GAME_MWWORLD_PTR_H
|
|
|
|
#define GAME_MWWORLD_PTR_H
|
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
#include <boost/any.hpp>
|
|
|
|
|
|
|
|
#include <components/esm_store/cell_store.hpp>
|
|
|
|
|
|
|
|
#include "refdata.hpp"
|
|
|
|
|
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
/// \brief Pointer to a LiveCellRef
|
|
|
|
|
|
|
|
class Ptr
|
|
|
|
{
|
2010-07-10 11:19:04 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
typedef ESMS::CellStore<RefData> CellStore;
|
|
|
|
|
2010-07-03 15:46:55 +00:00
|
|
|
boost::any mPtr;
|
|
|
|
ESM::CellRef *mCellRef;
|
|
|
|
RefData *mRefData;
|
2010-07-10 11:19:04 +00:00
|
|
|
CellStore *mCell;
|
2010-07-03 15:46:55 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2010-07-10 11:19:04 +00:00
|
|
|
Ptr() : mCellRef (0), mRefData (0), mCell (0) {}
|
2010-07-03 15:46:55 +00:00
|
|
|
|
2010-07-05 10:09:04 +00:00
|
|
|
bool isEmpty() const
|
|
|
|
{
|
|
|
|
return mPtr.empty();
|
|
|
|
}
|
|
|
|
|
2010-07-03 15:46:55 +00:00
|
|
|
template<typename T>
|
2010-07-10 11:19:04 +00:00
|
|
|
Ptr (ESMS::LiveCellRef<T, RefData> *liveCellRef, CellStore *cell)
|
2010-07-03 15:46:55 +00:00
|
|
|
{
|
|
|
|
mPtr = liveCellRef;
|
|
|
|
mCellRef = &liveCellRef->ref;
|
|
|
|
mRefData = &liveCellRef->mData;
|
2010-07-10 11:19:04 +00:00
|
|
|
mCell = cell;
|
2010-07-03 15:46:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
ESMS::LiveCellRef<T, RefData> *get() const
|
|
|
|
{
|
|
|
|
return boost::any_cast<const ESMS::LiveCellRef<T, RefData>*> (mPtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
ESM::CellRef& getCellRef() const
|
|
|
|
{
|
|
|
|
assert (mCellRef);
|
|
|
|
return *mCellRef;
|
|
|
|
}
|
|
|
|
|
|
|
|
RefData& getRefData() const
|
|
|
|
{
|
|
|
|
assert (mRefData);
|
|
|
|
return *mRefData;
|
|
|
|
}
|
2010-07-10 11:19:04 +00:00
|
|
|
|
|
|
|
Ptr::CellStore *getCell() const
|
|
|
|
{
|
|
|
|
assert (mCell);
|
|
|
|
return mCell;
|
|
|
|
}
|
2010-07-03 15:46:55 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|