/vqdr/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/vqdr/trunk

« back to all changes in this revision

Viewing changes to src/libvqdr/context.vala

  • Committer: Gustav Hartvigsson
  • Date: 2020-06-07 18:48:24 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20200607184824-jf14f7a1b1di2i2q
* Initial code - far from done

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
using Gee;
2
 
using Vee;
 
2
using VQDR.Common;
3
3
 
4
4
namespace VQDR.Expression {
5
 
  /**
6
 
   * This is just a glorified key-value store. It is only used to provide
7
 
   * a mapping between variable-names and a Variable instance.
8
 
   */
 
5
  
9
6
  public class Context : GLib.Object{
10
7
    private bool changed;
11
8
    private Gee.TreeMap<string, Variable?> values;
14
11
    construct {
15
12
      changed = false;
16
13
      values = new Gee.TreeMap<string, Variable?>
17
 
                              (Vee.str_cmp, null);
 
14
                              (Common.Utils.str_cmp, null);
18
15
    }
19
16
    
20
17
    public Context () {
21
18
    }
22
19
    
23
20
    public void set_value (string name, 
24
 
                           int32 min_val,
25
 
                           int32 max_val,
26
 
                           int32 current_val) {
 
21
                           int min_val,
 
22
                           int max_val,
 
23
                           int current_val) {
27
24
      set_variable (name, Variable (min_val, max_val, current_val));
28
25
    }
29
26
    
30
27
    public Variable get_variable (string name) throws ArgError {
31
 
      throw_name (name);
32
 
      return values.@get (name.down ());
 
28
    throw_name (name);
 
29
    return values.@get (name.down ());
33
30
    }
34
 
 
 
31
    
35
32
    public void set_variable (string name, Variable? variable) {
36
33
      string new_name = name.down ();
37
34
      
51
48
       }
52
49
    }
53
50
    
54
 
    public FastNumber get_value (string name) throws ArgError {
 
51
    public int get_value (string name) throws ArgError {
55
52
      throw_name (name);
56
53
      return values.@get (name.down ()).current_val;
57
54
    }
58
55
    
59
 
    public FastNumber get_min_value (string name) throws ArgError {
 
56
    public int get_min_value (string name) throws ArgError {
60
57
      throw_name (name);
61
58
      return values.@get (name.down ()).min_val;
62
59
    }
63
60
    
64
 
    public FastNumber get_max_value (string name) throws ArgError {
 
61
    public int get_max_value (string name) throws ArgError {
65
62
      throw_name (name);
66
63
      return values.@get (name.down ()).max_val;
67
64
    }
68
65
 
69
 
    public FastNumber get_current_value (string name) throws ArgError {
 
66
    public int get_current_value (string name) throws ArgError {
70
67
      throw_name (name);
71
68
      return values.@get (name.down ()).current_val;
72
69
    }