LIBBATCH_FIND_ALL_LOCAL_COMMANDS()
ENDIF()
+INCLUDE(CheckCXXCompilerFlag)
+
+SET(LIBBATCH_NO_CXX11_SUPPORT FALSE CACHE BOOL "Switch OFF C++-11 standard")
+IF(NOT LIBBATCH_NO_CXX11_SUPPORT)
+ # C++11 support
+ CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
+ IF(COMPILER_SUPPORTS_CXX11)
+ MESSAGE(STATUS "Enable C++11 support")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+ ELSE()
+ CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
+ IF(COMPILER_SUPPORTS_CXX0X)
+ MESSAGE(STATUS "Enable C++0x support")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+ ELSE()
+ MESSAGE(WARNING "Compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
+ ENDIF()
+ ENDIF()
+ENDIF()
+
+IF(NOT (WIN32 OR APPLE))
+ SET(LIBBATCH_DEBUG_WARNINGS FALSE CACHE BOOL "Print more compiler warnings")
+ SET(LIBBATCH_TREAT_WARNINGS_AS_ERRORS FALSE CACHE BOOL "Treat compiler warnings as errors")
+ IF(LIBBATCH_DEBUG_WARNINGS)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
+ ENDIF()
+ IF(LIBBATCH_TREAT_WARNINGS_AS_ERRORS)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
+ ENDIF()
+ENDIF()
+
+# Compiler flag to disable treating alternative C++ tokens (compatibility with MSVS)
+CHECK_CXX_COMPILER_FLAG("-fno-operator-names" COMPILER_SUPPORTS_NO_OPERATOR_NAMES)
+IF(COMPILER_SUPPORTS_NO_OPERATOR_NAMES)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-operator-names")
+ENDIF()
+
# Prerequisites detection:
# ========================
FIND_PACKAGE(LibbatchPThread REQUIRED)
// Methode pour le controle des jobs : teste si un job est present en machine
- bool BatchManager_CCC::isRunning(const JobId & jobid)
+ bool BatchManager_CCC::isRunning(const JobId & /*jobid*/)
{
throw NotYetImplementedException("BatchManager_CCC::isRunning");
}
int edt = 0;
int mem = 0;
string queue = "";
+ LIBBATCH_UNUSED(nbproc);
+ LIBBATCH_UNUSED(edt);
+ LIBBATCH_UNUSED(mem);
// Mandatory parameters
if (params.find(WORKDIR) != params.end())
}
// Methode pour le controle des jobs : retire un job du gestionnaire
- void BatchManager::deleteJob(const JobId & jobid)
+ void BatchManager::deleteJob(const JobId & /*jobid*/)
{
throw NotYetImplementedException("Method deleteJob not implemented by Batch Manager \"" + _type + "\"");
}
// Methode pour le controle des jobs : suspend un job en file d'attente
- void BatchManager::holdJob(const JobId & jobid)
+ void BatchManager::holdJob(const JobId & /*jobid*/)
{
throw NotYetImplementedException("Method holdJob not implemented by Batch Manager \"" + _type + "\"");
}
// Methode pour le controle des jobs : relache un job suspendu
- void BatchManager::releaseJob(const JobId & jobid)
+ void BatchManager::releaseJob(const JobId & /*jobid*/)
{
throw NotYetImplementedException("Method releaseJob not implemented by Batch Manager \"" + _type + "\"");
}
// Methode pour le controle des jobs : modifie un job en file d'attente
- void BatchManager::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env)
+ void BatchManager::alterJob(const JobId & /*jobid*/, const Parametre & /*param*/, const Environnement & /*env*/)
{
throw NotYetImplementedException("Method alterJob not implemented by Batch Manager \"" + _type + "\"");
}
// Methode pour le controle des jobs : modifie un job en file d'attente
- void BatchManager::alterJob(const JobId & jobid, const Parametre & param)
+ void BatchManager::alterJob(const JobId & /*jobid*/, const Parametre & /*param*/)
{
throw NotYetImplementedException("Method alterJob not implemented by Batch Manager \"" + _type + "\"");
}
// Methode pour le controle des jobs : modifie un job en file d'attente
- void BatchManager::alterJob(const JobId & jobid, const Environnement & env)
+ void BatchManager::alterJob(const JobId & /*jobid*/, const Environnement & /*env*/)
{
throw NotYetImplementedException("Method alterJob not implemented by Batch Manager \"" + _type + "\"");
}
// Methode pour le controle des jobs : renvoie l'etat du job
- JobInfo BatchManager::queryJob(const JobId & jobid)
+ JobInfo BatchManager::queryJob(const JobId & /*jobid*/)
{
throw NotYetImplementedException("Method queryJob not implemented by Batch Manager \"" + _type + "\"");
}
- const JobId BatchManager::addJob(const Job & job, const string & reference)
+ const JobId BatchManager::addJob(const Job & /*job*/, const string & reference)
{
return JobId(this, reference);
}
}
}
- const Batch::JobId BatchManager::runJob(const Batch::Job & job)
+ const Batch::JobId BatchManager::runJob(const Batch::Job & /*job*/)
{
throw NotYetImplementedException("Method runJob not implemented by Batch Manager \"" + _type + "\"");
}
private:
// Forbid the use of copy constructor and assignment operator
- BatchManagerCatalog(const BatchManagerCatalog & orig) {}
- void operator=(const BatchManagerCatalog & orig) {}
+ BatchManagerCatalog(const BatchManagerCatalog &) {}
+ void operator=(const BatchManagerCatalog &) {}
};
}
vector<string> CommunicationProtocolSH::getExecCommandArgs(const string & subCommand,
- const string & host,
- const string & user) const
+ const string & /*host*/,
+ const string & /*user*/) const
{
vector<string> cmd;
}
vector<string> CommunicationProtocolSH::getCopyCommandArgs(const string & sourcePath,
- const string & sourceHost,
- const string & sourceUser,
+ const string & /*sourceHost*/,
+ const string & /*sourceUser*/,
const string & destinationPath,
- const string & destinationHost,
- const string & destinationUser) const
+ const string & /*destinationHost*/,
+ const string & /*destinationUser*/) const
{
vector<string> cmd;
cmd.push_back(CP_COMMAND);
// TODO: replace those static declarations by an external description file (XML for instance)
#define decl_extern_Constant(constant) extern BATCH_EXPORT const std::string constant
#define def_Constant(constant) const std::string constant = #constant
+#define LIBBATCH_UNUSED(var) (void)var
namespace Batch {
static Log & getInstance();
// Forbid the use of copy constructor and assignment operator
- Log(const Log & orig) {}
- void operator=(const Log & orig) {}
+ Log(const Log &) {}
+ void operator=(const Log &) {}
std::ofstream _stream;
return "${LAMRANK}";
}
-string MpiImpl_LAM::boot(const string machinefile, const unsigned int nbnodes)
+string MpiImpl_LAM::boot(const string machinefile, const unsigned int /*nbnodes*/)
{
ostringstream oss;
oss << "lamboot " << machinefile << endl;
return oss.str();
}
-string MpiImpl_LAM::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
+string MpiImpl_LAM::run(const string /*machinefile*/, const unsigned int nbproc, const string fileNameToExecute)
{
ostringstream oss;
oss << "mpirun -np " << nbproc << " " << fileNameToExecute << endl;
return "${MPIRUN_RANK}";
}
-string MpiImpl_MPICH1::boot(const string machinefile, const unsigned int nbnodes)
+string MpiImpl_MPICH1::boot(const string /*machinefile*/, const unsigned int /*nbnodes*/)
{
return "";
}
return oss.str();
}
-string MpiImpl_MPICH2::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
+string MpiImpl_MPICH2::run(const string /*machinefile*/, const unsigned int nbproc, const string fileNameToExecute)
{
ostringstream oss;
oss << "mpirun -np " << nbproc << " " << fileNameToExecute << endl;
return "${OMPI_MCA_ns_nds_vpid}";
}
-string MpiImpl_OPENMPI::boot(const string machinefile, const unsigned int nbnodes)
+string MpiImpl_OPENMPI::boot(const string /*machinefile*/, const unsigned int /*nbnodes*/)
{
return "";
}
return "${OMPI_MCA_ns_nds_vpid}";
}
-string MpiImpl_OMPI::boot(const string machinefile, const unsigned int nbnodes)
+string MpiImpl_OMPI::boot(const string /*machinefile*/, const unsigned int /*nbnodes*/)
{
return "";
}
return "${SLURM_PROCID}";
}
-string MpiImpl_SLURM::boot(const string machinefile, const unsigned int nbnodes)
+string MpiImpl_SLURM::boot(const string /*machinefile*/, const unsigned int /*nbnodes*/)
{
return "";
}
-string MpiImpl_SLURM::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
+string MpiImpl_SLURM::run(const string /*machinefile*/, const unsigned int /*nbproc*/, const string fileNameToExecute)
{
ostringstream oss;
oss << "srun " << fileNameToExecute << endl;
return "${RMS_RANK}";
}
-string MpiImpl_PRUN::boot(const string machinefile, const unsigned int nbnodes)
+string MpiImpl_PRUN::boot(const string /*machinefile*/, const unsigned int /*nbnodes*/)
{
return "";
}
-string MpiImpl_PRUN::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
+string MpiImpl_PRUN::run(const string /*machinefile*/, const unsigned int nbproc, const string fileNameToExecute)
{
ostringstream oss;
oss << "prun -n " << nbproc << " " << "-p mpi " << fileNameToExecute << endl;
private:
// Forbid the use of copy constructor and assignment operator
- ParameterTypeMap(const ParameterTypeMap & orig) {}
- void operator=(const ParameterTypeMap & orig) {}
+ ParameterTypeMap(const ParameterTypeMap &) {}
+ void operator=(const ParameterTypeMap &) {}
};
using namespace std;
-ParserException::ParserException(string msg) throw()
+ParserException::ParserException(string msg) noexcept
: exception(),
_msg(msg)
{
}
-ParserException::~ParserException() throw()
+ParserException::~ParserException() noexcept
{
}
-const char * ParserException::what() const throw()
+const char * ParserException::what() const noexcept
{
return _msg.c_str();
}
-SimpleParser::SimpleParser() throw()
+SimpleParser::SimpleParser() noexcept
{
}
-SimpleParser::~SimpleParser() throw()
+SimpleParser::~SimpleParser() noexcept
{
}
-std::string SimpleParser::trim(const std::string & str) const throw()
+std::string SimpleParser::trim(const std::string & str) const noexcept
{
size_t beg = str.find_first_not_of(" \t");
if (beg == string::npos) beg = 0;
return str.substr(beg, end-beg+1);
}
-void SimpleParser::parse(const string & filename) throw(ParserException)
+void SimpleParser::parse(const string & filename)
{
ifstream fileStream(filename.c_str());
if (!fileStream) {
fileStream.close();
}
-void SimpleParser::parseTestConfigFile() throw(ParserException)
+void SimpleParser::parseTestConfigFile()
{
char * filename = getenv(TEST_CONFIG_FILE_ENV_VAR);
if (filename == NULL) {
}
}
-const string & SimpleParser::getValue(const string & key) const throw(ParserException)
+const string & SimpleParser::getValue(const string & key) const
{
map<string,string>::const_iterator iter = _configmap.find(key);
if (iter == _configmap.end()) {
}
const string & SimpleParser::getTestValue(const string & bmType, const string & protocolStr,
- const string & key) const throw(ParserException)
+ const string & key) const
{
string fullkey = string("TEST_") + bmType + "_" + protocolStr + "_" + key;
try {
return getValue(fullkey);
}
-int SimpleParser::getValueAsInt(const string & key) const throw(ParserException)
+int SimpleParser::getValueAsInt(const string & key) const
{
const string & valueStr = getValue(key);
const char * valueCStr = valueStr.c_str();
}
int SimpleParser::getTestValueAsInt(const string & bmType, const string & protocolStr,
- const string & key) const throw(ParserException)
+ const string & key) const
{
string fullkey = string("TEST_") + bmType + "_" + protocolStr + "_" + key;
try {
return getValueAsInt(fullkey);
}
-ostream & operator <<(ostream & os, const SimpleParser & parser) throw()
+ostream & operator <<(ostream & os, const SimpleParser & parser) noexcept
{
if (parser._configmap.empty()) {
os << "Empty map" << endl;
class ParserException : public std::exception
{
public:
- ParserException(std::string msg) throw();
- virtual ~ParserException() throw();
+ ParserException(std::string msg) noexcept;
+ virtual ~ParserException() noexcept;
- virtual const char *what() const throw();
+ virtual const char *what() const noexcept;
private:
std::string _msg;
class SimpleParser
{
public:
- SimpleParser() throw();
- virtual ~SimpleParser() throw();
+ SimpleParser() noexcept;
+ virtual ~SimpleParser() noexcept;
- void parse(const std::string & filename) throw(ParserException);
- void parseTestConfigFile() throw(ParserException);
- const std::string & getValue(const std::string & key) const throw(ParserException);
+ void parse(const std::string & filename);
+ void parseTestConfigFile();
+ const std::string & getValue(const std::string & key) const;
const std::string & getTestValue(const std::string & bmType, const std::string & protocolStr,
- const std::string & key) const throw(ParserException);
- int getValueAsInt(const std::string & key) const throw(ParserException);
+ const std::string & key) const;
+ int getValueAsInt(const std::string & key) const;
int getTestValueAsInt(const std::string & bmType, const std::string & protocolStr,
- const std::string & key) const throw(ParserException);
+ const std::string & key) const;
- friend std::ostream & operator <<(std::ostream & os, const SimpleParser & parser) throw();
+ friend std::ostream & operator <<(std::ostream & os, const SimpleParser & parser) noexcept;
private:
- std::string trim(const std::string & str) const throw();
+ std::string trim(const std::string & str) const noexcept;
std::map<std::string, std::string> _configmap;
};
using namespace std;
-int main(int argc, char** argv)
+int main(int /*argc*/, char** /*argv*/)
{
cout << "*******************************************************************************************" << endl;
cout << "This program tests the simple parser that parses the configuration file used in the other" << endl;
try {
// Parse the configuration file
parser.parseTestConfigFile();
- } catch (ParserException e) {
+ } catch (const ParserException& e) {
cerr << "Parser error: " << e.what() << endl;
return 1;
}
}
Versatile::Versatile(const Versatile & V)
- : _discriminator(V._discriminator),
- _maxsize(V._maxsize),
- _name(V._name)
+ : list(),
+ _discriminator(V._discriminator),
+ _maxsize(V._maxsize),
+ _name(V._name)
{
Versatile::const_iterator it;
for(it=V.begin(); it!=V.end(); it++)
eraseAll();
}
- Versatile & Versatile::operator = (const long l) throw(TypeMismatchException)
+ Versatile & Versatile::operator = (const long l)
{
checkType(LONG);
eraseAll();
return *this;
}
- Versatile & Versatile::operator = (const string & ch) throw(TypeMismatchException)
+ Versatile & Versatile::operator = (const string & ch)
{
checkType(STRING);
eraseAll();
return *this;
}
- Versatile & Versatile::operator +=(const string & ch) throw(TypeMismatchException,ListIsFullException)
+ Versatile & Versatile::operator +=(const string & ch)
{
checkType(STRING);
return *this;
}
- Versatile & Versatile::operator , (const string & ch) throw(TypeMismatchException,ListIsFullException)
+ Versatile & Versatile::operator , (const string & ch)
{
*this += ch;
return *this;
}
- Versatile & Versatile::operator = (const char * ch) throw(TypeMismatchException)
+ Versatile & Versatile::operator = (const char * ch)
{
return operator=(string(ch));
}
- Versatile & Versatile::operator +=(const char * ch) throw(TypeMismatchException,ListIsFullException)
+ Versatile & Versatile::operator +=(const char * ch)
{
return operator+=(string(ch));
}
- Versatile & Versatile::operator , (const char * ch) throw(TypeMismatchException,ListIsFullException)
+ Versatile & Versatile::operator , (const char * ch)
{
return operator,(string(ch));
}
- Versatile & Versatile::operator = (const Couple & cp) throw(TypeMismatchException)
+ Versatile & Versatile::operator = (const Couple & cp)
{
checkType(COUPLE);
eraseAll();
return *this;
}
- Versatile & Versatile::operator +=(const Couple & cp) throw(TypeMismatchException,ListIsFullException)
+ Versatile & Versatile::operator +=(const Couple & cp)
{
checkType(COUPLE);
// If max size is reached, throw a ListIsFullException
return *this;
}
- Versatile & Versatile::operator , (const Couple & cp) throw(TypeMismatchException,ListIsFullException)
+ Versatile & Versatile::operator , (const Couple & cp)
{
*this += cp;
return *this;
return os;
}
- Versatile & Versatile::operator = (const int i) throw(TypeMismatchException)
+ Versatile & Versatile::operator = (const int i)
{
checkType(LONG);
eraseAll();
return *this;
}
- Versatile & Versatile::operator = (const bool b) throw(TypeMismatchException)
+ Versatile & Versatile::operator = (const bool b)
{
checkType(BOOL);
eraseAll();
return *this;
}
- void Versatile::checkType(DiscriminatorType t) const throw(TypeMismatchException)
+ void Versatile::checkType(DiscriminatorType t) const
{
if (_discriminator != t)
throw (TypeMismatchException("Trying to change type of Versatile object \"" + _name + "\""));
}
- Versatile::operator long() const throw(TypeMismatchException)
+ Versatile::operator long() const
{
// If the type does not correspond or if the list has more than one element,
// throw a TypeMismatchException
return *( static_cast<LongType *>(this->front()) );
}
- Versatile::operator bool() const throw(TypeMismatchException)
+ Versatile::operator bool() const
{
// If the type does not correspond or if the list has more than one element,
// throw a TypeMismatchException
return *( static_cast<BoolType *>(this->front()) );
}
- Versatile::operator int() const throw(TypeMismatchException)
+ Versatile::operator int() const
{
return operator long();
}
- Versatile::operator Couple() const throw(TypeMismatchException)
+ Versatile::operator Couple() const
{
// If the type does not correspond or if the list has more than one element,
// throw a TypeMismatchException
return *( static_cast<CoupleType *>(this->front()) );
}
- string Versatile::str() const throw(TypeMismatchException)
+ string Versatile::str() const
{
// If the type does not correspond, throw a TypeMismatchException
if ( _discriminator != STRING || size() == 0 ) {
return s;
}
- Versatile::operator string () const throw(TypeMismatchException)
+ Versatile::operator string () const
{
return str();
}
virtual ~Versatile();
// Affectation and concatenation operators from base types
- Versatile & operator = (const long l) throw(TypeMismatchException);
- Versatile & operator = (const std::string & ch) throw(TypeMismatchException);
- Versatile & operator +=(const std::string & ch) throw(TypeMismatchException,ListIsFullException);
- Versatile & operator , (const std::string & ch) throw(TypeMismatchException,ListIsFullException);
- Versatile & operator = (const char * ch) throw(TypeMismatchException);
- Versatile & operator +=(const char * ch) throw(TypeMismatchException,ListIsFullException);
- Versatile & operator , (const char * ch) throw(TypeMismatchException,ListIsFullException);
- Versatile & operator = (const Couple & cp) throw(TypeMismatchException);
- Versatile & operator +=(const Couple & cp) throw(TypeMismatchException,ListIsFullException);
- Versatile & operator , (const Couple & cp) throw(TypeMismatchException,ListIsFullException);
- Versatile & operator = (const int i) throw(TypeMismatchException);
- Versatile & operator = (const bool b) throw(TypeMismatchException);
+ Versatile & operator = (const long l);
+ Versatile & operator = (const std::string & ch);
+ Versatile & operator +=(const std::string & ch);
+ Versatile & operator , (const std::string & ch);
+ Versatile & operator = (const char * ch);
+ Versatile & operator +=(const char * ch);
+ Versatile & operator , (const char * ch);
+ Versatile & operator = (const Couple & cp);
+ Versatile & operator +=(const Couple & cp);
+ Versatile & operator , (const Couple & cp);
+ Versatile & operator = (const int i);
+ Versatile & operator = (const bool b);
// Type conversion to base types
- operator long() const throw(TypeMismatchException);
- operator std::string() const throw(TypeMismatchException);
- operator Couple() const throw(TypeMismatchException);
- std::string str() const throw(TypeMismatchException);
- operator bool() const throw(TypeMismatchException);
- operator int() const throw(TypeMismatchException);
+ operator long() const;
+ operator std::string() const;
+ operator Couple() const;
+ std::string str() const;
+ operator bool() const;
+ operator int() const;
// Display on a stream
BATCH_EXPORT friend std::ostream & operator << (std::ostream & os, const Versatile & );
// Check the type
- void checkType(DiscriminatorType t) const throw (TypeMismatchException);
+ void checkType(DiscriminatorType t) const;
// Getter methods
DiscriminatorType getType() const;
private:
- // Forbid the use of affectation operator
- void operator= (const Versatile & V) {}
+ // Forbid the use of assignment operator
+ void operator= (const Versatile &) {}
};
// Methode pour le controle des jobs : teste si un job est present en machine
- bool BatchManager_LSF::isRunning(const JobId & jobid)
+ bool BatchManager_LSF::isRunning(const JobId & /*jobid*/)
{
throw NotYetImplementedException("BatchManager_LSF::isRunning");
}
// On force donc l'état du job à erreur - pour cela on ne donne pas d'Id
// au JobId
const Batch::JobId
- BatchManager_Local::addJob(const Batch::Job & job, const std::string & reference)
+ BatchManager_Local::addJob(const Batch::Job & /*job*/, const std::string & /*reference*/)
{
return JobId(this, "undefined");
}
mem = params[MAXRAMSIZE];
if (params.find(QUEUE) != params.end())
queue = params[QUEUE].str();
+ LIBBATCH_UNUSED(mem);
string::size_type p1 = fileToExecute.find_last_of("/");
string::size_type p2 = fileToExecute.find_last_of(".");
}
// Methode pour le controle des jobs : teste si un job est present en machine
- bool BatchManager_PBS::isRunning(const JobId & jobid)
+ bool BatchManager_PBS::isRunning(const JobId & /*jobid*/)
{
throw NotYetImplementedException("BatchManager_PBS::isRunning");
}
}
// Methode pour le controle des jobs : teste si un job est present en machine
- bool BatchManager_SGE::isRunning(const JobId & jobid)
+ bool BatchManager_SGE::isRunning(const JobId & /*jobid*/)
{
throw NotYetImplementedException("BatchManager_SGE::isRunning");
}
BatchManager_Vishnu::BatchManager_Vishnu(const FactBatchManager * parent,
const char * host,
const char * username,
- CommunicationProtocolType protocolType,
+ CommunicationProtocolType /*protocolType*/,
const char * mpiImpl)
: // Force SH protocol for Vishnu
BatchManager(parent, host, username, SH, mpiImpl)