TuttleOFX
1
|
00001 #ifndef OFXH_PLUGIN_HPP 00002 #define OFXH_PLUGIN_HPP 00003 00004 #include "OfxhPluginDesc.hpp" 00005 #include "OfxhPluginAPICache.hpp" 00006 00007 namespace tuttle { 00008 namespace host { 00009 namespace ofx { 00010 00011 class OfxhPluginBinary; 00012 00013 /** 00014 * class that we use to manipulate a plugin. 00015 * 00016 * Owned by the PluginBinary it lives inside. 00017 * Plugins can only be pass about either by pointer or reference. 00018 */ 00019 class OfxhPlugin : public OfxhPluginDesc 00020 { 00021 public: 00022 typedef OfxhPlugin This; 00023 00024 private: 00025 OfxhPlugin( const This& ); ///< hidden 00026 OfxhPlugin& operator=( const This& ); ///< hidden 00027 00028 protected: 00029 OfxhPluginBinary* _binary; ///< the file I live inside 00030 int _index; ///< where I live inside that file 00031 00032 public: 00033 OfxhPlugin() {} 00034 00035 /** 00036 * construct this based on the struct returned by the getNthPlugin() in the binary 00037 */ 00038 OfxhPlugin( OfxhPluginBinary& bin, int idx, OfxPlugin& o ) : OfxhPluginDesc( o ) 00039 , _binary( &bin ) 00040 , _index( idx ) {} 00041 00042 /** 00043 * construct me from the cache 00044 */ 00045 OfxhPlugin( OfxhPluginBinary& bin, int idx, const std::string& api, 00046 int apiVersion, const std::string& identifier, 00047 const std::string& rawIdentifier, 00048 int majorVersion, int minorVersion ) 00049 : OfxhPluginDesc( api, apiVersion, identifier, rawIdentifier, majorVersion, minorVersion ) 00050 , _binary( &bin ) 00051 , _index( idx ) {} 00052 00053 virtual ~OfxhPlugin() = 0; 00054 00055 bool operator==( const This& other ) const; 00056 bool operator!=( const This& other ) const { return !This::operator==( other ); } 00057 00058 void setBinary( OfxhPluginBinary& binary ) { _binary = &binary; } 00059 OfxhPluginBinary& getBinary() { return *_binary; } 00060 const OfxhPluginBinary& getBinary() const { return *_binary; } 00061 00062 int getIndex() const 00063 { 00064 return _index; 00065 } 00066 00067 bool trumps( OfxhPlugin& other ) 00068 { 00069 int myMajor = getVersionMajor(); 00070 int theirMajor = other.getVersionMajor(); 00071 00072 int myMinor = getVersionMinor(); 00073 int theirMinor = other.getVersionMinor(); 00074 00075 if( myMajor > theirMajor ) 00076 { 00077 return true; 00078 } 00079 00080 if( myMajor == theirMajor && myMinor > theirMinor ) 00081 { 00082 return true; 00083 } 00084 00085 return false; 00086 } 00087 00088 #ifndef SWIG 00089 virtual void setApiHandler( APICache::OfxhPluginAPICacheI& ) = 0; 00090 virtual APICache::OfxhPluginAPICacheI& getApiHandler() = 0; 00091 virtual const APICache::OfxhPluginAPICacheI& getApiHandler() const = 0; 00092 00093 private: 00094 friend class boost::serialization::access; 00095 template<class Archive> 00096 void serialize( Archive& ar, const unsigned int version ) 00097 { 00098 ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP( OfxhPluginDesc ); 00099 // ar & BOOST_SERIALIZATION_NVP(_binary); // just a link, don't save 00100 ar& BOOST_SERIALIZATION_NVP( _index ); 00101 } 00102 00103 #endif 00104 }; 00105 00106 } 00107 } 00108 } 00109 00110 // BOOST_SERIALIZATION_ASSUME_ABSTRACT(tuttle::host::ofx::OfxhPlugin) 00111 00112 #endif 00113