Version: 1.0
config_data.h
Go to the documentation of this file.
1 // Copyright (c) 2020, the GRAPHGEN contributors, as
2 // shown by the AUTHORS file. All rights reserved.
3 //
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6 
7 #ifndef GRAPGHSGEN_CONFIG_DATA_H_
8 #define GRAPGHSGEN_CONFIG_DATA_H_
9 
10 #include <filesystem>
11 #include <iostream>
12 #include <numeric>
13 
14 #include "yaml-cpp/yaml.h"
15 
20 struct ConfigData {
21 
22  std::string description_ = "";
24  std::string config_file_ = "config.yaml";
26  // Global names/paths
27  std::filesystem::path global_output_path_;
28  std::filesystem::path algorithm_output_path_;
29  std::filesystem::path global_input_path_;
30  std::string algorithm_name_;
31  std::string mask_name_;
32 
33  // Dot configurations
34  std::string dot_background_color_ = "\"transparent\"";
35  std::string dot_output_format_ = ".pdf";
36  std::string dot_ranksep_ = "0.5";
37 
38 
39  // Dot Code
40  std::string dotcode_suffix_ = "_dotcode.txt";
41  std::filesystem::path dotcode_path_;
42 
43  // ODT
44  std::string odt_suffix_ = "_odt.txt";
45  std::filesystem::path odt_path_;
46 
47  // Code
48  std::string code_suffix_ = "_code.cpp";
49  std::filesystem::path code_path_;
50 
51  // Tree / Forest / Dag (.inc)
52  std::string treecode_suffix_ = "_tree_code.inc.h";
53  std::filesystem::path treecode_path_;
54  std::string forestcode_suffix_ = "_forest_code.inc.h";
55  std::filesystem::path forestcode_path_;
56 
57  std::string treedagcode_suffix_ = "_tree_dag_code.inc.h";
58  std::filesystem::path treedagcode_path_;
59  std::string forestdagcode_suffix_ = "_forest_dag_code.inc.h";
60  std::filesystem::path forestdagcode_path_;
61 
62  // Rule Set / Decision Table
63  std::string rstable_suffix_ = "_rstable.yaml";
64  std::filesystem::path rstable_path_;
65 
66  // Datasets
67  std::vector<std::string> datasets_;
68  std::vector<std::filesystem::path> datasets_path_;
69 
70  // Frequencies
71  std::string frequencies_local_path_ = "frequencies";
72  std::filesystem::path frequencies_path_;
73  std::string frequencies_suffix_ = ".bin";
74 
75  // CTBE Ruleset path
76  std::filesystem::path ctbe_rstable_path_;
77  std::string chaincode_rstable_filename_ = "ChainCode_rstable.yaml";
78 
79  // Chaincode Ruleset Path
80  std::filesystem::path chaincode_rstable_path_;
81  std::string ctbe_rstable_filename_ = "ctbe_rstable.yaml";
82 
83  bool force_odt_generation_ = false;
84 
86 
87  ConfigData(std::string& algorithm_name, const std::string& mask_name, bool use_frequencies = false);
88 
89  // Dot code
90  std::filesystem::path GetDotCodePath(const std::string& out_base_name) {
91  return algorithm_output_path_ / std::filesystem::path(out_base_name + dotcode_suffix_);
92  }
93 
94  // Dot output
95  std::filesystem::path GetDotOutPath(const std::string& out_base_name) {
96  return algorithm_output_path_ / std::filesystem::path(out_base_name + dot_output_format_);
97  }
98 
99  // Forest code
100  std::filesystem::path GetForestCodePath(const std::string& out_base_name) {
101  return algorithm_output_path_ / std::filesystem::path(algorithm_name_ + "_" + out_base_name + forestcode_suffix_);
102  }
103 
104  // Frequencies cache
105  std::filesystem::path GetFrequenciesPath(const std::string& datasets_name) const {
106  return algorithm_output_path_ / std::filesystem::path(algorithm_name_ + "_" + datasets_name + frequencies_suffix_);
107  }
108 
109  // Get ODT path with custom suffix (used in conjunction with frequencies)
110  std::filesystem::path GetCustomOdtPath(const std::string& custom_suffix) const {
111  return algorithm_output_path_ / std::filesystem::path(algorithm_name_ + "_" + custom_suffix + odt_suffix_);
112  }
113 
114  std::string GetDatasetsString(const std::string& separator = ", ") {
115  std::string dataset_names;
116  bool first = true;
117  for (const auto &d : datasets_) {
118  if (!first) {
119  dataset_names += separator;
120  }
121  else {
122  first = false;
123  }
124  dataset_names += d;
125  }
126  return dataset_names;
127  }
128 
129  // This serves to use a special algorithm name when using frequencies
131  algorithm_name_ += "_" + GetDatasetsString("-");
132  }
133 
134  void SetDescription(std::string description) {
135  description_ = description;
136  }
137 
138 };
139 
140 #endif // GRAPGHSGEN_CONFIG_DATA_H_
This class stores the configuration data loaded from file. All data are placed in the config global v...
Definition: config_data.h:20
std::string dot_background_color_
Definition: config_data.h:34
std::string treecode_suffix_
Definition: config_data.h:52
std::filesystem::path GetCustomOdtPath(const std::string &custom_suffix) const
Definition: config_data.h:110
std::string treedagcode_suffix_
Definition: config_data.h:57
std::string ctbe_rstable_filename_
Definition: config_data.h:81
std::string GetDatasetsString(const std::string &separator=", ")
Definition: config_data.h:114
ConfigData(std::string &algorithm_name, const std::string &mask_name, bool use_frequencies=false)
std::filesystem::path global_input_path_
Definition: config_data.h:29
std::filesystem::path forestdagcode_path_
Definition: config_data.h:60
std::filesystem::path code_path_
Definition: config_data.h:49
std::filesystem::path rstable_path_
Definition: config_data.h:64
std::string mask_name_
Definition: config_data.h:31
std::string frequencies_local_path_
Definition: config_data.h:71
std::string frequencies_suffix_
Definition: config_data.h:73
std::filesystem::path dotcode_path_
Definition: config_data.h:41
std::filesystem::path odt_path_
Definition: config_data.h:45
std::string forestdagcode_suffix_
Definition: config_data.h:59
std::filesystem::path GetForestCodePath(const std::string &out_base_name)
Definition: config_data.h:100
std::vector< std::filesystem::path > datasets_path_
Definition: config_data.h:68
std::filesystem::path chaincode_rstable_path_
Definition: config_data.h:80
void UpdateAlgoNameWithDatasets()
Definition: config_data.h:130
std::vector< std::string > datasets_
Definition: config_data.h:67
std::string forestcode_suffix_
Definition: config_data.h:54
std::string dotcode_suffix_
Definition: config_data.h:40
std::string dot_ranksep_
Definition: config_data.h:36
std::filesystem::path GetFrequenciesPath(const std::string &datasets_name) const
Definition: config_data.h:105
std::filesystem::path algorithm_output_path_
Definition: config_data.h:28
std::string code_suffix_
Definition: config_data.h:48
std::string odt_suffix_
Definition: config_data.h:44
std::filesystem::path ctbe_rstable_path_
Definition: config_data.h:76
std::filesystem::path GetDotCodePath(const std::string &out_base_name)
Definition: config_data.h:90
std::filesystem::path forestcode_path_
Definition: config_data.h:55
std::string description_
Definition: config_data.h:22
std::filesystem::path frequencies_path_
Definition: config_data.h:72
std::filesystem::path GetDotOutPath(const std::string &out_base_name)
Definition: config_data.h:95
std::filesystem::path treecode_path_
Definition: config_data.h:53
std::filesystem::path treedagcode_path_
Definition: config_data.h:58
std::string chaincode_rstable_filename_
Definition: config_data.h:77
std::filesystem::path global_output_path_
Definition: config_data.h:27
std::string rstable_suffix_
Definition: config_data.h:63
std::string algorithm_name_
Definition: config_data.h:30
void SetDescription(std::string description)
Definition: config_data.h:134
std::string config_file_
Definition: config_data.h:24
bool force_odt_generation_
Definition: config_data.h:83
std::string dot_output_format_
Definition: config_data.h:35