Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
ModelConfig Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-01-23/TensorFlowEvaluator/SliceLID/simple_model/ModelConfig.h"

Public Member Functions

 ModelConfig (const std::string &savedir, const std::vector< InputConfigKeys > &scalarInputKeys, const std::vector< InputConfigKeys > &vectorInputKeys, const std::vector< std::string > &outputKeys)
 
void load ()
 
bool isLoaded () const
 
std::string getConfigPath () const
 
std::string getModelPath () const
 
std::string getSavedir () const
 

Public Attributes

std::vector< InputConfigscalarInputs
 
std::vector< InputConfigvectorInputs
 
std::vector< std::stringoutputNodes
 

Private Member Functions

void parseConfig (const std::string &fname)
 

Static Private Member Functions

static InputConfig parseInput (pt::ptree &tree, const InputConfigKeys &keys)
 

Private Attributes

std::string savedir
 
bool loaded
 
std::vector< InputConfigKeysscalarInputKeys
 
std::vector< InputConfigKeysvectorInputKeys
 
std::vector< std::stringoutputKeys
 

Detailed Description

Definition at line 26 of file ModelConfig.h.

Constructor & Destructor Documentation

ModelConfig::ModelConfig ( const std::string savedir,
const std::vector< InputConfigKeys > &  scalarInputKeys,
const std::vector< InputConfigKeys > &  vectorInputKeys,
const std::vector< std::string > &  outputKeys 
)

Definition at line 5 of file ModelConfig.cxx.

References outputNodes, scalarInputs, and vectorInputs.

10  : savedir(savedir),
11  loaded(false),
15 {
16  scalarInputs.reserve(scalarInputKeys.size());
17  vectorInputs.reserve(vectorInputKeys.size());
18  outputNodes.reserve(outputKeys.size());
19 }
std::vector< std::string > outputKeys
Definition: ModelConfig.h:40
std::vector< InputConfigKeys > scalarInputKeys
Definition: ModelConfig.h:38
std::vector< std::string > outputNodes
Definition: ModelConfig.h:59
std::vector< InputConfigKeys > vectorInputKeys
Definition: ModelConfig.h:39
std::string savedir
Definition: ModelConfig.h:29
std::vector< InputConfig > vectorInputs
Definition: ModelConfig.h:58
std::vector< InputConfig > scalarInputs
Definition: ModelConfig.h:57

Member Function Documentation

std::string ModelConfig::getConfigPath ( ) const

Definition at line 82 of file ModelConfig.cxx.

References CONFIG_NAME, and savedir.

Referenced by load().

83 {
84  return savedir + "/" + CONFIG_NAME;
85 }
std::string savedir
Definition: ModelConfig.h:29
const std::string CONFIG_NAME
Definition: ModelConfig.h:10
std::string ModelConfig::getModelPath ( ) const

Definition at line 87 of file ModelConfig.cxx.

References MODEL_NAME, and savedir.

88 {
89  return savedir + "/" + MODEL_NAME;
90 }
std::string savedir
Definition: ModelConfig.h:29
const std::string MODEL_NAME
Definition: ModelConfig.h:11
std::string ModelConfig::getSavedir ( ) const

Definition at line 77 of file ModelConfig.cxx.

References savedir.

78 {
79  return savedir;
80 }
std::string savedir
Definition: ModelConfig.h:29
bool ModelConfig::isLoaded ( ) const

Definition at line 21 of file ModelConfig.cxx.

References loaded.

22 {
23  return loaded;
24 }
void ModelConfig::load ( )

Definition at line 26 of file ModelConfig.cxx.

References e, getConfigPath(), loaded, parseConfig(), and string.

