00001 /* 00002 * Copyright (C) 2006-2010 Jacek Sieka, arnetheduck on gmail point com 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 #ifndef ADCHPP_PLUGIN_H_ 00019 #define ADCHPP_PLUGIN_H_ 00020 00021 #include "forward.h" 00022 00023 namespace adchpp { 00024 00031 class Plugin { 00032 public: 00033 Plugin() { } 00034 virtual ~Plugin() { } 00036 virtual int getVersion() = 0; 00037 }; 00038 00039 typedef std::function<void (void*)> PluginDataDeleter; 00040 00041 class PluginData { 00042 public: 00043 template<typename T> 00044 static void simpleDataDeleter(void* p) { delete reinterpret_cast<T*>(p); } 00045 private: 00046 friend class PluginManager; 00047 friend class Entity; 00048 00049 PluginData(const PluginDataDeleter& deleter_) : deleter(deleter_) { } 00050 00051 void operator()(void* p) { if(deleter) deleter(p); } 00052 00053 PluginDataDeleter deleter; 00054 }; 00055 00056 typedef shared_ptr<PluginData> PluginDataHandle; 00057 00058 } 00059 00060 #endif /* PLUGIN_H_ */