Implementation of Serice object into structure.
This commit is contained in:
1 parent
a2526dd3ed
commit
2cb1e3e2f2
23 files changed
+278
-293
No files matched your search
@@ -1,79 +1,79 @@
|
||||
#ifndef __Command_h__
|
||||
#define __Command_h__
|
||||
|
||||
#include "includes"
|
||||
#include "Object.h"
|
||||
# define __Command_h__
|
||||
|
||||
# include "includes"
|
||||
# include "Object.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
|
||||
class Session;
|
||||
|
||||
///
|
||||
/// Command
|
||||
///
|
||||
/// Use the Command object in combination with a CommandList object to maintain
|
||||
/// a list of functions that can be invoked as a result of processing a request.
|
||||
///
|
||||
|
||||
///
|
||||
/// Command
|
||||
///
|
||||
/// Use the Command object in combination with a CommandList object to maintain
|
||||
/// a list of functions that can be invoked as a result of processing a request.
|
||||
///
|
||||
|
||||
class Command : public Object {
|
||||
|
||||
public:
|
||||
|
||||
///
|
||||
/// Implement check method to provide a special check rule upon the request to see
|
||||
/// if the command should be processed.
|
||||
///
|
||||
/// The default rule is to verify that the first token in the request string matches
|
||||
/// the name given on the registration of the command to the CommandList. This can
|
||||
/// be overridden by implementing the check() method to perform the test and return
|
||||
/// the condition of the command.
|
||||
///
|
||||
/// @param request The request passed to the parser to check the rule.
|
||||
/// @return Return true to execute the command. Returning false will cause no action
|
||||
/// on this command.
|
||||
///
|
||||
|
||||
virtual bool check(std::string request);
|
||||
|
||||
///
|
||||
/// This method is used to implement the functionality of the requested command.
|
||||
/// This pure virtual function must be implemented in your inheriting object.
|
||||
///
|
||||
/// @param request The request that was entered by the user to invoke this command.
|
||||
/// @param session Specify the requesting session so that the execution of the
|
||||
/// command process can return its output to the session.
|
||||
/// @return Returns 0 if execution of the command was successful. Otherwise returns
|
||||
/// a non-zero value indicating an error condition.
|
||||
///
|
||||
|
||||
|
||||
public:
|
||||
|
||||
///
|
||||
/// Implement check method to provide a special check rule upon the request to see
|
||||
/// if the command should be processed.
|
||||
///
|
||||
/// The default rule is to verify that the first token in the request string matches
|
||||
/// the name given on the registration of the command to the CommandList. This can
|
||||
/// be overridden by implementing the check() method to perform the test and return
|
||||
/// the condition of the command.
|
||||
///
|
||||
/// @param request The request passed to the parser to check the rule.
|
||||
/// @return Return true to execute the command. Returning false will cause no action
|
||||
/// on this command.
|
||||
///
|
||||
|
||||
virtual bool check(std::string request);
|
||||
|
||||
///
|
||||
/// This method is used to implement the functionality of the requested command.
|
||||
/// This pure virtual function must be implemented in your inheriting object.
|
||||
///
|
||||
/// @param request The request that was entered by the user to invoke this command.
|
||||
/// @param session Specify the requesting session so that the execution of the
|
||||
/// command process can return its output to the session.
|
||||
/// @return Returns 0 if execution of the command was successful. Otherwise returns
|
||||
/// a non-zero value indicating an error condition.
|
||||
///
|
||||
|
||||
virtual int processCommand(std::string request, Session *session) = 0;
|
||||
|
||||
///
|
||||
/// Specify the output that will occur to the specified session.
|
||||
///
|
||||
/// @param session The session that will receive the output.
|
||||
///
|
||||
|
||||
virtual void output(Session *session);
|
||||
|
||||
///
|
||||
/// Set the name of this command used in default rule checking during request parsing.
|
||||
/// NOTE: You do not need to call this under normal conditions as adding a Command
|
||||
/// to a CommandList using the add() method contains a parameter to pass the name
|
||||
/// of the Command.
|
||||
///
|
||||
/// @param name Specify the name of this command for default parsing.
|
||||
///
|
||||
|
||||
void setName(std::string name);
|
||||
|
||||
std::string getName();
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
|
||||
///
|
||||
/// Specify the output that will occur to the specified session.
|
||||
///
|
||||
/// @param session The session that will receive the output.
|
||||
///
|
||||
|
||||
virtual void output(Session *session);
|
||||
|
||||
///
|
||||
/// Set the name of this command used in default rule checking during request parsing.
|
||||
/// NOTE: You do not need to call this under normal conditions as adding a Command
|
||||
/// to a CommandList using the add() method contains a parameter to pass the name
|
||||
/// of the Command.
|
||||
///
|
||||
/// @param name Specify the name of this command for default parsing.
|
||||
///
|
||||
|
||||
void setName(std::string name);
|
||||
|
||||
std::string getName();
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user