TuttleOFX  1
Core.hpp
Go to the documentation of this file.
00001 #ifndef _TUTTLE_HOST_CORE_HPP_
00002 #define _TUTTLE_HOST_CORE_HPP_
00003 
00004 #include "Preferences.hpp"
00005 
00006 #include <tuttle/host/memory/IMemoryCache.hpp>
00007 #include <tuttle/host/HostDescriptor.hpp>
00008 #include <tuttle/host/ofx/OfxhPluginCache.hpp>
00009 #include <tuttle/host/ofx/OfxhImageEffectPluginCache.hpp>
00010 
00011 #include <tuttle/common/patterns/Singleton.hpp>
00012 
00013 #include <boost/preprocessor/stringize.hpp>
00014 
00015 
00016 #define TUTTLE_HOST_VERSION_MAJOR 0
00017 #define TUTTLE_HOST_VERSION_MINOR 8
00018 #define TUTTLE_HOST_VERSION_MICRO 0
00019 
00020 #define TUTTLE_HOST_VERSION_STR BOOST_PP_STRINGIZE(TUTTLE_HOST_VERSION_MAJOR) "." BOOST_PP_STRINGIZE(TUTTLE_HOST_VERSION_MINOR) "." BOOST_PP_STRINGIZE(TUTTLE_HOST_VERSION_MICRO)
00021 
00022 
00023 namespace tuttle {
00024 namespace host {
00025 
00026 class Core : public Singleton<Core>
00027 {
00028 public:
00029         typedef Core This;
00030         friend class Singleton<Core>;
00031 
00032 private:
00033         Core();
00034         ~Core();
00035 
00036 private:
00037         Host _host;
00038         ofx::imageEffect::OfxhImageEffectPluginCache _imageEffectPluginCache;
00039         ofx::OfxhPluginCache _pluginCache;
00040         memory::IMemoryPool& _memoryPool;
00041         memory::IMemoryCache& _memoryCache;
00042         bool _isPreloaded;
00043         
00044         Preferences _preferences;
00045 
00046 public:
00047               ofx::OfxhPluginCache& getPluginCache()       { return _pluginCache; }
00048         const ofx::OfxhPluginCache& getPluginCache() const { return _pluginCache; }
00049         
00050         const std::list<ofx::OfxhPlugin*>& getPlugins() const { return getPluginCache().getPlugins(); }
00051 
00052         const Host&                 getHost() const        { return _host; }
00053 
00054               Preferences& getPreferences()       { return _preferences; }
00055         const Preferences& getPreferences() const { return _preferences; }
00056 
00057 public:
00058         const ofx::imageEffect::OfxhImageEffectPluginCache& getImageEffectPluginCache() const { return _imageEffectPluginCache; }
00059 
00060         memory::IMemoryPool&        getMemoryPool()        { return _memoryPool; }
00061         const memory::IMemoryPool&  getMemoryPool() const  { return _memoryPool; }
00062         memory::IMemoryCache&       getMemoryCache()       { return _memoryCache; }
00063         const memory::IMemoryCache& getMemoryCache() const { return _memoryCache; }
00064 
00065 public:
00066         ofx::imageEffect::OfxhImageEffectPlugin* getImageEffectPluginById( const std::string& id, int vermaj = -1, int vermin = -1 )
00067         {
00068                 return _imageEffectPluginCache.getPluginById( id, vermaj, vermin );
00069         }
00070 
00071 
00072 public:
00073         void preload( const bool useCache = true );
00074 
00075         const ofx::OfxhPlugin& operator[]( const std::string& name ) const
00076         {
00077                 return *( this->getPluginCache().getPluginById( name ) );
00078         }
00079 
00080         friend std::ostream& operator<<( std::ostream& os, const This& v );
00081 };
00082 
00083 inline Core& core() { return Core::instance(); }
00084 
00085 }
00086 }
00087 
00088 #endif
00089