File: LogField.h

package info (click to toggle)
quickplot 0.8.6-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,544 kB
  • ctags: 1,019
  • sloc: cpp: 10,051; sh: 7,597; makefile: 176
file content (80 lines) | stat: -rw-r--r-- 2,086 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* Copyright (c) 1998, 1999, 2003, 2004  Lance Arsenault, (GNU GPL (v2+))
 */

/* class LogField: takes the log of the field passed to it.  The log
 * is computed at the time of the read() call.  This does not store
 * the field data in the LogField objects data, but just reads it from
 * the Field object that was passed to it. The Field object that is
 * passed to the constructor must stay valid for this to work.
 *
 *
 * The function log(x) is not valid for x <= 0.  So we need an error
 * check.
 *
 */


class LogField : public Field
{
 public:

  // value = count * scale + offset
  inline LogField(Source *s, Field *f, value_t base=(value_t)10.0):
    Field(s), 
    {
      error = 0; // start with no error.
      
      here lanceman
        
      _isIncreasing = (scale > 0.0)? true: false;
      _numberOfValues = MAXCOUNT;
      _max = (_numberOfValues-1)*scale + offset;
      _min = offset;
      // assuming that count_t is unsigned so that -1 is the maxmum
      // value
      index = 0;

      setName("linear field");
      
    }
  
  // read the list and advance the pointer to the next value in the
  // series.
  inline value_t read(void)
    {
      return scale*(index++) + offset;
    }

  // find the minimum values in the range of indexes
  // indexing starts at 0.
  inline value_t max(count_t i_max=((count_t) -1), count_t i_min=0)
    {
      if(i_max == ((count_t) -1))
        i_max = _numberOfValues - 1;
      if(scale > (value_t) 0.0)
        return scale*(i_max) + offset;
      else
        return scale*(i_min) + offset;
    }
  
  // find the maximum values in the range of indexes
  // indexing starts at 0.
  inline value_t min(count_t i_max=((count_t) -1), count_t i_min=0)
    {
      if(i_max == ((count_t) -1))
        i_max = _numberOfValues - 1;
      if(scale < (value_t) 0.0)
        return scale*(i_max) + offset;
      else
        return scale*(i_min) + offset;
    }

  // move the pointer to the first value.
  inline void rewind(void) { index = 0; }
  
private:
  
  // Index to the element to be read.
  value_t base;
  
};