/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: 2024-12-22 00:30:29 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20241222003029-k74ogrm32zobz325
[General] Split libvee into it's own library.

Show diffs side-by-side

added added

removed removed

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