23#include <boost/thread.hpp>
27#include <unordered_map>
249 template <
class Comp,
typename... Args>
256 template <
class Comp>
269 template <
class Comp = jevois::Component>
342 template <
typename T>
343 std::vector<std::string>
setParamVal(std::string
const & paramdescriptor, T
const & val);
348 template <
typename T>
369 template <
typename T>
370 std::vector<std::pair<std::string, T> >
getParamVal(std::string
const & paramdescriptor)
const;
383 template <
typename T>
392 std::vector<std::string>
setParamString(std::string
const & paramdescriptor, std::string
const & val);
406 std::vector<std::pair<std::string, std::string> >
getParamString(std::string
const & paramdescriptor)
const;
414 void freezeParam(std::string
const & paramdescriptor,
bool doit);
435 virtual void paramInfo(std::shared_ptr<UserInterface> s, std::map<std::string, std::string> & categs,
436 bool skipFrozen, std::string
const & cname =
"", std::string
const & pfx =
"");
440 std::string
const & cname =
"");
448 template <
typename T>
449 std::shared_ptr<DynamicParameter<T>>
458 template <
typename T,
template <
typename>
class ValidValuesSpec>
459 std::shared_ptr<DynamicParameter<T>>
466 template <
typename T>
468 bool callnow =
true);
484 void setPath(std::string
const & path);
488 std::filesystem::path
absolutePath(std::filesystem::path
const & path =
"");
517 mutable boost::shared_mutex itsMtx;
520 std::vector<std::shared_ptr<Component> > itsSubComponents;
523 mutable boost::shared_mutex itsSubMtx;
526 void populateHelpMessage(std::string
const & cname,
527 std::unordered_map<std::string ,
528 std::unordered_map<std::string ,
529 std::vector<std::pair<std::string /* component */, std::string /* value */ > > > > &
530 helplist,
bool recurse =
true)
const;
539 void setInitialized();
545 virtual void uninit();
551 void setUninitialized();
554 void runPostUninit();
557 mutable boost::shared_mutex itsMetaMtx;
558 std::string
const itsClassName;
559 std::string itsInstanceName;
562 volatile bool itsInitialized;
568 void findParamAndActOnIt(std::string
const & descrip,
570 std::function<
bool()> empty)
const;
571 void findParamAndActOnIt(std::vector<std::string>
const & descrip,
bool recur,
size_t idx,
572 std::string
const & unrolled,
582 std::string computeInstanceName(std::string
const & instance, std::string
const & classname =
"")
const;
588 void doRemoveSubComponent(std::vector<std::shared_ptr<Component> >::iterator & itr,
589 boost::upgrade_lock<boost::shared_mutex> & uplck,
590 std::string
const & displayname);
593 std::map<std::string , std::shared_ptr<ParameterBase>> itsDynParams;
594 mutable std::mutex itsDynParMtx;
616#include <jevois/Component/details/ComponentImpl.H>
A component of a model hierarchy.
std::vector< std::string > setParamString(std::string const ¶mdescriptor, std::string const &val)
Set a parameter value, by string.
std::filesystem::path absolutePath(std::filesystem::path const &path="")
If given path is relative (not starting with /), prepend the Component path to it.
std::string descriptor() const
Get our full descriptor (including all parents) as [Instancename]:[...]:[...].
void setParamValUnique(std::string const ¶mdescriptor, T const &val)
Set a parameter value, simple version assuming only one parameter match.
std::vector< std::pair< std::string, std::string > > getParamString(std::string const ¶mdescriptor) const
Get a parameter value, by string.
std::vector< std::string > setParamVal(std::string const ¶mdescriptor, T const &val)
Set a parameter value.
void freezeParam(std::string const ¶mdescriptor, bool doit)
Freeze/unfreeze a parameter, by name, see ParameterBase::freeze()
bool initialized() const
Has this component been initialized yet?
std::shared_ptr< Comp > getSubComponent(std::string const &instance) const
Get a sub-component by instance name.
std::string const & instanceName() const
The instance name of this component.
std::shared_ptr< DynamicParameter< T > > addDynamicParameter(std::string const &name, std::string const &description, T const &defaultValue, ParameterCategory const &category)
Add a new parameter after the Component has already been constructed.
void foreachParam(std::function< void(std::string const &compname, ParameterBase *p)> func, std::string const &cname="")
Run a function on every param we hold.
std::istream & setParamsFromStream(std::istream &is, std::string const &absfile)
Set some parameters from an open stream.
void freezeAllParams(bool doit)
Freeze all parameters.
void removeSubComponent(std::shared_ptr< Comp > &component)
Remove a sub-Component from this Component, by shared_ptr.
bool isTopLevel() const
Returns true if this component is top-level, i.e., its parent is jevois::Manager.
std::shared_ptr< Comp > addSubComponent(std::string const &instance, Args &&...args)
Pseudo-constructor: construct and add another component as a subcomponent of this one.
std::vector< std::pair< std::string, T > > getParamVal(std::string const ¶mdescriptor) const
Get parameter(s) value(s) by descriptor.
virtual void preUninit()
Called before all sub-Components are uninit()ed.
void setPath(std::string const &path)
Assign a filesystem path to this component.
std::shared_ptr< DynamicParameter< T > > addDynamicParameter(std::string const &name, std::string const &description, T const &defaultValue, ValidValuesSpec< T > const &validValuesSpec, ParameterCategory const &category)
Add a new parameter after the Component has already been constructed.
virtual ~Component()
Virtual destructor for safe inheritance.
void setDynamicParameterCallback(std::string const &name, std::function< void(T const &)> cb, bool callnow=true)
Register a callback with a previously created dynamic parameter.
virtual void postUninit()
Called after all sub-Components are uninit()ed.
virtual void preInit()
Called before all sub-Components are init()ed.
virtual void paramInfo(std::shared_ptr< UserInterface > s, std::map< std::string, std::string > &categs, bool skipFrozen, std::string const &cname="", std::string const &pfx="")
Get machine-oriented descriptions of all parameters.
std::string const & className() const
The class name of this component.
std::string getParamStringUnique(std::string const ¶mdescriptor) const
Get a parameter value by string, simple version assuming only one parameter match.
virtual void postInit()
Called after all sub-Components are init()ed.
void setParamsFromFile(std::string const &filename)
Set some parameters from a file.
void removeDynamicParameter(std::string const &name, bool throw_if_not_found=true)
Remove a previously added dynamic parameter.
void setParamStringUnique(std::string const ¶mdescriptor, std::string const &val)
Set a parameter value by string, simple version assuming only one parameter match.
T getParamValUnique(std::string const ¶mdescriptor) const
Get a parameter value, simple version assuming only one parameter match.
JeVois processing engine - gets images from camera sensor, processes them, and sends results over USB...
size_t frameNum()
Get the current video processing frame number.
Manager of a hierarchy of Component objects.
Virtual base class for a vision processing module.
Base class for Parameter.
A changeable parameter for a Component, core class.
A simple registry of all parameters associated with a Component.
friend class Component
Allow Component and DynamicParameter to access our registry data, everyone else is locked out.
Main namespace for all JeVois classes and functions.
A category to which multiple ParameterDef definitions can belong.