Turn some configuration-related classes into nested classes

master
Sébastien Villemot 2023-12-11 17:27:17 +01:00
parent 4389e5320d
commit 7c83b81623
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
2 changed files with 64 additions and 79 deletions

View File

@ -20,7 +20,6 @@
#include <fstream>
#include <iostream>
#include <utility>
#include <vector>
#include "Configuration.hh"
@ -31,9 +30,7 @@
#include <boost/tokenizer.hpp>
#pragma GCC diagnostic pop
using namespace std;
Hook::Hook(string global_init_file_arg)
Configuration::Hook::Hook(string global_init_file_arg)
{
if (global_init_file_arg.empty())
{
@ -43,7 +40,7 @@ Hook::Hook(string global_init_file_arg)
hooks["global_init_file"] = move(global_init_file_arg);
}
Path::Path(vector<string> includepath_arg)
Configuration::Path::Path(vector<string> includepath_arg)
{
if (includepath_arg.empty())
{
@ -53,12 +50,13 @@ Path::Path(vector<string> includepath_arg)
paths["include"] = move(includepath_arg);
}
FollowerNode::FollowerNode(string computerName_arg, string port_arg, int minCpuNbr_arg,
int maxCpuNbr_arg, string userName_arg, string password_arg,
string remoteDrive_arg, string remoteDirectory_arg,
string programPath_arg, string programConfig_arg,
string matlabOctavePath_arg, bool singleCompThread_arg,
int numberOfThreadsPerJob_arg, string operatingSystem_arg) :
Configuration::FollowerNode::FollowerNode(string computerName_arg, string port_arg,
int minCpuNbr_arg, int maxCpuNbr_arg, string userName_arg,
string password_arg, string remoteDrive_arg,
string remoteDirectory_arg, string programPath_arg,
string programConfig_arg, string matlabOctavePath_arg,
bool singleCompThread_arg, int numberOfThreadsPerJob_arg,
string operatingSystem_arg) :
computerName {move(computerName_arg)},
port {move(port_arg)},
minCpuNbr {minCpuNbr_arg},
@ -89,7 +87,8 @@ FollowerNode::FollowerNode(string computerName_arg, string port_arg, int minCpuN
}
}
Cluster::Cluster(member_nodes_t member_nodes_arg) : member_nodes {move(member_nodes_arg)}
Configuration::Cluster::Cluster(member_nodes_t member_nodes_arg) :
member_nodes {move(member_nodes_arg)}
{
if (member_nodes.empty())
{

View File

@ -28,73 +28,6 @@
using namespace std;
using member_nodes_t = map<string, double>;
class Hook
{
public:
explicit Hook(string global_init_file_arg);
private:
map<string, string> hooks;
public:
[[nodiscard]] map<string, string>
get_hooks() const
{
return hooks;
};
};
class Path
{
public:
explicit Path(vector<string> includepath_arg);
private:
map<string, vector<string>> paths;
public:
[[nodiscard]] map<string, vector<string>>
get_paths() const
{
return paths;
};
};
class FollowerNode
{
friend class Configuration;
public:
FollowerNode(string computerName_arg, string port_arg, int minCpuNbr_arg, int maxCpuNbr_arg,
string userName_arg, string password_arg, string remoteDrive_arg,
string remoteDirectory_arg, string programPath_arg, string programConfig_arg,
string matlabOctavePath_arg, bool singleCompThread_arg,
int numberOfThreadsPerJob_arg, string operatingSystem_arg);
protected:
const string computerName, port;
int minCpuNbr, maxCpuNbr;
const string userName, password;
const string remoteDrive, remoteDirectory;
const string programPath, programConfig, matlabOctavePath;
const bool singleCompThread;
const int numberOfThreadsPerJob;
const string operatingSystem;
};
class Cluster
{
friend class Configuration;
public:
explicit Cluster(member_nodes_t member_nodes_arg);
protected:
member_nodes_t member_nodes;
};
/* The abstract representation of the configuration.
Merges information from the command-line and from the configuration file. */
class Configuration
@ -104,6 +37,59 @@ public:
bool parallel_use_psexec_arg, string cluster_name);
private:
using member_nodes_t = map<string, double>;
class Hook
{
public:
explicit Hook(string global_init_file_arg);
[[nodiscard]] map<string, string>
get_hooks() const
{
return hooks;
};
private:
map<string, string> hooks;
};
class Path
{
public:
explicit Path(vector<string> includepath_arg);
[[nodiscard]] map<string, vector<string>>
get_paths() const
{
return paths;
};
private:
map<string, vector<string>> paths;
};
struct FollowerNode
{
FollowerNode(string computerName_arg, string port_arg, int minCpuNbr_arg, int maxCpuNbr_arg,
string userName_arg, string password_arg, string remoteDrive_arg,
string remoteDirectory_arg, string programPath_arg, string programConfig_arg,
string matlabOctavePath_arg, bool singleCompThread_arg,
int numberOfThreadsPerJob_arg, string operatingSystem_arg);
const string computerName, port;
int minCpuNbr, maxCpuNbr;
const string userName, password;
const string remoteDrive, remoteDirectory;
const string programPath, programConfig, matlabOctavePath;
const bool singleCompThread;
const int numberOfThreadsPerJob;
const string operatingSystem;
};
struct Cluster
{
explicit Cluster(member_nodes_t member_nodes_arg);
member_nodes_t member_nodes;
};
const bool parallel, parallel_test, parallel_follower_open_mode, parallel_use_psexec;
const string cluster_name;
string firstClusterName;