Blame view

src/amdaParameterGenerator/Main.cc 2.39 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
 * Main.cc
 *  Created on: 15 oct. 2012
 *      Author: AKKA IS
 */
#include <iostream>

#include <boost/program_options.hpp>

#include "AMDA-Kernel_Config.hh"
#include <Application.hh>

// Parameters module include
#include "ParameterManager.hh"
#include "Parameter.hh"
#include "Process.hh"
#include "ParameterGenerator.hh"
#include "ServicesServer.hh"

using namespace std;
namespace po = boost::program_options;
using namespace log4cxx;
using namespace log4cxx::helpers;
using namespace AMDA::Parameters;


/**
 * Main function
 */
int main(int argc, char *argv[]) {
	int result = AMDA_EXIT_OK;

	/// Parse command line parameters
	po::options_description desc("Allowed options");

	desc.add_options()
		("help,h", "Produce help message")
		("version,v", "Program version")
		("parameter,p", po::value< vector<string> >(), "Parameter(s) name")
	;

	po::positional_options_description p;
	p.add("parameter", -1);

	po::variables_map vm;
	po::store(po::command_line_parser(argc, argv).options(desc).positional(p).run(), vm);
	po::notify(vm);

	if (vm.count("help")) {
		cout << desc << "\n";
		return result;
	}
	if (vm.count("version")) {
		cout << "Version: " << AMDA_Kernel_VERSION << "\n";
		return result;
	}

	if (!vm.count("parameter")) {
		return result;
	}

	AMDA::Common::Application lMain;

d6c7a344   RENARD Benjamin   Fix some warning ...
64
	return lMain.main(argc,argv,[&](int , char **, AMDA::helpers::Properties& lProperties) -> int {
fbe3c2bb   Benjamin Renard   First commit
65
66
67
68
69

			vector<string> lParameterList = vm["parameter"].as< vector<string> >();

			///Create ParameterManager and configuration
			ParameterManager parameterManager;
897858c8   Benjamin Renard   Support multi TT ...
70
71
			std::string emptyStr;
			parameterManager.addInputInterval(0, 0, 0, emptyStr, emptyStr, 0);
fbe3c2bb   Benjamin Renard   First commit
72
73
74

			if (!lProperties["app.param.gapthreshold"].empty())
			{
c6a67968   Benjamin Renard   Fix some violatio...
75
				double defaultGapThreshold = atof(lProperties["app.param.gapthreshold"].c_str());
fbe3c2bb   Benjamin Renard   First commit
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
				if (defaultGapThreshold > 0.)
					parameterManager.setDefaultGapThreshold(defaultGapThreshold);
			}

			for (auto lParamName : lParameterList) {
				try {
					///Create Parameter
					parameterManager.createParameter(lParamName);

					///Generate Output
					AMDA::Parameters::Generator* lGenerator =
							new AMDA::Parameters::Generator(parameterManager);
					ParamOutputSPtr lParamOutput(lGenerator);
					lGenerator->setParamName(lParamName);
					parameterManager.getParamOutputList().push_back( lParamOutput);
				} catch (...) {
				}
			}
			/// launch request
			parameterManager.execute("");

			return result;
});

}