diff --git a/src/filters/filters.cpp b/src/filters/filters.cpp index 558cc2ab..d806268d 100644 --- a/src/filters/filters.cpp +++ b/src/filters/filters.cpp @@ -41,3 +41,5 @@ const std::map makeFilterMap() InsertFilter("sdlStretch3x",sdlStretch3x,sdlStretch3x); InsertFilter("sdlStretch4x",sdlStretch4x,sdlStretch4x); } + +const std::map filters::filterMap = makeFilterMap(); diff --git a/src/filters/filters.hpp b/src/filters/filters.hpp index 0e787c59..470695ef 100644 --- a/src/filters/filters.hpp +++ b/src/filters/filters.hpp @@ -4,6 +4,7 @@ #include #include +#include #include "interframe.hpp" #include "../common/Types.h" @@ -15,11 +16,33 @@ typedef void(*FilterFunc)(u8*, u32, u8*, u8*, u32, int, int); typedef std::pair filterpair; typedef std::pair namedfilter; -//Function to make the filterMap -const std::map makeFilterMap(); - -//A named map of all the filters -// static const std::map filterMap = makeFilterMap(); +///A class allowing for easy access to all the filters +class filters { +private: + //A named map of all the filters + static const std::map filterMap; +public: + ///Returns a function pointer to a 32 bit filter + FilterFunc GetFilter(std::string filterName) + { + std::map::const_iterator found = filterMap.find(filterName); + if(found == filterMap.end()){ + throw std::runtime_error("ERROR: Filter not found!"); + return NULL; + } + return found->second.first; + }; + ///Returns a function pointer to a 16 bit filter + FilterFunc GetFilter16(std::string filterName) + { + std::map::const_iterator found = filterMap.find(filterName); + if(found == filterMap.end()){ + throw std::runtime_error("ERROR: Filter not found!"); + return NULL; + } + return found->second.second; + }; +}; //These are the available filters