added Action class, a base class for 3m actions
This commit is contained in:
parent
5aabfdc764
commit
fe74f6ddf2
42
Action.cpp
Normal file
42
Action.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#include "Action.h"
|
||||||
|
using namespace mmm;
|
||||||
|
|
||||||
|
Action::Action() {
|
||||||
|
parameters.clear();
|
||||||
|
parametersIterator = -1;
|
||||||
|
parametersEndIndicator = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Action::~Action() {
|
||||||
|
parameters.clear();
|
||||||
|
parametersIterator = -1;
|
||||||
|
parametersEndIndicator = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Action::insertParameter(std::string param) {
|
||||||
|
parameters.push_back(param);
|
||||||
|
if(parametersEndIndicator) {
|
||||||
|
parametersEndIndicator = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Action::getNextParameter() {
|
||||||
|
if(parametersIterator+1 < parameters.size()) {
|
||||||
|
parametersIterator++;
|
||||||
|
return parameters[parametersIterator];
|
||||||
|
} else {
|
||||||
|
parametersEndIndicator = true;
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Action::resetParametersIterator() {
|
||||||
|
parametersIterator = -1;
|
||||||
|
if(parametersEndIndicator) {
|
||||||
|
parametersEndIndicator = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Action::parametersEnd() {
|
||||||
|
return parametersEndIndicator;
|
||||||
|
}
|
34
Action.h
Normal file
34
Action.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#ifndef _ACTION_H
|
||||||
|
#define _ACTION_H
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
/// \file Action.h
|
||||||
|
/// \brief A base class for 3m actions.
|
||||||
|
/// \author Phitherek_
|
||||||
|
/// \date 2013
|
||||||
|
/// \version 0.1-pre
|
||||||
|
|
||||||
|
/// \namespace mmm
|
||||||
|
/// \brief A global namespace for 3m.
|
||||||
|
namespace mmm {
|
||||||
|
/// \class Action
|
||||||
|
/// \brief A base class for 3m actions.
|
||||||
|
class Action {
|
||||||
|
protected:
|
||||||
|
std::vector<std::string> parameters; ///< Action parameters.
|
||||||
|
int parametersIterator; ///< Parameter list iterator.
|
||||||
|
bool parametersEndIndicator; ///< Indicates if the parameter list iterator has reached end of the list.
|
||||||
|
public:
|
||||||
|
Action(); ///< A constructor.
|
||||||
|
~Action(); ///< A destructor.
|
||||||
|
void insertParameter(std::string param); ///< \brief A function that inserts parameter to action' s parameter list.
|
||||||
|
///< \param param Parameter to insert.
|
||||||
|
std::string getNextParameter(); ///< \brief A function that gets next parameter from the parameter list.
|
||||||
|
///< \return Next parameter from the parameter list.
|
||||||
|
void resetParametersIterator(); ///< A function that resets iterator of parameter list.
|
||||||
|
bool parametersEnd(); ///< \brief A function that returns if parameter list iterator is at the end of the list.
|
||||||
|
///< \return True if parameter list iterator is at the end of the list, false otherwise.
|
||||||
|
virtual void run() {} ///< A virtual function that executes the action.
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
2
OBJECTS
2
OBJECTS
@ -9,7 +9,7 @@ ModListDescription: name, server, modlistPath x
|
|||||||
ModInfoDescription: name, server, modinfoPath x
|
ModInfoDescription: name, server, modinfoPath x
|
||||||
ModInfo: ModInfoDescription, vector<ModDescription> x
|
ModInfo: ModInfoDescription, vector<ModDescription> x
|
||||||
ParameterParser: actionList, argc, argv
|
ParameterParser: actionList, argc, argv
|
||||||
Action:
|
Action: x
|
||||||
SyncAction
|
SyncAction
|
||||||
InstallAction
|
InstallAction
|
||||||
UpdateAction
|
UpdateAction
|
||||||
|
Loading…
x
Reference in New Issue
Block a user