Project

General

Profile

root / branches / compiler / cSharp / ooasCompiler / src / codegen / CSharp / ooaCSharpRuntime.cs @ 3

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
using TUG.Mogentes.Codegen;
23

    
24

    
25
namespace TUG.Mogentes.Codegen.CSharp //Simulation.SimulationCore
26
{
27
    public class UlyssesList<T> : System.Collections.Generic.List<T>
28
    {
29
        public UlyssesList()
30
            : base()
31
        { }
32

    
33
        public UlyssesList(T element)
34
            :base()
35
        {
36
            if (element != null)
37
                base.Add(element);
38
        }
39

    
40
        public UlyssesList(T[] elements)
41
            : base()
42
        {
43
            if (elements != null)
44
            {
45
                base.AddRange(elements);
46
            }
47
        }
48
    }
49

    
50
    public class UlyssesQualitativeValue
51
    {
52
        public int? intervalLow;
53
        public int? intervalHigh;
54
        public int? derivation;
55

    
56
        public UlyssesQualitativeValue(int? lowval, int? highval, int? deriv)
57
        {
58
            intervalLow = lowval;
59
            intervalHigh = highval;
60
            derivation = deriv;
61
        }
62
    }
63

    
64
    public delegate void CallBack(UlyssesActionSystemClass self);
65

    
66

    
67
    // class all instances in simulation inherit from
68
    public class UlyssesActionSystemClass
69
    {
70
        public static OoaCSharpInitVisitor objectInstantiator;
71
        public static C5.HashSet<String> givenObjectNames = new C5.HashSet<string>();
72

    
73
        public string givenName;
74
        public string objectName;
75
        public int objectCreationCounter = 0;
76
        public int _AstTypeLookupIndex = -1;
77
        public UlyssesActionSystemClass parent = null;
78
        public OoActionSystemInstance objectInstance = null;
79

    
80
        public UlyssesActionSystemClass(UlyssesActionSystemClass aParent, int constrNum, int LookupIndex, string aGivenName)
81
        {
82
            parent = aParent;
83
            _AstTypeLookupIndex = LookupIndex;
84
            if (parent == null)
85
                objectName = String.Format("{0}_root", this.GetType().Name);
86
            else
87
            {
88
                objectName = String.Format("{0}_{1}_{2}", this.GetType().Name, parent.objectName, parent.objectCreationCounter);
89
                parent.objectCreationCounter += 1;
90
            }
91

    
92
            if (aGivenName != String.Empty)
93
            {
94
                if (givenObjectNames.Contains(aGivenName))
95
                {
96
                    objectInstantiator.Error(0, 0, String.Format("Another object with name {0} exists.", aGivenName));
97
                }
98
                else
99
                {
100
                    objectName = aGivenName;
101
                    givenObjectNames.Add(aGivenName);
102
                }
103
            }
104

    
105
            objectInstantiator.visit(this, constrNum);
106
        }
107
    }
108
}