Changeset a71ad8 for molecuilder


Ignore:
Timestamp:
May 8, 2010, 7:14:29 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Children:
4d2636
Parents:
3bbc59
git-author:
Frederik Heber <heber@…> (05/08/10 18:40:49)
git-committer:
Frederik Heber <heber@…> (05/08/10 19:14:29)
Message:

Begin of Refactoring of ParseCommandLineOptions().

  • new singleton class CommandLineParser which wraps boost's program_options
  • main() uses the new CommandLineParser and calls UIFactory with CommandLine specizliation if commands detected.
  • files added toe Makefile.am
  • BOOST_PROGRAM_OPTIONS added to configure.ac
  • BOOST_PROGRAM_OPTIONS_LIB added to molecuilder/src/Makefile.am

Signed-off-by: Frederik Heber <heber@…>

Location:
molecuilder
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/configure.ac

    r3bbc59 ra71ad8  
    2828# Boost libraries
    2929AX_BOOST_BASE([1.33.1])
    30 #AX_BOOST_PROGRAM_OPTIONS
     30AX_BOOST_PROGRAM_OPTIONS
    3131#AX_BOOST_FOREACH
    3232#AX_BOOST_FILESYSTEM
  • molecuilder/src/Makefile.am

    r3bbc59 ra71ad8  
    241241  bondgraph.cpp \
    242242  boundary.cpp \
     243  CommandLineParser.cpp \
    243244  config.cpp \
    244245  element.cpp \
     
    284285  bondgraph.hpp \
    285286  boundary.hpp \
     287  CommandLineParser.hpp \
    286288  config.hpp \
    287289  defs.hpp \
     
    324326molecuilder_LDFLAGS = $(BOOST_LDFLAGS)
    325327molecuilder_SOURCES = builder.cpp
    326 molecuilder_LDADD = libmolecuilder.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
     328molecuilder_LDADD = libmolecuilder.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB}
    327329joiner_SOURCES = joiner.cpp datacreator.cpp parser.cpp datacreator.hpp helpers.hpp parser.hpp periodentafel.hpp
    328330joiner_LDADD = libmolecuilder.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
  • molecuilder/src/builder.cpp

    r3bbc59 ra71ad8  
    6060#include "bondgraph.hpp"
    6161#include "boundary.hpp"
     62#include "CommandLineParser.hpp"
    6263#include "config.hpp"
    6364#include "element.hpp"
     
    25492550  logger::purgeInstance();
    25502551  errorLogger::purgeInstance();
     2552  CommandLineParser::purgeInstance();
    25512553  ActionRegistry::purgeInstance();
    25522554  ActionHistory::purgeInstance();
     
    25552557int main(int argc, char **argv)
    25562558{
    2557     molecule *mol = NULL;
    25582559    config *configuration = new config;
    25592560    Vector x, y, z, n;
     
    25622563    string line;
    25632564    char *ConfigFileName = NULL;
    2564     int j;
    25652565
    25662566    cout << ESPACKVersion << endl;
     
    25692569    // need to init the history before any action is created
    25702570    ActionHistory::init();
    2571     /* structure of ParseCommandLineOptions will be refactored later */
    2572     j = ParseCommandLineOptions(argc, argv,  World::getInstance().getMolecules(), World::getInstance().getPeriode(), *configuration, ConfigFileName);
    2573     switch (j){
    2574         case 255:
    2575         case 2:
    2576         case 1:
    2577             cleanUp(configuration);
    2578             return (j == 1 ? 0 : j);
    2579         default:
    2580             break;
     2571
     2572    {
     2573      // Parse command line options and if present create respective UI
     2574      CommandLineParser::getInstance().generic.add_options()
     2575          ("help,h", "produce help message")
     2576          ("parse-xyz,p", po::value< vector<string> >(), "parse xyz file into World")
     2577          ;
     2578      CommandLineParser::getInstance().Run(argc,argv);
     2579      if (!CommandLineParser::getInstance().isEmpty())
     2580        UIFactory::makeUserInterface(UIFactory::CommandLine);
     2581      else
     2582        UIFactory::makeUserInterface(UIFactory::Text);
    25812583    }
    2582     if(World::getInstance().numMolecules() == 0){
    2583         mol = World::getInstance().createMolecule();
    2584         World::getInstance().getMolecules()->insert(mol);
    2585         cout << "Molecule created" << endl;
    2586         if(World::getInstance().getDomain()[0] == 0.){
    2587             Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl;
    2588             for(int i = 0;i < 6;i++){
    2589                 Log() << Verbose(1) << "Cell size" << i << ": ";
    2590                 cin >> World::getInstance().getDomain()[i];
    2591             }
    2592         }
    2593         mol->ActiveFlag = true;
    2594     }
    25952584
    25962585    {
    2597       cout << ESPACKVersion << endl;
    2598 
    2599       setVerbosity(0);
    2600 
    26012586      menuPopulaters populaters;
    26022587      populaters.MakeEditMoleculesMenu = populateEditMoleculesMenu;
    26032588
    2604       UIFactory::makeUserInterface(UIFactory::Text);
    26052589      MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow(populaters,World::getInstance().getMolecules(), configuration, World::getInstance().getPeriode(), ConfigFileName);
    26062590      mainWindow->display();
Note: See TracChangeset for help on using the changeset viewer.