JeVois  1.21
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
Loading...
Searching...
No Matches
ParameterRegistry.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
22#include <jevois/Debug/Log.H>
23
24// ######################################################################
27
28// ######################################################################
30{
31 JEVOIS_TRACE(1);
32
33 boost::upgrade_lock<boost::shared_mutex> uplck(itsParamMtx);
34 if (itsParameterList.find(param->name()) != itsParameterList.end())
35 LFATAL("Duplicate Parameter Name: " << param->name());
36
37 boost::upgrade_to_unique_lock<boost::shared_mutex> ulck(uplck);
38 itsParameterList[param->name()] = param;
39
40 LDEBUG("Added Parameter [" << param->name() << ']');
41}
42
43// ######################################################################
45{
46 JEVOIS_TRACE(1);
47
48 boost::upgrade_lock<boost::shared_mutex> uplck(itsParamMtx);
49 auto itr = itsParameterList.find(param->name());
50
51 if (itr == itsParameterList.end())
52 LERROR("Parameter " << param->name() << " not owned by this component -- NOT REMOVED");
53 else
54 {
55 boost::upgrade_to_unique_lock<boost::shared_mutex> ulck(uplck);
56 itsParameterList.erase(itr);
57 }
58
59 LDEBUG("Removed Parameter [" << param->name() << ']');
60}
61
62// ######################################################################
64{
65 JEVOIS_TRACE(1);
66
67 boost::shared_lock<boost::shared_mutex> _(itsParamMtx);
68
69 for (auto const & pl : itsParameterList) pl.second->callbackInitCall();
70}
Base class for Parameter.
Definition Parameter.H:123
virtual std::string const & name() const =0
Get the parameter name.
virtual ~ParameterRegistry()
Virtual destructor for safe inheritance.
void callbackInitCall()
For all parameters that have a callback which has never been called, call it with the default param v...
void removeParameter(ParameterBase *const param)
The Parameter class uses this method to un-register itself on destruction with its owning Component.
void addParameter(ParameterBase *const param)
The Parameter class uses this method to register itself on construction with its owning Component.
#define LFATAL(msg)
Convenience macro for users to print out console or syslog messages, FATAL level.
Definition Log.H:230
#define LDEBUG(msg)
Convenience macro for users to print out console or syslog messages, DEBUG level.
Definition Log.H:173
#define JEVOIS_TRACE(level)
Trace object.
Definition Log.H:296
#define LERROR(msg)
Convenience macro for users to print out console or syslog messages, ERROR level.
Definition Log.H:211