00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00028 #if ! defined( PLUGIN_HH )
00029 #define PLUGIN_HH
00030
00031
00032 #include <iostream>
00033 #include <string>
00034
00035
00036 #include "piave_base.hh"
00037
00038 #define PLUGIN_IFACE_VERSION 1
00039
00040 namespace PIAVE {
00041
00042 class PropertyNode;
00043
00044 class Plugin;
00045
00046 typedef Plugin * (*PluginMaker)();
00047
00051 struct PluginInfo {
00052 const char * name;
00053 int iface_version;
00054 PluginMaker maker;
00055 };
00056
00062 #define PIAVE_PLUGIN( N ) \
00063 Plugin * new_ ## N () { return new N (); }; \
00064 PluginInfo pluginInfo[] = { { #N , PLUGIN_IFACE_VERSION , &new_ ##N } , \
00065 { 0 , 0 , 0 } \
00066 };;
00067
00075 enum PluginType_e {
00076
00077 PLUGIN_NO_TYPE = 0,
00078 PLUGIN_ANY_TYPE,
00079
00080 PLUGIN_VIDEO_OP,
00081 PLUGIN_AUDIO_OP,
00082
00083 PLUGIN_INSTREAM,
00084 PLUGIN_OUTSTREAM,
00085
00086 PLUGIN_VIDEO_CODEC,
00087 PLUGIN_AUDIO_CODEC,
00088
00089 PLUGIN_MEDIA_ELEMENT
00090 };
00091
00092
00097 class PluginBase
00098 {
00099 public:
00100 PluginBase() {};
00101 virtual ~PluginBase() {}
00102 virtual PropertyNode * getProperties( PropertyNode *p = 0 ) const = 0;
00103
00104 };
00105
00111 class Plugin
00112 {
00113 public:
00114 Plugin( const std::string & name, PluginType_e t );
00115 virtual ~Plugin();
00116
00117 std::string getName() const { return _name; }
00118 int getPriority()const { return _priority; }
00119 PluginType_e getType() const { return _type; }
00120 PropertyNode * getCapabilities() const;
00121 bool isEnabled() const { return _enabled; }
00122
00123 void setName( const std::string & n ) { _name = n; }
00124 void setPriority( int p ) { _priority = p; }
00125 void setCapabilities( PropertyNode * caps ) { _caps = caps; };
00126 void setEnabled( bool enabled = true ) { _enabled = enabled; }
00127
00129 virtual PluginBase * newElement( const PropertyNode * p = 0 ) = 0;
00130
00131
00132 private:
00136 std::string _name;
00137
00141 int _priority;
00142
00148 PluginType_e _type;
00149
00158 PropertyNode * _caps;
00159
00164 bool _enabled;
00165
00166 };
00167
00168 }
00169
00170 #endif