Archived
1
0
This repository has been archived on 2024-10-17. You can view files and clone it, but cannot push or open issues or pull requests.
winamp/Src/Plugins/Input/in_wmvdrm/CachedData.h
2024-09-24 14:54:57 +02:00

48 lines
560 B
C++

#ifndef CACHEDDATAH
#define CACHEDDATAH
template <class DataType>
class CachedData
{
public:
CachedData() : cached(false)
{
}
CachedData(DataType _data) : cached(true), data(_data)
{
}
operator DataType()
{
return data;
}
bool IsCached()
{
return cached;
}
void ClearCache()
{
cached=false;
}
DataType *operator &()
{
if (cached)
return &data;
else
return 0;
}
template <class FromType>
bool operator =(FromType from)
{
data = from;
cached=true;
return cached;
}
private:
bool cached;
DataType data;
};
#endif