1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 02:49:55 +00:00
openmw-tes3mp/apps/openmw/mwworld/ptr.hpp
2010-07-05 12:09:04 +02:00

60 lines
1.3 KiB
C++

#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
{
boost::any mPtr;
ESM::CellRef *mCellRef;
RefData *mRefData;
public:
Ptr() : mCellRef (0), mRefData (0) {}
bool isEmpty() const
{
return mPtr.empty();
}
template<typename T>
Ptr (ESMS::LiveCellRef<T, RefData> *liveCellRef)
{
mPtr = liveCellRef;
mCellRef = &liveCellRef->ref;
mRefData = &liveCellRef->mData;
}
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;
}
};
}
#endif