TuttleOFX  1
OfxhImageEffectPluginCache.hpp
Go to the documentation of this file.
00001 #ifndef _OFXH_IMAGEEFFECTPLUGINCACHE_HPP_
00002 #define _OFXH_IMAGEEFFECTPLUGINCACHE_HPP_
00003 
00004 #include "OfxhImageEffectHost.hpp"
00005 #include "OfxhImageEffectNode.hpp"
00006 #include "OfxhMajorPlugin.hpp"
00007 #include "OfxhHost.hpp"
00008 
00009 #include <string>
00010 #include <vector>
00011 #include <set>
00012 #include <map>
00013 #include <memory>
00014 
00015 namespace tuttle {
00016 namespace host {
00017 namespace ofx {
00018 namespace imageEffect {
00019 
00020 /// implementation of the specific Image Effect handler API cache.
00021 class OfxhImageEffectPluginCache : public APICache::OfxhPluginAPICacheI
00022 {
00023 public:
00024         typedef OfxhImageEffectPluginCache This;
00025 
00026 private:
00027         /// all plugins
00028         std::vector<OfxhImageEffectPlugin*> _plugins;
00029 
00030         /// latest version of each plugin by ID
00031         std::map<std::string, OfxhImageEffectPlugin*> _pluginsByID;
00032 
00033         /// latest minor version of each plugin by (ID,major)
00034         std::map<OfxhMajorPlugin, OfxhImageEffectPlugin*> _pluginsByIDMajor;
00035 
00036         /// pointer to our image effect host
00037         OfxhImageEffectHost* _host;
00038 
00039 public:
00040         explicit OfxhImageEffectPluginCache( OfxhImageEffectHost& host );
00041         ~OfxhImageEffectPluginCache();
00042 
00043         /// get the plugin by id.  vermaj and vermin can be specified.  if they are not it will
00044         /// pick the highest found version.
00045         OfxhImageEffectPlugin*       getPluginById( const std::string& id, int vermaj = -1, int vermin = -1 );
00046         const OfxhImageEffectPlugin* getPluginById( const std::string& id, int vermaj = -1, int vermin = -1 ) const { return const_cast<This&>( *this ).getPluginById( id, vermaj, vermin ); }
00047 
00048         /// get the plugin by label.  vermaj and vermin can be specified.  if they are not it will
00049         /// pick the highest found version.
00050         OfxhImageEffectPlugin*       getPluginByLabel( const std::string& label, int vermaj = -1, int vermin = -1 );
00051         const OfxhImageEffectPlugin* getPluginByLabel( const std::string& label, int vermaj = -1, int vermin = -1 ) const { return const_cast<This&>( *this ).getPluginByLabel( label, vermaj, vermin ); }
00052 
00053         OfxhImageEffectHost& getHost() { return *_host; }
00054 
00055         const std::vector<OfxhImageEffectPlugin*>& getPlugins() const;
00056 
00057         const std::map<std::string, OfxhImageEffectPlugin*>& getPluginsByID() const;
00058 
00059         const std::map<OfxhMajorPlugin, OfxhImageEffectPlugin*>& getPluginsByIDMajor() const { return _pluginsByIDMajor; }
00060 
00061         /// handle the case where the info needs filling in from the file.  runs the "describe" action on the plugin.
00062         void loadFromPlugin( OfxhPlugin& p );
00063 
00064         void confirmPlugin( OfxhPlugin& p );
00065 
00066         bool pluginSupported( const OfxhPlugin& p, std::string& reason ) const;
00067 
00068 #ifndef SWIG
00069         OfxhPlugin* newPlugin( OfxhPluginBinary& pb,
00070                                int               pi,
00071                                OfxPlugin&        pl );
00072 
00073         OfxhPlugin* newPlugin( OfxhPluginBinary&  pb,
00074                                int                pi,
00075                                const std::string& api,
00076                                int                apiVersion,
00077                                const std::string& pluginId,
00078                                const std::string& rawId,
00079                                int                pluginMajorVersion,
00080                                int                pluginMinorVersion );
00081 #endif
00082 
00083         friend std::ostream& operator<<( std::ostream& os, const This& g );
00084 };
00085 
00086 }
00087 }
00088 }
00089 }
00090 
00091 #endif
00092