graphlcd-base/glcddrivers/config.h
author root@rika
Wed, 06 Feb 2008 17:32:55 +0000
changeset 4 df6a40031aa5
permissions -rw-r--r--
added graphlcd-base
     1 /*
     2  * GraphLCD driver library
     3  *
     4  * config.h  -  config file classes
     5  *
     6  * This file is released under the GNU General Public License. Refer
     7  * to the COPYING file distributed with this package.
     8  *
     9  * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
    10  */
    11 
    12 #ifndef _GLCDDRIVERS_CONFIG_H_
    13 #define _GLCDDRIVERS_CONFIG_H_
    14 
    15 #include <string>
    16 #include <vector>
    17 
    18 
    19 namespace GLCD
    20 {
    21 
    22 const int kWaitUsleep       = 0;
    23 const int kWaitNanosleep    = 1;
    24 const int kWaitNanosleepRR  = 2;
    25 const int kWaitGettimeofday = 3;
    26 
    27 
    28 struct tOption
    29 {
    30     std::string name;
    31     std::string value;
    32 };
    33 
    34 class cDriverConfig
    35 {
    36 public:
    37     std::string name;
    38     std::string driver;
    39     int id;
    40     std::string device;
    41     int port;
    42     int width;
    43     int height;
    44     bool upsideDown;
    45     bool invert;
    46     int brightness;
    47     int contrast;
    48     bool backlight;
    49     int adjustTiming;
    50     int refreshDisplay;
    51     std::vector <tOption> options;
    52 
    53 public:
    54     cDriverConfig();
    55     cDriverConfig(const cDriverConfig & rhs);
    56     ~cDriverConfig();
    57     cDriverConfig & operator=(const cDriverConfig & rhs);
    58     bool Parse(const std::string & line);
    59     int GetInt(const std::string & value);
    60     bool GetBool(const std::string & value);
    61 };
    62 
    63 class cConfig
    64 {
    65 public:
    66     int waitMethod;
    67     int waitPriority;
    68     std::vector <cDriverConfig> driverConfigs;
    69 
    70 public:
    71     cConfig();
    72     ~cConfig();
    73     bool Load(const std::string & filename);
    74     bool Save(const std::string & filename);
    75     bool Parse(const std::string & line);
    76     int GetInt(const std::string & value);
    77     bool GetBool(const std::string & value);
    78     int GetConfigIndex(const std::string & name);
    79 };
    80 
    81 extern cConfig Config;
    82 
    83 } // end of namespace
    84 
    85 #endif