Files
wlan-cloud-lib-poco/Shell/include/Poco/Shell/Command.h
Aleksandar Fabijanic d712530c7d added Poco::Shell
2013-04-23 20:06:03 -05:00

100 lines
3.2 KiB
C++

//
// Command.h
//
// $Id: //poco/1.4/Shell/include/Poco/Shell/Command.h#1 $
//
// Library: Shell
// Package: Shell
// Module: Command
//
// Definition of the Command class.
//
// Copyright (c) 2009-2013, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Shell_Command_INCLUDED
#define Shell_Command_INCLUDED
#include "Poco/Shell/Shell.h"
#include <vector>
#include <ostream>
namespace Poco {
namespace Shell {
class Session;
class Shell_API Command
/// Command defines the interface every shell command must implement.
///
/// The interface is quite simple, consisting only of a single member
/// function that subclasses must override.
{
public:
enum CommandStatus
{
STATUS_OK = 0, /// successful execution
STATUS_USAGE = 1, /// command line usage error
STATUS_ERROR = 2, /// command execution error
STATUS_DENIED = 3 /// bad credentials or insufficient permissions to execute the command
};
Command();
/// Creates the Command.
virtual ~Command();
/// Destroys the Command.
virtual int execute(Session& session, const std::vector<std::string>& args, std::ostream& ostr) = 0;
/// Execute the command, using the given arguments, within
/// the given session.
/// The first element of the args vector is the command name.
///
/// Any output produced by executing the command can be
/// written to the given output stream.
///
/// An integer must be returned that denotes success or failure of the command.
/// Upon success, 0 shall be returned. The CommandStatus enumeration defines
/// a few commonly used error codes that should be used. Other statis codes in
/// the range 0 - 99 can be used as well. Negative status codes are reserved
/// for internal use.
private:
Command(const Command&);
Command& operator = (const Command&);
};
} } // namespace Poco::Shell
#endif // Shell_Command_INCLUDED