orca-robotics


INTRODUCTION
Overview
Download and Install
Documentation

REPOSITORY
Interfaces
Drivers
Libraries
Utilities
Software Map

DEVELOPER
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

properties.h

00001 /*
00002 Orca Project: Components for robotics 
00003              http://orca-robotics.sf.net/
00004 Copyright (c) 2004-2007 Alex Brooks, Alexei Makarenko, Tobias Kaupp
00005  *
00006 This copy of Orca is licensed to you under the terms described in the
00007 ORCA_LICENSE file included in this distribution.
00008  *
00009  */
00010 
00011 #ifndef HYDROUTIL_PROPERTIES_H
00012 #define HYDROUTIL_PROPERTIES_H
00013 
00014 #include <string>
00015 #include <map>
00016 #include <vector>
00017 
00018 namespace hydroutil
00019 {
00020 
00026 class Properties
00027 {
00028 public:
00029 
00031     struct Config
00032     {
00034         Config( bool warnDefaultProp=false ) :
00035             warnDefaultProperty(warnDefaultProp) {};
00036 
00039         bool warnDefaultProperty;
00040     };
00041 
00043     Properties( const Config& config=Config() );
00044     
00051     Properties( const std::map<std::string,std::string>& props, 
00052                 const std::string& removePrefix="",
00053                 const Config& config=Config() );
00054 
00056     bool isDefined( const ::std::string& key );
00057     
00059     int getProperty( const ::std::string& key, std::string &value ) const;
00060     
00062     std::string getPropertyWithDefault( const ::std::string& key, const std::string &defaultValue ) const;
00063     
00066     int getPropertyAsDouble( const ::std::string& key, double &value ) const;
00067     
00070     double getPropertyAsDoubleWithDefault( const ::std::string& key, const double defaultValue ) const;
00071 
00076     int getPropertyAsDoubleVector( const ::std::string& key, std::vector<double> &value ) const;
00077     
00080     std::vector<double> getPropertyAsDoubleVectorWithDefault( const ::std::string& key, const std::vector<double> &defaultValue ) const;
00081 
00084     int getPropertyAsInt( const ::std::string& key, int &value ) const;
00085     
00088     int getPropertyAsIntWithDefault( const ::std::string& key, const int defaultValue ) const;
00089 
00094     int getPropertyAsIntVector( const ::std::string& key, std::vector<int> &value ) const;
00095 
00098     std::vector<int> getPropertyAsIntVectorWithDefault( const ::std::string& key, const std::vector<int> &defaultValue ) const;
00099     
00101     void setProperty( const ::std::string& key, const ::std::string& value );
00102     
00104     const std::map<std::string,std::string>& data() const { return props_; };
00105 
00107     size_t size() const { return props_.size(); }; 
00108 
00110     std::string toString() const;
00111 
00114     static std::string missingPropertyWarning( const std::string & prop, bool fatal=false );
00115 
00116 private:
00117     
00118     std::map<std::string,std::string> props_;
00119 
00120     Config config_;
00121 };
00122 
00123 } // end namespace
00124 
00125 #endif
 

Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)


Generated for Orca Robotics by  doxygen 1.4.5