Project

General

Profile

root / branches / compiler / cSharp / ooasCompiler / src / math / Range.cs

1
/**
2
  *
3
  *                      OOAS Compiler (Deprecated)
4
  *
5
  * Copyright 2015, Institute for Software Technology, Graz University of
6
  * Technology. Portions are copyright 2015 by the AIT Austrian Institute
7
  * of Technology. All rights reserved.
8
  *
9
  * SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED.
10
  *
11
  * Please notice that this version of the OOAS compiler is considered de-
12
  * precated. Only the Java version is maintained.
13
  *
14
  * Contributors:
15
  *               Willibald Krenn (TU Graz/AIT)
16
  *               Stefan Tiran (TU Graz/AIT)
17
  */
18

    
19
using System;
20
using System.Collections.Generic;
21
using System.Text;
22

    
23
namespace TUG.Mogentes
24
{
25

    
26
    public delegate Range<T> RangeConstructor<T>(T max, T min);
27

    
28
    public abstract class AbstractRange
29
    {
30
    }
31

    
32
    public class Range<T> : AbstractRange
33
    {
34
        protected RangeConstructor<T> m_constructor;
35

    
36
        public T max;
37
        public T min;
38
        public T precision;
39
        public T typemax;
40
        public T typemin;
41

    
42
        public Range<T> Create(T amax, T amin)
43
        {
44
            return m_constructor(amax, amin);
45
        }
46

    
47
        public Range(T amax, T amin, T aprecision, T atypemax, T atypemin, RangeConstructor<T> aconstr)
48
        {
49
            max = amax;
50
            min = amin;
51
            precision = aprecision;
52
            typemax = atypemax;
53
            typemin = atypemin;
54
            m_constructor = aconstr;
55
        }
56

    
57
    }
58

    
59
    public sealed class IntegerRange : Range<int>
60
    {
61
        public IntegerRange(int max, int min)
62
            : base(max, min, 1, int.MaxValue, int.MinValue, (a, b) => new IntegerRange(a, b))
63
        { }
64
    }
65

    
66
    public sealed class DoubleRange : Range<double>
67
    {
68
        public DoubleRange(double max, double min)
69
            : base(max, min, double.Epsilon, double.MaxValue, double.MinValue, (a, b) => new DoubleRange(a, b))
70
        { }
71
    }
72
}