Commit 63f0dae5 authored by Steven Murray's avatar Steven Murray
Browse files

AcsDismountCmdLine, AcsMountCmdLine and AcsQueryVolumeCmdLine now inherit from AcsCmdLine

parent d80d6922
......@@ -59,22 +59,21 @@ int castor::acs::AcsCmdLine::parseTimeout(const std::string &s) {
//------------------------------------------------------------------------------
// handleMissingParameter
//------------------------------------------------------------------------------
void castor::acs::AcsCmdLine::handleMissingParameter(const int option) {
void castor::acs::AcsCmdLine::handleMissingParameter(const int opt) {
castor::exception::MissingOperand ex;
ex.getMessage() << "The -" << (char)optopt
<< " option requires a parameter";
ex.getMessage() << "The -" << (char)opt << " option requires a parameter";
throw ex;
}
//------------------------------------------------------------------------------
// handleUnknownOption
//------------------------------------------------------------------------------
void castor::acs::AcsCmdLine::handleUnknownOption(const int option) {
void castor::acs::AcsCmdLine::handleUnknownOption(const int opt) {
castor::exception::InvalidArgument ex;
if(0 == optopt) {
ex.getMessage() << "Unknown command-line option";
} else {
ex.getMessage() << "Unknown command-line option: -" << (char)optopt;
ex.getMessage() << "Unknown command-line option: -" << (char)opt;
}
throw ex;
}
......@@ -33,34 +33,35 @@ namespace acs {
* command-line tools provided by CASTOR.
*/
struct AcsCmdLine {
protected:
/**
* Parses the specified query interval.
*
* @return The parse query interval.
*/
static int parseQueryInterval(const std::string &s);
int parseQueryInterval(const std::string &s);
/**
* Parses the specified timeout.
*
* @return The parse query interval.
*/
static int parseTimeout(const std::string &s);
int parseTimeout(const std::string &s);
/**
* Handles the specified parameter that is missing a parameter.
*
* @param option The option.
* @param opt The option.
*/
static void handleMissingParameter(const int option);
void handleMissingParameter(const int opt);
/**
* Handles the specified unknown option.
*
* @param option The option.
* @param opt The option.
*/
static void handleUnknownOption(const int option);
void handleUnknownOption(const int opt);
}; // class AcsCmdLine
......
......@@ -131,15 +131,15 @@ void castor::acs::AcsDismountCmdLine::processOption(const int opt) {
help = true;
break;
case 'q':
queryInterval = AcsCmdLine::parseQueryInterval(optarg);
queryInterval = parseQueryInterval(optarg);
break;
case 't':
timeout = AcsCmdLine::parseTimeout(optarg);
timeout = parseTimeout(optarg);
break;
case ':':
return AcsCmdLine::handleMissingParameter(optopt);
return handleMissingParameter(optopt);
case '?':
return AcsCmdLine::handleUnknownOption(optopt);
return handleUnknownOption(optopt);
default:
{
castor::exception::Exception ex;
......
......@@ -23,6 +23,8 @@
#pragma once
#include "castor/acs/AcsCmdLine.hpp"
extern "C" {
#include "acssys.h"
#include "acsapi.h"
......@@ -36,7 +38,7 @@ namespace acs {
/**
* Data type used to store the results of parsing the command-line.
*/
struct AcsDismountCmdLine {
struct AcsDismountCmdLine: public AcsCmdLine {
/**
* True if the debug option has been set.
*/
......
......@@ -22,7 +22,6 @@
*****************************************************************************/
#include "castor/acs/Acs.hpp"
#include "castor/acs/AcsCmdLine.hpp"
#include "castor/acs/AcsMountCmdLine.hpp"
#include "castor/exception/InvalidArgument.hpp"
#include "castor/exception/MissingOperand.hpp"
......@@ -119,18 +118,18 @@ void castor::acs::AcsMountCmdLine::processOption(const int opt) {
help = true;
break;
case 'q':
queryInterval = AcsCmdLine::parseQueryInterval(optarg);
queryInterval = parseQueryInterval(optarg);
break;
case 'r':
readOnly = TRUE;
break;
case 't':
timeout = AcsCmdLine::parseTimeout(optarg);
timeout = parseTimeout(optarg);
break;
case ':':
return AcsCmdLine::handleMissingParameter(optopt);
return handleMissingParameter(optopt);
case '?':
return AcsCmdLine::handleUnknownOption(optopt);
return handleUnknownOption(optopt);
default:
{
castor::exception::Exception ex;
......
......@@ -23,6 +23,8 @@
#pragma once
#include "castor/acs/AcsCmdLine.hpp"
extern "C" {
#include "acssys.h"
#include "acsapi.h"
......@@ -36,7 +38,7 @@ namespace acs {
/**
* Data type used to store the results of parsing the command-line.
*/
struct AcsMountCmdLine {
struct AcsMountCmdLine: public AcsCmdLine {
/**
* True if the debug option has been set.
*/
......
......@@ -22,7 +22,6 @@
*****************************************************************************/
#include "castor/acs/Acs.hpp"
#include "castor/acs/AcsCmdLine.hpp"
#include "castor/acs/AcsQueryVolumeCmdLine.hpp"
#include "castor/exception/InvalidArgument.hpp"
#include "castor/exception/MissingOperand.hpp"
......@@ -109,15 +108,15 @@ void castor::acs::AcsQueryVolumeCmdLine::processOption(const int opt) {
help = true;
break;
case 'q':
queryInterval = AcsCmdLine::parseQueryInterval(optarg);
queryInterval = parseQueryInterval(optarg);
break;
case 't':
timeout = AcsCmdLine::parseTimeout(optarg);
timeout = parseTimeout(optarg);
break;
case ':':
return AcsCmdLine::handleMissingParameter(optopt);
return handleMissingParameter(optopt);
case '?':
return AcsCmdLine::handleUnknownOption(optopt);
return handleUnknownOption(optopt);
default:
{
castor::exception::Exception ex;
......
......@@ -23,6 +23,8 @@
#pragma once
#include "castor/acs/AcsCmdLine.hpp"
extern "C" {
#include "acssys.h"
#include "acsapi.h"
......@@ -36,7 +38,7 @@ namespace acs {
/**
* Data type used to store the results of parsing the command-line.
*/
struct AcsQueryVolumeCmdLine {
struct AcsQueryVolumeCmdLine: public AcsCmdLine {
/**
* True if the debug option has been set.
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment