TuttleOFX  1
TuttleOFX/libraries/tuttle/src/tuttle/host/ofx/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         typedef std::map<std::string, OfxhImageEffectPlugin*> MapPluginsByID;
00026 
00027 private:
00028         /// all plugins
00029         std::vector<OfxhImageEffectPlugin*> _plugins;
00030 
00031         /// latest version of each plugin by ID
00032         MapPluginsByID _pluginsByID;
00033 
00034         /// latest minor version of each plugin by (ID,major)
00035         std::map<OfxhMajorPlugin, OfxhImageEffectPlugin*> _pluginsByIDMajor;
00036 
00037         /// pointer to our image effect host
00038         OfxhImageEffectHost* _host;
00039 
00040 public:
00041         explicit OfxhImageEffectPluginCache( OfxhImageEffectHost& host );
00042         ~OfxhImageEffectPluginCache();
00043 
00044         /// get the plugin by id.  vermaj and vermin can be specified.  if they are not it will
00045         /// pick the highest found version.
00046         OfxhImageEffectPlugin*       getPluginById( const std::string& id, int vermaj = -1, int vermin = -1 );
00047         const OfxhImageEffectPlugin* getPluginById( const std::string& id, int vermaj = -1, int vermin = -1 ) const { return const_cast<This&>( *this ).getPluginById( id, vermaj, vermin ); }
00048 
00049         /// get the plugin by label.  vermaj and vermin can be specified.  if they are not it will
00050         /// pick the highest found version.
00051         OfxhImageEffectPlugin*       getPluginByLabel( const std::string& label, int vermaj = -1, int vermin = -1 );
00052         const OfxhImageEffectPlugin* getPluginByLabel( const std::string& label, int vermaj = -1, int vermin = -1 ) const { return const_cast<This&>( *this ).getPluginByLabel( label, vermaj, vermin ); }
00053 
00054         OfxhImageEffectHost& getHost() { return *_host; }
00055 
00056         const std::vector<OfxhImageEffectPlugin*>& getPlugins() const;
00057 
00058         const MapPluginsByID& getPluginsByID() const;
00059 
00060         /// handle the case where the info needs filling in from the file.  runs the "describe" action on the plugin.
00061         void loadFromPlugin( OfxhPlugin& p );
00062 
00063         void confirmPlugin( OfxhPlugin& p );
00064 
00065         bool pluginSupported( const OfxhPlugin& p, std::string& reason ) const;
00066 
00067 #ifndef SWIG
00068         OfxhPlugin* newPlugin( OfxhPluginBinary& pb,
00069                                int               pi,
00070                                OfxPlugin&        pl );
00071 
00072         OfxhPlugin* newPlugin( OfxhPluginBinary&  pb,
00073                                int                pi,
00074                                const std::string& api,
00075                                int                apiVersion,
00076                                const std::string& pluginId,
00077                                const std::string& rawId,
00078                                int                pluginMajorVersion,
00079                                int                pluginMinorVersion );
00080 #endif
00081 
00082         friend std::ostream& operator<<( std::ostream& os, const This& g );
00083 };
00084 
00085 }
00086 }
00087 }
00088 }
00089 
00090 #endif
00091