#include <iostream>
#include <fstream>
#include "ofxhPluginCache.h"
#include "ofxhPropertySuite.h"
#include "ofxhImageEffectAPI.h"
class CacheHost : public OFX::Host::ImageEffect::Host
{
public :
OFX::Host::ImageEffect::Instance* newInstance(void* clientData,
OFX::Host::ImageEffect::ImageEffectPlugin* plugin,
OFX::Host::ImageEffect::Descriptor& desc,
const std::string& context)
{
return NULL;
}
OFX::Host::ImageEffect::Descriptor *makeDescriptor(OFX::Host::ImageEffect::ImageEffectPlugin* plugin)
{
OFX::Host::ImageEffect::Descriptor *desc = new OFX::Host::ImageEffect::Descriptor(plugin);
return desc;
}
OFX::Host::ImageEffect::Descriptor *makeDescriptor(const OFX::Host::ImageEffect::Descriptor &rootContext,
OFX::Host::ImageEffect::ImageEffectPlugin *plugin)
{
OFX::Host::ImageEffect::Descriptor *desc = new OFX::Host::ImageEffect::Descriptor(rootContext, plugin);
return desc;
}
OFX::Host::ImageEffect::Descriptor *makeDescriptor(const std::string &bundlePath,
OFX::Host::ImageEffect::ImageEffectPlugin *plugin)
{
OFX::Host::ImageEffect::Descriptor *desc = new OFX::Host::ImageEffect::Descriptor(bundlePath, plugin);
return desc;
}
OfxStatus vmessage(const char* type,
const char* id,
const char* format,
va_list args)
{
bool isQuestion = false;
const char *prefix = "Message : ";
if (strcmp(type, kOfxMessageLog) == 0) {
prefix = "Log : ";
}
else if(strcmp(type, kOfxMessageFatal) == 0 ||
strcmp(type, kOfxMessageError) == 0) {
prefix = "Error : ";
}
else if(strcmp(type, kOfxMessageQuestion) == 0) {
prefix = "Question : ";
isQuestion = true;
}
fputs(prefix, stdout);
vprintf(format, args);
printf("\n");
if(isQuestion) {
return kOfxStatReplyYes;
}
else {
return kOfxStatOK;
}
}
OfxStatus setPersistentMessage(const char* type,
const char* id,
const char* format,
va_list args)
{
return vmessage(type, id, format, args);
}
OfxStatus clearPersistentMessage()
{
return kOfxStatOK;
}
#ifdef OFX_SUPPORTS_OPENGLRENDER
virtual OfxStatus flushOpenGLResources() const { return kOfxStatFailed; };
#endif
};
int main(int argc, char **argv)
{
#ifdef _WIN32
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
OFX::Host::PluginCache::getPluginCache()->setCacheVersion("cacheDemoV1");
CacheHost myHost;
OFX::Host::ImageEffect::PluginCache imageEffectPluginCache(myHost);
imageEffectPluginCache.registerInCache(*OFX::Host::PluginCache::getPluginCache());
std::ifstream ifs("oldcache.xml");
OFX::Host::PluginCache::getPluginCache()->readCache(ifs);
OFX::Host::PluginCache::getPluginCache()->scanPluginFiles();
ifs.close();
std::ofstream of("newCache.xml");
OFX::Host::PluginCache::getPluginCache()->writePluginCache(of);
of.close();
imageEffectPluginCache.dumpToStdOut();
OFX::Host::PluginCache::clearPluginCache();
}