Action.h
Go to the documentation of this file.
/* Frobby: Software for monomial ideal computations.
Copyright (C) 2007 Bjarke Hammersholt Roune (www.broune.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
*/
#ifndef ACTION_GUARD
#define ACTION_GUARD
#include "BoolParameter.h"
#include "CliParams.h"
class Parameter;
class Action {
public:
Action(const char* name,
const char* shortDescription,
const char* description,
bool acceptsNonParameter);
virtual ~Action();
const char* getName() const;
const char* getShortDescription() const;
const char* getDescription() const;
// processNonParameter() can be called at most once, and only if
// acceptsNonParameter() returns true.
bool acceptsNonParameter() const;
virtual void processNonParameter(const char* str);
virtual void obtainParameters(vector<Parameter*>& parameters);
virtual void parseCommandLine(unsigned int tokenCount,
const char** tokens);
virtual void perform() = 0;
virtual bool displayAction() const;
const Parameter& getParam(const string& name) const;
static void getActionNames(vector<string>& names);
static unique_ptr<Action> createActionWithPrefix(const string& prefix);
protected:
CliParams _params;
const char* _name;
const char* _shortDescription;
const char* _description;
bool _acceptsNonParameter;
BoolParameter _printActions;
};
#endif
BoolParameter.h
CliParams.h
Action::getName
const char * getName() const
Definition Action.cpp:113
Action::_params
CliParams _params
Definition Action.h:59
Action::_printActions
BoolParameter _printActions
Definition Action.h:68
Action::Action
Action(const char *name, const char *shortDescription, const char *description, bool acceptsNonParameter)
Definition Action.cpp:46
Action::parseCommandLine
virtual void parseCommandLine(unsigned int tokenCount, const char **tokens)
Definition Action.cpp:137
Action::getDescription
const char * getDescription() const
Definition Action.cpp:121
Action::acceptsNonParameter
bool acceptsNonParameter() const
Definition Action.cpp:125
Action::processNonParameter
virtual void processNonParameter(const char *str)
Definition Action.cpp:129
Action::_shortDescription
const char * _shortDescription
Definition Action.h:64
Action::obtainParameters
virtual void obtainParameters(vector< Parameter * > &parameters)
Definition Action.cpp:133
Action::displayAction
virtual bool displayAction() const
Returns whether this action should be shown to the user by the help action.
Definition Action.cpp:97
Action::_description
const char * _description
Definition Action.h:65
Action::getActionNames
static void getActionNames(vector< string > &names)
Definition Action.cpp:105
Action::_name
const char * _name
Definition Action.h:63
Action::perform
virtual void perform()=0
Action::_acceptsNonParameter
bool _acceptsNonParameter
Definition Action.h:66
Action::getParam
const Parameter & getParam(const string &name) const
Definition Action.cpp:101
Action::~Action
virtual ~Action()
Definition Action.cpp:59
Action::createActionWithPrefix
static unique_ptr< Action > createActionWithPrefix(const string &prefix)
Definition Action.cpp:109
Action::getShortDescription
const char * getShortDescription() const
Definition Action.cpp:117
BoolParameter
Definition BoolParameter.h:24
CliParams
Definition CliParams.h:28
Parameter
Definition Parameter.h:24