PCMPlugin.h

Go to the documentation of this file.
00001 
00002 //
00003 // This source file is a part of ParCompMark
00004 // Parallel Compositing Benchmark Framework
00005 //
00006 // for latest info see http://parcompmark.sourceforge.net
00007 
00008 //
00009 // Copyright (C) 2006 IT2 ParCompMark Dev. Team
00010 // 
00011 // This program is free software; you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License
00013 // as published by the Free Software Foundation; either version 2
00014 // of the License, or (at your option) any later version.
00015 // 
00016 // This program is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019 // GNU General Public License for more details.
00020 // 
00021 // You should have received a copy of the GNU General Public License
00022 // along with this program; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00024 
00027 
00028 #ifndef __PCM_PLUGIN_H__
00029 #  define __PCM_PLUGIN_H__
00030 
00031 //
00032 // Inner includes
00033 //
00034 
00035 #  include "PCMPremeditations.h"
00036 
00037 #  include "PCMDynLoad.h"
00038 
00039 #  include "PCMName.h"
00040 
00041 #  include "PCMException.h"
00042 
00043 #  include "PCMLogger.h"
00044 
00045 #  include "PCMPointer.h"
00046 
00047 //
00048 // Outer includes
00049 //
00050 
00051 #  include <list>
00052 
00053 namespace ParCompMark
00054 {
00055 
00060   class Plugin:public DynLoad,
00061    public Name
00062   {
00063 
00064         //
00065         // Unit test class
00066         //
00067 #  ifdef PARCOMPMARK_TEST
00068         friend class ParCompMarkTest::TestPlugin;
00069 #  endif
00070 
00071         //
00072         // Enumerations
00073         //
00074 
00075    public:
00076 
00078         enum PluginType
00079         {
00080 
00082          BASIC_PLUGIN,
00083 
00085          RENDERER_PLUGIN
00086         };
00087 
00088         //
00089         // Typedefs
00090         //
00091 
00092    public:
00093 
00095         typedef ParCompMark::Pointer < Plugin,
00096         Mutex > Pointer;
00097 
00098    protected:
00099 
00101         typedef const char **(*pcmGetNeededLibsType) ();
00102 
00104         typedef void (*loggerFunctionType) (const void *, const char *);
00105 
00107         typedef int (*pcmSetPluginHandleType) (void *);
00108 
00110         typedef int (*pcmSetLoggerFunctionType) (loggerFunctionType);
00111 
00113         typedef int (*pcmOnLoadType) ();
00114 
00116         typedef int (*pcmOnUnloadType) ();
00117 
00119         typedef const char *(*pcmGetErrorMsgType) (const int);
00120 
00121         //
00122         // Variables
00123         //
00124 
00126 
00127 
00128    protected:
00129 
00135         PluginType mPluginType;
00136 
00142         bool mInitialized;
00143 
00149         std::list < std::string > mNeededLibs;
00150 
00156         s32 mLastError;
00157 
00159 
00160         //
00161         // Constructors & destructor
00162         //
00163 
00165 
00166 
00167    public:
00168 
00175         Plugin(const PluginType & type, const std::string & name, const std::string & filename);
00176 
00180         virtual ~ Plugin();
00181 
00183 
00184         //
00185         // Getters & setters
00186         //
00187 
00189 
00190 
00191    public:
00192 
00198         const Plugin::PluginType & getPluginType() const;
00199 
00205         const bool & getInitialized() const;
00206 
00212         const std::list < std::string > &getNeededLibs() const;
00213 
00219         const s32 & getLastError() const;
00220 
00222 
00223         //
00224         // Class methods
00225         //
00226 
00228 
00229 
00230    protected:
00231 
00237         static void _loggerFunction(const void *handle, const char *message);
00238 
00240 
00241         //
00242         // Methods
00243         //
00244 
00246 
00247 
00248    public:
00249 
00253         virtual void initialize();
00254 
00258         virtual void finalize();
00259 
00260    protected:
00261 
00265         virtual void _initializeSpecific() = 0;
00266 
00270         virtual void _finalizeSpecific() = 0;
00271 
00275         virtual void _getNeededLibs();
00276 
00280         virtual void _setPluginHandle();
00281 
00285         virtual void _setLoggerFunction();
00286 
00290         virtual void _onLoad();
00291 
00295         virtual void _onUnload();
00296 
00301         virtual const char *_getErrorMsg();
00302 
00306         virtual void _checkError();
00307 
00309 
00310   };
00311 
00312   //
00313   // Include header implementation
00314   //
00315 
00316 #  include "PCMPlugin_impl.h"
00317 
00318 }
00319 
00320 #endif