22 #include <openbabel/babelconfig.h> 41 struct OBERROR
CharPtrLess :
public std::binary_function<const char*,const char*, bool>
44 {
return strcasecmp(p1,p2)<0; }
69 virtual const char*
TypeID(){
return "plugins"; }
76 virtual bool Display(std::string&txt,
const char* param,
const char* ID=NULL);
90 static OBPlugin* GetPlugin(
const char* Type,
const char* ID);
93 const char*
GetID()
const{
return _id;};
98 static bool ListAsVector(
const char* PluginID,
const char* param, std::vector<std::string>& vlist);
101 static void List(
const char* PluginID,
const char* param=NULL, std::ostream* os=&std::cout);
104 static std::string ListAsString(
const char* PluginID,
const char* param=NULL);
107 static std::string FirstLine(
const char* txt);
111 static PluginIterator
Begin(
const char* PluginID)
113 if( !strcmp(PluginID,
"plugins") || GetTypeMap(PluginID)!=PluginMap())
114 return GetTypeMap(PluginID).begin();
116 return PluginMap().end();
119 static PluginIterator
End(
const char* PluginID)
121 return GetTypeMap(PluginID).end();
125 virtual PluginMapType& GetMap()
const =0;
128 static void LoadAllPlugins();
135 static PluginMapType m;
143 static PluginMapType& GetTypeMap(
const char* PluginID);
147 static OBPlugin* BaseFindType(PluginMapType& Map,
const char* ID);
153 #if defined(__CYGWIN__) || defined(__MINGW32__) 156 #define MAKE_PLUGIN(BaseClass)\ 158 static PluginMapType& Map();\ 159 virtual PluginMapType& GetMap() const {\ 163 static BaseClass*& Default() {\ 164 static BaseClass* d;\ 167 BaseClass(const char* ID, bool IsDefault=false) {\ 170 if (IsDefault || Map().empty()) {\ 173 if (Map().count(ID) == 0) {\ 175 PluginMap()[TypeID()] = this;\ 179 static BaseClass* FindType(const char* ID) {\ 180 if (!ID || *ID==0 || *ID==' ') {\ 183 return static_cast<BaseClass*>(BaseFindType(Map(),ID));\ 186 #define PLUGIN_CPP_FILE(BaseClass)\ 187 OBPlugin::PluginMapType& BaseClass::Map() {\ 188 static OBPlugin::PluginMapType map;\ 192 #else // __CYGWIN__ || __MINGW32__ 195 #define MAKE_PLUGIN(BaseClass)\ 197 static PluginMapType& Map() {\ 198 static PluginMapType m;\ 201 virtual PluginMapType& GetMap() const {\ 205 static BaseClass*& Default() {\ 206 static BaseClass* d;\ 209 BaseClass(const char* ID, bool IsDefault=false) {\ 212 if (IsDefault || Map().empty()) {\ 215 if (Map().count(ID) == 0) {\ 217 PluginMap()[TypeID()] = this;\ 221 static BaseClass* FindType(const char* ID) {\ 222 if (!ID || *ID==0 || *ID==' ') {\ 225 return static_cast<BaseClass*>(BaseFindType(Map(),ID));\ 228 #endif // __CYGWIN__ || __MINGW32__ 368 #ifndef SWIG // Skipped by SWIG (for the moment) 370 #ifndef USING_DYNAMIC_LIBS 372 #define OB_STATIC_PLUGIN(className,instanceName) \ 374 OBAPI EXTERN className instanceName; 496 #ifdef HAVE_STATIC_LIBXML 503 #ifdef HAVE_STATIC_INCHI 510 #ifdef HAVE_RPC_XDR_H 570 #ifdef HAVE_STATIC_INCHI 591 #endif // USING_DYNAMIC_LIBS const char * _id
Definition: plugin.h:150
const char * GetID() const
Return the ID of the sub-type instance.
Definition: plugin.h:93
static int AllPluginsLoaded
Keep a record if all plugins have been loaded.
Definition: plugin.h:140
virtual const char * Description()
Required description of a sub-type.
Definition: plugin.h:66
std::map< const char *, OBPlugin *, CharPtrLess > PluginMapType
Definition: plugin.h:59
virtual void Init()
Definition: plugin.h:86
std::vector< std::string > EnableStaticPlugins()
Definition: plugin.cpp:225
#define OB_STATIC_PLUGIN(className, instanceName)
Definition: plugin.h:372
Base class for all types of dynamic classes discovered at runtime.
Definition: plugin.h:52
Dynamic loader for file format modules.
virtual ~OBPlugin()
Virtual destructor necessary for classes with virtual functions.
Definition: plugin.h:63
bool operator()(const char *p1, const char *p2) const
Definition: plugin.h:43
virtual OBPlugin * MakeInstance(const std::vector< std::string > &)
Definition: plugin.h:82
PluginMapType::const_iterator PluginIterator
Definition: plugin.h:60
Case insensitive string comparison for PluginMapType key.
Definition: plugin.h:41
static PluginMapType & PluginMap()
Returns a reference to the map of the plugin types. Is a function rather than a static member variabl...
Definition: plugin.h:133
static PluginIterator End(const char *PluginID)
Definition: plugin.h:119
static PluginIterator Begin(const char *PluginID)
Definition: plugin.h:111
virtual const char * TypeID()
Redefined by each plugin type: "formats", "fingerprints", etc.
Definition: plugin.h:69
Global namespace for all Open Babel code.
Definition: alias.h:22