}
+PipelineTemplate::PostProcessorRegistry &PipelineTemplate::get_postprocessor_registry()
+{
+ static PostProcessorRegistry registry;
+ static bool initialized = false;
+ if(!initialized)
+ {
+ registry.register_type<AmbientOcclusion>("ambient_occlusion");
+ registry.register_type<Bloom>("bloom");
+ registry.register_type<ColorCurve>("colorcurve");
+ initialized = true;
+ }
+ return registry;
+}
+
+
PipelineTemplate::Pass::~Pass()
{ }
void PipelineTemplate::Loader::init()
{
- add("ambient_occlusion", &Loader::postprocessor<AmbientOcclusion>);
- add("bloom", &Loader::postprocessor<Bloom>);
- add("colorcurve", &Loader::postprocessor<ColorCurve>);
add("hdr", &PipelineTemplate::hdr);
add("multisample", &Loader::multisample);
add("multisample", &Loader::multisample_range);
add("pass", &Loader::pass);
+
+ get_postprocessor_registry().add_all(*this);
}
void PipelineTemplate::Loader::multisample(unsigned samples)
obj.passes.push_back(pss);
}
-template<typename T>
-void PipelineTemplate::Loader::postprocessor()
-{
- RefPtr<typename T::Template> postproc = new typename T::Template;
- load_sub(*postproc);
- obj.postprocessors.push_back(postproc.release());
-}
-
PipelineTemplate::Pass::Loader::Loader(Pass &p):
DataFile::CollectionObjectLoader<Pass>(p, 0)
#include <string>
#include <vector>
+#include <msp/datafile/loadabletyperegistry.h>
#include <msp/datafile/objectloader.h>
#include "blend.h"
#include "postprocessor.h"
public:
class Loader: public DataFile::CollectionObjectLoader<PipelineTemplate>
{
+ private:
+ template<typename T>
+ struct AddPostProc
+ {
+ static void add(Loader &ldr, const std::string &kw) { ldr.add(kw, &Loader::postprocessor<T>); }
+ };
+
public:
Loader(PipelineTemplate &);
Loader(PipelineTemplate &, Collection &);
template<typename T>
void postprocessor();
+
+ friend class PipelineTemplate;
};
struct Pass
typedef std::vector<PostProcessor::Template *> PostProcessorArray;
private:
+ typedef DataFile::LoadableTypeRegistry<Loader, Loader::AddPostProc> PostProcessorRegistry;
+
bool hdr;
unsigned required_multisample;
unsigned max_multisample;
unsigned get_maximum_multisample() const { return max_multisample; }
const PassArray &get_passes() const { return passes; }
const PostProcessorArray &get_postprocessors() const { return postprocessors; }
+
+ template<typename T>
+ static void register_postprocessor(const std::string &);
+private:
+ static PostProcessorRegistry &get_postprocessor_registry();
};
+template<typename T>
+void PipelineTemplate::register_postprocessor(const std::string &kw)
+{
+ get_postprocessor_registry().register_type<T>(kw);
+}
+
+template<typename T>
+void PipelineTemplate::Loader::postprocessor()
+{
+ RefPtr<typename T::Template> postproc = new typename T::Template;
+ load_sub(*postproc);
+ obj.postprocessors.push_back(postproc.release());
+}
+
} // namespace GL
} // namespace Msp