corobot_cameraConfig.h
Go to the documentation of this file.
00001 //#line 2 "/opt/ros/hydro/share/dynamic_reconfigure/templates/ConfigType.h.template"
00002 // *********************************************************
00003 // 
00004 // File autogenerated for the corobot_camera package 
00005 // by the dynamic_reconfigure package.
00006 // Please do not edit.
00007 // 
00008 // ********************************************************/
00009 
00010 /***********************************************************
00011  * Software License Agreement (BSD License)
00012  *
00013  *  Copyright (c) 2008, Willow Garage, Inc.
00014  *  All rights reserved.
00015  *
00016  *  Redistribution and use in source and binary forms, with or without
00017  *  modification, are permitted provided that the following conditions
00018  *  are met:
00019  *
00020  *   * Redistributions of source code must retain the above copyright
00021  *     notice, this list of conditions and the following disclaimer.
00022  *   * Redistributions in binary form must reproduce the above
00023  *     copyright notice, this list of conditions and the following
00024  *     disclaimer in the documentation and/or other materials provided
00025  *     with the distribution.
00026  *   * Neither the name of the Willow Garage nor the names of its
00027  *     contributors may be used to endorse or promote products derived
00028  *     from this software without specific prior written permission.
00029  *
00030  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00031  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00032  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00033  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00034  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00035  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00036  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00037  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00038  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00039  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00040  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00041  *  POSSIBILITY OF SUCH DAMAGE.
00042  ***********************************************************/
00043 
00044 // Author: Blaise Gassend
00045 
00046 
00047 #ifndef __corobot_camera__COROBOT_CAMERACONFIG_H__
00048 #define __corobot_camera__COROBOT_CAMERACONFIG_H__
00049 
00050 #include <dynamic_reconfigure/config_tools.h>
00051 #include <limits>
00052 #include <ros/node_handle.h>
00053 #include <dynamic_reconfigure/ConfigDescription.h>
00054 #include <dynamic_reconfigure/ParamDescription.h>
00055 #include <dynamic_reconfigure/Group.h>
00056 #include <dynamic_reconfigure/config_init_mutex.h>
00057 #include <boost/any.hpp>
00058 
00059 namespace corobot_camera
00060 {
00061   class corobot_cameraConfigStatics;
00062   
00063   class corobot_cameraConfig
00064   {
00065   public:
00066     class AbstractParamDescription : public dynamic_reconfigure::ParamDescription
00067     {
00068     public:
00069       AbstractParamDescription(std::string n, std::string t, uint32_t l, 
00070           std::string d, std::string e)
00071       {
00072         name = n;
00073         type = t;
00074         level = l;
00075         description = d;
00076         edit_method = e;
00077       }
00078       
00079       virtual void clamp(corobot_cameraConfig &config, const corobot_cameraConfig &max, const corobot_cameraConfig &min) const = 0;
00080       virtual void calcLevel(uint32_t &level, const corobot_cameraConfig &config1, const corobot_cameraConfig &config2) const = 0;
00081       virtual void fromServer(const ros::NodeHandle &nh, corobot_cameraConfig &config) const = 0;
00082       virtual void toServer(const ros::NodeHandle &nh, const corobot_cameraConfig &config) const = 0;
00083       virtual bool fromMessage(const dynamic_reconfigure::Config &msg, corobot_cameraConfig &config) const = 0;
00084       virtual void toMessage(dynamic_reconfigure::Config &msg, const corobot_cameraConfig &config) const = 0;
00085       virtual void getValue(const corobot_cameraConfig &config, boost::any &val) const = 0;
00086     };
00087 
00088     typedef boost::shared_ptr<AbstractParamDescription> AbstractParamDescriptionPtr;
00089     typedef boost::shared_ptr<const AbstractParamDescription> AbstractParamDescriptionConstPtr;
00090     
00091     template <class T>
00092     class ParamDescription : public AbstractParamDescription
00093     {
00094     public:
00095       ParamDescription(std::string name, std::string type, uint32_t level, 
00096           std::string description, std::string edit_method, T corobot_cameraConfig::* f) :
00097         AbstractParamDescription(name, type, level, description, edit_method),
00098         field(f)
00099       {}
00100 
00101       T (corobot_cameraConfig::* field);
00102 
00103       virtual void clamp(corobot_cameraConfig &config, const corobot_cameraConfig &max, const corobot_cameraConfig &min) const
00104       {
00105         if (config.*field > max.*field)
00106           config.*field = max.*field;
00107         
00108         if (config.*field < min.*field)
00109           config.*field = min.*field;
00110       }
00111 
00112       virtual void calcLevel(uint32_t &comb_level, const corobot_cameraConfig &config1, const corobot_cameraConfig &config2) const
00113       {
00114         if (config1.*field != config2.*field)
00115           comb_level |= level;
00116       }
00117 
00118       virtual void fromServer(const ros::NodeHandle &nh, corobot_cameraConfig &config) const
00119       {
00120         nh.getParam(name, config.*field);
00121       }
00122 
00123       virtual void toServer(const ros::NodeHandle &nh, const corobot_cameraConfig &config) const
00124       {
00125         nh.setParam(name, config.*field);
00126       }
00127 
00128       virtual bool fromMessage(const dynamic_reconfigure::Config &msg, corobot_cameraConfig &config) const
00129       {
00130         return dynamic_reconfigure::ConfigTools::getParameter(msg, name, config.*field);
00131       }
00132 
00133       virtual void toMessage(dynamic_reconfigure::Config &msg, const corobot_cameraConfig &config) const
00134       {
00135         dynamic_reconfigure::ConfigTools::appendParameter(msg, name, config.*field);
00136       }
00137 
00138       virtual void getValue(const corobot_cameraConfig &config, boost::any &val) const
00139       {
00140         val = config.*field;
00141       }
00142     };
00143 
00144     class AbstractGroupDescription : public dynamic_reconfigure::Group
00145     {
00146       public:
00147       AbstractGroupDescription(std::string n, std::string t, int p, int i, bool s)
00148       {
00149         name = n;
00150         type = t;
00151         parent = p;
00152         state = s;
00153         id = i;
00154       }
00155 
00156       std::vector<AbstractParamDescriptionConstPtr> abstract_parameters;
00157       bool state;
00158 
00159       virtual void toMessage(dynamic_reconfigure::Config &msg, const boost::any &config) const = 0;
00160       virtual bool fromMessage(const dynamic_reconfigure::Config &msg, boost::any &config) const =0;
00161       virtual void updateParams(boost::any &cfg, corobot_cameraConfig &top) const= 0;
00162       virtual void setInitialState(boost::any &cfg) const = 0;
00163 
00164 
00165       void convertParams()
00166       {
00167         for(std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = abstract_parameters.begin(); i != abstract_parameters.end(); i++)
00168         {
00169           parameters.push_back(dynamic_reconfigure::ParamDescription(**i));
00170         }
00171       }
00172     };
00173 
00174     typedef boost::shared_ptr<AbstractGroupDescription> AbstractGroupDescriptionPtr;
00175     typedef boost::shared_ptr<const AbstractGroupDescription> AbstractGroupDescriptionConstPtr;
00176 
00177     template<class T, class PT>
00178     class GroupDescription : public AbstractGroupDescription
00179     {
00180     public:
00181       GroupDescription(std::string name, std::string type, int parent, int id, bool s, T PT::* f) : AbstractGroupDescription(name, type, parent, id, s), field(f)
00182       {
00183       }
00184 
00185       GroupDescription(const GroupDescription<T, PT>& g): AbstractGroupDescription(g.name, g.type, g.parent, g.id, g.state), field(g.field), groups(g.groups)
00186       {
00187         parameters = g.parameters;
00188         abstract_parameters = g.abstract_parameters;
00189       }
00190 
00191       virtual bool fromMessage(const dynamic_reconfigure::Config &msg, boost::any &cfg) const
00192       {
00193         PT* config = boost::any_cast<PT*>(cfg);
00194         if(!dynamic_reconfigure::ConfigTools::getGroupState(msg, name, (*config).*field))
00195           return false;
00196         
00197         for(std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = groups.begin(); i != groups.end(); i++) 
00198         {
00199           boost::any n = &((*config).*field);
00200           if(!(*i)->fromMessage(msg, n))
00201             return false;
00202         }
00203 
00204         return true;
00205       }
00206 
00207       virtual void setInitialState(boost::any &cfg) const
00208       {
00209         PT* config = boost::any_cast<PT*>(cfg);
00210         T* group = &((*config).*field);
00211         group->state = state;
00212 
00213         for(std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = groups.begin(); i != groups.end(); i++)
00214         {
00215           boost::any n = boost::any(&((*config).*field));
00216           (*i)->setInitialState(n);
00217         }
00218 
00219       }
00220       
00221       virtual void updateParams(boost::any &cfg, corobot_cameraConfig &top) const
00222       {
00223         PT* config = boost::any_cast<PT*>(cfg);
00224 
00225         T* f = &((*config).*field);
00226         f->setParams(top, abstract_parameters);
00227 
00228         for(std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = groups.begin(); i != groups.end(); i++) 
00229         {
00230           boost::any n = &((*config).*field);
00231           (*i)->updateParams(n, top);
00232         }
00233       }
00234 
00235       virtual void toMessage(dynamic_reconfigure::Config &msg, const boost::any &cfg) const
00236       {
00237         const PT config = boost::any_cast<PT>(cfg);
00238         dynamic_reconfigure::ConfigTools::appendGroup<T>(msg, name, id, parent, config.*field);
00239 
00240         for(std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = groups.begin(); i != groups.end(); i++)
00241         {
00242           (*i)->toMessage(msg, config.*field);
00243         }
00244       }
00245 
00246       T (PT::* field);
00247       std::vector<corobot_cameraConfig::AbstractGroupDescriptionConstPtr> groups;
00248     };
00249     
00250 class DEFAULT
00251 {
00252   public:
00253     DEFAULT()
00254     {
00255       state = true;
00256       name = "Default";
00257     }
00258 
00259     void setParams(corobot_cameraConfig &config, const std::vector<AbstractParamDescriptionConstPtr> params)
00260     {
00261       for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = params.begin(); i != params.end(); i++)
00262       {
00263         boost::any val;
00264         (*i)->getValue(config, val);
00265 
00266         if("camera_activated"==(*i)->name){camera_activated = boost::any_cast<bool>(val);}
00267       }
00268     }
00269 
00270     bool camera_activated;
00271 
00272     bool state;
00273     std::string name;
00274 
00275     
00276 }groups;
00277 
00278 
00279 
00280 //#line 259 "/opt/ros/hydro/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator.py"
00281       bool camera_activated;
00282 //#line 255 "/opt/ros/hydro/share/dynamic_reconfigure/templates/ConfigType.h.template"
00283 
00284     bool __fromMessage__(dynamic_reconfigure::Config &msg)
00285     {
00286       const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00287       const std::vector<AbstractGroupDescriptionConstPtr> &__group_descriptions__ = __getGroupDescriptions__();
00288 
00289       int count = 0;
00290       for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00291         if ((*i)->fromMessage(msg, *this))
00292           count++;
00293 
00294       for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = __group_descriptions__.begin(); i != __group_descriptions__.end(); i ++)
00295       {
00296         if ((*i)->id == 0)
00297         {
00298           boost::any n = boost::any(this);
00299           (*i)->updateParams(n, *this);
00300           (*i)->fromMessage(msg, n);
00301         }
00302       }
00303 
00304       if (count != dynamic_reconfigure::ConfigTools::size(msg))
00305       {
00306         ROS_ERROR("corobot_cameraConfig::__fromMessage__ called with an unexpected parameter.");
00307         ROS_ERROR("Booleans:");
00308         for (unsigned int i = 0; i < msg.bools.size(); i++)
00309           ROS_ERROR("  %s", msg.bools[i].name.c_str());
00310         ROS_ERROR("Integers:");
00311         for (unsigned int i = 0; i < msg.ints.size(); i++)
00312           ROS_ERROR("  %s", msg.ints[i].name.c_str());
00313         ROS_ERROR("Doubles:");
00314         for (unsigned int i = 0; i < msg.doubles.size(); i++)
00315           ROS_ERROR("  %s", msg.doubles[i].name.c_str());
00316         ROS_ERROR("Strings:");
00317         for (unsigned int i = 0; i < msg.strs.size(); i++)
00318           ROS_ERROR("  %s", msg.strs[i].name.c_str());
00319         // @todo Check that there are no duplicates. Make this error more
00320         // explicit.
00321         return false;
00322       }
00323       return true;
00324     }
00325 
00326     // This version of __toMessage__ is used during initialization of
00327     // statics when __getParamDescriptions__ can't be called yet.
00328     void __toMessage__(dynamic_reconfigure::Config &msg, const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__, const std::vector<AbstractGroupDescriptionConstPtr> &__group_descriptions__) const
00329     {
00330       dynamic_reconfigure::ConfigTools::clear(msg);
00331       for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00332         (*i)->toMessage(msg, *this);
00333 
00334       for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = __group_descriptions__.begin(); i != __group_descriptions__.end(); i++)
00335       {
00336         if((*i)->id == 0)
00337         {
00338           (*i)->toMessage(msg, *this);
00339         }
00340       }
00341     }
00342     
00343     void __toMessage__(dynamic_reconfigure::Config &msg) const
00344     {
00345       const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00346       const std::vector<AbstractGroupDescriptionConstPtr> &__group_descriptions__ = __getGroupDescriptions__();
00347       __toMessage__(msg, __param_descriptions__, __group_descriptions__);
00348     }
00349     
00350     void __toServer__(const ros::NodeHandle &nh) const
00351     {
00352       const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00353       for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00354         (*i)->toServer(nh, *this);
00355     }
00356 
00357     void __fromServer__(const ros::NodeHandle &nh)
00358     {
00359       static bool setup=false;
00360 
00361       const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00362       for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00363         (*i)->fromServer(nh, *this);
00364 
00365       const std::vector<AbstractGroupDescriptionConstPtr> &__group_descriptions__ = __getGroupDescriptions__();
00366       for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = __group_descriptions__.begin(); i != __group_descriptions__.end(); i++){
00367         if (!setup && (*i)->id == 0) {
00368           setup = true;
00369           boost::any n = boost::any(this);
00370           (*i)->setInitialState(n);
00371         }
00372       }
00373     }
00374 
00375     void __clamp__()
00376     {
00377       const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00378       const corobot_cameraConfig &__max__ = __getMax__();
00379       const corobot_cameraConfig &__min__ = __getMin__();
00380       for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00381         (*i)->clamp(*this, __max__, __min__);
00382     }
00383 
00384     uint32_t __level__(const corobot_cameraConfig &config) const
00385     {
00386       const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00387       uint32_t level = 0;
00388       for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00389         (*i)->calcLevel(level, config, *this);
00390       return level;
00391     }
00392     
00393     static const dynamic_reconfigure::ConfigDescription &__getDescriptionMessage__();
00394     static const corobot_cameraConfig &__getDefault__();
00395     static const corobot_cameraConfig &__getMax__();
00396     static const corobot_cameraConfig &__getMin__();
00397     static const std::vector<AbstractParamDescriptionConstPtr> &__getParamDescriptions__();
00398     static const std::vector<AbstractGroupDescriptionConstPtr> &__getGroupDescriptions__();
00399     
00400   private:
00401     static const corobot_cameraConfigStatics *__get_statics__();
00402   };
00403   
00404   template <> // Max and min are ignored for strings.
00405   inline void corobot_cameraConfig::ParamDescription<std::string>::clamp(corobot_cameraConfig &config, const corobot_cameraConfig &max, const corobot_cameraConfig &min) const
00406   {
00407     return;
00408   }
00409 
00410   class corobot_cameraConfigStatics
00411   {
00412     friend class corobot_cameraConfig;
00413     
00414     corobot_cameraConfigStatics()
00415     {
00416 corobot_cameraConfig::GroupDescription<corobot_cameraConfig::DEFAULT, corobot_cameraConfig> Default("Default", "", 0, 0, true, &corobot_cameraConfig::groups);
00417 //#line 259 "/opt/ros/hydro/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator.py"
00418       __min__.camera_activated = 0;
00419 //#line 259 "/opt/ros/hydro/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator.py"
00420       __max__.camera_activated = 1;
00421 //#line 259 "/opt/ros/hydro/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator.py"
00422       __default__.camera_activated = 1;
00423 //#line 259 "/opt/ros/hydro/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator.py"
00424       Default.abstract_parameters.push_back(corobot_cameraConfig::AbstractParamDescriptionConstPtr(new corobot_cameraConfig::ParamDescription<bool>("camera_activated", "bool", 0, "Activate the camera or not", "", &corobot_cameraConfig::camera_activated)));
00425 //#line 259 "/opt/ros/hydro/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator.py"
00426       __param_descriptions__.push_back(corobot_cameraConfig::AbstractParamDescriptionConstPtr(new corobot_cameraConfig::ParamDescription<bool>("camera_activated", "bool", 0, "Activate the camera or not", "", &corobot_cameraConfig::camera_activated)));
00427 //#line 233 "/opt/ros/hydro/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator.py"
00428       Default.convertParams();
00429 //#line 233 "/opt/ros/hydro/lib/python2.7/dist-packages/dynamic_reconfigure/parameter_generator.py"
00430       __group_descriptions__.push_back(corobot_cameraConfig::AbstractGroupDescriptionConstPtr(new corobot_cameraConfig::GroupDescription<corobot_cameraConfig::DEFAULT, corobot_cameraConfig>(Default)));
00431 //#line 390 "/opt/ros/hydro/share/dynamic_reconfigure/templates/ConfigType.h.template"
00432     
00433       for (std::vector<corobot_cameraConfig::AbstractGroupDescriptionConstPtr>::const_iterator i = __group_descriptions__.begin(); i != __group_descriptions__.end(); i++)
00434       {
00435         __description_message__.groups.push_back(**i);
00436       }
00437       __max__.__toMessage__(__description_message__.max, __param_descriptions__, __group_descriptions__); 
00438       __min__.__toMessage__(__description_message__.min, __param_descriptions__, __group_descriptions__); 
00439       __default__.__toMessage__(__description_message__.dflt, __param_descriptions__, __group_descriptions__); 
00440     }
00441     std::vector<corobot_cameraConfig::AbstractParamDescriptionConstPtr> __param_descriptions__;
00442     std::vector<corobot_cameraConfig::AbstractGroupDescriptionConstPtr> __group_descriptions__;
00443     corobot_cameraConfig __max__;
00444     corobot_cameraConfig __min__;
00445     corobot_cameraConfig __default__;
00446     dynamic_reconfigure::ConfigDescription __description_message__;
00447 
00448     static const corobot_cameraConfigStatics *get_instance()
00449     {
00450       // Split this off in a separate function because I know that
00451       // instance will get initialized the first time get_instance is
00452       // called, and I am guaranteeing that get_instance gets called at
00453       // most once.
00454       static corobot_cameraConfigStatics instance;
00455       return &instance;
00456     }
00457   };
00458 
00459   inline const dynamic_reconfigure::ConfigDescription &corobot_cameraConfig::__getDescriptionMessage__() 
00460   {
00461     return __get_statics__()->__description_message__;
00462   }
00463 
00464   inline const corobot_cameraConfig &corobot_cameraConfig::__getDefault__()
00465   {
00466     return __get_statics__()->__default__;
00467   }
00468   
00469   inline const corobot_cameraConfig &corobot_cameraConfig::__getMax__()
00470   {
00471     return __get_statics__()->__max__;
00472   }
00473   
00474   inline const corobot_cameraConfig &corobot_cameraConfig::__getMin__()
00475   {
00476     return __get_statics__()->__min__;
00477   }
00478   
00479   inline const std::vector<corobot_cameraConfig::AbstractParamDescriptionConstPtr> &corobot_cameraConfig::__getParamDescriptions__()
00480   {
00481     return __get_statics__()->__param_descriptions__;
00482   }
00483 
00484   inline const std::vector<corobot_cameraConfig::AbstractGroupDescriptionConstPtr> &corobot_cameraConfig::__getGroupDescriptions__()
00485   {
00486     return __get_statics__()->__group_descriptions__;
00487   }
00488 
00489   inline const corobot_cameraConfigStatics *corobot_cameraConfig::__get_statics__()
00490   {
00491     const static corobot_cameraConfigStatics *statics;
00492   
00493     if (statics) // Common case
00494       return statics;
00495 
00496     boost::mutex::scoped_lock lock(dynamic_reconfigure::__init_mutex__);
00497 
00498     if (statics) // In case we lost a race.
00499       return statics;
00500 
00501     statics = corobot_cameraConfigStatics::get_instance();
00502     
00503     return statics;
00504   }
00505 
00506 
00507 }
00508 
00509 #endif // __COROBOT_CAMERARECONFIGURATOR_H__


corobot_camera
Author(s):
autogenerated on Sun Oct 5 2014 23:17:57