Go to the documentation of this file.00001 #include <iostream>
00002 #include <cstdlib>
00003
00004 #include "inspect.hh"
00005 #include "import.hh"
00006 #include "typelib/pluginmanager.hh"
00007
00008 #include "genom.hh"
00009
00010 using namespace std;
00011
00012 namespace
00013 {
00014 void usage()
00015 {
00016 cout <<
00017 "Usage: typelib [mode] [mode-args]\n"
00018 "\twhere mode is one of: inspect, import\n"
00019 "\tcall typelib [mode] help for information on a particular mode" << endl;
00020 exit(1);
00021 }
00022
00023 typedef map<string, Mode*> ModeMap;
00024 ModeMap modes;
00025 void registerMode(Mode* mode)
00026 {
00027 ModeMap::iterator it = modes.find(mode->getName());
00028 if (it != modes.end())
00029 delete it->second;
00030 modes[mode->getName()] = mode;
00031 }
00032 }
00033
00034 int main(int argc, char** argv)
00035 {
00036
00037 Typelib::PluginManager::self the_manager;
00038
00039 registerMode(new Inspect);
00040 registerMode(new Import);
00041
00042 if (argc < 2)
00043 usage();
00044
00045 string mode_name = argv[1];
00046 ModeMap::iterator it = modes.find(mode_name);
00047 if (it == modes.end())
00048 usage();
00049
00050 return
00051 ((it->second) -> main(argc - 2, argv + 2) ? 0 : 1);
00052 };
00053