10config_file = sys.argv[2]
12factoryfile = sys.argv[4]
14if os.path.exists(root+
'/config.json'):
15 config_file = root +
'/config.json'
19with open(config_file,
'r', encoding=
'utf-8')
as load_f:
21 data = json.load(load_f)
24 _txt =
''.join(open(header.replace(
'..', root)).readlines())
26 for i
in re.findall(
'class (.*?) : public', _txt, re.S):
28 } else if (%s == %s::name()) {
29 %s = new %s(%s);'''%(name1, i, name2, i, name3)
35 for i
in data[
'models']:
36 list1 = glob.glob(root+
'/'+i)
38 objs += [ j.replace(root,
"..") ]
41 txt+=
'#include "modelfactory.h"\n\n'
42 txt+=
'#include <string>\n\n'
44 txt +=
'#include "%s.h"\n'%i[:-4]
47Model* init_model(const std::string& model_name, const Param& parm) {
48 Model* mymodel = NULL;
49 if (false) { // just do nothing (placeholder)'''
56 LOG(FATAL) << "Cannot parse <forcefield> " << model_name << std::endl;
61 f = open(factoryfile,
'w')
66 print(i.replace(
'../models/',
''))
68elif target ==
'solvers':
69 for i
in data[
'solvers']:
70 list1 = glob.glob(root+
'/'+i)
72 objs += [ j.replace(root,
"..") ]
75 txt+=
'#include "solverfactory.h"\n\n'
76 txt+=
'#include <string>\n\n'
78 txt +=
'#include "%s.h"\n'%i[:-4]
81Solver* init_solver(const std::string& solver_name, const Param& parm, Model* pM) {
82 Solver* mysolver = NULL;
83 if (false) { // just do nothing (placeholder)'''
89 LOG(FATAL) << "Cannot parse method name: " << solver_name << std::endl;
94 f = open(factoryfile,
'w')
99 print(i.replace(
'../solvers/',
'') +
';')
creat_object_codes(header, name1, name2, name3)