2022-04-10 00:17:06 +00:00
|
|
|
#ifndef _CTOKEN_HPP
|
|
|
|
#define _CTOKEN_HPP
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
2022-08-09 23:03:51 +00:00
|
|
|
#include "Kyoto/IObjectStore.hpp"
|
2022-07-14 16:24:26 +00:00
|
|
|
|
2022-08-09 23:03:51 +00:00
|
|
|
#include "rstl/auto_ptr.hpp"
|
2022-04-10 00:17:06 +00:00
|
|
|
|
|
|
|
class CToken {
|
|
|
|
public:
|
|
|
|
~CToken();
|
|
|
|
|
|
|
|
private:
|
|
|
|
CObjectReference* x0_objRef;
|
|
|
|
bool x4_lockHeld;
|
|
|
|
};
|
|
|
|
|
2022-07-14 16:24:26 +00:00
|
|
|
class IObj {
|
|
|
|
public:
|
|
|
|
virtual ~IObj() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class TObjOwnerDerivedFromIObjUntyped : public IObj {
|
|
|
|
public:
|
|
|
|
template < typename T >
|
|
|
|
TObjOwnerDerivedFromIObjUntyped(const rstl::auto_ptr< T >& obj) : m_objPtr(obj.release()) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void* m_objPtr;
|
|
|
|
};
|
|
|
|
|
2022-04-10 00:17:06 +00:00
|
|
|
template < typename T >
|
2022-07-14 16:24:26 +00:00
|
|
|
class TObjOwnerDerivedFromIObj : public TObjOwnerDerivedFromIObjUntyped {
|
|
|
|
TObjOwnerDerivedFromIObj(const rstl::auto_ptr< T >& obj) : TObjOwnerDerivedFromIObjUntyped(obj) {}
|
|
|
|
|
|
|
|
public:
|
|
|
|
static rstl::auto_ptr< TObjOwnerDerivedFromIObj< T > > GetNewDerivedObject(const rstl::auto_ptr< T >& obj) {
|
|
|
|
return new TObjOwnerDerivedFromIObj< T >(obj);
|
|
|
|
}
|
|
|
|
~TObjOwnerDerivedFromIObj() override { delete Owned(); }
|
|
|
|
T* Owned() { return static_cast< T* >(m_objPtr); }
|
|
|
|
};
|
|
|
|
|
|
|
|
template < typename T >
|
|
|
|
class TToken : public CToken {
|
|
|
|
public:
|
|
|
|
static rstl::auto_ptr< TObjOwnerDerivedFromIObj< T > > GetIObjObjectFor(const rstl::auto_ptr< T >& obj) {
|
|
|
|
return TObjOwnerDerivedFromIObj< T >::GetNewDerivedObject(obj);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-04-10 00:17:06 +00:00
|
|
|
template < typename T >
|
|
|
|
class TCachedToken : public TToken< T > {
|
|
|
|
private:
|
|
|
|
T* x8_item;
|
|
|
|
};
|
2022-07-14 16:24:26 +00:00
|
|
|
|
2022-04-10 00:17:06 +00:00
|
|
|
template < typename T >
|
|
|
|
class TLockedToken : public TCachedToken< T > {};
|
|
|
|
|
|
|
|
#endif
|