00001 //###################################################################### 00002 // 00003 // GraspIt! 00004 // Copyright (C) 2002-2009 Columbia University in the City of New York. 00005 // All rights reserved. 00006 // 00007 // GraspIt! is free software: you can redistribute it and/or modify 00008 // it under the terms of the GNU General Public License as published by 00009 // the Free Software Foundation, either version 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // GraspIt! is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with GraspIt!. If not, see <http://www.gnu.org/licenses/>. 00019 // 00020 // Author(s): Matei T. Ciocarlie 00021 // 00022 // $Id: application.h,v 1.1 2010/08/11 21:34:54 cmatei Exp $ 00023 // 00024 //###################################################################### 00025 00030 #include <string> 00031 00033 class Plugin 00034 { 00035 public: 00037 virtual ~Plugin(){} 00039 virtual int init(int argc, char **argv) = 0; 00041 virtual int mainLoop() = 0; 00042 }; 00043 00044 class PluginCreator 00045 { 00046 public: 00047 typedef Plugin* (*CreatePluginFctn)(); 00048 typedef std::string (*GetTypeFctn)(); 00049 private: 00050 void* mLibraryHandle; 00051 CreatePluginFctn mCreatePluginFctn; 00052 00053 bool mAutoStart; 00054 std::string mType; 00055 std::string mDefaultArgs; 00056 public: 00057 PluginCreator(void* libraryHandle, CreatePluginFctn createPluginFctn, 00058 bool autoStart, std::string type, std::string defaultArgs) : 00059 mLibraryHandle(libraryHandle), 00060 mCreatePluginFctn(createPluginFctn), 00061 mAutoStart(autoStart), 00062 mType(type), 00063 mDefaultArgs(defaultArgs) 00064 {} 00065 00066 ~PluginCreator(); 00067 00068 Plugin* createPlugin(std::string args); 00069 00070 bool autoStart() const {return mAutoStart;} 00071 std::string type() const {return mType;} 00072 std::string defaultArgs() const {return mDefaultArgs;} 00073 00074 static PluginCreator* loadFromLibrary(std::string libName); 00075 };