25 #include <Ice/BuiltinSequences.h>
26 #include <Ice/Handle.h>
27 #include <Ice/Initialize.h>
28 #include <Ice/ObjectF.h>
29 #include <Ice/PropertiesF.h>
31 #include <boost/program_options.hpp>
55 #include <SimoxUtility/algorithm/string/string_tools.h>
62 Ice::StringSeq args = Ice::argsToStringSeq(argc, argv);
63 args = properties->parseCommandLineOptions(
"", args);
72 options.
error =
false;
78 options.
description.reset(
new options_description(std::string(
79 "This executable is an application within the ArmarX framework.\n")
80 +
"==================================================================\n"
81 +
" Starting an ArmarX application\n"
82 +
"==================================================================\n"
83 +
"In order to start the application, execute it normally and pass optional config"
84 +
" parameters to it:\n\n"
86 +
" > " + argv[0] +
" [options]\n\n"
88 +
"Make sure that Ice is started using the ice-start.sh script.\n"
89 +
"Options for the component can be provided either in the command line\n"
90 +
"or in a separate config file. In order to provide config files use \n\n"
92 +
" > " + argv[0] +
" --Ice.Config=cfg1,cfg2\n\n"
94 +
"where multiple config files are allowed.\n\n"
98 options.
description->add_options()(
"help,h",
"Help option");
99 options.
description->add_options()(
"version,v",
"Shows version of this application, which is usually the version of the package.");
101 options.
description->add_options()(
"print-options,p",
"Print detailed application options description");
103 options.
description->add_options()(
"options-format,f", value<std::string>(),
"Options print format: { help, config, doxygen, doxygen_component_pages, xml }");
105 options.
description->add_options()(
"output-file,o", value <std::string>(),
"Optional output file (outherwise gets printed to std::cout)");
108 store(command_line_parser(argc, argv).options(*options.
description).allow_unregistered().run(), vm);
111 if (vm.count(
"print-options"))
113 std::map<std::string, OptionsFormat> optionsFormats;
115 optionsFormats[
"doxygen"] =
eDoxygen;
117 optionsFormats[
"config"] =
eConfig;
118 optionsFormats[
"xml"] =
eXml;
120 if (vm.count(
"options-format"))
122 std::string optionsFormatName = vm[
"options-format"].as<std::string>();
123 optionsFormatName = simox::alg::to_lower(optionsFormatName);
125 if (optionsFormats.find(optionsFormatName) != optionsFormats.end())
127 options.
format = optionsFormats[optionsFormatName];
131 std::cout <<
"Unknown options-format:" << optionsFormatName << std::endl;
134 options.
error =
true;
143 else if (vm.count(
"help") || properties->getProperty(
"Ice.Default.Locator").empty())
147 else if (vm.count(
"version"))
157 if (vm.count(
"output-file"))
159 std::string outputFilePath = vm[
"output-file"].as<std::string>();
160 options.
outfile = outputFilePath;
172 boost::program_options::options_description& desc = *options.
description;
178 switch (optionsFormat)
186 out << desc << std::endl;
188 out <<
"By default the following config files are loaded:\n ";
189 Ice::StringSeq paths = application->GetDefaultsPaths();
193 out <<
"\t" << p << std::endl;
198 boost::program_options::options_description applicationDesc(
"Application properties");
203 puList.insert(puList.begin(), application);
207 boost::program_options::options_description componentDesc(
"Component properties");
209 delete definitionFormatter;
210 delete containerFormatter;
218 delete definitionFormatter;
219 delete containerFormatter;
249 ARMARX_WARNING <<
"ConfigFormatter with id " << (int)optionsFormat <<
" not available";
256 puList.insert(puList.begin(), application);
269 std::vector<ManagedIceObjectPtr> objects = dummyManager->getManagedObjects();
271 for (
auto& it : objects)
277 propertyUsers.push_back(user);
283 auto additionalPropertyUsers = comp->getAdditionalPropertyUsers();
284 propertyUsers.insert(propertyUsers.end(), additionalPropertyUsers.begin(), additionalPropertyUsers.end());
288 return propertyUsers;