33 #include <boost/program_options.hpp>
35 #include <Ice/BuiltinSequences.h>
36 #include <Ice/Handle.h>
37 #include <Ice/Initialize.h>
38 #include <Ice/ObjectF.h>
39 #include <Ice/PropertiesF.h>
41 #include <SimoxUtility/algorithm/string/string_tools.h>
66 Ice::StringSeq args = Ice::argsToStringSeq(argc, argv);
67 args = properties->parseCommandLineOptions(
"", args);
77 options.
error =
false;
84 std::string(
"This executable is an application within the ArmarX framework.\n") +
85 "==================================================================\n" +
86 " Starting an ArmarX application\n" +
87 "==================================================================\n" +
88 "In order to start the application, execute it normally and pass optional config" +
89 " parameters to it:\n\n"
91 +
" > " + argv[0] +
" [options]\n\n"
93 +
"Make sure that Ice is started using the ice-start.sh script.\n" +
94 "Options for the component can be provided either in the command line\n" +
95 "or in a separate config file. In order to provide config files use \n\n"
97 +
" > " + argv[0] +
" --Ice.Config=cfg1,cfg2\n\n"
99 +
"where multiple config files are allowed.\n\n"
103 options.
description->add_options()(
"help,h",
"Help option");
106 "Shows version of this application, which is usually the version of the package.");
108 options.
description->add_options()(
"print-options,p",
109 "Print detailed application options description");
113 value<std::string>(),
114 "Options print format: { help, config, doxygen, doxygen_component_pages, xml }");
118 value<std::string>(),
119 "Optional output file (outherwise gets printed to std::cout)");
122 store(command_line_parser(argc, argv)
124 .allow_unregistered()
129 if (vm.count(
"print-options"))
131 std::map<std::string, OptionsFormat> optionsFormats;
133 optionsFormats[
"doxygen"] =
eDoxygen;
135 optionsFormats[
"config"] =
eConfig;
136 optionsFormats[
"xml"] =
eXml;
138 if (vm.count(
"options-format"))
140 std::string optionsFormatName = vm[
"options-format"].as<std::string>();
141 optionsFormatName = simox::alg::to_lower(optionsFormatName);
143 if (optionsFormats.find(optionsFormatName) != optionsFormats.end())
145 options.
format = optionsFormats[optionsFormatName];
149 std::cout <<
"Unknown options-format:" << optionsFormatName << std::endl;
152 options.
error =
true;
161 else if (vm.count(
"help") || properties->getProperty(
"Ice.Default.Locator").empty())
165 else if (vm.count(
"version"))
175 if (vm.count(
"output-file"))
177 std::string outputFilePath = vm[
"output-file"].as<std::string>();
178 options.
outfile = outputFilePath;
194 boost::program_options::options_description& desc = *options.
description;
200 switch (optionsFormat)
208 out << desc << std::endl;
210 out <<
"By default the following config files are loaded:\n ";
211 Ice::StringSeq paths = application->GetDefaultsPaths();
215 out <<
"\t" << p << std::endl;
220 boost::program_options::options_description applicationDesc(
221 "Application properties");
225 *definitionFormatter, &applicationDesc);
227 puList.insert(puList.begin(), application);
231 boost::program_options::options_description componentDesc(
"Component properties");
233 delete definitionFormatter;
234 delete containerFormatter;
238 *definitionFormatter, &componentDesc);
243 delete definitionFormatter;
244 delete containerFormatter;
274 ARMARX_WARNING <<
"ConfigFormatter with id " << (int)optionsFormat
282 puList.insert(puList.begin(), application);
295 std::vector<ManagedIceObjectPtr> objects = dummyManager->getManagedObjects();
297 for (
auto& it : objects)
303 propertyUsers.push_back(user);
309 auto additionalPropertyUsers = comp->getAdditionalPropertyUsers();
310 propertyUsers.insert(propertyUsers.end(),
311 additionalPropertyUsers.begin(),
312 additionalPropertyUsers.end());
316 return propertyUsers;