Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Plugin.H

00001 /* $Id: Plugin.H,v 1.2 2000/11/03 22:03:28 rpav Exp $
00002  *
00003  * SFW - Studio FrameWork
00004  * Copyright (C) 2000  Ryan Pavlik
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019  *
00020  */
00021 
00022 #ifndef PLUGIN_H
00023 #define PLUGIN_H
00024 
00025 #include <string>
00026 #include <SFW/Object.H>
00027 #include <SFW/Thread.H>
00028 
00029 namespace SFW {
00030 
00031     class Plugin : public Object {
00032     void   *dlHandle;
00033     string path;
00034 
00035     string type;
00036     string idstring;
00037 
00038     Mutex mutex;
00039 
00040     typedef Object* (*FactoryFn)();
00041     FactoryFn factory;
00042 
00043     public:
00044     TYPE_INFO(SFW::Plugin, SFW::Object);
00045     
00046     Plugin(string _path);
00047     ~Plugin();
00048 
00049     bool isLoaded();
00050 
00051     string getPath();
00052     string getIDString();
00053     string getType();
00054 
00055     bool load();
00056     bool unload();
00057 
00058     Object* makeObject();
00059     };
00060 }
00061 
00062 /* Define magic for easily making plugins */
00063 
00064 #define PLUGIN_INIT(type, idstring, obj) \
00065 static char SFWPl_IDString[] = idstring;\
00066 static char SFWPl_Type[]     = #type;\
00067 \
00068 extern "C" {\
00069     char * getIDString() {\
00070         return SFWPl_IDString;\
00071     }\
00072     \
00073     char * getType() {\
00074         return SFWPl_Type;\
00075     }\
00076     \
00077     SFW::Object * factory() {\
00078     return (SFW::Object*)obj;\
00079     }\
00080 }
00081 
00082 
00083 
00084 #endif /* PLUGIN_H */

Generated at Tue Jan 2 15:38:34 2001 for SFW by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000