TuttleOFX
1
|
00001 #ifndef _OFXH_PLUGINDESC_HPP_ 00002 #define _OFXH_PLUGINDESC_HPP_ 00003 00004 #include <ofxCore.h> 00005 00006 #include <boost/algorithm/string.hpp> 00007 #include <boost/serialization/serialization.hpp> 00008 #include <boost/serialization/nvp.hpp> 00009 #include <boost/serialization/export.hpp> 00010 #include <boost/serialization/string.hpp> 00011 00012 namespace tuttle { 00013 namespace host { 00014 namespace ofx { 00015 00016 struct OfxhPluginIdent 00017 { 00018 OfxhPluginIdent() : _versionMinor( 0 ) 00019 , _versionMajor( 0 ) {} 00020 OfxhPluginIdent( const std::string& identifier, const std::string& rawId, int verMin, int verMax ) 00021 : _identifier( identifier ) 00022 , _rawIdentifier( rawId ) 00023 , _versionMinor( verMin ) 00024 , _versionMajor( verMax ) 00025 {} 00026 00027 bool operator<( const OfxhPluginIdent& d2 ) const 00028 { 00029 return _identifier < d2._identifier || 00030 ( _identifier == d2._identifier && _versionMajor < d2._versionMajor ) || 00031 ( _identifier == d2._identifier && _versionMajor == d2._versionMajor && _versionMinor < d2._versionMinor ); 00032 } 00033 00034 bool operator!=( const OfxhPluginIdent& d2 ) const 00035 { 00036 return _identifier != d2._identifier && 00037 _rawIdentifier != d2._rawIdentifier && 00038 _versionMinor != d2._versionMinor && 00039 _versionMajor != d2._versionMajor; 00040 } 00041 00042 std::string _identifier; 00043 std::string _rawIdentifier; 00044 int _versionMinor, _versionMajor; 00045 }; 00046 00047 /** 00048 * C++ version of the information kept inside an OfxPlugin struct 00049 */ 00050 class OfxhPluginDesc 00051 { 00052 public: 00053 typedef OfxhPluginDesc This; 00054 00055 protected: 00056 std::string _pluginApi; ///< the API I implement 00057 int _apiVersion; ///< the version of the API 00058 00059 OfxhPluginIdent _ident; ///< The plugin identity 00060 00061 public: 00062 OfxhPluginDesc(); 00063 00064 OfxhPluginDesc( const std::string& api, 00065 int apiVersion, 00066 const std::string& identifier, 00067 const std::string& rawIdentifier, 00068 int versionMajor, 00069 int versionMinor ); 00070 00071 /** 00072 * constructor for the case where we have already loaded the plugin binary and 00073 * are populating this object from it 00074 */ 00075 OfxhPluginDesc( OfxPlugin& ofxPlugin ); 00076 00077 virtual ~OfxhPluginDesc(); 00078 00079 bool operator==( const This& other ) const; 00080 bool operator!=( const This& other ) const { return !This::operator==( other ); } 00081 00082 public: 00083 const std::string& getPluginApi() const 00084 { 00085 return _pluginApi; 00086 } 00087 00088 int getApiVersion() const 00089 { 00090 return _apiVersion; 00091 } 00092 00093 const OfxhPluginIdent& getIdentity() const 00094 { 00095 return _ident; 00096 } 00097 00098 OfxhPluginIdent& getIdentity() 00099 { 00100 return _ident; 00101 } 00102 00103 const std::string& getIdentifier() const 00104 { 00105 return _ident._identifier; 00106 } 00107 00108 const std::string& getRawIdentifier() const 00109 { 00110 return _ident._rawIdentifier; 00111 } 00112 00113 int getVersionMajor() const 00114 { 00115 return _ident._versionMajor; 00116 } 00117 00118 int getVersionMinor() const 00119 { 00120 return _ident._versionMinor; 00121 } 00122 00123 std::size_t getHash() const; 00124 00125 private: 00126 friend class boost::serialization::access; 00127 template<class Archive> 00128 void serialize( Archive& ar, const unsigned int version ) 00129 { 00130 ar& BOOST_SERIALIZATION_NVP( _pluginApi ); 00131 ar& BOOST_SERIALIZATION_NVP( _apiVersion ); 00132 // ar & BOOST_SERIALIZATION_NVP(_ident._identifier); 00133 ar& BOOST_SERIALIZATION_NVP( _ident._rawIdentifier ); 00134 ar& BOOST_SERIALIZATION_NVP( _ident._versionMajor ); 00135 ar& BOOST_SERIALIZATION_NVP( _ident._versionMinor ); 00136 00137 if( typename Archive::is_loading() ) 00138 { 00139 _ident._identifier = _ident._rawIdentifier; 00140 boost::to_lower( _ident._identifier ); 00141 } 00142 } 00143 00144 }; 00145 00146 } 00147 } 00148 } 00149 00150 #ifndef SWIG 00151 BOOST_SERIALIZATION_ASSUME_ABSTRACT( tuttle::host::ofx::OfxhPluginDesc ) 00152 #endif 00153 00154 #endif 00155