JeVois  1.20
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  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 }
jevois::ParameterRegistry::removeParameter
void removeParameter(ParameterBase *const param)
The Parameter class uses this method to un-register itself on destruction with its owning Component.
Definition: ParameterRegistry.C:44
LDEBUG
#define LDEBUG(msg)
Convenience macro for users to print out console or syslog messages, DEBUG level.
Definition: Log.H:173
jevois::ParameterRegistry::~ParameterRegistry
virtual ~ParameterRegistry()
Virtual destructor for safe inheritance.
Definition: ParameterRegistry.C:25
jevois::ParameterBase
Base class for Parameter.
Definition: Parameter.H:121
jevois::ParameterBase::name
virtual const std::string & name() const =0
Get the parameter name.
JEVOIS_TRACE
#define JEVOIS_TRACE(level)
Trace object.
Definition: Log.H:296
LERROR
#define LERROR(msg)
Convenience macro for users to print out console or syslog messages, ERROR level.
Definition: Log.H:211
jevois::ParameterRegistry::addParameter
void addParameter(ParameterBase *const param)
The Parameter class uses this method to register itself on construction with its owning Component.
Definition: ParameterRegistry.C:29
ParameterRegistry.H
Log.H
Parameter.H
jevois::ParameterRegistry::callbackInitCall
void callbackInitCall()
For all parameters that have a callback which has never been called, call it with the default param v...
Definition: ParameterRegistry.C:63
LFATAL
#define LFATAL(msg)
Convenience macro for users to print out console or syslog messages, FATAL level.