diff options
Diffstat (limited to 'src/lut_cache.h')
| -rw-r--r-- | src/lut_cache.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/lut_cache.h b/src/lut_cache.h new file mode 100644 index 00000000..b60ee109 --- /dev/null +++ b/src/lut_cache.h @@ -0,0 +1,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 |
