Frobby  0.9.5
Action.h
Go to the documentation of this file.
1 /* Frobby: Software for monomial ideal computations.
2  Copyright (C) 2007 Bjarke Hammersholt Roune (www.broune.com)
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see http://www.gnu.org/licenses/.
16 */
17 #ifndef ACTION_GUARD
18 #define ACTION_GUARD
19 
20 #include "BoolParameter.h"
21 #include "CliParams.h"
22 
23 class Parameter;
24 
25 class Action {
26  public:
27  Action(const char* name,
28  const char* shortDescription,
29  const char* description,
30  bool acceptsNonParameter);
31  virtual ~Action();
32 
33  const char* getName() const;
34  const char* getShortDescription() const;
35  const char* getDescription() const;
36 
37  // processNonParameter() can be called at most once, and only if
38  // acceptsNonParameter() returns true.
39  bool acceptsNonParameter() const;
40  virtual void processNonParameter(const char* str);
41 
42  virtual void obtainParameters(vector<Parameter*>& parameters);
43 
44  virtual void parseCommandLine(unsigned int tokenCount,
45  const char** tokens);
46 
47  virtual void perform() = 0;
48 
51  virtual bool displayAction() const;
52 
53  const Parameter& getParam(const string& name) const;
54 
55  static void getActionNames(vector<string>& names);
56  static auto_ptr<Action> createActionWithPrefix(const string& prefix);
57 
58  protected:
60 
61 
62 
63  const char* _name;
64  const char* _shortDescription;
65  const char* _description;
67 
69 
70 };
71 
72 #endif
Definition: Action.h:25
const char * getName() const
Definition: Action.cpp:113
CliParams _params
Definition: Action.h:59
BoolParameter _printActions
Definition: Action.h:68
static auto_ptr< Action > createActionWithPrefix(const string &prefix)
Definition: Action.cpp:109
Action(const char *name, const char *shortDescription, const char *description, bool acceptsNonParameter)
Definition: Action.cpp:46
virtual void parseCommandLine(unsigned int tokenCount, const char **tokens)
Definition: Action.cpp:137
const char * getDescription() const
Definition: Action.cpp:121
bool acceptsNonParameter() const
Definition: Action.cpp:125
virtual void processNonParameter(const char *str)
Definition: Action.cpp:129
const char * _shortDescription
Definition: Action.h:64
virtual void obtainParameters(vector< Parameter * > &parameters)
Definition: Action.cpp:133
virtual bool displayAction() const
Returns whether this action should be shown to the user by the help action.
Definition: Action.cpp:97
const char * _description
Definition: Action.h:65
static void getActionNames(vector< string > &names)
Definition: Action.cpp:105
const char * _name
Definition: Action.h:63
virtual void perform()=0
bool _acceptsNonParameter
Definition: Action.h:66
const Parameter & getParam(const string &name) const
Definition: Action.cpp:101
virtual ~Action()
Definition: Action.cpp:59
const char * getShortDescription() const
Definition: Action.cpp:117