Skip to content

Commit 571626c

Browse files
committed
1. add global functions in class Input_Process
1 parent 9d631a5 commit 571626c

File tree

6 files changed

+47
-18
lines changed

6 files changed

+47
-18
lines changed

source/Makefile.Objects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ read_txt_stru.o\
250250
read_txt_input_value.o\
251251
read_txt_input_list.o\
252252
read_txt_input_process.o\
253+
read_txt_input_process_global.o\
253254
read_txt_input-general.o\
254255
read_txt_input-pw.o\
255256
write_pot.o\

source/src_io/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ add_library(
2727
read_txt_input_value.cpp
2828
read_txt_input_list.cpp
2929
read_txt_input_process.cpp
30+
read_txt_input_process_global.cpp
3031
read_txt_input-general.cpp
3132
read_txt_input-pw.cpp
3233
read_txt_stru.cpp

source/src_io/read_txt_input_item.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ namespace Read_Txt_Input
2727
template<typename T>
2828
void default_1(const T &value);
2929
template <typename T_head, typename... T_tail>
30-
void default_1( const T_head &value_head, const T_tail... values_tail);
30+
void default_1(const T_head &value_head, const T_tail... values_tail);
3131

3232
// set these variables and functions
3333
std::string annotation;
3434
std::function<void(Input_Item&)> check_transform
3535
= [](Input_Item&self){};
36-
std::function<void(const std::map<std::string, Input_Item>&)> default2
37-
= [](const std::map<std::string, Input_Item>&list){};
36+
std::function<void(Input_Item&, const std::map<std::string, Input_Item>&)> default_2
37+
= [](Input_Item&self, const std::map<std::string, Input_Item>&list){};
3838
std::function<void(const Input_Item&)> convert
3939
= [](const Input_Item&item){};
4040

source/src_io/read_txt_input_process.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace Read_Txt_Input
2424
{
2525
this->read(file_name);
2626
this->check_transform();
27-
this->default2();
27+
this->default_2();
2828
this->out(GlobalV::global_out_dir + file_name);
2929
}
3030
this->bcast();
@@ -37,8 +37,8 @@ namespace Read_Txt_Input
3737
= Read_Txt_Tools::read_file_to_map(file_name, {"#","\\"}, true);
3838
for(const auto & input_read : inputs_read)
3939
{
40-
const auto ptr = input.list.find(input_read.first);
41-
if(ptr==input.list.end())
40+
const auto ptr = this->input.list.find(input_read.first);
41+
if(ptr==this->input.list.end())
4242
throw std::out_of_range("input_read.first");
4343

4444
//if(input_read.second.size() > ptr->second.values.size())
@@ -55,7 +55,7 @@ namespace Read_Txt_Input
5555

5656
void Input_Process::check_transform()
5757
{
58-
for(auto &item : input.list)
58+
for(auto &item : this->input.list)
5959
{
6060
item.second.check_transform(item.second);
6161

@@ -68,21 +68,23 @@ namespace Read_Txt_Input
6868
}
6969
}
7070
}
71+
this->check_transform_global(this->input.list);
7172
}
7273

73-
void Input_Process::default2()
74+
void Input_Process::default_2()
7475
{
75-
for(auto &item : input.list)
76-
item.second.default2(input.list);
76+
for(auto &item : this->input.list)
77+
item.second.default_2(item.second, this->input.list);
78+
this->default_2_global(this->input.list);
7779
}
7880

7981
void Input_Process::out(const std::string &file_name) const
8082
{
8183
std::ofstream ofs(file_name);
82-
for(const std::string &label : input.output_labels)
84+
for(const std::string &label : this->input.output_labels)
8385
{
84-
const auto ptr = input.list.find(label);
85-
if(ptr==input.list.end())
86+
const auto ptr = this->input.list.find(label);
87+
if(ptr==this->input.list.end())
8688
{
8789
ofs<<std::endl<<"# "<<label<<std::endl;
8890
}
@@ -121,7 +123,7 @@ namespace Read_Txt_Input
121123
std::stringstream ss;
122124
{
123125
cereal::BinaryOutputArchive ar(ss);
124-
ar(input.list);
126+
ar(this->input.list);
125127
}
126128
const int size = ss.str().size();
127129
MPI_Bcast( const_cast<int*>(&size), 1, MPI_INT, 0, MPI_COMM_WORLD );
@@ -137,7 +139,7 @@ namespace Read_Txt_Input
137139
ss.rdbuf()->pubsetbuf(c.data(),size);
138140
{
139141
cereal::BinaryInputArchive ar(ss);
140-
ar(input.list);
142+
ar(this->input.list);
141143
}
142144
}
143145
#else
@@ -147,7 +149,8 @@ namespace Read_Txt_Input
147149

148150
void Input_Process::convert()
149151
{
150-
for(auto &item : input.list)
152+
for(auto &item : this->input.list)
151153
item.second.convert(item.second);
154+
this->convert_global(this->input.list);
152155
}
153156
}

source/src_io/read_txt_input_process.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@ namespace Read_Txt_Input
1818

1919
private:
2020
Input_List &input;
21+
2122
void read(const std::string &file_name);
2223
void check_transform();
23-
void default2();
24+
void default_2();
2425
void out(const std::string &file_name) const;
2526
void bcast();
26-
void convert();
27+
void convert();
28+
29+
void check_transform_global(std::map<std::string, Input_Item> &list);
30+
void default_2_global(std::map<std::string, Input_Item> &list);
31+
void convert_global(const std::map<std::string, Input_Item> &list);
2732
};
2833
}
2934

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include "read_txt_input_process.h"
2+
3+
namespace Read_Txt_Input
4+
{
5+
void Input_Process::check_transform_global(std::map<std::string, Input_Item> &list)
6+
{
7+
8+
}
9+
10+
void Input_Process::default_2_global(std::map<std::string, Input_Item> &list)
11+
{
12+
13+
}
14+
15+
void Input_Process::convert_global(const std::map<std::string, Input_Item> &list)
16+
{
17+
18+
}
19+
}

0 commit comments

Comments
 (0)