Changeset a37c37


Ignore:
Timestamp:
May 8, 2010, 10:57:18 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Children:
c93262
Parents:
788eeb
Message:

FIX: wrong use of Singleton pattern for CommandLineParser.

  • we set _may_create to false, which is only needed for Factories.
  • if we set to true, then we have to make constructor and destructor private and introduce the Singleton<> as friend.
  • BUGFIX: setOptions() was called with internal argc,argv instead of given parameters in CommandLineParser::Run().
Location:
molecuilder/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/CommandLineParser.cpp

    r788eeb ra37c37  
    7373void CommandLineParser::Run(int _argc, char **_argv)
    7474{
    75   setOptions(argc,argv);
     75  setOptions(_argc,_argv);
    7676  Parse();
    7777}
  • molecuilder/src/CommandLineParser.hpp

    r788eeb ra37c37  
    1616
    1717
    18 class CommandLineParser : public Singleton<CommandLineParser, false> {
     18class CommandLineParser : public Singleton<CommandLineParser> {
     19  friend class Singleton<CommandLineParser>;
    1920public:
    20   virtual ~CommandLineParser();
    2121
    2222  // Parses the command line arguments in CommandLineParser::**argv with currently known options.
     
    3737  po::options_description visible;
    3838
    39 protected:
    40   CommandLineParser();
     39  po::variables_map vm;
    4140
    4241private:
     42  // private constructor and destructor
     43  CommandLineParser();
     44  virtual ~CommandLineParser();
     45
    4346  /* The following program_options options_decriptions are used to
    4447   * generate the various cases and call differently in Parse().
     
    4649  po::options_description cmdline_options;
    4750  po::options_description config_file_options;
    48 
    49   po::variables_map vm;
    5051
    5152  // Sets the options from the three cases.
Note: See TracChangeset for help on using the changeset viewer.