compiled preset -> native preset

git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/personal/carm/represet@1171 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
w1z7ard
2008-09-19 19:18:37 +00:00
parent 894ecd275b
commit ca7cf490d3
5 changed files with 26 additions and 26 deletions

View File

@ -34,7 +34,7 @@ Func.cpp Eval.cpp PerFrameEqn.cpp PerPointEqn.cpp fftsg.cpp KeyHandler.cpp
timer.cpp wipemalloc.cpp BuiltinFuncs.cpp BuiltinParams.cpp Renderer.cpp
PresetLoader.cpp PresetChooser.cpp PresetFrameIO.cpp PresetMerge.cpp PipelineContext.cpp
ConfigFile.cpp IdlePreset.cpp TextureManager.cpp TimeKeeper.cpp Filters.cpp Renderable.cpp Pipeline.cpp PerPixelMesh.cpp
MilkdropWaveform.cpp Waveform.cpp VideoEcho.cpp Shader.cpp PerlinNoise.cpp UserTexture.cpp ShaderEngine.cpp MilkdropPreset.cpp MilkdropPresetFactory.cpp CompiledPresetFactory.cpp PresetFactory.cpp PresetFactoryManager.cpp ${GLEW_SOURCES})
MilkdropWaveform.cpp Waveform.cpp VideoEcho.cpp Shader.cpp PerlinNoise.cpp UserTexture.cpp ShaderEngine.cpp MilkdropPreset.cpp MilkdropPresetFactory.cpp NativePresetFactory.cpp PresetFactory.cpp PresetFactoryManager.cpp ${GLEW_SOURCES})
if (USE_DEVIL)
SET (projectM_SOURCES ${projectM_SOURCES})

View File

@ -5,8 +5,8 @@
* Author: carm
*/
#ifndef __COMPILED_PRESET_HPP_
#define __COMPILED_PRESET_HPP_
#ifndef __NATIVE_PRESET_HPP_
#define __NATIVE_PRESET_HPP_
#include <string>
@ -17,13 +17,13 @@
/// A templated preset class to build different various hard coded presets and
/// compile them into object files to be loaded into a playlist
template <class PipelineT>
class CompiledPreset : public Preset {
class NativePreset : public Preset {
public:
inline CompiledPreset(const std::string & name=std::string(),
inline NativePreset(const std::string & name=std::string(),
const std::string & author = std::string()) : Preset(name, author) {}
virtual ~CompiledPreset() {}
virtual ~NativePreset() {}
inline PipelineT & pipeline() { return _pipeline; }
inline virtual void Render(const BeatDetect &music, const PipelineContext &context) {
@ -35,12 +35,12 @@ private:
};
template <class PipelineT>
extern "C" CompiledPreset<PipelineT> * create(const char * url) {
return new CompiledPreset<PipelineT>(std::string(url));
extern "C" NativePreset<PipelineT> * create(const char * url) {
return new NativePreset<PipelineT>(std::string(url));
}
template <class PipelineT>
extern "C" void destroy(CompiledPreset<PipelineT> * preset) {
extern "C" void destroy(NativePreset<PipelineT> * preset) {
delete preset;
}

View File

@ -1,5 +1,5 @@
//
// C++ Implementation: CompiledPresetFactory
// C++ Implementation: NativePresetFactory
//
// Description:
//
@ -11,7 +11,7 @@
//
#include <dlfcn.h>
#include "CompiledPresetFactory.hpp"
#include "NativePresetFactory.hpp"
typedef void Handle;
typedef Preset * CreateFunctor(const char * url);
@ -38,9 +38,9 @@ class PresetLibrary {
};
CompiledPresetFactory::CompiledPresetFactory() {}
NativePresetFactory::NativePresetFactory() {}
CompiledPresetFactory::~CompiledPresetFactory() {
NativePresetFactory::~NativePresetFactory() {
for (PresetLibraryMap::iterator pos = _libraries.begin(); pos != _libraries.end(); ++pos)
delete(pos->second);
@ -48,7 +48,7 @@ for (PresetLibraryMap::iterator pos = _libraries.begin(); pos != _libraries.end(
}
PresetLibrary * CompiledPresetFactory::loadLibrary(const std::string & url) {
PresetLibrary * NativePresetFactory::loadLibrary(const std::string & url) {
if (_libraries.count(url))
return _libraries[url];
@ -56,7 +56,7 @@ PresetLibrary * CompiledPresetFactory::loadLibrary(const std::string & url) {
// load the preset library
void* handle = dlopen(url.c_str(), RTLD_LAZY);
if (!handle) {
std::cerr << "[CompiledPresetFactory] Cannot load library: " << dlerror() << '\n';
std::cerr << "[NativePresetFactory] Cannot load library: " << dlerror() << '\n';
return 0;
}
@ -67,14 +67,14 @@ PresetLibrary * CompiledPresetFactory::loadLibrary(const std::string & url) {
CreateFunctor * create = (CreateFunctor*) dlsym(handle, "create");
const char * dlsym_error = dlerror();
if (dlsym_error) {
std::cerr << "[CompiledPresetFactory] Cannot load symbol create: " << dlsym_error << '\n';
std::cerr << "[NativePresetFactory] Cannot load symbol create: " << dlsym_error << '\n';
return 0;
}
DestroyFunctor * destroy = (DestroyFunctor*) dlsym(handle, "destroy");
dlsym_error = dlerror();
if (dlsym_error) {
std::cerr << "[CompiledPresetFactory] Cannot load symbol destroy: " << dlsym_error << '\n';
std::cerr << "[NativePresetFactory] Cannot load symbol destroy: " << dlsym_error << '\n';
return 0;
}
@ -85,7 +85,7 @@ PresetLibrary * CompiledPresetFactory::loadLibrary(const std::string & url) {
}
std::auto_ptr<Preset> CompiledPresetFactory::allocate
std::auto_ptr<Preset> NativePresetFactory::allocate
(const std::string & url, const std::string & name, const std::string & author) {
PresetLibrary * library;

View File

@ -1,5 +1,5 @@
//
// C++ Interface: CompiledPresetFactory
// C++ Interface: NativePresetFactory
//
// Description:
//
@ -10,21 +10,21 @@
//
//
#ifndef __COMPILED_PRESET_FACTORY_HPP
#define __COMPILED_PRESET_FACTORY_HPP
#ifndef __NATIVE_PRESET_FACTORY_HPP
#define __NATIVE_PRESET_FACTORY_HPP
#include <memory>
#include "PresetFactory.hpp"
class PresetLibrary;
class CompiledPresetFactory : public PresetFactory {
class NativePresetFactory : public PresetFactory {
public:
CompiledPresetFactory();
NativePresetFactory();
virtual ~CompiledPresetFactory();
virtual ~NativePresetFactory();
virtual std::auto_ptr<Preset> allocate(const std::string & url, const std::string & name = std::string(),
const std::string & author = std::string());

View File

@ -16,7 +16,7 @@
#endif
#ifndef DISABLE_COMPILED_PRESETS
#include "CompiledPresetFactory.hpp"
#include "NativePresetFactory.hpp"
#endif
#include <sstream>
@ -39,7 +39,7 @@ void PresetFactoryManager::initialize(int gx, int gy) {
#endif
#ifndef DISABLE_COMPILED_PRESETS
factory = new CompiledPresetFactory();
factory = new NativePresetFactory();
registerFactory(factory->supportedExtensions(), factory);
#endif
}