27 {
28  if (loaded) {
29  return;
30  }
31 
32  const std::string configPath = getConfigPath();
33  try {
34  parseConfig(configPath);
35  }
36  catch (const std::exception& e) {
37  std::throw_with_nested(
38  std::runtime_error("Failed to parse config file: " + configPath)
39  );
40  }
41 
42  loaded = true;
43 }
std::string getConfigPath() const
Definition: ModelConfig.cxx:82
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
void parseConfig(const std::string &fname)
Definition: ModelConfig.cxx:59
Float_t e
Definition: plot.C:35
enum BeamMode string
void ModelConfig::parseConfig ( const std::string fname)
private

Definition at line 59 of file ModelConfig.cxx.

References outputKeys, outputNodes, parseInput(), scalarInputKeys, scalarInputs, string, compareCafs::tree, vectorInputKeys, and vectorInputs.

Referenced by load().

60 {
61  pt::ptree tree;
62  pt::read_json(fname, tree);
63 
64  for (const auto &inputKeys : scalarInputKeys) {
65  scalarInputs.emplace_back(parseInput(tree, inputKeys));
66  }
67 
68  for (const auto &inputKeys : vectorInputKeys) {
69  vectorInputs.emplace_back(parseInput(tree, inputKeys));
70  }
71 
72  for (const auto &outputKey : outputKeys) {
73  outputNodes.emplace_back(tree.get<std::string>(outputKey));
74  }
75 }
std::vector< std::string > outputKeys
Definition: ModelConfig.h:40
std::vector< InputConfigKeys > scalarInputKeys
Definition: ModelConfig.h:38
std::vector< std::string > outputNodes
Definition: ModelConfig.h:59
std::vector< InputConfigKeys > vectorInputKeys
Definition: ModelConfig.h:39
std::vector< InputConfig > vectorInputs
Definition: ModelConfig.h:58
std::vector< InputConfig > scalarInputs
Definition: ModelConfig.h:57
static InputConfig parseInput(pt::ptree &tree, const InputConfigKeys &keys)
Definition: ModelConfig.cxx:45
enum BeamMode string
InputConfig ModelConfig::parseInput ( pt::ptree &  tree,
const InputConfigKeys keys 
)
staticprivate

Definition at line 45 of file ModelConfig.cxx.

References InputConfigKeys::nodeName, string, and InputConfigKeys::varNames.

Referenced by parseConfig().

48 {
49  std::string nodeName = tree.get<std::string>(keys.nodeName);
50  std::vector<std::string> varNames;
51 
52  for (auto &stree : tree.get_child(keys.varNames)) {
53  varNames.push_back(stree.second.get_value<std::string>());
54  }
55 
56  return InputConfig{ std::move(nodeName), std::move(varNames) };
57 }
std::string nodeName
Definition: ModelConfig.h:16
std::string varNames
Definition: ModelConfig.h:17
enum BeamMode string

Member Data Documentation

bool ModelConfig::loaded
private

Definition at line 30 of file ModelConfig.h.

Referenced by isLoaded(), and load().

std::vector<std::string> ModelConfig::outputKeys
private

Definition at line 40 of file ModelConfig.h.

Referenced by parseConfig().

std::vector<std::string> ModelConfig::outputNodes

Definition at line 59 of file ModelConfig.h.

Referenced by ModelConfig(), and parseConfig().

std::string ModelConfig::savedir
private

Definition at line 29 of file ModelConfig.h.

Referenced by getConfigPath(), getModelPath(), and getSavedir().

std::vector<InputConfigKeys> ModelConfig::scalarInputKeys
private

Definition at line 38 of file ModelConfig.h.

Referenced by parseConfig().

std::vector<InputConfig> ModelConfig::scalarInputs

Definition at line 57 of file ModelConfig.h.

Referenced by ModelConfig(), and parseConfig().

std::vector<InputConfigKeys> ModelConfig::vectorInputKeys
private

Definition at line 39 of file ModelConfig.h.

Referenced by parseConfig().

std::vector<InputConfig> ModelConfig::vectorInputs

Definition at line 58 of file ModelConfig.h.

Referenced by ModelConfig(), and parseConfig().


The documentation for this class was generated from the following files: