blob: b60ee109009521ee3b7d50db1947ba65d0b4c39e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#ifndef LIBDCP_LUT_CACHE_H
#define LIBDCP_LUT_CACHE_H
#include <list>
#include <boost/shared_ptr.hpp>
template<class T>
class LUTCache
{
public:
boost::shared_ptr<T> get (int bit_depth, float gamma)
{
for (typename std::list<boost::shared_ptr<T> >::iterator i = _cache.begin(); i != _cache.end(); ++i) {
if ((*i)->bit_depth() == bit_depth && (*i)->gamma() == gamma) {
return *i;
}
}
boost::shared_ptr<T> lut (new T (bit_depth, gamma));
_cache.push_back (lut);
return lut;
}
private:
std::list<boost::shared_ptr<T> > _cache;
};
#endif
|