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