readConfig.H

Go to the documentation of this file.
00001 /*!@file Util/readConfig.H CINNIC classes */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00005 // University of Southern California (USC) and the iLab at USC.         //
00006 // See http://iLab.usc.edu for information about this project.          //
00007 // //////////////////////////////////////////////////////////////////// //
00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00010 // in Visual Environments, and Applications'' by Christof Koch and      //
00011 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00012 // pending; application number 09/912,225 filed July 23, 2001; see      //
00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00014 // //////////////////////////////////////////////////////////////////// //
00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00016 //                                                                      //
00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00018 // redistribute it and/or modify it under the terms of the GNU General  //
00019 // Public License as published by the Free Software Foundation; either  //
00020 // version 2 of the License, or (at your option) any later version.     //
00021 //                                                                      //
00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00025 // PURPOSE.  See the GNU General Public License for more details.       //
00026 //                                                                      //
00027 // You should have received a copy of the GNU General Public License    //
00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00030 // Boston, MA 02111-1307 USA.                                           //
00031 // //////////////////////////////////////////////////////////////////// //
00032 //
00033 // Primary maintainer for this file: T. Nathan Mundhenk <mundhenk@usc.edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Util/readConfig.H $
00035 // $Id: readConfig.H 6003 2005-11-29 17:22:45Z rjpeters $
00036 //
00037 
00038 #ifndef READCONFIG_H_DEFINED
00039 #define READCONFIG_H_DEFINED
00040 
00041 #include "Util/Types.H"
00042 #include <cstdlib>
00043 #include <string>
00044 #include <vector>
00045 
00046 // ############################################################
00047 // ############################################################
00048 // ##### ---CINNIC---
00049 // ##### readConfig:
00050 // ##### T. Nathan Mundhenk nathan@mundhenk.com
00051 // ############################################################
00052 // ############################################################
00053 
00054 //#define vectorValue 25
00055 
00056 //!open a config file and parse it for data retreaval
00057 /*! This class works to open a file for parsing which has name value
00058   key pairs. Each pair is seperated and loaded into a vector. Values
00059   can then be retrieved by either calling a values item number or
00060   name. This will then return the value. Comments can be handeled
00061   in the config file so long as they are in the form '# words #'.
00062   That is place a # with a space before and after each comment.
00063 */
00064 class readConfig
00065 {
00066 private:
00067   std::vector<std::string> first;
00068   std::vector<std::string> second;
00069   std::vector<bool> isItem;
00070   std::string in;
00071   std::string fileName;
00072   bool comment;
00073   bool item;
00074   int vectorSize;
00075   int SiZE;
00076   int vectorValue;
00077 public:
00078   //! constructor with initial size = 25
00079   readConfig();
00080   //! constructor with initial size
00081   readConfig(int size);
00082   //! destructor for readConfig
00083   ~readConfig();
00084   //! open a config file with filename
00085   void openFile(const char* filename, bool echo = false);
00086   //! write the file back to disk as filename
00087   void writeFile();
00088   //! write the file back to disk with a new file name
00089   void writeFile(const char* filename);
00090   //! returns true if item number itemNumber exists
00091   bool readFileTrue(int itemNumber);
00092   //! return value of item as an integer
00093   int readFileValueI(int itemNumber);
00094   //! return value of item as a float
00095   float readFileValueF(int itemNumber);
00096   //! return value of item as a string
00097   std::string readFileValueS(int itemNumber);
00098   //! return value of item as a C style char*
00099   const char* readFileValueC(int itemNumber);
00100   //! return the item name
00101   std::string readFileValueName(int itemNumber);
00102   //! return item name as a C style char*
00103   const char* readFileValueNameC(int itemNumber);
00104   //! return item name as a float
00105   float readFileValueNameF(int itemNumber);
00106   //! return the float value of a number with name itemName
00107   float getItemValueF(std::string itemName);
00108   //! return the string value of a number with name itemName
00109   std::string getItemValueS(std::string itemName);
00110   //! return a bool representation of the value 1 = true else false
00111   bool getItemValueB(std::string itemName);
00112   //! return the char* value of a number with name itemName
00113   const char* getItemValueC(std::string itemName); //return the char*
00114                                               //value of a number
00115                                               //with name itemName
00116   //! Set the item with string name itemName to a float _set
00117   void setItemValue(std::string itemName, float _set);
00118   //! Set the item with string name itemName to a string _set
00119   void setItemValue(std::string itemName, std::string _set);
00120   //! Set the item with string name itemName to a const char* _set
00121   void setItemValue(std::string itemName, const char* _set);
00122   //! Set the item signified by its number to a float
00123   void setFileValue(int itemNumber, float _set);
00124   //! Set the item signified by its number to a string
00125   void setFileValue(int itemNumber, std::string _set);
00126   //! Set the item signified by its number to a const char*
00127   void setFileValue(int itemNumber, const char* _set);
00128   //! Set the item with string name itemName to a float _set
00129   int addItemValue(std::string itemName, float _set);
00130   //! Set the item with string name itemName to a string _set
00131   int addItemValue(std::string itemName, std::string _set);
00132   //! Set the item with string name itemName to a string _set
00133   int addItemValue(std::string itemName, const char* _set);
00134   //! returns how many items exist
00135   int itemCount();
00136   //void closeFile(); //close the file
00137 };
00138 
00139 // ######################################################################
00140 /* So things look consistent in everyone's emacs... */
00141 /* Local Variables: */
00142 /* indent-tabs-mode: nil */
00143 /* End: */
00144 
00145 #endif
Generated on Sun May 8 08:42:28 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3