23 #include <unordered_map>
33 jevois::
Component(instanceID), itsCommandLineArgs((char const **)(argv), (char const **)(argv+argc)),
40 itsCommandLineArgs = std::vector<std::string>((
char const **)(argv), (
char const **)(argv+argc));
51 if (itsGotArgs ==
false)
52 LERROR(
"No command-line arguments given; did you forget to call jevois::Manager::setArgs()?");
54 if (itsCommandLineArgs.size() > 0) itsRemainingArgs = parseCommandLine(itsCommandLineArgs);
70 #if !defined(JEVOIS_TRACE_ENABLE) || !defined(JEVOIS_LDEBUG_ENABLE)
78 constructHelpMessage(std::cout);
84 std::unordered_map<std::string,
85 std::unordered_map<std::string,
86 std::vector<std::pair<std::string,
90 this->populateHelpMessage(
"", helplist,
false);
95 boost::shared_lock<boost::shared_mutex> lck(itsSubMtx);
96 for (std::shared_ptr<jevois::Component> c : itsSubComponents) c->populateHelpMessage(
"", helplist);
100 if (helplist.empty()) { out <<
"NO PARAMETERS.";
return; }
102 out <<
"PARAMETERS:" << std::endl << std::endl;
104 for (
auto & c : helplist)
107 out << c.first << std::endl;
110 for (
auto const & n : c.second)
112 out << n.first << std::endl;
116 out <<
" Exported By: ";
117 for (
auto const & cp : n.second)
120 if (cp.second.empty() ==
false) out <<
" value=[" << cp.second <<
']';
121 if (cp != *(n.second.end()-1)) out <<
", ";
133 std::vector<std::string>
const jevois::Manager::parseCommandLine(std::vector<std::string>
const & commandLineArgs)
136 std::vector<std::string> remainingArgs;
137 remainingArgs.push_back(commandLineArgs[0]);
140 std::vector<std::string>::const_iterator argIt;
141 for (argIt = commandLineArgs.begin() + 1; argIt != commandLineArgs.end(); ++argIt)
144 if (argIt->length() < 2 || (*argIt)[0] !=
'-' || (*argIt)[1] !=
'-') { remainingArgs.push_back(*argIt);
continue; }
147 if (*argIt ==
"--")
break;
150 size_t const equalsPos = argIt->find_first_of(
'=');
151 if (equalsPos < 3)
LFATAL(
"Cannot parse command-line argument with no name [" << *argIt <<
']');
153 std::string
const parameterName = argIt->substr(2, equalsPos - 2);
154 std::string
const parameterValue = (equalsPos == std::string::npos) ?
"true" : argIt->substr(equalsPos + 1);
158 setParamString(parameterName, parameterValue);
162 while (argIt != commandLineArgs.end()) { remainingArgs.push_back(*argIt); ++argIt; }
164 return remainingArgs;
169 {
return itsRemainingArgs; }
176 boost::upgrade_lock<boost::shared_mutex> uplck(itsSubMtx);
178 for (
auto itr = itsSubComponents.begin(); itr != itsSubComponents.end(); ++itr)
179 if ((*itr)->instanceName() == instance)
181 doRemoveSubComponent(itr, uplck,
"Component");
185 if (warnIfNotFound)
LERROR(
"Component [" << instance <<
"] not found. Ignored.");
191 jevois::manager::LogLevel
const & newval)
198 #ifdef JEVOIS_LDEBUG_ENABLE
206 unsigned int const & newval)
210 #if !defined(JEVOIS_TRACE_ENABLE) || !defined(JEVOIS_LDEBUG_ENABLE)
211 LERROR(
"Debug trace has been disabled at compile-time, re-compile with -DJEVOIS_LDEBUG_ENABLE=ON and "
212 "-DJEVOIS_TRACE_ENABLE=ON to see trace info");