JeVois  1.20
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
ParameterRegistry.H
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 #pragma once
21 
22 #include <map>
23 #include <string>
24 #include <boost/thread/shared_mutex.hpp>
25 
26 namespace jevois
27 {
28  class Component;
29  class ParameterBase;
30 
31  //! A simple registry of all parameters associated with a Component
32  /*! This registry allows one to loop over or search for given parameters in a Component. \ingroup parameter */
34  {
35  public:
36  //! Virtual destructor for safe inheritance
37  virtual ~ParameterRegistry();
38 
39  protected:
40  //! The Parameter class uses this method to register itself on construction with its owning Component
41  void addParameter(ParameterBase * const param);
42 
43  //! The Parameter class uses this method to un-register itself on destruction with its owning Component
44  void removeParameter(ParameterBase * const param);
45 
46  //! For all parameters that have a callback which has never been called, call it with the default param value
47  void callbackInitCall();
48 
49  private:
50  //! Allow Component and DynamicParameter to access our registry data, everyone else is locked out
51  friend class Component;
52  template <typename T> friend class DynamicParameter;
53 
54  // A list of pointers to all Parameters registered with this Component
55  std::map<std::string, ParameterBase *> itsParameterList;
56 
57  // Mutex to protect our list of parameters
58  mutable boost::shared_mutex itsParamMtx;
59  };
60 
61 } // namespace jevois
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
jevois::ParameterRegistry::~ParameterRegistry
virtual ~ParameterRegistry()
Virtual destructor for safe inheritance.
Definition: ParameterRegistry.C:25
jevois::Component
A component of a model hierarchy.
Definition: Component.H:181
jevois::ParameterBase
Base class for Parameter.
Definition: Parameter.H:121
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
jevois
Definition: Concepts.dox:1
jevois::ParameterRegistry
A simple registry of all parameters associated with a Component.
Definition: ParameterRegistry.H:33
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
jevois::DynamicParameter
Dynamic parameter added to a component at runtime.
Definition: Parameter.H:396