config.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2012, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 #ifndef CONFIG_H
00030 #define CONFIG_H
00031 
00032 #include <stdio.h>
00033 
00034 #include <string>
00035 
00036 #include <boost/shared_ptr.hpp>
00037 
00038 #include <QMap>
00039 #include <QString>
00040 #include <QVariant>
00041 
00042 namespace rviz
00043 {
00044 
00123 class Config
00124 {
00125 private:
00126   class Node;
00127   typedef boost::shared_ptr<Node> NodePtr;
00128 
00129 public:
00131   Config();
00133   Config( const Config& source );
00135   Config( QVariant value );
00136 
00138   void copy( const Config& source );
00139 
00147   enum Type { Map, List, Value, Empty, Invalid };
00148 
00151   Type getType() const;
00152 
00163   void setType( Type new_type );
00164 
00167   bool isValid() const;
00168 
00181   void mapSetValue( const QString& key, QVariant value );
00182 
00186   Config mapMakeChild( const QString& key );
00187 
00192   Config mapGetChild( const QString& key ) const;
00193 
00201   bool mapGetValue( const QString& key, QVariant *value_out ) const;
00202 
00211   bool mapGetInt( const QString& key, int *value_out ) const;
00212 
00221   bool mapGetFloat( const QString& key, float *value_out ) const;
00222 
00231   bool mapGetBool( const QString& key, bool *value_out ) const;
00232 
00241   bool mapGetString( const QString& key, QString *value_out ) const;
00242 
00245   void setValue( const QVariant& value );
00246 
00249   QVariant getValue() const;
00250 
00253   int listLength() const;
00254 
00258   Config listChildAt( int i ) const;
00259 
00263   Config listAppendNew();
00264 
00280   class MapIterator
00281   {
00282   public:
00284     void advance();
00285 
00289     bool isValid();
00290 
00292     void start();
00293 
00295     QString currentKey();
00296 
00298     Config currentChild();
00299 
00300   private:
00303     MapIterator();
00304 
00305     Config::NodePtr node_;
00306     QMap<QString, Config::NodePtr>::const_iterator iterator_;
00307     bool iterator_valid_;
00308     friend class Config;
00309   };
00310 
00318   MapIterator mapIterator() const;
00319 
00320 private:
00321   Config( NodePtr node );
00322   static Config invalidConfig();
00323 
00325   void makeValid();
00326 
00327   NodePtr node_;
00328 
00329   friend class MapIterator;
00330 };
00331 
00332 } // end namespace rviz
00333 
00334 #endif // CONFIG_H


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Thu Aug 27 2015 15:02:27