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 = itsInstanceName + ':' + p.second->name();
328  if (unrolled.empty() == false) ur = unrolled + ':' + ur;
329  doit(p.second, ur);
330  }
331  }
332 
333  // Recurse through our subcomponents if recur is on or we have not yet reached the bottom:
334  if (recur || descrip.size() > idx + 1)
335  {
336  boost::shared_lock<boost::shared_mutex> lck(itsSubMtx);
337 
338  std::string ur;
339  if (unrolled.empty()) ur = itsInstanceName; else ur = unrolled + ':' + itsInstanceName;
340 
341  for (std::shared_ptr<jevois::Component> c : itsSubComponents) c->findParamAndActOnIt(descrip, recur, idx, ur, doit);
342  }
343 }
344 
345 // ######################################################################
346 std::vector<std::string> jevois::Component::setParamString(std::string const & descriptor, std::string const & val)
347 {
348  JEVOIS_TRACE(7);
349 
350  std::vector<std::string> ret;
351  findParamAndActOnIt(descriptor,
352 
353  [&ret,&val](jevois::ParameterBase * param, std::string const & unrolled)
354  { param->strset(val); ret.push_back(unrolled); },
355 
356  [&ret]() { return ret.empty(); }
357  );
358  return ret;
359 }
360 
361 // ######################################################################
362 void jevois::Component::setParamStringUnique(std::string const & descriptor, std::string const & val)
363 {
364  JEVOIS_TRACE(7);
365 
366  std::vector<std::string> ret = setParamString(descriptor, val);
367  if (ret.size() > 1)
368  throw std::range_error("Multiple matches for descriptor [" + descriptor + "] while only one is allowed");
369 }
370 
371 // ######################################################################
372 std::vector<std::pair<std::string, std::string> >
373 jevois::Component::getParamString(std::string const & descriptor) const
374 {
375  JEVOIS_TRACE(8);
376 
377  std::vector<std::pair<std::string, std::string> > ret;
378  findParamAndActOnIt(descriptor,
379 
380  [&ret](jevois::ParameterBase * param, std::string const & unrolled)
381  { ret.push_back(std::make_pair(unrolled, param->strget())); },
382 
383  [&ret]() { return ret.empty(); }
384  );
385  return ret;
386 }
387 
388 // ######################################################################
389 std::string jevois::Component::getParamStringUnique(std::string const & descriptor) const
390 {
391  JEVOIS_TRACE(8);
392 
393  std::vector<std::pair<std::string, std::string> > ret = getParamString(descriptor);
394  if (ret.size() > 1)
395  throw std::range_error("Multiple matches for descriptor [" + descriptor + "] while only one is allowed");
396  return ret[0].second;
397 }
398 
399 // ######################################################################
400 void jevois::Component::freezeParam(std::string const & paramdescriptor)
401 {
402  int n = 0;
403  findParamAndActOnIt(paramdescriptor,
404  [&n](jevois::ParameterBase * param, std::string const & JEVOIS_UNUSED_PARAM(unrolled))
405  { param->freeze(); ++n; },
406 
407  [&n]() { return (n == 0); }
408  );
409 }
410 
411 // ######################################################################
412 void jevois::Component::unFreezeParam(std::string const & paramdescriptor)
413 {
414  int n = 0;
415  findParamAndActOnIt(paramdescriptor,
416  [&n](jevois::ParameterBase * param, std::string const & JEVOIS_UNUSED_PARAM(unrolled))
417  { param->unFreeze(); ++n; },
418 
419  [&n]() { return (n == 0); }
420  );
421 }
422 
423 // ######################################################################
425 {
426  boost::shared_lock<boost::shared_mutex> lck(itsParamMtx);
427 
428  for (auto const & p : itsParameterList) p.second->freeze();
429 }
430 
431 // ######################################################################
433 {
434  boost::shared_lock<boost::shared_mutex> lck(itsParamMtx);
435 
436  for (auto const & p : itsParameterList) p.second->unFreeze();
437 }
438 
439 // ######################################################################
440 void jevois::Component::setParamsFromFile(std::string const & filename)
441 {
442  std::string const absfile = absolutePath(filename);
443  std::ifstream ifs(absfile);
444  if (!ifs) LFATAL("Could not open file " << absfile);
445  setParamsFromStream(ifs, absfile);
446 }
447 
448 // ######################################################################
449 std::istream & jevois::Component::setParamsFromStream(std::istream & is,std::string const & absfile)
450 {
451  size_t linenum = 1;
452  for (std::string line; std::getline(is, line); /* */)
453  {
454  // Skip over comments:
455  if (line.length() && line[0] == '#') { ++linenum; continue; }
456 
457  // Skip over empty lines:
458  if (std::all_of(line.begin(), line.end(), [](unsigned char c) { return std::isspace(c); })) { ++linenum; continue; }
459 
460  // Parse descriptor=value:
461  size_t idx = line.find('=');
462  if (idx == line.npos) LFATAL("No '=' symbol found at line " << linenum << " in " << absfile);
463  if (idx == 0) LFATAL("No parameter descriptor found at line " << linenum << " in " << absfile);
464  if (idx == line.length() - 1) LFATAL("No parameter value found at line " << linenum << " in " << absfile);
465 
466  std::string desc = line.substr(0, idx);
467  std::string val = line.substr(idx + 1);
468 
469  // Be nice and clean whitespace at start and end (not in the middle):
470  while (desc.length() > 0 && std::isspace(desc[0])) desc.erase(0, 1);
471  while (desc.length() > 0 && std::isspace(desc[desc.length()-1])) desc.erase(desc.length()-1, 1);
472  if (desc.empty()) LFATAL("Invalid blank parameter descriptor at line " << linenum << " in " << absfile);
473 
474  while (val.length() > 0 && std::isspace(val[0])) val.erase(0, 1);
475  while (val.length() > 0 && std::isspace(val[val.length()-1])) val.erase(val.length()-1, 1);
476  if (val.empty()) LFATAL("Invalid blank parameter value at line " << linenum << " in " << absfile);
477 
478  // Ok, set that param:
479  setParamString(desc, val);
480 
481  ++linenum;
482  }
483  return is;
484 }
485 
486 // ######################################################################
487 void jevois::Component::setPath(std::string const & path)
488 {
489  JEVOIS_TRACE(5);
490 
491  // First all subComponents:
492  {
493  boost::shared_lock<boost::shared_mutex> lck(itsSubMtx);
494  for (std::shared_ptr<jevois::Component> c : itsSubComponents) c->setPath(path);
495  }
496 
497  itsPath = path;
498 }
499 
500 // ######################################################################
501 std::string jevois::Component::absolutePath(std::string const & path)
502 {
503  JEVOIS_TRACE(6);
504 
505  // If path is empty, return itsPath (be it empty of not):
506  if (path.empty()) return itsPath;
507 
508  // no-op if the given path is already absolute:
509  if (path[0] == '/') return path;
510 
511  // no-op if itsPath is empty:
512  if (itsPath.empty()) return path;
513 
514  // We know itsPath is not empty and path does not start with a / and is not empty; concatenate both:
515  return itsPath + '/' + path;
516 }
517 
518 // ######################################################################
519 void jevois::Component::populateHelpMessage(std::string const & cname,
520  std::unordered_map<std::string,
521  std::unordered_map<std::string,
522  std::vector<std::pair<std::string, std::string> > > > & helplist,
523  bool recurse) const
524 {
525  JEVOIS_TRACE(9);
526 
527  std::string const compname = cname.empty() ? itsInstanceName : cname + ':' + itsInstanceName;
528 
529  // First add our own params:
530  {
531  boost::shared_lock<boost::shared_mutex> lck(itsParamMtx);
532  for (auto const & p : itsParameterList)
533  {
534  jevois::ParameterSummary const ps = p.second->summary();
535 
536  if (ps.frozen) continue; // skip frozen parameters
537 
538  std::string const key1 = ps.category + ": "+ ps.categorydescription;
539  std::string const key2 = " --" + ps.name + " (" + ps.valuetype + ") default=[" + ps.defaultvalue + "]" +
540  (ps.validvalues == "None:[]" ? "\n" : " " + ps.validvalues + "\n") + " " + ps.description;
541  std::string val = "";
542  if (ps.value != ps.defaultvalue) val = "value=["+ps.value+']';
543  helplist[key1][key2].push_back(std::make_pair(compname, val));
544  }
545  }
546 
547  // Then recurse through our subcomponents:
548  if (recurse)
549  {
550  boost::shared_lock<boost::shared_mutex> lck(itsSubMtx);
551  for (std::shared_ptr<jevois::Component> c : itsSubComponents) c->populateHelpMessage(compname, helplist);
552  }
553 }
554 
555 // ######################################################################
556 std::string jevois::Component::computeInstanceName(std::string const & instance, std::string const & classname) const
557 {
558  JEVOIS_TRACE(9);
559 
560  std::string inst = instance;
561 
562  // If empty instance, replace it by the classname:
563  if (inst.empty())
564  {
565  // Use the class name:
566  inst = classname + '#';
567 
568  // Remove any namespace:: prefix:
569  size_t const idxx = inst.rfind(':'); if (idxx != inst.npos) inst = inst.substr(idxx + 1);
570  }
571 
572  // Replace all # characters by some number, if necessary:
573  std::vector<std::string> vec = jevois::split(inst, "#");
574  if (vec.size() > 1)
575  {
576  // First try to have no numbers in there:
577  inst = jevois::join(vec, ""); bool found = false;
578  for (std::shared_ptr<Component> const & c : itsSubComponents)
579  if (c->instanceName() == inst) { found = true; break; }
580 
581  if (found)
582  {
583  // Ok, we have some conflict, so let's add some numbers where the # signs were:
584  inst = "";
585  for (std::string const & v : vec)
586  {
587  if (v.empty()) continue;
588 
589  inst += v;
590  size_t largestId = 1;
591 
592  while (true)
593  {
594  std::string stem = inst + std::to_string(largestId);
595  bool gotit = false;
596 
597  for (std::shared_ptr<Component> const & c : itsSubComponents)
598  if (c->instanceName() == stem) { gotit = true; break; }
599 
600  if (gotit == false) { inst = stem; break; }
601 
602  ++largestId;
603  }
604  }
605  }
606 
607  LDEBUG("Using automatic instance name [" << inst << ']');
608  return inst;
609  }
610 
611  // If we have not returned yet, no # was given. Throw if there is a conflict:
612  for (std::shared_ptr<Component> const & c : itsSubComponents)
613  if (c->instanceName() == inst)
614  throw std::runtime_error("Provided instance name [" + instance + "] clashes with existing sub-components.");
615 
616  return inst;
617 }
618 
#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:90
std::string validvalues
Description of the parameter's valid values specification, as a string.
Definition: Parameter.H:105
std::string description
Description of the parameter.
Definition: Parameter.H:93
std::vector< std::string > setParamString(std::string const &paramdescriptor, std::string const &val)
Set a parameter value, by string.
Definition: Component.C:346
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:65
ParameterSummary provides a summary about a parameter.
Definition: Parameter.H:83
std::string value
Current value of the parameter, as a string.
Definition: Parameter.H:102
std::vector< std::pair< std::string, std::string > > getParamString(std::string const &paramdescriptor) const
Get a parameter value, by string.
Definition: Component.C:373
std::string defaultvalue
Default value of the parameter, as a string.
Definition: Parameter.H:99
void setPath(std::string const &path)
Assign a filesystem path to this component.
Definition: Component.C:487
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:362
void setParamsFromFile(std::string const &filename)
Set some parameters from a file.
Definition: Component.C:440
#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:400
#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:75
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:96
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:389
virtual ~Component()
Virtual destructor for safe inheritance.
Definition: Component.C:52
bool frozen
Flag that indicates whether parameter is frozen.
Definition: Parameter.H:114
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:121
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:449
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:108
void unFreezeParam(std::string const &paramdescriptor)
Unfreeze a parameter, by name, see ParameterBase::unFreeze()
Definition: Component.C:412
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:424
void unFreezeAllParams()
Unfreeze all parameters.
Definition: Component.C:432
std::string categorydescription
Category description.
Definition: Parameter.H:111
std::string absolutePath(std::string const &path="")
If given path is relative (not starting with /), prepend the Component path to it.
Definition: Component.C:501