JeVois  1.5
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
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 // ######################################################################
26 { }
27 
28 // ######################################################################
30 {
31  boost::upgrade_lock<boost::shared_mutex> uplck(itsParamMtx);
32  if (itsParameterList.find(param->name()) != itsParameterList.end())
33  LFATAL("Duplicate Parameter Name: " << param->name());
34 
35  boost::upgrade_to_unique_lock<boost::shared_mutex> ulck(uplck);
36  itsParameterList[param->name()] = param;
37 
38  LDEBUG("Added Parameter [" << param->name() << ']');
39 }
40 
41 // ######################################################################
43 {
44  boost::upgrade_lock<boost::shared_mutex> uplck(itsParamMtx);
45  auto itr = itsParameterList.find(param->name());
46 
47  if (itr == itsParameterList.end())
48  LERROR("Parameter " << param->name() << " not owned by this component -- NOT REMOVED");
49  else
50  {
51  boost::upgrade_to_unique_lock<boost::shared_mutex> ulck(uplck);
52  itsParameterList.erase(itr);
53  }
54 
55  LDEBUG("Removed Parameter [" << param->name() << ']');
56 }
57 
58 // ######################################################################
60 {
61  boost::shared_lock<boost::shared_mutex> _(itsParamMtx);
62 
63  for (auto const & pl : itsParameterList) pl.second->callbackInitCall();
64 }
#define LDEBUG(msg)
Convenience macro for users to print out console or syslog messages, DEBUG level. ...
Definition: Log.H:155
virtual ~ParameterRegistry()
Virtual destructor for safe inheritance.
#define LERROR(msg)
Convenience macro for users to print out console or syslog messages, ERROR level. ...
Definition: Log.H:193
void addParameter(ParameterBase *const param)
The Parameter class uses this method to register itself on construction with its owning Component...
Base class for Parameter.
Definition: Parameter.H:121
#define LFATAL(msg)
Convenience macro for users to print out console or syslog messages, FATAL level. ...
Definition: Log.H:212
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...
virtual std::string const & name() const =0
Get the parameter name.