~ubuntu-branches/debian/sid/stella/sid

« back to all changes in this revision

Viewing changes to src/emucore/Settings.hxx

  • Committer: Package Import Robot
  • Author(s): Stephen Kitt
  • Date: 2013-06-28 09:53:13 UTC
  • mfrom: (1.3.6)
  • Revision ID: package-import@ubuntu.com-20130628095313-j8jkkgxpvx1t18ym
Tags: 3.9-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
// See the file "License.txt" for information on usage and redistribution of
15
15
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
16
16
//
17
 
// $Id: Settings.hxx 2579 2013-01-04 19:49:01Z stephena $
 
17
// $Id: Settings.hxx 2726 2013-05-08 23:34:42Z stephena $
18
18
//============================================================================
19
19
 
20
20
#ifndef SETTINGS_HXX
23
23
class OSystem;
24
24
 
25
25
#include "Array.hxx"
 
26
#include "Variant.hxx"
26
27
#include "bspf.hxx"
27
28
 
28
29
/**
29
30
  This class provides an interface for accessing frontend specific settings.
30
31
 
31
32
  @author  Stephen Anthony
32
 
  @version $Id: Settings.hxx 2579 2013-01-04 19:49:01Z stephena $
 
33
  @version $Id: Settings.hxx 2726 2013-05-08 23:34:42Z stephena $
33
34
*/
34
35
class Settings
35
36
{
66
67
    void usage();
67
68
 
68
69
    /**
69
 
      Get the value assigned to the specified key.  If the key does
70
 
      not exist then -1 is returned.
71
 
 
72
 
      @param key The key of the setting to lookup
73
 
      @return The integer value of the setting
74
 
    */
75
 
    int getInt(const string& key) const;
76
 
 
77
 
    /**
78
 
      Get the value assigned to the specified key.  If the key does
79
 
      not exist then -1.0 is returned.
80
 
 
81
 
      @param key The key of the setting to lookup
82
 
      @return The floating point value of the setting
83
 
    */
84
 
    float getFloat(const string& key) const;
85
 
 
86
 
    /**
87
 
      Get the value assigned to the specified key.  If the key does
88
 
      not exist then false is returned.
89
 
 
90
 
      @param key The key of the setting to lookup
91
 
      @return The boolean value of the setting
92
 
    */
93
 
    bool getBool(const string& key) const;
94
 
 
95
 
    /**
96
 
      Get the value assigned to the specified key.  If the key does
97
 
      not exist then the empty string is returned.
98
 
 
99
 
      @param key The key of the setting to lookup
100
 
      @return The string value of the setting
101
 
    */
102
 
    const string& getString(const string& key) const;
103
 
 
104
 
    /**
105
 
      Get the x*y size assigned to the specified key.  If the key does
106
 
      not exist (or is invalid) then results are -1 for each item.
107
 
 
108
 
      @param key The key of the setting to lookup
109
 
      @return The x and y values encoded in the key
110
 
    */
111
 
    void getSize(const string& key, int& x, int& y) const;
112
 
 
113
 
    /**
114
 
      Set the value associated with key to the given value.
115
 
 
116
 
      @param key   The key of the setting
117
 
      @param value The value to assign to the setting
118
 
    */
119
 
    void setInt(const string& key, const int value);
120
 
 
121
 
    /**
122
 
      Set the value associated with key to the given value.
123
 
 
124
 
      @param key   The key of the setting
125
 
      @param value The value to assign to the setting
126
 
    */
127
 
    void setFloat(const string& key, const float value);
128
 
 
129
 
    /**
130
 
      Set the value associated with key to the given value.
131
 
 
132
 
      @param key   The key of the setting
133
 
      @param value The value to assign to the setting
134
 
    */
135
 
    void setBool(const string& key, const bool value);
136
 
 
137
 
    /**
138
 
      Set the value associated with key to the given value.
139
 
 
140
 
      @param key   The key of the setting
141
 
      @param value The value to assign to the setting
142
 
    */
143
 
    void setString(const string& key, const string& value);
144
 
 
145
 
    /**
146
 
      Set the value associated with key to the given value.
147
 
 
148
 
      @param key   The key of the setting
149
 
      @param value The value to assign to the setting
150
 
    */
151
 
    void setSize(const string& key, const int value1, const int value2);
 
70
      Get the value assigned to the specified key.
 
71
 
 
72
      @param key The key of the setting to lookup
 
73
      @return The (variant) value of the setting
 
74
    */
 
75
    const Variant& value(const string& key) const;
 
76
 
 
77
    /**
 
78
      Set the value associated with the specified key.
 
79
 
 
80
      @param key   The key of the setting
 
81
      @param value The (variant) value to assign to the setting
 
82
    */
 
83
    void setValue(const string& key, const Variant& value);
 
84
 
 
85
    /**
 
86
      Convenience methods to return specific types.
 
87
 
 
88
      @param key The key of the setting to lookup
 
89
      @return The specific type value of the setting
 
90
    */
 
91
    int getInt(const string& key) const     { return value(key).toInt();   }
 
92
    float getFloat(const string& key) const { return value(key).toFloat(); }
 
93
    bool getBool(const string& key) const   { return value(key).toBool();  }
 
94
    const string& getString(const string& key) const { return value(key).toString(); }
 
95
    const GUI::Size getSize(const string& key) const { return value(key).toSize();   }
152
96
 
153
97
  protected:
154
98
    /**
184
128
    struct Setting
185
129
    {
186
130
      string key;
187
 
      string value;
188
 
      string initialValue;
 
131
      Variant value;
 
132
      Variant initialValue;
189
133
    };
190
134
    typedef Common::Array<Setting> SettingsArray;
191
135
 
199
143
    int getExternalPos(const string& key) const;
200
144
 
201
145
    /** Add key,value pair to specified array at specified position */
202
 
    int setInternal(const string& key, const string& value,
 
146
    int setInternal(const string& key, const Variant& value,
203
147
                    int pos = -1, bool useAsInitial = false);
204
 
    int setExternal(const string& key, const string& value,
 
148
    int setExternal(const string& key, const Variant& value,
205
149
                    int pos = -1, bool useAsInitial = false);
206
150
 
207
151
  private: