JeVois  1.0
JeVois Smart Embedded Machine Vision Toolkit
Component.C
Go to the documentation of this file.
1 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 //
3 // JeVois Smart Embedded Machine Vision Toolkit - Copyright (C) 2016 by Laurent Itti, the University of Southern
4 // California (USC), and iLab at USC. See http://iLab.usc.edu and http://jevois.org for information about this project.
5 //
6 // This file is part of the JeVois Smart Embedded Machine Vision Toolkit. This program is free software; you can
7 // redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
8 // Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
10 // License for more details. You should have received a copy of the GNU General Public License along with this program;
11 // if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12 //
13 // Contact information: Laurent Itti - 3641 Watt Way, HNB-07A - Los Angeles, CA 90089-2520 - USA.
14 // Tel: +1 213 740 3527 - itti@pollux.usc.edu - http://iLab.usc.edu - http://jevois.org
15 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16 /*! \file */
17 
18 // This code is inspired by the Neuromorphic Robotics Toolkit (http://nrtkit.org)
19 
20 #include <jevois/Debug/Log.H>
24 #include <jevois/Util/Utils.H>
25 
26 #include <fstream>
27 #include <algorithm> // for std::all_of
28 
29 // ######################################################################
30 jevois::Component::Component(std::string const & instanceName) :
31  itsInstanceName(instanceName), itsInitialized(false), itsParent(nullptr), itsPath()
32 {
33  JEVOIS_TRACE(5);
34 }
35 
36 // ######################################################################
37 std::string const & jevois::Component::className() const
38 {
39  boost::shared_lock<boost::shared_mutex> lck(itsMetaMtx);
40 
41  // We need the (derived!) component to be fully constructed for demangle to work, hence the const_cast here:
42  if (itsClassName.empty()) *(const_cast<std::string *>(&itsClassName)) = jevois::demangle(typeid(*this).name());
43 
44  return itsClassName;
45 }
46 
47 // ######################################################################
48 std::string const & jevois::Component::instanceName() const
49 { return itsInstanceName; }
50 
51 // ######################################################################
53 {
54  JEVOIS_TRACE(5);
55 
56  LDEBUG("Deleting Component");
57 
58  // Recursively un-init us and our subs; call base class version as derived classes are destroyed:
59  if (itsInitialized) jevois::Component::uninit();
60 
61  // All right, we need to nuke our subs BEFORE we get destroyed, since they will backflow to us (for param
62  // notices, recursive descriptor access, etc):
63  boost::upgrade_lock<boost::shared_mutex> uplck(itsSubMtx);
64 
65  while (itsSubComponents.empty() == false)
66  {
67  auto itr = itsSubComponents.begin();
68  doRemoveSubComponent(itr, uplck, "SubComponent");
69  }
70 }
71 
72 // ######################################################################
73 void jevois::Component::removeSubComponent(std::string const & instanceName, bool warnIfNotFound)
74 {
75  JEVOIS_TRACE(5);
76 
77  boost::upgrade_lock<boost::shared_mutex> uplck(itsSubMtx);
78 
79  for (auto itr = itsSubComponents.begin(); itr != itsSubComponents.end(); ++itr)
80  if ((*itr)->instanceName() == instanceName)
81  {
82  // All checks out, get doRemoveSubComponent() to do the work:
83  doRemoveSubComponent(itr, uplck, "SubComponent");
84  return;
85  }
86 
87  if (warnIfNotFound) LERROR("SubComponent [" << instanceName << "] not found. Ignored.");
88 }
89 
90 // ######################################################################
91 void jevois::Component::doRemoveSubComponent(std::vector<std::shared_ptr<jevois::Component> >::iterator & itr,
92  boost::upgrade_lock<boost::shared_mutex> & uplck,
93  std::string const & displayname)
94 {
95  JEVOIS_TRACE(5);
96 
97  // Try to delete and let's check that it will actually be deleted:
98  std::shared_ptr<jevois::Component> component = *itr;
99 
100  LDEBUG("Removing " << displayname << " [" << component->descriptor() << ']');
101 
102  // Un-init the component:
103  if (component->initialized()) component->uninit();
104 
105  // Remove it from our list of subs:
106  boost::upgrade_to_unique_lock<boost::shared_mutex> ulck(uplck);
107  itsSubComponents.erase(itr);
108 
109  if (component.use_count() > 1)
110  LERROR(component.use_count() - 1 << " additional external shared_ptr reference(s) exist to "
111  << displayname << " [" << component->descriptor() << "]. It was removed but NOT deleted.");
112 
113  component.reset(); // nuke the shared_ptr, this should yield a delete unless use_count was > 1
114 }
115 
116 // ######################################################################
118 {
119  JEVOIS_TRACE(6);
120 
121  boost::shared_lock<boost::shared_mutex> lck(itsMtx);
122 
123  if (dynamic_cast<jevois::Manager *>(itsParent) != nullptr) return true;
124 
125  return false;
126 }
127 
128 // ######################################################################
129 void jevois::Component::init()
130 {
131  JEVOIS_TRACE(5);
132 
133  if (itsInitialized) { LERROR("Already initialized. Ignored."); return; }
134 
135  LDEBUG("Initializing...");
136 
137  runPreInit();
138  setInitialized();
139  runPostInit();
140 
141  LDEBUG("Initialized.");
142 }
143 
144 // ######################################################################
145 void jevois::Component::runPreInit()
146 {
147  JEVOIS_TRACE(6);
148 
149  // Pre-init all subComponents:
150  {
151  boost::shared_lock<boost::shared_mutex> lck(itsSubMtx);
152  for (std::shared_ptr<jevois::Component> c : itsSubComponents) c->runPreInit();
153  }
154 
155  // Then us. So the last one here will be the manager, and its preInit() will parse the command line:
156  preInit();
157 
158  // If we have some parameters with callbacks that have not been set expicitly by the command-line, call the callback a
159  // first time here. This may add some new parameters
161 }
162 
163 // ######################################################################
164 void jevois::Component::setInitialized()
165 {
166  JEVOIS_TRACE(6);
167 
168  // First all subComponents
169  {
170  boost::shared_lock<boost::shared_mutex> lck(itsSubMtx);
171  for (std::shared_ptr<jevois::Component> c : itsSubComponents) c->setInitialized();
172  }
173 
174  // Then us:
175  itsInitialized = true;
176 }
177 
178 // ######################################################################
179 void jevois::Component::runPostInit()
180 {
181  JEVOIS_TRACE(6);
182 
183  // First all subComponents:
184  {
185  boost::shared_lock<boost::shared_mutex> lck(itsSubMtx);
186  for (std::shared_ptr<jevois::Component> c : itsSubComponents) c->runPostInit();
187  }
188 
189  // Then us:
190  postInit();
191 }
192 
193 // ######################################################################
195 {
196  JEVOIS_TRACE(6);
197 
198  return itsInitialized;
199 }
200 
201 // ######################################################################
202 void jevois::Component::uninit()
203 {
204  JEVOIS_TRACE(5);
205 
206  if (itsInitialized)
207  {
208  LDEBUG("Uninitializing...");
209 
210  runPreUninit();
211  setUninitialized();
212  runPostUninit();
213 
214  LDEBUG("Uninitialized.");
215  }
216 }
217 
218 // ######################################################################
219 void jevois::Component::runPreUninit()
220 {
221  JEVOIS_TRACE(6);
222 
223  // First all subComponents:
224  {
225  boost::shared_lock<boost::shared_mutex> lck(itsSubMtx);
226  for (std::shared_ptr<jevois::Component> c : itsSubComponents) c->runPreUninit();
227  }
228 
229  // Then us:
230  preUninit();
231 }
232 
233 // ######################################################################
234 void jevois::Component::setUninitialized()
235 {
236  JEVOIS_TRACE(6);
237 
238  // First us:
239  itsInitialized = false;
240 
241  // Then all subComponents
242  {
243  boost::shared_lock<boost::shared_mutex> lck(itsSubMtx);
244  for (std::shared_ptr<jevois::Component> c : itsSubComponents) c->setUninitialized();
245  }
246 }
247 
248 // ######################################################################
249 void jevois::Component::runPostUninit()
250 {
251  JEVOIS_TRACE(6);
252 
253  // First us:
254  postUninit();
255 
256  // Then all subComponents:
257  {
258  boost::shared_lock<boost::shared_mutex> lck(itsSubMtx);
259  for (std::shared_ptr<jevois::Component> c : itsSubComponents) c->runPostUninit();
260  }
261 }
262 
263 // ######################################################################
264 std::string jevois::Component::descriptor() const
265 {
266  JEVOIS_TRACE(8);
267 
268  // Top-level components or those with no parent just return their instance name. Sub-components return a chain of
269  // component instance names up to the top level:
270 
271  boost::shared_lock<boost::shared_mutex> lck(itsMtx);
272 
273  if (itsParent && dynamic_cast<jevois::Manager *>(itsParent) == nullptr)
274  return itsParent->descriptor() + ':' + itsInstanceName;
275 
276  return itsInstanceName;
277 }
278 
279 // ######################################################################
280 void jevois::Component::findParamAndActOnIt(std::string const & descrip,
281  std::function<void(jevois::ParameterBase *, std::string const &)> doit,
282  std::function<bool()> empty) const
283 {
284  JEVOIS_TRACE(9);
285 
286  // Split this parameter descriptor by single ":" (skipping over all "::")
287  std::vector<std::string> desc = jevois::split(descrip, ":" /*"FIXME "(?<!:):(?!:)" */);
288 
289  if (desc.empty()) std::range_error(descriptor() + ": Cannot parse empty parameter name");
290 
291  // Recursive call with the vector of tokens:
292  findParamAndActOnIt(desc, true, 0, "", doit);
293 
294  if (empty()) throw std::range_error(descriptor() + ": No Parameter named [" + descrip + ']');
295 }
296 
297 // ######################################################################
298 void jevois::Component::findParamAndActOnIt(std::vector<std::string> const & descrip,
299  bool recur, size_t idx, std::string const & unrolled,
300  std::function<void(jevois::ParameterBase *, std::string const &)> doit) const
301 {
302  JEVOIS_TRACE(9);
303 
304  // Have we not yet reached the bottom (still have some component names before the param)?
305  if (descrip.size() > idx + 1)
306  {
307  // We have some token before the param, is it a '*', in which case we turn on recursion?
308  if (descrip[idx] == "*") { recur = true; ++idx; }
309  else {
310  // We have some Instance specification(s) of component(s) before the param. Let's see if we match against the
311  // first one. If it's a match, eat up the first token and send the rest of the tokens to our subcomponents,
312  // otherwise keep the token and recurse the entire list to the subs:
313  if (itsInstanceName == descrip[idx]) { recur = false; ++idx; }
314  }
315  }
316 
317  // Have we reached the end of the list (the param name)?
318  if (descrip.size() == idx + 1)
319  {
320  // We have just a paramname, let's see if we have that param:
321  boost::shared_lock<boost::shared_mutex> lck(itsParamMtx);
322 
323  for (auto const & p : itsParameterList)
324  if (p.second->name() == descrip[idx])
325  {
326  // param name is a match, act on it:
327  std::string ur; if (unrolled.empty()) ur = p.second->name(); else ur = unrolled + ':' + p.second->name();
328  doit(p.second, ur);
329  }
330  }
331 
332  // Recurse through our subcomponents if recur is on or we have not yet reached the bottom:
333  if (recur || descrip.size() > idx + 1)
334  {
335  boost::shared_lock<boost::shared_mutex> lck(itsSubMtx);
336 
337  std::string ur;
338  if (unrolled.empty()) ur = itsInstanceName; else ur = unrolled + ':' + itsInstanceName;
339 
340  for (std::shared_ptr<jevois::Component> c : itsSubComponents) c->findParamAndActOnIt(descrip, recur, idx, ur, doit);
341  }
342 }
343 
344 // ######################################################################
345 std::vector<std::string> jevois::Component::setParamString(std::string const & descriptor, std::string const & val)
346 {
347  JEVOIS_TRACE(7);
348 
349  std::vector<std::string> ret;
350  findParamAndActOnIt(descriptor,
351 
352  [&ret,&val](jevois::ParameterBase * param, std::string const & unrolled)
353  { param->strset(val); ret.push_back(unrolled); },
354 
355  [&ret]() { return ret.empty(); }
356  );
357  return ret;
358 }
359 
360 // ######################################################################
361 void jevois::Component::setParamStringUnique(std::string const & descriptor, std::string const & val)
362 {
363  JEVOIS_TRACE(7);
364 
365  std::vector<std::string> ret = setParamString(descriptor, val);
366  if (ret.size() > 1)
367  throw std::range_error("Multiple matches for descriptor [" + descriptor + "] while only one is allowed");
368 }
369 
370 // ######################################################################
371 std::vector<std::pair<std::string, std::string> >
372 jevois::Component::getParamString(std::string const & descriptor) const
373 {
374  JEVOIS_TRACE(8);
375 
376  std::vector<std::pair<std::string, std::string> > ret;
377  findParamAndActOnIt(descriptor,
378 
379  [&ret](jevois::ParameterBase * param, std::string const & unrolled)
380  { ret.push_back(std::make_pair(unrolled, param->strget())); },
381 
382  [&ret]() { return ret.empty(); }
383  );
384  return ret;
385 }
386 
387 // ######################################################################
388 std::string jevois::Component::getParamStringUnique(std::string const & descriptor) const
389 {
390  JEVOIS_TRACE(8);
391 
392  std::vector<std::pair<std::string, std::string> > ret = getParamString(descriptor);
393  if (ret.size() > 1)
394  throw std::range_error("Multiple matches for descriptor [" + descriptor + "] while only one is allowed");
395  return ret[0].second;
396 }
397 
398 // ######################################################################
399 void jevois::Component::freezeParam(std::string const & paramdescriptor)
400 {
401  int n = 0;
402  findParamAndActOnIt(paramdescriptor,
403  [&n](jevois::ParameterBase * param, std::string const & JEVOIS_UNUSED_PARAM(unrolled))
404  { param->freeze(); ++n; },
405 
406  [&n]() { return (n == 0); }
407  );
408 }
409 
410 // ######################################################################
411 void jevois::Component::unFreezeParam(std::string const & paramdescriptor)
412 {
413  int n = 0;
414  findParamAndActOnIt(paramdescriptor,
415  [&n](jevois::ParameterBase * param, std::string const & JEVOIS_UNUSED_PARAM(unrolled))
416  { param->unFreeze(); ++n; },
417 
418  [&n]() { return (n == 0); }
419  );
420 }
421 
422 // ######################################################################
424 {
425  boost::shared_lock<boost::shared_mutex> lck(itsParamMtx);
426 
427  for (auto const & p : itsParameterList) p.second->freeze();
428 }
429 
430 // ######################################################################
432 {
433  boost::shared_lock<boost::shared_mutex> lck(itsParamMtx);
434 
435  for (auto const & p : itsParameterList) p.second->unFreeze();
436 }
437 
438 // ######################################################################
439 void jevois::Component::setParamsFromFile(std::string const & filename)
440 {
441  std::string const absfile = absolutePath(filename);
442  std::ifstream ifs(absfile);
443  if (!ifs) LFATAL("Could not open file " << absfile);
444  setParamsFromStream(ifs, absfile);
445 }
446 
447 // ######################################################################
448 std::istream & jevois::Component::setParamsFromStream(std::istream & is,std::string const & absfile)
449 {
450  size_t linenum = 1;
451  for (std::string line; std::getline(is, line); /* */)
452  {
453  // Skip over comments:
454  if (line.length() && line[0] == '#') { ++linenum; continue; }
455 
456  // Skip over empty lines:
457  if (std::all_of(line.begin(), line.end(), [](unsigned char c) { return std::isspace(c); })) { ++linenum; continue; }
458 
459  // Parse descriptor=value:
460  size_t idx = line.find('=');
461  if (idx == line.npos) LFATAL("No '=' symbol found at line " << linenum << " in " << absfile);
462  if (idx == 0) LFATAL("No parameter descriptor found at line " << linenum << " in " << absfile);
463  if (idx == line.length() - 1) LFATAL("No parameter value found at line " << linenum << " in " << absfile);
464 
465  std::string desc = line.substr(0, idx);
466  std::string val = line.substr(idx + 1);
467 
468  // Be nice and clean whitespace at start and end (not in the middle):
469  while (desc.length() > 0 && std::isspace(desc[0])) desc.erase(0, 1);
470  while (desc.length() > 0 && std::isspace(desc[desc.length()-1])) desc.erase(desc.length()-1, 1);
471  if (desc.empty()) LFATAL("Invalid blank parameter descriptor at line " << linenum << " in " << absfile);
472 
473  while (val.length() > 0 && std::isspace(val[0])) val.erase(0, 1);
474  while (val.length() > 0 && std::isspace(val[val.length()-1])) val.erase(val.length()-1, 1);
475  if (val.empty()) LFATAL("Invalid blank parameter value at line " << linenum << " in " << absfile);
476 
477  // Ok, set that param:
478  setParamString(desc, val);
479 
480  ++linenum;
481  }
482  return is;
483 }
484 
485 // ######################################################################
486 void jevois::Component::setPath(std::string const & path)
487 {
488  JEVOIS_TRACE(5);
489 
490  // First all subComponents:
491  {
492  boost::shared_lock<boost::shared_mutex> lck(itsSubMtx);
493  for (std::shared_ptr<jevois::Component> c : itsSubComponents) c->setPath(path);
494  }
495 
496  itsPath = path;
497 }
498 
499 // ######################################################################
500 std::string jevois::Component::absolutePath(std::string const & path)
501 {
502  JEVOIS_TRACE(6);
503 
504  // If path is empty, return itsPath (be it empty of not):
505  if (path.empty()) return itsPath;
506 
507  // no-op if the given path is already absolute:
508  if (path[0] == '/') return path;
509 
510  // no-op if itsPath is empty:
511  if (itsPath.empty()) return path;
512 
513  // We know itsPath is not empty and path does not start with a / and is not empty; concatenate both:
514  return itsPath + '/' + path;
515 }
516 
517 // ######################################################################
518 void jevois::Component::populateHelpMessage(std::string const & cname,
519  std::unordered_map<std::string,
520  std::unordered_map<std::string,
521  std::vector<std::pair<std::string, std::string> > > > & helplist,
522  bool recurse) const
523 {
524  JEVOIS_TRACE(9);
525 
526  std::string const compname = cname.empty() ? itsInstanceName : cname + ':' + itsInstanceName;
527 
528  // First add our own params:
529  {
530  boost::shared_lock<boost::shared_mutex> lck(itsParamMtx);
531  for (auto const & p : itsParameterList)
532  {
533  jevois::ParameterSummary const ps = p.second->summary();
534 
535  if (ps.frozen) continue; // skip frozen parameters
536 
537  std::string const key1 = ps.category + ": "+ ps.categorydescription;
538  std::string const key2 = " --" + ps.name + " (" + ps.valuetype + ") default=[" + ps.defaultvalue + "]" +
539  (ps.validvalues == "None:[]" ? "\n" : " " + ps.validvalues + "\n") + " " + ps.description;
540  std::string val = "";
541  if (ps.value != ps.defaultvalue) val = "value=["+ps.value+']';
542  helplist[key1][key2].push_back(std::make_pair(compname, val));
543  }
544  }
545 
546  // Then recurse through our subcomponents:
547  if (recurse)
548  {
549  boost::shared_lock<boost::shared_mutex> lck(itsSubMtx);
550  for (std::shared_ptr<jevois::Component> c : itsSubComponents) c->populateHelpMessage(compname, helplist);
551  }
552 }
553 
554 // ######################################################################
555 std::string jevois::Component::computeInstanceName(std::string const & instance, std::string const & classname) const
556 {
557  JEVOIS_TRACE(9);
558 
559  std::string inst = instance;
560 
561  // If empty instance, replace it by the classname:
562  if (inst.empty())
563  {
564  // Use the class name:
565  inst = classname + '#';
566 
567  // Remove any namespace:: prefix:
568  size_t const idxx = inst.rfind(':'); if (idxx != inst.npos) inst = inst.substr(idxx + 1);
569  }
570 
571  // Replace all # characters by some number, if necessary:
572  std::vector<std::string> vec = jevois::split(inst, "#");
573  if (vec.size() > 1)
574  {
575  // First try to have no numbers in there:
576  inst = jevois::join(vec, ""); bool found = false;
577  for (std::shared_ptr<Component> const & c : itsSubComponents)
578  if (c->instanceName() == inst) { found = true; break; }
579 
580  if (found)
581  {
582  // Ok, we have some conflict, so let's add some numbers where the # signs were:
583  inst = "";
584  for (std::string const & v : vec)
585  {
586  if (v.empty()) continue;
587 
588  inst += v;
589  size_t largestId = 1;
590 
591  while (true)
592  {
593  std::string stem = inst + std::to_string(largestId);
594  bool gotit = false;
595 
596  for (std::shared_ptr<Component> const & c : itsSubComponents)
597  if (c->instanceName() == stem) { gotit = true; break; }
598 
599  if (gotit == false) { inst = stem; break; }
600 
601  ++largestId;
602  }
603  }
604  }
605 
606  LDEBUG("Using automatic instance name [" << inst << ']');
607  return inst;
608  }
609 
610  // If we have not returned yet, no # was given. Throw if there is a conflict:
611  for (std::shared_ptr<Component> const & c : itsSubComponents)
612  if (c->instanceName() == inst)
613  throw std::runtime_error("Provided instance name [" + instance + "] clashes with existing sub-components.");
614 
615  return inst;
616 }
617 
#define LDEBUG(msg)
Convenience macro for users to print out console or syslog messages, DEBUG level. ...
Definition: Log.H:148
bool initialized() const
Has this component been initialized yet?
Definition: Component.C:194
bool isTopLevel() const
Returns true if this component is top-level, i.e., its parent is jevois::Manager. ...
Definition: Component.C:117
std::string name
Plain name of the parameter.
Definition: Parameter.H:60
std::string validvalues
Description of the parameter's valid values specification, as a string.
Definition: Parameter.H:75
std::string description
Description of the parameter.
Definition: Parameter.H:63
std::vector< std::string > setParamString(std::string const &paramdescriptor, std::string const &val)
Set a parameter value, by string.
Definition: Component.C:345
void unFreeze()
Unfreeze this parameter, it becomes read-write and will show up in the help message.
Definition: ParameterImpl.H:41
std::vector< std::string > split(std::string const &input, std::string const &regex="\\s+")
Split string into vector of tokens using a regex to specify what to split on; default regex splits by...
Definition: Utils.C:63
ParameterSummary provides a summary about a parameter.
Definition: Parameter.H:53
std::string value
Current value of the parameter, as a string.
Definition: Parameter.H:72
std::vector< std::pair< std::string, std::string > > getParamString(std::string const &paramdescriptor) const
Get a parameter value, by string.
Definition: Component.C:372
std::string defaultvalue
Default value of the parameter, as a string.
Definition: Parameter.H:69
void setPath(std::string const &path)
Assign a filesystem path to this component.
Definition: Component.C:486
void setParamStringUnique(std::string const &paramdescriptor, std::string const &val)
Set a parameter value by string, simple version assuming only one parameter match.
Definition: Component.C:361
void setParamsFromFile(std::string const &filename)
Set some parameters from a file.
Definition: Component.C:439
#define JEVOIS_TRACE(level)
Trace object.
Definition: Log.H:260
void freezeParam(std::string const &paramdescriptor)
Freeze a parameter, by name, see ParameterBase::freeze()
Definition: Component.C:399
#define LERROR(msg)
Convenience macro for users to print out console or syslog messages, ERROR level. ...
Definition: Log.H:186
std::string join(std::vector< std::string > const &strings, std::string const &delimiter)
Concatenate a vector of tokens into a string.
Definition: Utils.C:73
std::string demangle(std::string const &mangledName)
Demangle a mangled name.
Definition: DemangleImpl.H:54
std::string valuetype
Parameter value type, as a string.
Definition: Parameter.H:66
std::string descriptor() const
Get our full descriptor (including all parents) as [Instancename]:[...]:[...].
Definition: Component.C:264
std::string getParamStringUnique(std::string const &paramdescriptor) const
Get a parameter value by string, simple version assuming only one parameter match.
Definition: Component.C:388
virtual ~Component()
Virtual destructor for safe inheritance.
Definition: Component.C:52
bool frozen
Flag that indicates whether parameter is frozen.
Definition: Parameter.H:84
void removeSubComponent(std::shared_ptr< Comp > &component)
Remove a sub-Component from this Component, by shared_ptr.
void freeze()
Freeze this parameter, it becomes read-only and will not show up in the help message.
Definition: ParameterImpl.H:37
Base class for Parameter.
Definition: Parameter.H:91
Component(std::string const &instance)
Constructor.
Definition: Component.C:30
std::string const & className() const
The class name of this component.
Definition: Component.C:37
virtual void strset(std::string const &valstring)=0
Set the value from a string representation of it.
#define LFATAL(msg)
Convenience macro for users to print out console or syslog messages, FATAL level. ...
Definition: Log.H:205
std::string const & instanceName() const
The instance name of this component.
Definition: Component.C:48
std::istream & setParamsFromStream(std::istream &is, std::string const &absfile)
Set some parameters from an open stream.
Definition: Component.C:448
virtual std::string const strget() const =0
Get the value as a string.
std::string category
Category of the parameter, as a string.
Definition: Parameter.H:78
void unFreezeParam(std::string const &paramdescriptor)
Unfreeze a parameter, by name, see ParameterBase::unFreeze()
Definition: Component.C:411
std::string to_string(T const &val)
Convert from type to string.
Definition: UtilsImpl.H:51
void callbackInitCall()
For all parameters that have a callback which has never been called, call it with the default param v...
void freezeAllParams()
Freeze all parameters.
Definition: Component.C:423
void unFreezeAllParams()
Unfreeze all parameters.
Definition: Component.C:431
std::string categorydescription
Category description.
Definition: Parameter.H:81
std::string absolutePath(std::string const &path="")
If given path is relative (not starting with /), prepend the Component path to it.
Definition: Component.C:500