1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00
vcmi/lib/ConstTransitivePtr.h
Ivan Savenko 2ff07fa66a - Next part of animation system:
-- Reduced memory usage for images with margins
-- Implemented RLE compression
- Linux-related changes:
-- build system updated to include changed paths
-- new dependency: boost-program-options
-- configure option --disable-debug will produce optimized build

- Several gcc compile fixes
- Optimized CPU usage on town screens
- Removed several includes from headers
- Possible fix for #496
2011-02-06 17:26:27 +00:00

67 lines
844 B
C++

#pragma once
class CGameHandler;
template <typename T>
class ConstTransitivePtr
{
T *ptr;
ConstTransitivePtr(const T *Ptr)
: ptr(const_cast<T*>(Ptr))
{}
public:
ConstTransitivePtr(T *Ptr = NULL)
: ptr(Ptr)
{}
const T& operator*() const
{
return *ptr;
}
T& operator*()
{
return *ptr;
}
operator const T*() const
{
return ptr;
}
T* get()
{
return ptr;
}
const T* get() const
{
return ptr;
}
operator T*()
{
return ptr;
}
T *operator->()
{
return ptr;
}
const T *operator->() const
{
return ptr;
}
const T*operator=(T *t)
{
return ptr = t;
}
void dellNull()
{
delete ptr;
ptr = NULL;
}
template <typename Handler> void serialize(Handler &h, const int version)
{
h & ptr;
}
friend class CGameHandler;
};