00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _PLUGIN_LIST_H
00019 #define _PLUGIN_LIST_H
00020
00021 #include "String.h"
00022 #include <vector.h>
00023
00024
00025
00026
00031 template <class Info_Typ>
00032 class PluginList: public vector<Info_Typ*> {
00033 public:
00034 PluginList();
00035 ~PluginList();
00036
00039 void Libname( const char *name );
00040
00043 PluginList<Info_Typ> &operator += ( PluginList &liste );
00044
00047 PluginList<Info_Typ> &operator += ( const Info_Typ &element );
00048
00051 PluginList<Info_Typ> &operator += ( const Info_Typ *element );
00052
00055 Info_Typ &Element( unsigned int num );
00056
00059 unsigned int NumElements( void ){ return size(); }
00060
00061 protected:
00062 String lib_name;
00063 Info_Typ std_format;
00064 };
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 template <class Info_Typ>
00083 PluginList<Info_Typ>::PluginList()
00084 {
00085 }
00086
00087
00088
00089
00090 template <class Info_Typ>
00091 PluginList<Info_Typ>::~PluginList()
00092 {
00093 while( size() > 0 ) {
00094 delete back();
00095 pop_back();
00096 }
00097 }
00098
00099
00100
00101
00102
00103
00106 template <class Info_Typ>
00107 void PluginList<Info_Typ>::Libname( const char *name )
00108 {
00109 lib_name = name;
00110 }
00111
00112
00113
00114
00115
00116
00119 template <class Info_Typ>
00120 PluginList<Info_Typ> &PluginList<Info_Typ>::operator += ( PluginList<Info_Typ> &liste )
00121 {
00122 for( unsigned int i=0; i < liste.size(); i++ ) {
00123 (*this) += liste.Element( i );
00124 }
00125
00126 return *this;
00127 }
00128
00129
00130
00131
00132
00133 template <class Info_Typ>
00134 PluginList<Info_Typ> &PluginList<Info_Typ>::operator += ( const Info_Typ &element )
00135 {
00136 Info_Typ *format = new Info_Typ( element );
00137 format->SetLibname( lib_name );
00138 push_back( format );
00139 return *this;
00140 }
00141
00142
00143
00146 template <class Info_Typ>
00147 PluginList<Info_Typ> &PluginList<Info_Typ>::operator += ( const Info_Typ *element )
00148 {
00149 return *this += *element;
00150 }
00151
00152
00153
00154
00155
00158 template <class Info_Typ>
00159 Info_Typ &PluginList<Info_Typ>::Element( unsigned int num )
00160 {
00161 if( num < size() )
00162 return **(begin() + num );
00163
00164 return std_format;
00165 }
00166
00167 #endif