[doc_tool] Added Projects used for gerneration tests.
authorDaniel G <daniel@giritzer.eu>
Mon, 14 May 2018 04:00:59 +0000 (06:00 +0200)
committerDaniel G <daniel@giritzer.eu>
Mon, 14 May 2018 04:00:59 +0000 (06:00 +0200)
102 files changed:
src/tests/BSY3/Abgabe/Abgabe.pdf [new file with mode: 0644]
src/tests/BSY3/Abgabe/src/CharToFile.c [new file with mode: 0644]
src/tests/BSY3/Abgabe/src/CharToFile.h [new file with mode: 0644]
src/tests/BSY3/Abgabe/src/CommandInterpreter.c [new file with mode: 0644]
src/tests/BSY3/Abgabe/src/CommandInterpreter.h [new file with mode: 0644]
src/tests/BSY3/Abgabe/src/Commands.c [new file with mode: 0644]
src/tests/BSY3/Abgabe/src/Commands.h [new file with mode: 0644]
src/tests/BSY3/Abgabe/src/Makefile [new file with mode: 0644]
src/tests/BSY3/Abgabe/src/main.c [new file with mode: 0644]
src/tests/BSY3/Angabe.pdf [new file with mode: 0644]
src/tests/BSY3/src/CharToFile.c [new file with mode: 0644]
src/tests/BSY3/src/CharToFile.h [new file with mode: 0644]
src/tests/BSY3/src/CommandInterpreter.c [new file with mode: 0644]
src/tests/BSY3/src/CommandInterpreter.h [new file with mode: 0644]
src/tests/BSY3/src/Commands.c [new file with mode: 0644]
src/tests/BSY3/src/Commands.h [new file with mode: 0644]
src/tests/BSY3/src/Makefile [new file with mode: 0644]
src/tests/BSY3/src/main.c [new file with mode: 0644]
src/tests/MPT3_KOM4/Angabe.pdf [new file with mode: 0644]
src/tests/MPT3_KOM4/src/main.c [new file with mode: 0644]
src/tests/MPT3_KOM4/src/uart3.c [new file with mode: 0644]
src/tests/MPT3_KOM4/src/uart3.h [new file with mode: 0644]
src/tests/PSS4/Angabe.pdf [new file with mode: 0644]
src/tests/PSS4/Beispiel1/.vs/Process/v14/.suo [new file with mode: 0755]
src/tests/PSS4/Beispiel1/Process.sln [new file with mode: 0755]
src/tests/PSS4/Beispiel1/Process/Hlp.cpp [new file with mode: 0755]
src/tests/PSS4/Beispiel1/Process/Hlp.h [new file with mode: 0755]
src/tests/PSS4/Beispiel1/Process/Process.cpp [new file with mode: 0755]
src/tests/PSS4/Beispiel1/Process/Process.vcxproj [new file with mode: 0755]
src/tests/PSS4/Beispiel1/Process/Process.vcxproj.filters [new file with mode: 0755]
src/tests/PSS4/Beispiel1/Process/Process.vcxproj.user [new file with mode: 0755]
src/tests/PSS4/Beispiel2/.vs/Threads/v14/.suo [new file with mode: 0755]
src/tests/PSS4/Beispiel2/Threads.sln [new file with mode: 0755]
src/tests/PSS4/Beispiel2/Threads/Threads.cpp [new file with mode: 0755]
src/tests/PSS4/Beispiel2/Threads/Threads.vcxproj [new file with mode: 0755]
src/tests/PSS4/Beispiel2/Threads/Threads.vcxproj.filters [new file with mode: 0755]
src/tests/PSS4/Beispiel3/MatrixMultiplikation.sln [new file with mode: 0755]
src/tests/PSS4/Beispiel3/MatrixMultiplikation/Matrix.cpp [new file with mode: 0755]
src/tests/PSS4/Beispiel3/MatrixMultiplikation/Matrix.h [new file with mode: 0755]
src/tests/PSS4/Beispiel3/MatrixMultiplikation/MatrixMultiplikation.vcxproj [new file with mode: 0755]
src/tests/PSS4/Beispiel3/MatrixMultiplikation/MatrixMultiplikation.vcxproj.filters [new file with mode: 0755]
src/tests/PSS4/Beispiel3/MatrixMultiplikation/main.cpp [new file with mode: 0755]
src/tests/SDP3/Angabe.pdf [new file with mode: 0644]
src/tests/SDP3/src/Cesar.cpp [new file with mode: 0644]
src/tests/SDP3/src/Cesar.h [new file with mode: 0644]
src/tests/SDP3/src/EpicosAdapter.cpp [new file with mode: 0644]
src/tests/SDP3/src/EpicosAdapter.h [new file with mode: 0644]
src/tests/SDP3/src/EpicosCrypto.cpp [new file with mode: 0644]
src/tests/SDP3/src/EpicosCrypto.h [new file with mode: 0644]
src/tests/SDP3/src/EpicosCryptoIF.h [new file with mode: 0644]
src/tests/SDP3/src/HSECrypto.cpp [new file with mode: 0644]
src/tests/SDP3/src/HSECrypto.h [new file with mode: 0644]
src/tests/SDP3/src/HSECryptoIF.cpp [new file with mode: 0644]
src/tests/SDP3/src/HSECryptoIF.h [new file with mode: 0644]
src/tests/SDP3/src/Makefile [new file with mode: 0644]
src/tests/SDP3/src/NortelAdapter.cpp [new file with mode: 0644]
src/tests/SDP3/src/NortelAdapter.h [new file with mode: 0644]
src/tests/SDP3/src/NortelCrypto.cpp [new file with mode: 0644]
src/tests/SDP3/src/NortelCrypto.h [new file with mode: 0644]
src/tests/SDP3/src/NortelCryptoIF.h [new file with mode: 0644]
src/tests/SDP3/src/Object.h [new file with mode: 0644]
src/tests/SDP3/src/Rsa.cpp [new file with mode: 0644]
src/tests/SDP3/src/Rsa.h [new file with mode: 0644]
src/tests/SDP3/src/main.cpp [new file with mode: 0644]
src/tests/SDP3/src/test/secret.txt [new file with mode: 0644]
src/tests/SDP3/src/test/secret.txt.Cesar [new file with mode: 0644]
src/tests/SDP3/src/test/secret.txt.Cesar-Nortel-backup [new file with mode: 0644]
src/tests/SDP3/src/test/secret.txt.Cesar-backup [new file with mode: 0644]
src/tests/SDP3/src/test/secret.txt.RSA [new file with mode: 0644]
src/tests/SDP3/src/test/secret.txt.RSA-Epicos-backup [new file with mode: 0644]
src/tests/SDP3/src/test/secret.txt.RSA-Nortel-backup [new file with mode: 0644]
src/tests/SDP3/src/test/secret.txt.RSA-backup [new file with mode: 0644]
src/tests/SEN1/Angabe.pdf [new file with mode: 0644]
src/tests/SEN1/Beispiel1/LeetSpeak.cpp [new file with mode: 0644]
src/tests/SEN1/Beispiel1/LeetSpeak.h [new file with mode: 0644]
src/tests/SEN1/Beispiel1/Makefile [new file with mode: 0644]
src/tests/SEN1/Beispiel1/main.cpp [new file with mode: 0644]
src/tests/SEN1/Beispiel2/Makefile [new file with mode: 0644]
src/tests/SEN1/Beispiel2/main.cpp [new file with mode: 0644]
src/tests/SEN1/Beispiel2/weatherstations.cpp [new file with mode: 0644]
src/tests/SEN1/Beispiel2/weatherstations.h [new file with mode: 0644]
src/tests/SEN1/Beispiel3/Makefile [new file with mode: 0644]
src/tests/SEN1/Beispiel3/main.cpp [new file with mode: 0644]
src/tests/SEN2/Angabe.pdf [new file with mode: 0644]
src/tests/SEN2/Beispiel1/GenCoordinates.cpp [new file with mode: 0644]
src/tests/SEN2/Beispiel1/GenCoordinates.h [new file with mode: 0644]
src/tests/SEN2/Beispiel1/Makefile [new file with mode: 0644]
src/tests/SEN2/Beispiel1/RandomGen.cpp [new file with mode: 0644]
src/tests/SEN2/Beispiel1/RandomGen.h [new file with mode: 0644]
src/tests/SEN2/Beispiel1/main.cpp [new file with mode: 0644]
src/tests/SEN2/Beispiel2/Makefile [new file with mode: 0644]
src/tests/SEN2/Beispiel2/Output_Testdriver.tex [new file with mode: 0644]
src/tests/SEN2/Beispiel2/SameDimension.cpp [new file with mode: 0644]
src/tests/SEN2/Beispiel2/SameDimension.h [new file with mode: 0644]
src/tests/SEN2/Beispiel2/base.h [new file with mode: 0644]
src/tests/SEN2/Beispiel2/main.cpp [new file with mode: 0644]
src/tests/SEN2/Beispiel2/scanner.cpp [new file with mode: 0644]
src/tests/SEN2/Beispiel2/scanner.h [new file with mode: 0644]
src/tests/SEN2/Beispiel2/scanner_impl.cpp [new file with mode: 0644]
src/tests/SEN2/Beispiel2/scanner_impl.h [new file with mode: 0644]
src/tests/SEN2/Beispiel2/symbol.cpp [new file with mode: 0644]
src/tests/SEN2/Beispiel2/symbol.h [new file with mode: 0644]

diff --git a/src/tests/BSY3/Abgabe/Abgabe.pdf b/src/tests/BSY3/Abgabe/Abgabe.pdf
new file mode 100644 (file)
index 0000000..5752fa3
Binary files /dev/null and b/src/tests/BSY3/Abgabe/Abgabe.pdf differ
diff --git a/src/tests/BSY3/Abgabe/src/CharToFile.c b/src/tests/BSY3/Abgabe/src/CharToFile.c
new file mode 100644 (file)
index 0000000..188d54e
--- /dev/null
@@ -0,0 +1,50 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: CharToFile.c
+// Author: Daniel Giritzer
+// Date: 30.11.2016
+// Description: Schreibt uebergebenen char auf eine Datei (append)
+// Remarks: Source Datei
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include <stdio.h>
+#include "CharToFile.h"
+#include "CommandInterpreter.h"
+
+int PutCharToFile(int ch)
+{
+
+    //Dateiname
+    char const * const fname = "CharToFile.txt";
+
+    //Versuche Dateien zu oeffnen
+    //Erstelle zu schreibende Datei falls sie nicht existiert
+    FILE * fd_write = fopen(fname, "a");
+
+    //Fehler ausgeben Falls Datei nicht
+    //geoeffnet / erstellt werden kann
+    if(fd_write == NOK)
+    {
+        perror("Error in Open: ");
+        return NOK;
+    }
+
+
+    if(fprintf(fd_write, "%c", ch) < NOK)
+    {
+        //Fehler ausgeben Falls nicht geschrieben
+        //werden kann
+        perror("Error in Write: ");
+        return NOK;
+    }
+
+    //schliessen der Datei
+    if(fclose(fd_write) == EOF)
+    {
+        //Fehler falls Error beim
+        //schliessen
+        perror("Error in Close: ");
+        return NOK;
+    }
+
+    return OK;
+}
diff --git a/src/tests/BSY3/Abgabe/src/CharToFile.h b/src/tests/BSY3/Abgabe/src/CharToFile.h
new file mode 100644 (file)
index 0000000..2f75347
--- /dev/null
@@ -0,0 +1,17 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: CharToFile.c
+// Author: Daniel Giritzer
+// Date: 30.11.2016
+// Description: Schreibt uebergebenen char auf eine Datei (append)
+// Remarks: Header Datei
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#ifndef CHARTOFILE_H_INCLUDED
+#define CHARTOFILE_H_INCLUDED
+//---------------------------------
+//Schreibt uebergebenen Char
+//auf eine Datei
+//---------------------------------
+int PutCharToFile(int);
+
+#endif // CHARTOFILE_H_INCLUDED
diff --git a/src/tests/BSY3/Abgabe/src/CommandInterpreter.c b/src/tests/BSY3/Abgabe/src/CommandInterpreter.c
new file mode 100644 (file)
index 0000000..420929d
--- /dev/null
@@ -0,0 +1,154 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: CommandInterpreter.c
+// Author: Daniel Giritzer
+// Date: 29.11.2016
+// Description: Interpretiert Texteingaben und fuehrt die Dazugehörigen
+//              Funktionen aus.
+// Remarks: Quelldatei
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include "CommandInterpreter.h"
+#include "string.h"
+#include "stdio.h"
+
+static TParameters params; //Eingabepuffer
+static int (*PutChar)(int);
+static TCmdHndTable const * cmdTable;
+
+//---------------------------------
+//Leert den Eingabepuffer.
+//---------------------------------
+static void ClearParams()
+{
+    for(int i = 0; i < MAX_PARAMS+1; i++)
+    {
+        memset(params.params[i], 0, MAX_PARAMLEN+1);
+    }
+}
+
+//---------------------------------
+//Initialisiert den CommandInterpreter
+//und Startet Eingabe.
+//---------------------------------
+void Init(TCmdHndTable const cmds[], int (*PutCharacter)(int))
+{
+    PutChar = PutCharacter;
+    cmdTable = cmds;
+    int isError = 0;
+
+    Print("Willkommen!\n");
+    PutChar('>');
+    while((isError = Process(getchar())) != ESCAPE)
+    {
+        //Error ausgeben
+        if(isError == NOK)
+        {
+            Print("\nERROR!");
+            PutChar('\n');
+            PutChar('>');
+        }
+    }
+}
+
+//---------------------------------
+//Gibt die Parameterliste
+//zurrueck.
+//---------------------------------
+TParameters GetParams()
+{
+    return params;
+}
+
+//---------------------------------
+//Wertet die Eingabe aus, und
+//ruft Falls nötig die entsprechende
+//Funktion auf.
+//---------------------------------
+int Process(char ch)
+{
+    static int param = 0;
+    static int paramlen = 0;
+    int i = 0;
+    int isError = OK;
+
+    //Beendet Eingabe (Escape)
+    if(ch == '\033')
+    {
+        return ESCAPE;
+    }
+
+    //Parse parameter bei \n oder \r
+    else if(ch == '\n' || ch == '\r')
+    {
+        while(cmdTable[i].cmd_name != 0)
+        {
+            //Ist Parameter in der Kommandoliste enthalten
+            //fuehre die dazugehoerende Funktion aus
+            if(strcmp(params.params[0],cmdTable[i].cmd_name) == 0)
+            {
+                isError = cmdTable[i].command();
+                break;
+            }
+            //Hinweis dass Kommando nicht gefunden wurde
+            //ausgeben
+            else if(cmdTable[i + 1].cmd_name == 0)
+            {
+                Print("\nKommando nicht gefunden.");
+            }
+            i++;
+        }
+
+        //OK ausgeben
+        if(isError == OK)
+        {
+            Print("\nOK");
+            //Promptzeichen ausgeben
+            PutChar('\n');
+            PutChar('>');
+        }
+
+        //Parameterbuffer Ruecksetzten
+        ClearParams();
+        param = 0;
+        paramlen = 0;
+        return isError;
+    }
+
+    //Nach leerschritt Folgen Parameter
+    else if(ch == ' ')
+    {
+        param++;
+        paramlen = 0;
+        if(param > MAX_PARAMS)
+        {
+            isError = NOK;
+        }
+    }
+
+    //Zeichen in den Parameterpuffer schreiben
+    else
+    {
+        params.params[param][paramlen] = ch;
+        paramlen++;
+        if(paramlen > MAX_PARAMLEN)
+        {
+            isError = NOK;
+        }
+    }
+
+    PutChar(ch);
+
+    return isError;
+}
+
+//---------------------------------
+//Gibt einen String (char array)
+//mit der PutChar Funktion aus.
+//---------------------------------
+void Print(char* str)
+{
+    for(int i = 0; i < strlen(str); i++)
+    {
+        PutChar(str[i]);
+    }
+}
diff --git a/src/tests/BSY3/Abgabe/src/CommandInterpreter.h b/src/tests/BSY3/Abgabe/src/CommandInterpreter.h
new file mode 100644 (file)
index 0000000..a62adee
--- /dev/null
@@ -0,0 +1,52 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: CommandInterpreter.h
+// Author: Daniel Giritzer
+// Date: 29.11.2016
+// Description: Interpretiert Texteingaben und fuehrt die Dazugehörigen
+//              Funktionen aus.
+// Remarks: Header Datei
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#ifndef COMMANDINTERPRETER_H_INCLUDED
+#define COMMANDINTERPRETER_H_INCLUDED
+#include "Commands.h"
+
+//Konstanten
+#define MAX_INPUTLEN 128
+#define MAX_PARAMS 16
+#define MAX_PARAMLEN 32
+#define NOK 0
+#define OK 1
+#define ESCAPE 003
+
+//Dateityp fuer die Parameterliste
+typedef struct
+{
+    char params[MAX_PARAMS+1][MAX_PARAMLEN+1];
+} TParameters;
+
+//---------------------------------
+//Initialisiert den CommandInterpreter
+//und Startet Eingabe.
+//---------------------------------
+void Init(TCmdHndTable const cmds[], int (*PutCharacter)(int));
+
+//---------------------------------
+//Gibt die Parameterliste
+//zurrueck.
+//---------------------------------
+TParameters GetParams();
+
+//---------------------------------
+//Wertet die Eingabe aus, und
+//ruft Falls nötig die entsprechende
+//Funktion auf.
+//---------------------------------
+int Process(char ch);
+
+//---------------------------------
+//Gibt einen String (char array)
+//mit der PutChar Funktion aus.
+//---------------------------------
+void Print(char* str);
+#endif //COMMANDINTERPRETER_H
diff --git a/src/tests/BSY3/Abgabe/src/Commands.c b/src/tests/BSY3/Abgabe/src/Commands.c
new file mode 100644 (file)
index 0000000..994acbe
--- /dev/null
@@ -0,0 +1,166 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Commands.c
+// Author: Daniel Giritzer
+// Date: 29.11.2016
+// Description: Verschiedene Befehle die mit dem CommandoInterpreter
+//              Modul verwendet werden koennen.
+// Remarks: Source Datei
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include "Commands.h"
+#include "CommandInterpreter.h"
+#include <stdio.h>
+
+//Kommandotabelle
+static TCmdHndTable const cmdTable[] =
+{
+    //Funktion, Kommando, Beschreibung
+    {CmdHelp, "help", "show help text"},
+    {CmdHelp, "?", "show help text"},
+    {CmdParamInt, "int", "[value] first parameter as integer"},
+    {CmdParamFloat, "float", "[value] first parameter as float"},
+    {CmdParamString, "string", "[value] first parameter as string"},
+    {CmdParamAddInt, "addint", "addint [value1] [value2] adds two integer values"},
+    {0, 0, 0}
+};
+
+//---------------------------------
+//Gibt Pointer auf die Kommandotabelle
+//zurrueck.
+//---------------------------------
+TCmdHndTable const* GetCmdHndTable()
+{
+    return cmdTable;
+}
+
+//---------------------------------
+//Gibt Hilfetext aus.
+//---------------------------------
+int CmdHelp()
+{
+    int i = 0;
+    Print("\n");
+    while(cmdTable[i].command != 0)
+    {
+        //Durch Kommandotabeele iterieren
+        //und Befehlsname + Befehlstext ausgeben.
+        Print(cmdTable[i].cmd_name);
+        Print("\t - \t");
+        Print(cmdTable[i].cmd_info);
+        Print("\n");
+        i++;
+    }
+    return OK;
+}
+
+//---------------------------------
+//Gibt Parameter als Integer aus.
+//---------------------------------
+int CmdParamInt()
+{
+    int i;
+    char c[MAX_PARAMLEN];
+    TParameters params = GetParams();
+    Print("\n");
+    Print("Parameter: ");
+    if(sscanf(params.params[1], "%d", &i) == OK)
+    {
+        //Falls Umwandlung OK Ergebnis in einen String Speichern
+        sprintf(c, "%d", i);
+
+        //String ausgeben
+        Print(c);
+        return OK;
+    }
+    else
+    {
+        //Ansonsten Parameter ausgeben
+        Print(params.params[1]);
+    }
+    return NOK;
+}
+
+//---------------------------------
+//Gibt Parameter als Float aus.
+//---------------------------------
+int CmdParamFloat()
+{
+    float i;
+    char c[MAX_PARAMLEN];
+    TParameters params = GetParams();
+    Print("\n");
+    Print("Parameter: ");
+    if(sscanf(params.params[1], "%f", &i) == OK)
+    {
+        //Falls Umwandlung OK Ergebnis in einen String Speichern
+        sprintf(c, "%f", i);
+
+        //String ausgeben
+        Print(c);
+        return OK;
+    }
+    else
+    {
+        //Ansonsten Parameter ausgeben
+        Print(params.params[1]);
+    }
+    return NOK;
+}
+
+//---------------------------------
+//Gibt Parameter als String aus.
+//---------------------------------
+int CmdParamString()
+{
+    char i[MAX_PARAMLEN];
+    char c[MAX_PARAMLEN];
+    TParameters params = GetParams();
+    Print("\n");
+    Print("Parameter: ");
+    if(sscanf(params.params[1], "%s", i) == OK)
+    {
+        //Falls Umwandlung OK Ergebnis in einen String Speichern
+        sprintf(c, "%s", i);
+
+        //String ausgeben
+        Print(c);
+        return OK;
+    }
+    else
+    {
+        Print(params.params[1]);
+    }
+    return NOK;
+}
+
+//---------------------------------
+//Addiert zwei Parameter und gibt
+//das Ergebnis aus.
+//---------------------------------
+int CmdParamAddInt()
+{
+    int i;
+    int ii;
+    char c[MAX_PARAMLEN];
+    TParameters params = GetParams();
+
+    Print("\n");
+    Print("Result: ");
+    if(sscanf(params.params[1], "%d", &i) == OK && sscanf(params.params[2], "%d", &ii) == OK)
+    {
+        //Falls Umwandlung OK Ergebnis in einen String Speichern
+        sprintf(c, "%d + %d = %d", i, ii, i + ii);
+
+        //String ausgeben
+        Print(c);
+        return OK;
+    }
+    else
+    {
+        //Ansonsten Parameter ausgeben
+        Print(params.params[1]);
+        Print(" ");
+        Print(params.params[2]);
+    }
+    return NOK;
+}
diff --git a/src/tests/BSY3/Abgabe/src/Commands.h b/src/tests/BSY3/Abgabe/src/Commands.h
new file mode 100644 (file)
index 0000000..469f833
--- /dev/null
@@ -0,0 +1,55 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Commands.h
+// Author: Daniel Giritzer
+// Date: 29.11.2016
+// Description: Verschiedene Befehle die mit dem CommandoInterpreter
+//              Modul verwendet werden koennen.
+// Remarks: Header Datei
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#ifndef COMMANDS_H_INCLUDED
+#define COMMANDS_H_INCLUDED
+
+//Datentyp der die Kommandotabelle
+//beschreibt.
+typedef struct
+{
+    int (* const command)();
+    char * const cmd_name;
+    char * const cmd_info;
+} TCmdHndTable;
+
+//---------------------------------
+//Gibt Pointer auf die Kommandotabelle
+//zurrueck.
+//---------------------------------
+TCmdHndTable const* GetCmdHndTable();
+
+//---------------------------------
+//Gibt Hilfetext aus.
+//---------------------------------
+int CmdHelp();
+
+//---------------------------------
+//Gibt Parameter als Integer aus.
+//---------------------------------
+int CmdParamInt();
+
+//---------------------------------
+//Gibt Parameter als Float aus.
+//---------------------------------
+int CmdParamFloat();
+
+//---------------------------------
+//Gibt Parameter als String aus.
+//---------------------------------
+int CmdParamString();
+
+//---------------------------------
+//Addiert zwei Parameter und gibt
+//das Ergebnis aus.
+//---------------------------------
+int CmdParamAddInt();
+
+#endif //COMMANDS_H
+
diff --git a/src/tests/BSY3/Abgabe/src/Makefile b/src/tests/BSY3/Abgabe/src/Makefile
new file mode 100644 (file)
index 0000000..137c0a1
--- /dev/null
@@ -0,0 +1,108 @@
+############################################################################
+# Workfile: Makefile
+# Author: Daniel Giritzer
+# Date: 25.10.2016
+# Description: Advanced Makefile for Unix based Operating Systems
+# Revision: 5.7
+# Usage: make debug            - builds debug version
+#               make release   - builds release version
+#               make (all)             - builds debug and release version
+#               make clean             - cleans project
+#               make rebuild           - builds everything from scratch
+############################################################################
+
+####################
+#GENERAL | EDIT 1/3
+####################
+WORKDIR = $(shell pwd)
+SOURCES := $(shell ls *.c)
+PROJNAME = CommandInterpreter
+
+CC = gcc
+LD = gcc
+
+INC =
+CFLAGS = -Wall -fexceptions
+LIBDIR =
+LIB =
+LDFLAGS =
+
+############################
+#DEBUG SETTINGS | EDIT: 2/3
+############################
+INC_DEBUG = $(INC)
+CFLAGS_DEBUG = $(CFLAGS) -ggdb3
+LIBDIR_DEBUG = $(LIBDIR)
+LIB_DEBUG = $(LIB)
+LDFLAGS_DEBUG = $(LDFLAGS)
+OBJDIR_DEBUG = obj/Debug
+DEP_DEBUG =
+OUT_DEBUG = bin/Debug/$(PROJNAME)
+
+
+##############################
+#RELEASE SETTINGS | EDIT: 3/3
+##############################
+INC_RELEASE = $(INC)
+CFLAGS_RELEASE = $(CFLAGS) -O2
+LIBDIR_RELEASE = $(LIBDIR)
+LIB_RELEASE = $(LIB)
+LDFLAGS_RELEASE = $(LDFLAGS) -s
+OBJDIR_RELEASE = obj/Release
+DEP_RELEASE =
+OUT_RELEASE = bin/Release/$(PROJNAME)
+
+############################
+#OBJECT LISTS | DO NOT EDIT!
+############################
+OBJ_DEBUG = $(addprefix $(OBJDIR_DEBUG)/,$(SOURCES:%.c=%.o))
+OBJ_RELEASE = $(addprefix $(OBJDIR_RELEASE)/,$(SOURCES:%.c=%.o))
+
+
+##########################
+#FUNCTIONS | DO NOT EDIT!
+##########################
+
+######## General
+all All: debug release
+clean Clean: cleanDebug cleanRelease
+rebuild Rebuild: clean debug release
+
+######## DEBUG
+before_debug:
+       test -d bin/Debug || mkdir -p bin/Debug
+       test -d $(OBJDIR_DEBUG) || mkdir -p $(OBJDIR_DEBUG)
+
+debug Debug: before_debug out_debug
+
+out_debug: before_debug $(OBJ_DEBUG) $(DEP_DEBUG)
+       $(LD) $(LDFLAGS_DEBUG) $(LIBDIR_DEBUG) $(OBJ_DEBUG) $(LIB_DEBUG) -o $(OUT_DEBUG)
+
+$(OBJDIR_DEBUG)/%.o: %.c
+       $(CC) $(CFLAGS_DEBUG) $(INC_DEBUG) -c $< -o $@
+
+clean_debug cleanDebug:
+       rm -f $(OBJ_DEBUG) $(OUT_DEBUG)
+       rm -rf bin/Debug
+       rm -rf $(OBJDIR_DEBUG)
+
+
+######## RELEASE
+before_release:
+       test -d bin/Release || mkdir -p bin/Release
+       test -d $(OBJDIR_RELEASE) || mkdir -p $(OBJDIR_RELEASE)
+
+release Release: before_release out_release
+
+out_release: before_release $(OBJ_RELEASE) $(DEP_RELEASE)
+       $(LD) $(LDFLAGS_RELEASE) $(LIBDIR_RELEASE) $(OBJ_RELEASE) $(LIB_RELEASE) -o $(OUT_RELEASE)
+
+$(OBJDIR_RELEASE)/%.o: %.c
+       $(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c $< -o $@
+
+clean_release cleanRelease:
+       rm -f $(OBJ_RELEASE) $(OUT_RELEASE)
+       rm -rf bin/Release
+       rm -rf $(OBJDIR_RELEASE)
+
+.PHONY: before_debug clean_debug cleanDebug before_release clean_release cleanRelease
diff --git a/src/tests/BSY3/Abgabe/src/main.c b/src/tests/BSY3/Abgabe/src/main.c
new file mode 100644 (file)
index 0000000..0f13efe
--- /dev/null
@@ -0,0 +1,22 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: main.c
+// Author: Daniel Giritzer
+// Date: 30.11.2016
+// Description: Testtreiber fuer den Kommandointerpreter und die dazugehoer
+//              enden Module.
+// Remarks: -
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include <stdio.h>
+#include <stdlib.h>
+#include "CommandInterpreter.h"
+#include "Commands.h"
+#include "CharToFile.h"
+
+int main()
+{
+    Init(GetCmdHndTable(), (*putchar));
+    Init(GetCmdHndTable(), (*PutCharToFile));
+
+    return EXIT_SUCCESS;
+}
diff --git a/src/tests/BSY3/Angabe.pdf b/src/tests/BSY3/Angabe.pdf
new file mode 100644 (file)
index 0000000..c174c01
Binary files /dev/null and b/src/tests/BSY3/Angabe.pdf differ
diff --git a/src/tests/BSY3/src/CharToFile.c b/src/tests/BSY3/src/CharToFile.c
new file mode 100644 (file)
index 0000000..188d54e
--- /dev/null
@@ -0,0 +1,50 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: CharToFile.c
+// Author: Daniel Giritzer
+// Date: 30.11.2016
+// Description: Schreibt uebergebenen char auf eine Datei (append)
+// Remarks: Source Datei
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include <stdio.h>
+#include "CharToFile.h"
+#include "CommandInterpreter.h"
+
+int PutCharToFile(int ch)
+{
+
+    //Dateiname
+    char const * const fname = "CharToFile.txt";
+
+    //Versuche Dateien zu oeffnen
+    //Erstelle zu schreibende Datei falls sie nicht existiert
+    FILE * fd_write = fopen(fname, "a");
+
+    //Fehler ausgeben Falls Datei nicht
+    //geoeffnet / erstellt werden kann
+    if(fd_write == NOK)
+    {
+        perror("Error in Open: ");
+        return NOK;
+    }
+
+
+    if(fprintf(fd_write, "%c", ch) < NOK)
+    {
+        //Fehler ausgeben Falls nicht geschrieben
+        //werden kann
+        perror("Error in Write: ");
+        return NOK;
+    }
+
+    //schliessen der Datei
+    if(fclose(fd_write) == EOF)
+    {
+        //Fehler falls Error beim
+        //schliessen
+        perror("Error in Close: ");
+        return NOK;
+    }
+
+    return OK;
+}
diff --git a/src/tests/BSY3/src/CharToFile.h b/src/tests/BSY3/src/CharToFile.h
new file mode 100644 (file)
index 0000000..2f75347
--- /dev/null
@@ -0,0 +1,17 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: CharToFile.c
+// Author: Daniel Giritzer
+// Date: 30.11.2016
+// Description: Schreibt uebergebenen char auf eine Datei (append)
+// Remarks: Header Datei
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#ifndef CHARTOFILE_H_INCLUDED
+#define CHARTOFILE_H_INCLUDED
+//---------------------------------
+//Schreibt uebergebenen Char
+//auf eine Datei
+//---------------------------------
+int PutCharToFile(int);
+
+#endif // CHARTOFILE_H_INCLUDED
diff --git a/src/tests/BSY3/src/CommandInterpreter.c b/src/tests/BSY3/src/CommandInterpreter.c
new file mode 100644 (file)
index 0000000..420929d
--- /dev/null
@@ -0,0 +1,154 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: CommandInterpreter.c
+// Author: Daniel Giritzer
+// Date: 29.11.2016
+// Description: Interpretiert Texteingaben und fuehrt die Dazugehörigen
+//              Funktionen aus.
+// Remarks: Quelldatei
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include "CommandInterpreter.h"
+#include "string.h"
+#include "stdio.h"
+
+static TParameters params; //Eingabepuffer
+static int (*PutChar)(int);
+static TCmdHndTable const * cmdTable;
+
+//---------------------------------
+//Leert den Eingabepuffer.
+//---------------------------------
+static void ClearParams()
+{
+    for(int i = 0; i < MAX_PARAMS+1; i++)
+    {
+        memset(params.params[i], 0, MAX_PARAMLEN+1);
+    }
+}
+
+//---------------------------------
+//Initialisiert den CommandInterpreter
+//und Startet Eingabe.
+//---------------------------------
+void Init(TCmdHndTable const cmds[], int (*PutCharacter)(int))
+{
+    PutChar = PutCharacter;
+    cmdTable = cmds;
+    int isError = 0;
+
+    Print("Willkommen!\n");
+    PutChar('>');
+    while((isError = Process(getchar())) != ESCAPE)
+    {
+        //Error ausgeben
+        if(isError == NOK)
+        {
+            Print("\nERROR!");
+            PutChar('\n');
+            PutChar('>');
+        }
+    }
+}
+
+//---------------------------------
+//Gibt die Parameterliste
+//zurrueck.
+//---------------------------------
+TParameters GetParams()
+{
+    return params;
+}
+
+//---------------------------------
+//Wertet die Eingabe aus, und
+//ruft Falls nötig die entsprechende
+//Funktion auf.
+//---------------------------------
+int Process(char ch)
+{
+    static int param = 0;
+    static int paramlen = 0;
+    int i = 0;
+    int isError = OK;
+
+    //Beendet Eingabe (Escape)
+    if(ch == '\033')
+    {
+        return ESCAPE;
+    }
+
+    //Parse parameter bei \n oder \r
+    else if(ch == '\n' || ch == '\r')
+    {
+        while(cmdTable[i].cmd_name != 0)
+        {
+            //Ist Parameter in der Kommandoliste enthalten
+            //fuehre die dazugehoerende Funktion aus
+            if(strcmp(params.params[0],cmdTable[i].cmd_name) == 0)
+            {
+                isError = cmdTable[i].command();
+                break;
+            }
+            //Hinweis dass Kommando nicht gefunden wurde
+            //ausgeben
+            else if(cmdTable[i + 1].cmd_name == 0)
+            {
+                Print("\nKommando nicht gefunden.");
+            }
+            i++;
+        }
+
+        //OK ausgeben
+        if(isError == OK)
+        {
+            Print("\nOK");
+            //Promptzeichen ausgeben
+            PutChar('\n');
+            PutChar('>');
+        }
+
+        //Parameterbuffer Ruecksetzten
+        ClearParams();
+        param = 0;
+        paramlen = 0;
+        return isError;
+    }
+
+    //Nach leerschritt Folgen Parameter
+    else if(ch == ' ')
+    {
+        param++;
+        paramlen = 0;
+        if(param > MAX_PARAMS)
+        {
+            isError = NOK;
+        }
+    }
+
+    //Zeichen in den Parameterpuffer schreiben
+    else
+    {
+        params.params[param][paramlen] = ch;
+        paramlen++;
+        if(paramlen > MAX_PARAMLEN)
+        {
+            isError = NOK;
+        }
+    }
+
+    PutChar(ch);
+
+    return isError;
+}
+
+//---------------------------------
+//Gibt einen String (char array)
+//mit der PutChar Funktion aus.
+//---------------------------------
+void Print(char* str)
+{
+    for(int i = 0; i < strlen(str); i++)
+    {
+        PutChar(str[i]);
+    }
+}
diff --git a/src/tests/BSY3/src/CommandInterpreter.h b/src/tests/BSY3/src/CommandInterpreter.h
new file mode 100644 (file)
index 0000000..a62adee
--- /dev/null
@@ -0,0 +1,52 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: CommandInterpreter.h
+// Author: Daniel Giritzer
+// Date: 29.11.2016
+// Description: Interpretiert Texteingaben und fuehrt die Dazugehörigen
+//              Funktionen aus.
+// Remarks: Header Datei
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#ifndef COMMANDINTERPRETER_H_INCLUDED
+#define COMMANDINTERPRETER_H_INCLUDED
+#include "Commands.h"
+
+//Konstanten
+#define MAX_INPUTLEN 128
+#define MAX_PARAMS 16
+#define MAX_PARAMLEN 32
+#define NOK 0
+#define OK 1
+#define ESCAPE 003
+
+//Dateityp fuer die Parameterliste
+typedef struct
+{
+    char params[MAX_PARAMS+1][MAX_PARAMLEN+1];
+} TParameters;
+
+//---------------------------------
+//Initialisiert den CommandInterpreter
+//und Startet Eingabe.
+//---------------------------------
+void Init(TCmdHndTable const cmds[], int (*PutCharacter)(int));
+
+//---------------------------------
+//Gibt die Parameterliste
+//zurrueck.
+//---------------------------------
+TParameters GetParams();
+
+//---------------------------------
+//Wertet die Eingabe aus, und
+//ruft Falls nötig die entsprechende
+//Funktion auf.
+//---------------------------------
+int Process(char ch);
+
+//---------------------------------
+//Gibt einen String (char array)
+//mit der PutChar Funktion aus.
+//---------------------------------
+void Print(char* str);
+#endif //COMMANDINTERPRETER_H
diff --git a/src/tests/BSY3/src/Commands.c b/src/tests/BSY3/src/Commands.c
new file mode 100644 (file)
index 0000000..994acbe
--- /dev/null
@@ -0,0 +1,166 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Commands.c
+// Author: Daniel Giritzer
+// Date: 29.11.2016
+// Description: Verschiedene Befehle die mit dem CommandoInterpreter
+//              Modul verwendet werden koennen.
+// Remarks: Source Datei
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include "Commands.h"
+#include "CommandInterpreter.h"
+#include <stdio.h>
+
+//Kommandotabelle
+static TCmdHndTable const cmdTable[] =
+{
+    //Funktion, Kommando, Beschreibung
+    {CmdHelp, "help", "show help text"},
+    {CmdHelp, "?", "show help text"},
+    {CmdParamInt, "int", "[value] first parameter as integer"},
+    {CmdParamFloat, "float", "[value] first parameter as float"},
+    {CmdParamString, "string", "[value] first parameter as string"},
+    {CmdParamAddInt, "addint", "addint [value1] [value2] adds two integer values"},
+    {0, 0, 0}
+};
+
+//---------------------------------
+//Gibt Pointer auf die Kommandotabelle
+//zurrueck.
+//---------------------------------
+TCmdHndTable const* GetCmdHndTable()
+{
+    return cmdTable;
+}
+
+//---------------------------------
+//Gibt Hilfetext aus.
+//---------------------------------
+int CmdHelp()
+{
+    int i = 0;
+    Print("\n");
+    while(cmdTable[i].command != 0)
+    {
+        //Durch Kommandotabeele iterieren
+        //und Befehlsname + Befehlstext ausgeben.
+        Print(cmdTable[i].cmd_name);
+        Print("\t - \t");
+        Print(cmdTable[i].cmd_info);
+        Print("\n");
+        i++;
+    }
+    return OK;
+}
+
+//---------------------------------
+//Gibt Parameter als Integer aus.
+//---------------------------------
+int CmdParamInt()
+{
+    int i;
+    char c[MAX_PARAMLEN];
+    TParameters params = GetParams();
+    Print("\n");
+    Print("Parameter: ");
+    if(sscanf(params.params[1], "%d", &i) == OK)
+    {
+        //Falls Umwandlung OK Ergebnis in einen String Speichern
+        sprintf(c, "%d", i);
+
+        //String ausgeben
+        Print(c);
+        return OK;
+    }
+    else
+    {
+        //Ansonsten Parameter ausgeben
+        Print(params.params[1]);
+    }
+    return NOK;
+}
+
+//---------------------------------
+//Gibt Parameter als Float aus.
+//---------------------------------
+int CmdParamFloat()
+{
+    float i;
+    char c[MAX_PARAMLEN];
+    TParameters params = GetParams();
+    Print("\n");
+    Print("Parameter: ");
+    if(sscanf(params.params[1], "%f", &i) == OK)
+    {
+        //Falls Umwandlung OK Ergebnis in einen String Speichern
+        sprintf(c, "%f", i);
+
+        //String ausgeben
+        Print(c);
+        return OK;
+    }
+    else
+    {
+        //Ansonsten Parameter ausgeben
+        Print(params.params[1]);
+    }
+    return NOK;
+}
+
+//---------------------------------
+//Gibt Parameter als String aus.
+//---------------------------------
+int CmdParamString()
+{
+    char i[MAX_PARAMLEN];
+    char c[MAX_PARAMLEN];
+    TParameters params = GetParams();
+    Print("\n");
+    Print("Parameter: ");
+    if(sscanf(params.params[1], "%s", i) == OK)
+    {
+        //Falls Umwandlung OK Ergebnis in einen String Speichern
+        sprintf(c, "%s", i);
+
+        //String ausgeben
+        Print(c);
+        return OK;
+    }
+    else
+    {
+        Print(params.params[1]);
+    }
+    return NOK;
+}
+
+//---------------------------------
+//Addiert zwei Parameter und gibt
+//das Ergebnis aus.
+//---------------------------------
+int CmdParamAddInt()
+{
+    int i;
+    int ii;
+    char c[MAX_PARAMLEN];
+    TParameters params = GetParams();
+
+    Print("\n");
+    Print("Result: ");
+    if(sscanf(params.params[1], "%d", &i) == OK && sscanf(params.params[2], "%d", &ii) == OK)
+    {
+        //Falls Umwandlung OK Ergebnis in einen String Speichern
+        sprintf(c, "%d + %d = %d", i, ii, i + ii);
+
+        //String ausgeben
+        Print(c);
+        return OK;
+    }
+    else
+    {
+        //Ansonsten Parameter ausgeben
+        Print(params.params[1]);
+        Print(" ");
+        Print(params.params[2]);
+    }
+    return NOK;
+}
diff --git a/src/tests/BSY3/src/Commands.h b/src/tests/BSY3/src/Commands.h
new file mode 100644 (file)
index 0000000..469f833
--- /dev/null
@@ -0,0 +1,55 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Commands.h
+// Author: Daniel Giritzer
+// Date: 29.11.2016
+// Description: Verschiedene Befehle die mit dem CommandoInterpreter
+//              Modul verwendet werden koennen.
+// Remarks: Header Datei
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#ifndef COMMANDS_H_INCLUDED
+#define COMMANDS_H_INCLUDED
+
+//Datentyp der die Kommandotabelle
+//beschreibt.
+typedef struct
+{
+    int (* const command)();
+    char * const cmd_name;
+    char * const cmd_info;
+} TCmdHndTable;
+
+//---------------------------------
+//Gibt Pointer auf die Kommandotabelle
+//zurrueck.
+//---------------------------------
+TCmdHndTable const* GetCmdHndTable();
+
+//---------------------------------
+//Gibt Hilfetext aus.
+//---------------------------------
+int CmdHelp();
+
+//---------------------------------
+//Gibt Parameter als Integer aus.
+//---------------------------------
+int CmdParamInt();
+
+//---------------------------------
+//Gibt Parameter als Float aus.
+//---------------------------------
+int CmdParamFloat();
+
+//---------------------------------
+//Gibt Parameter als String aus.
+//---------------------------------
+int CmdParamString();
+
+//---------------------------------
+//Addiert zwei Parameter und gibt
+//das Ergebnis aus.
+//---------------------------------
+int CmdParamAddInt();
+
+#endif //COMMANDS_H
+
diff --git a/src/tests/BSY3/src/Makefile b/src/tests/BSY3/src/Makefile
new file mode 100644 (file)
index 0000000..137c0a1
--- /dev/null
@@ -0,0 +1,108 @@
+############################################################################
+# Workfile: Makefile
+# Author: Daniel Giritzer
+# Date: 25.10.2016
+# Description: Advanced Makefile for Unix based Operating Systems
+# Revision: 5.7
+# Usage: make debug            - builds debug version
+#               make release   - builds release version
+#               make (all)             - builds debug and release version
+#               make clean             - cleans project
+#               make rebuild           - builds everything from scratch
+############################################################################
+
+####################
+#GENERAL | EDIT 1/3
+####################
+WORKDIR = $(shell pwd)
+SOURCES := $(shell ls *.c)
+PROJNAME = CommandInterpreter
+
+CC = gcc
+LD = gcc
+
+INC =
+CFLAGS = -Wall -fexceptions
+LIBDIR =
+LIB =
+LDFLAGS =
+
+############################
+#DEBUG SETTINGS | EDIT: 2/3
+############################
+INC_DEBUG = $(INC)
+CFLAGS_DEBUG = $(CFLAGS) -ggdb3
+LIBDIR_DEBUG = $(LIBDIR)
+LIB_DEBUG = $(LIB)
+LDFLAGS_DEBUG = $(LDFLAGS)
+OBJDIR_DEBUG = obj/Debug
+DEP_DEBUG =
+OUT_DEBUG = bin/Debug/$(PROJNAME)
+
+
+##############################
+#RELEASE SETTINGS | EDIT: 3/3
+##############################
+INC_RELEASE = $(INC)
+CFLAGS_RELEASE = $(CFLAGS) -O2
+LIBDIR_RELEASE = $(LIBDIR)
+LIB_RELEASE = $(LIB)
+LDFLAGS_RELEASE = $(LDFLAGS) -s
+OBJDIR_RELEASE = obj/Release
+DEP_RELEASE =
+OUT_RELEASE = bin/Release/$(PROJNAME)
+
+############################
+#OBJECT LISTS | DO NOT EDIT!
+############################
+OBJ_DEBUG = $(addprefix $(OBJDIR_DEBUG)/,$(SOURCES:%.c=%.o))
+OBJ_RELEASE = $(addprefix $(OBJDIR_RELEASE)/,$(SOURCES:%.c=%.o))
+
+
+##########################
+#FUNCTIONS | DO NOT EDIT!
+##########################
+
+######## General
+all All: debug release
+clean Clean: cleanDebug cleanRelease
+rebuild Rebuild: clean debug release
+
+######## DEBUG
+before_debug:
+       test -d bin/Debug || mkdir -p bin/Debug
+       test -d $(OBJDIR_DEBUG) || mkdir -p $(OBJDIR_DEBUG)
+
+debug Debug: before_debug out_debug
+
+out_debug: before_debug $(OBJ_DEBUG) $(DEP_DEBUG)
+       $(LD) $(LDFLAGS_DEBUG) $(LIBDIR_DEBUG) $(OBJ_DEBUG) $(LIB_DEBUG) -o $(OUT_DEBUG)
+
+$(OBJDIR_DEBUG)/%.o: %.c
+       $(CC) $(CFLAGS_DEBUG) $(INC_DEBUG) -c $< -o $@
+
+clean_debug cleanDebug:
+       rm -f $(OBJ_DEBUG) $(OUT_DEBUG)
+       rm -rf bin/Debug
+       rm -rf $(OBJDIR_DEBUG)
+
+
+######## RELEASE
+before_release:
+       test -d bin/Release || mkdir -p bin/Release
+       test -d $(OBJDIR_RELEASE) || mkdir -p $(OBJDIR_RELEASE)
+
+release Release: before_release out_release
+
+out_release: before_release $(OBJ_RELEASE) $(DEP_RELEASE)
+       $(LD) $(LDFLAGS_RELEASE) $(LIBDIR_RELEASE) $(OBJ_RELEASE) $(LIB_RELEASE) -o $(OUT_RELEASE)
+
+$(OBJDIR_RELEASE)/%.o: %.c
+       $(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c $< -o $@
+
+clean_release cleanRelease:
+       rm -f $(OBJ_RELEASE) $(OUT_RELEASE)
+       rm -rf bin/Release
+       rm -rf $(OBJDIR_RELEASE)
+
+.PHONY: before_debug clean_debug cleanDebug before_release clean_release cleanRelease
diff --git a/src/tests/BSY3/src/main.c b/src/tests/BSY3/src/main.c
new file mode 100644 (file)
index 0000000..0f13efe
--- /dev/null
@@ -0,0 +1,22 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: main.c
+// Author: Daniel Giritzer
+// Date: 30.11.2016
+// Description: Testtreiber fuer den Kommandointerpreter und die dazugehoer
+//              enden Module.
+// Remarks: -
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include <stdio.h>
+#include <stdlib.h>
+#include "CommandInterpreter.h"
+#include "Commands.h"
+#include "CharToFile.h"
+
+int main()
+{
+    Init(GetCmdHndTable(), (*putchar));
+    Init(GetCmdHndTable(), (*PutCharToFile));
+
+    return EXIT_SUCCESS;
+}
diff --git a/src/tests/MPT3_KOM4/Angabe.pdf b/src/tests/MPT3_KOM4/Angabe.pdf
new file mode 100644 (file)
index 0000000..dbcb769
Binary files /dev/null and b/src/tests/MPT3_KOM4/Angabe.pdf differ
diff --git a/src/tests/MPT3_KOM4/src/main.c b/src/tests/MPT3_KOM4/src/main.c
new file mode 100644 (file)
index 0000000..13b6bd3
--- /dev/null
@@ -0,0 +1,146 @@
+////////////////////////////////////////////\r
+//Author: Daniel Giritzer, S1510306010\r
+//File: main.c\r
+//Description: Testet die Funktionen des\r
+//                                              UART3 Moduls.\r
+/////////////////////////////////////////////\r
+#include "stm32f2xx_hal.h"\r
+#include "board_led.h"\r
+#include "board_keys.h"\r
+#include "uart3.h"\r
+\r
+static void SystemClock_Config(void);\r
+\r
+///////////////////////////////\r
+//Daten empfangen und entsprechende\r
+//LED ein- oder ausschalten\r
+///////////////////////////////\r
+void UART_Led_Data(void)\r
+{\r
+               switch(UART3_GetChar())\r
+               {\r
+                       case '0' :      HAL_Delay(1000); LED_On(0); break;\r
+                       case '1' :      HAL_Delay(1000); LED_On(1); break;\r
+                       case '2' :      LED_On(2); break;\r
+                       case '3' :      LED_On(3); break;\r
+                       case '4' :      LED_On(4); break;\r
+                       case '5' :      LED_On(5); break;\r
+                       case '6' :      LED_On(6); break;\r
+                       case '7' :      LED_On(7); break;\r
+                       case '8' :  HAL_Delay(1000);    LED_Off(0); break;\r
+                       case '9' :      HAL_Delay(1000);        LED_Off(1); break;\r
+               }\r
+}\r
+\r
+\r
+///////////////////////////////\r
+//Hilfsfunktion:\r
+//Alle LEDs wieder ausschalten\r
+///////////////////////////////\r
+void Led_Reset(void)\r
+{\r
+       int i = 0;\r
+       for(i = 0; i <= 7; i++)\r
+       {\r
+               LED_Off(i);\r
+       }\r
+}\r
+\r
+\r
+int main(void)\r
+{\r
+       int i = 0;\r
+       \r
+  HAL_Init();\r
+  LED_Initialize();\r
+       KEYS_Init();\r
+       UART3_Init();\r
+\r
+  while (1)\r
+  {\r
+               \r
+               //Test1: String so lange wie TX Buffer\r
+               //Ist RX kleiner als TX gehen bytes verloren (Test 5)\r
+               //Ist TX kleiner als RX ist die uebertragung langsamer (Test 6)\r
+               UART3_PutStr("0123456789018901");\r
+               HAL_Delay(2000);\r
+               for(i = 0; i<=16; i++)\r
+               {\r
+                       UART_Led_Data();\r
+               }       \r
+               \r
+               HAL_Delay(2000);\r
+               Led_Reset();\r
+               \r
+               //Test2: String mit 10 Bytes senden\r
+               UART3_PutStr("0123456789");\r
+               HAL_Delay(2000);\r
+               for(i = 0; i<=11; i++)\r
+               {\r
+                       UART_Led_Data();\r
+               }\r
+               \r
+               HAL_Delay(2000);\r
+               Led_Reset();\r
+               \r
+               //Test3: zu langen String senden\r
+               UART3_PutStr("012345677777777789");\r
+               HAL_Delay(2000);\r
+               for(i = 0; i<= 16; i++)\r
+               {\r
+                       UART_Led_Data();\r
+               }\r
+               HAL_Delay(2000);\r
+               Led_Reset();\r
+               \r
+               //Test4: direkte Ausgabe (kein Delay)\r
+               UART3_PutStr("0123456789");\r
+               for(i = 0; i<=11; i++)\r
+               {\r
+                       UART_Led_Data();\r
+               }\r
+  }\r
+}\r
+\r
+static void SystemClock_Config(void)\r
+{\r
+  RCC_ClkInitTypeDef RCC_ClkInitStruct;\r
+  RCC_OscInitTypeDef RCC_OscInitStruct;\r
+\r
+  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;\r
+  RCC_OscInitStruct.HSEState = RCC_HSE_ON;\r
+  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;\r
+  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;\r
+  RCC_OscInitStruct.PLL.PLLM = 25;\r
+  RCC_OscInitStruct.PLL.PLLN = 240;\r
+  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;\r
+  RCC_OscInitStruct.PLL.PLLQ = 5;\r
+  HAL_RCC_OscConfig(&RCC_OscInitStruct);\r
+  \r
+  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK |\r
+                                RCC_CLOCKTYPE_PCLK1  | RCC_CLOCKTYPE_PCLK2;\r
+  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;\r
+  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;\r
+  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;\r
+  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;\r
+  HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3);\r
+}\r
+\r
+void HAL_MspInit(void) {\r
+  SystemClock_Config();\r
+  SystemCoreClockUpdate();\r
+  SysTick_Config(SystemCoreClock / 1000);\r
+}\r
+\r
+#ifdef RTE_CMSIS_RTOS_RTX\r
+\r
+extern uint32_t os_time;\r
+\r
+uint32_t HAL_GetTick(void) {\r
+  return os_time;\r
+}\r
+#else\r
+void SysTick_Handler(){\r
+  HAL_IncTick();\r
+}\r
+#endif\r
diff --git a/src/tests/MPT3_KOM4/src/uart3.c b/src/tests/MPT3_KOM4/src/uart3.c
new file mode 100644 (file)
index 0000000..bc2d04f
--- /dev/null
@@ -0,0 +1,177 @@
+////////////////////////////////////////////\r
+//Author: Daniel Giritzer, S1510306010\r
+//File: uart3.h\r
+//Description: Funktionen zur Verwendung des\r
+//                                              UART Interfaces mit Ringbuffer.\r
+/////////////////////////////////////////////\r
+#include "uart3.h"\r
+#include "stm32f2xx_hal.h"\r
+#include "board_led.h"\r
+#include <string.h>\r
+\r
+//Definitionen Ringbuffer\r
+#define RX_BUFFER_SIZE 16 //Test5: 8\r
+#define RX_BUFFER_MASK (RX_BUFFER_SIZE - 1)\r
+\r
+#define TX_BUFFER_SIZE 16 //Test6: 8\r
+#define TX_BUFFER_MASK (TX_BUFFER_SIZE - 1)\r
+\r
+static volatile uint8_t  UART_RxBuf[RX_BUFFER_SIZE];\r
+static volatile uint32_t UART_RxHead = 0;\r
+static volatile uint32_t UART_RxTail = 0;\r
+\r
+static volatile uint8_t UART_TxBuf[TX_BUFFER_SIZE];\r
+static volatile uint32_t UART_TxHead = 0;\r
+static volatile uint32_t UART_TxTail = 0;\r
+\r
+static const uint16_t NOK = -1;\r
+\r
+///////////////////////////////\r
+//Initialisiert die UART\r
+//Schnittstelle und den\r
+//Ringbuffer.\r
+///////////////////////////////\r
+void UART3_Init(void)\r
+{\r
+       GPIO_InitTypeDef GPIO_InitStruct;\r
+       //Clock fuer Port C einschalten\r
+       __GPIOC_CLK_ENABLE();\r
+\r
+       //GPIO Receive Port als Alternate Function Port\r
+       //Konfigurieren\r
+       GPIO_InitStruct.Pin = GPIO_PIN_10;\r
+       GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;\r
+       GPIO_InitStruct.Alternate = GPIO_AF7_USART3;\r
+       HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);\r
+\r
+       //GPIO Transmit Port als Alternate Function Port\r
+       //Konfigurieren\r
+       GPIO_InitStruct.Pin = GPIO_PIN_11;\r
+       HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);\r
+\r
+       //USART3 Clock einschalten\r
+       __USART3_CLK_ENABLE();\r
+\r
+       //Usart einschalten, receive enable, transmitter enable\r
+       USART3->CR1 |= USART_CR1_RE | USART_CR1_UE | USART_CR1_TE;\r
+\r
+       //Anzahl der Stopbits einstellen\r
+       USART3->CR2 |= USART_CR2_STOP_1;\r
+\r
+       //Baudrate Einstellen\r
+       //USARTDIV = 16,25 (aus Tabelle 30MHz)\r
+       //DIV_FRACTION = 0,25 * 16 = 0x4\r
+       //16,00 = 0x10\r
+       //Ergebnisse zusammensetzten: 0x104\r
+       USART3->BRR = 0x104;\r
+\r
+\r
+       //Init Ringbuffer Pointer\r
+       UART_RxHead = 0;\r
+       UART_RxTail = 0;\r
+       UART_TxHead = 0;\r
+       UART_TxTail = 0;\r
+\r
+       //Interrupt in der NVIC Tabelle Aktivieren\r
+       NVIC_EnableIRQ(USART3_IRQn);\r
+}\r
+\r
+///////////////////////////////\r
+//Sendet einen Char ueber die\r
+//UART Schnittstelle.\r
+///////////////////////////////\r
+void UART3_PutChar(uint8_t txByte)\r
+{\r
+       uint32_t tmpHead;\r
+       \r
+       tmpHead = (UART_TxHead + 1) & TX_BUFFER_MASK;\r
+       \r
+       //Warten bis Buffer frei wird\r
+       while(tmpHead == UART_TxTail){};\r
+       \r
+       UART_TxBuf[tmpHead] = txByte;\r
+       UART_TxHead = tmpHead;\r
+       \r
+       USART3->CR1 |= USART_CR1_TXEIE; \r
+}\r
+\r
+///////////////////////////////\r
+//Empfaengt einen Char ueber die\r
+//UART Schnittstelle.\r
+///////////////////////////////\r
+int16_t UART3_GetChar(void)\r
+{\r
+       // Pruefe ob Buffer leer ist\r
+       if(UART_RxTail == UART_RxHead)\r
+       {\r
+               // Falls ja, error\r
+               return NOK;\r
+       }\r
+       \r
+       // Tail nachruecken\r
+       UART_RxTail = (UART_RxTail + 1) & RX_BUFFER_MASK;\r
+       \r
+       // Tail zurrueckgeben\r
+       return (int16_t)UART_RxBuf[UART_RxTail];\r
+}\r
+\r
+///////////////////////////////\r
+//Sendet einen String ueber die\r
+//UART Schnittstelle.\r
+//(Unter Verwendung von PutChar)\r
+///////////////////////////////\r
+void UART3_PutStr(char* str)\r
+{\r
+       int i = 0;\r
+       for(i = 0; i <= strlen(str); i++)\r
+       {\r
+               UART3_PutChar(str[i]);\r
+       }\r
+\r
+}\r
+\r
+///////////////////////////////\r
+//Usart Interrupt Handler\r
+///////////////////////////////\r
+void USART3_IRQHandler(void)\r
+{\r
+       volatile uint32_t status = USART3->SR;\r
+       \r
+       if(status & USART_SR_TXE)\r
+       {\r
+               volatile uint32_t tmpTail;\r
+               \r
+               if(UART_TxHead == UART_TxTail)\r
+               {\r
+                       // Keine Daten mehr im TX Buffer\r
+                       // TX Interrupt ausschalten\r
+                       USART3->CR1 &= ~USART_CR1_TXEIE;\r
+               }\r
+               else\r
+               {\r
+                       tmpTail = (UART_TxTail + 1) & TX_BUFFER_MASK;\r
+                       UART_TxTail = tmpTail;\r
+                       // Uebertragung Starten\r
+                       USART3->DR = UART_TxBuf[UART_TxTail];\r
+               }\r
+       }\r
+       \r
+       if(status & USART_SR_RXNE)\r
+       {\r
+               volatile uint8_t  tmpData = (uint8_t)USART3->DR;\r
+               volatile uint32_t tmpHead;\r
+               \r
+               tmpHead = (UART_RxHead + 1) & RX_BUFFER_MASK;\r
+               \r
+               if(tmpHead == UART_RxTail)\r
+               {\r
+                       //Daten Verwerfen\r
+               }\r
+               else\r
+               {\r
+                       UART_RxBuf[tmpHead] = tmpData;\r
+                       UART_RxHead = tmpHead;\r
+               }\r
+       }\r
+}\r
+\r
diff --git a/src/tests/MPT3_KOM4/src/uart3.h b/src/tests/MPT3_KOM4/src/uart3.h
new file mode 100644 (file)
index 0000000..3aeb5eb
--- /dev/null
@@ -0,0 +1,33 @@
+////////////////////////////////////////////\r
+//Author: Daniel Giritzer, S1510306010\r
+//File: uart3.h\r
+//Description: Funktionen zur Verwendung des\r
+//                                              UART Interfaces mit Ringbuffer.\r
+/////////////////////////////////////////////\r
+#include <stdint.h>\r
+\r
+///////////////////////////////\r
+//Initialisiert die UART\r
+//Schnittstelle und den\r
+//Ringbuffer.\r
+///////////////////////////////\r
+void UART3_Init(void);\r
+\r
+///////////////////////////////\r
+//Sendet einen Char ueber die\r
+//UART Schnittstelle.\r
+///////////////////////////////\r
+void UART3_PutChar(uint8_t txByte);\r
+\r
+///////////////////////////////\r
+//Empfaengt einen Char ueber die\r
+//UART Schnittstelle.\r
+///////////////////////////////\r
+int16_t UART3_GetChar(void);\r
+\r
+///////////////////////////////\r
+//Sendet einen String ueber die\r
+//UART Schnittstelle.\r
+//(Unter Verwendung von PutChar)\r
+///////////////////////////////\r
+void UART3_PutStr(char* str);\r
diff --git a/src/tests/PSS4/Angabe.pdf b/src/tests/PSS4/Angabe.pdf
new file mode 100644 (file)
index 0000000..7321b99
Binary files /dev/null and b/src/tests/PSS4/Angabe.pdf differ
diff --git a/src/tests/PSS4/Beispiel1/.vs/Process/v14/.suo b/src/tests/PSS4/Beispiel1/.vs/Process/v14/.suo
new file mode 100755 (executable)
index 0000000..b4ea044
Binary files /dev/null and b/src/tests/PSS4/Beispiel1/.vs/Process/v14/.suo differ
diff --git a/src/tests/PSS4/Beispiel1/Process.sln b/src/tests/PSS4/Beispiel1/Process.sln
new file mode 100755 (executable)
index 0000000..974a5df
--- /dev/null
@@ -0,0 +1,28 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Visual Studio 14\r
+VisualStudioVersion = 14.0.25420.1\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Process", "Process\Process.vcxproj", "{455590C5-7DF0-41A6-B693-0F1B3CB7A6F8}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|x64 = Debug|x64\r
+               Debug|x86 = Debug|x86\r
+               Release|x64 = Release|x64\r
+               Release|x86 = Release|x86\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {455590C5-7DF0-41A6-B693-0F1B3CB7A6F8}.Debug|x64.ActiveCfg = Debug|x64\r
+               {455590C5-7DF0-41A6-B693-0F1B3CB7A6F8}.Debug|x64.Build.0 = Debug|x64\r
+               {455590C5-7DF0-41A6-B693-0F1B3CB7A6F8}.Debug|x86.ActiveCfg = Debug|Win32\r
+               {455590C5-7DF0-41A6-B693-0F1B3CB7A6F8}.Debug|x86.Build.0 = Debug|Win32\r
+               {455590C5-7DF0-41A6-B693-0F1B3CB7A6F8}.Release|x64.ActiveCfg = Release|x64\r
+               {455590C5-7DF0-41A6-B693-0F1B3CB7A6F8}.Release|x64.Build.0 = Release|x64\r
+               {455590C5-7DF0-41A6-B693-0F1B3CB7A6F8}.Release|x86.ActiveCfg = Release|Win32\r
+               {455590C5-7DF0-41A6-B693-0F1B3CB7A6F8}.Release|x86.Build.0 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/src/tests/PSS4/Beispiel1/Process/Hlp.cpp b/src/tests/PSS4/Beispiel1/Process/Hlp.cpp
new file mode 100755 (executable)
index 0000000..f22d68a
--- /dev/null
@@ -0,0 +1,30 @@
+// -----------------------------------------------------------\r
+// Implementation of simple helper functions\r
+// HSD / FH-Hagenberg\r
+// -----------------------------------------------------------\r
+\r
+#include "Hlp.h"\r
+\r
+\r
+// -----------------------------------------------------------\r
+// print a windows error as human readable string\r
+// usage:  cout << "Error: " << ErrMsg(GetLastError()) << endl;\r
+std::string Hlp::ErrMsg(DWORD LastError) {\r
+       LPVOID lpMsgBuf;\r
+       FormatMessage(\r
+               FORMAT_MESSAGE_ALLOCATE_BUFFER |\r
+               FORMAT_MESSAGE_FROM_SYSTEM |\r
+               FORMAT_MESSAGE_IGNORE_INSERTS,\r
+               0,\r
+               LastError,\r
+               MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language\r
+               (LPTSTR) &lpMsgBuf,\r
+               0,\r
+               0\r
+               );\r
+          std::string ErrStr(static_cast<char *>(lpMsgBuf));\r
+          // Free the buffer.\r
+          LocalFree( lpMsgBuf );\r
+\r
+          return ErrStr;\r
+}\r
diff --git a/src/tests/PSS4/Beispiel1/Process/Hlp.h b/src/tests/PSS4/Beispiel1/Process/Hlp.h
new file mode 100755 (executable)
index 0000000..9695a71
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef HLP_Included\r
+#define HLP_Included\r
+\r
+// -----------------------------------------------------\r
+// Simple Helper Class\r
+// This works as a repository for some useful functions.\r
+// As this are static methods no object need to be created.\r
+// HSD / FH-Hagenberg\r
+//\r
+// Usage: (1) copy Hlp.h and Hlp.cpp to your project\r
+//        (2) #include "Hlp.h"\r
+//        (3) call the method like:  Hlp::Method(..);\r
+// -----------------------------------------------------\r
+\r
+#include <string>\r
+#include <windows.h>\r
+\r
+class Hlp {\r
+       Hlp();\r
+       Hlp(Hlp const &);\r
+       Hlp& operator = (Hlp const &);\r
+\r
+public:\r
+\r
+// -----------------------------------------------------------\r
+// print a windows error as human readable string\r
+// usage:  cout << "Error: " << Hlp::ErrMsg(GetLastError()) << endl;\r
+static std::string ErrMsg(DWORD LastError);\r
+\r
+};\r
+\r
+\r
+// ---------------------------------------------------------------------------------\r
+// With this pragma you can mark positions in your code where you have to do something.\r
+// On each Rebuild-All your compiler will remind you about them (ouput window).\r
+// Simple double-click on the generated warnings and you are back at the position.\r
+//\r
+// Usage: #pragma TODO(Fehlerbehandlung einfügen!)\r
+\r
+#define todo_impl2(CodeLine) #CodeLine\r
+#define todo_impl(CodeLine)  todo_impl2(CodeLine)\r
+#define TODO(msg) message(__FILE__ "(" todo_impl(__LINE__) "): Warning TODO: " #msg)\r
+\r
+\r
+#endif
\ No newline at end of file
diff --git a/src/tests/PSS4/Beispiel1/Process/Process.cpp b/src/tests/PSS4/Beispiel1/Process/Process.cpp
new file mode 100755 (executable)
index 0000000..de1436f
--- /dev/null
@@ -0,0 +1,76 @@
+///////////////////////////////////////////////////////////////////////////\r
+// Workfile: Process.cpp\r
+// Author: Daniel Giritzer\r
+// Date: 23.03.2017\r
+// Description: Startet ein per Komanddozeile  Üergebenes Programm und \r
+//                             misst die Laufzeit.\r
+// Remarks: Verwendet Win32/64 API\r
+// Revision: 1\r
+///////////////////////////////////////////////////////////////////////////\r
+\r
+#include <iostream>\r
+#include <ctime>\r
+#include <Windows.h> //Win32/64 API\r
+#include "Hlp.h" //Hilfsklasse \r
+\r
+\r
+using namespace std;\r
+\r
+int main(int argc, char *argv[]) {\r
+\r
+       //Üergabeparameter auf 1 begrenzen\r
+       const size_t max_param = 1;\r
+\r
+       //Parameter prüfen\r
+       if (argc <= max_param)\r
+       {\r
+               cerr << "Es wurde kein Programm angegeben!" << endl;\r
+       }\r
+       else\r
+       {\r
+               cout << "Starte: " << argv[max_param] << endl;\r
+\r
+               STARTUPINFO si;\r
+               memset(&si, 0, sizeof(si));\r
+               si.cb = sizeof(si);\r
+\r
+               PROCESS_INFORMATION pi;\r
+               memset(&pi, 0, sizeof(pi));\r
+\r
+               //Starte Zeitmessung\r
+               const clock_t begin_time = clock();\r
+\r
+               //Erzeuge Prozess\r
+               if (!CreateProcess(\r
+                       0,\r
+                       argv[max_param],\r
+                       0,\r
+                       0,\r
+                       false,\r
+                       0,\r
+                       0,\r
+                       0,\r
+                       &si,\r
+                       &pi\r
+               )) \r
+               {\r
+                       //Bei Error entsprechende Fehlermeldung ausgeben.\r
+                       cout << "CreateProcess schlug fehl.... " << Hlp::ErrMsg(GetLastError()) << endl;\r
+                       return -1;\r
+               }\r
+\r
+               // Warte bis der Prozess beended wird\r
+               WaitForSingleObject(pi.hProcess, INFINITE); \r
+\r
+               // Laufzeit und PID ausgeben\r
+               cout << "Der Prozess mit der ID: " << pi.dwProcessId << " lief " <<\r
+                        float(clock() - begin_time) / CLOCKS_PER_SEC << " sek." << endl;\r
+\r
+               // Prozess und Threas handles schließen\r
+               CloseHandle(pi.hProcess);\r
+               CloseHandle(pi.hThread);\r
+       }\r
+\r
+       //Ende\r
+       return 0;\r
+}
\ No newline at end of file
diff --git a/src/tests/PSS4/Beispiel1/Process/Process.vcxproj b/src/tests/PSS4/Beispiel1/Process/Process.vcxproj
new file mode 100755 (executable)
index 0000000..07fcccb
--- /dev/null
@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup Label="ProjectConfigurations">\r
+    <ProjectConfiguration Include="Debug|Win32">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|Win32">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Debug|x64">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>x64</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|x64">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>x64</Platform>\r
+    </ProjectConfiguration>\r
+  </ItemGroup>\r
+  <PropertyGroup Label="Globals">\r
+    <ProjectGuid>{455590C5-7DF0-41A6-B693-0F1B3CB7A6F8}</ProjectGuid>\r
+    <Keyword>Win32Proj</Keyword>\r
+    <RootNamespace>ConsoleApplication1</RootNamespace>\r
+    <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>\r
+    <ProjectName>Process</ProjectName>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <PlatformToolset>v140</PlatformToolset>\r
+    <CharacterSet>NotSet</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <PlatformToolset>v140</PlatformToolset>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <PlatformToolset>v140</PlatformToolset>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <PlatformToolset>v140</PlatformToolset>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+  <ImportGroup Label="ExtensionSettings">\r
+  </ImportGroup>\r
+  <ImportGroup Label="Shared">\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <PropertyGroup Label="UserMacros" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <LinkIncremental>true</LinkIncremental>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <LinkIncremental>true</LinkIncremental>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <LinkIncremental>false</LinkIncremental>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <LinkIncremental>false</LinkIncremental>\r
+  </PropertyGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <ClCompile>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <SDLCheck>true</SDLCheck>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <ClCompile>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+      <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <SDLCheck>true</SDLCheck>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <SDLCheck>true</SDLCheck>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <SDLCheck>true</SDLCheck>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="Hlp.cpp" />\r
+    <ClCompile Include="Process.cpp" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="Hlp.h" />\r
+  </ItemGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+  <ImportGroup Label="ExtensionTargets">\r
+  </ImportGroup>\r
+</Project>
\ No newline at end of file
diff --git a/src/tests/PSS4/Beispiel1/Process/Process.vcxproj.filters b/src/tests/PSS4/Beispiel1/Process/Process.vcxproj.filters
new file mode 100755 (executable)
index 0000000..55e370d
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup>\r
+    <Filter Include="Source Files">\r
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\r
+    </Filter>\r
+    <Filter Include="Header Files">\r
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r
+      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>\r
+    </Filter>\r
+    <Filter Include="Resource Files">\r
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\r
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\r
+    </Filter>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="Process.cpp">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="Hlp.cpp">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="Hlp.h">\r
+      <Filter>Source Files</Filter>\r
+    </ClInclude>\r
+  </ItemGroup>\r
+</Project>
\ No newline at end of file
diff --git a/src/tests/PSS4/Beispiel1/Process/Process.vcxproj.user b/src/tests/PSS4/Beispiel1/Process/Process.vcxproj.user
new file mode 100755 (executable)
index 0000000..3702ae8
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <LocalDebuggerCommandArguments>notepad</LocalDebuggerCommandArguments>\r
+    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <LocalDebuggerCommandArguments>notepad</LocalDebuggerCommandArguments>\r
+    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>\r
+  </PropertyGroup>\r
+</Project>
\ No newline at end of file
diff --git a/src/tests/PSS4/Beispiel2/.vs/Threads/v14/.suo b/src/tests/PSS4/Beispiel2/.vs/Threads/v14/.suo
new file mode 100755 (executable)
index 0000000..093a654
Binary files /dev/null and b/src/tests/PSS4/Beispiel2/.vs/Threads/v14/.suo differ
diff --git a/src/tests/PSS4/Beispiel2/Threads.sln b/src/tests/PSS4/Beispiel2/Threads.sln
new file mode 100755 (executable)
index 0000000..7983468
--- /dev/null
@@ -0,0 +1,28 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Visual Studio 14\r
+VisualStudioVersion = 14.0.25420.1\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Threads", "Threads\Threads.vcxproj", "{92AD0C8A-8219-4DDE-BAAD-C1CDC687BBAF}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|x64 = Debug|x64\r
+               Debug|x86 = Debug|x86\r
+               Release|x64 = Release|x64\r
+               Release|x86 = Release|x86\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {92AD0C8A-8219-4DDE-BAAD-C1CDC687BBAF}.Debug|x64.ActiveCfg = Debug|x64\r
+               {92AD0C8A-8219-4DDE-BAAD-C1CDC687BBAF}.Debug|x64.Build.0 = Debug|x64\r
+               {92AD0C8A-8219-4DDE-BAAD-C1CDC687BBAF}.Debug|x86.ActiveCfg = Debug|Win32\r
+               {92AD0C8A-8219-4DDE-BAAD-C1CDC687BBAF}.Debug|x86.Build.0 = Debug|Win32\r
+               {92AD0C8A-8219-4DDE-BAAD-C1CDC687BBAF}.Release|x64.ActiveCfg = Release|x64\r
+               {92AD0C8A-8219-4DDE-BAAD-C1CDC687BBAF}.Release|x64.Build.0 = Release|x64\r
+               {92AD0C8A-8219-4DDE-BAAD-C1CDC687BBAF}.Release|x86.ActiveCfg = Release|Win32\r
+               {92AD0C8A-8219-4DDE-BAAD-C1CDC687BBAF}.Release|x86.Build.0 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/src/tests/PSS4/Beispiel2/Threads/Threads.cpp b/src/tests/PSS4/Beispiel2/Threads/Threads.cpp
new file mode 100755 (executable)
index 0000000..e23361c
--- /dev/null
@@ -0,0 +1,108 @@
+///////////////////////////////////////////////////////////////////////////\r
+// Workfile: Threads.cpp\r
+// Author: Daniel Giritzer\r
+// Date: 23.03.2017\r
+// Description: Erzeugt 4 Threads, die Fibonacci zahlen berechnen. \r
+//                             Der Main Thread Verwaltet diese.\r
+// Remarks: Verwendet Win32/64 API\r
+// Revision: 1\r
+///////////////////////////////////////////////////////////////////////////\r
+\r
+#include <iostream>\r
+#include <conio.h>\r
+#include <Windows.h>\r
+\r
+using namespace std;\r
+\r
+//----------------------------\r
+// Thread Funktion\r
+// Berechnet Fibonacci Zahlen.\r
+// Gibt ergebnis auf std::cout\r
+// aus.\r
+//-----------------------------\r
+DWORD WINAPI ThreadFunc(LPVOID fibonaccival) {\r
+       int num = *static_cast<size_t *>(fibonaccival);\r
+\r
+       //Fibonacci Algorithmus\r
+       int first = 0;\r
+       int second = 1;\r
+       int next = 0;\r
+\r
+       for (int i = 0; i < num; i++)\r
+       {\r
+\r
+               if (i <= 1)\r
+               {\r
+                       next = i;\r
+               }\r
+               else\r
+               {\r
+                       next = first + second;\r
+                       first = second;\r
+                       second = next;\r
+               }\r
+\r
+               DWORD currentThreadId = GetCurrentThreadId();\r
+\r
+               //Ergebnis ausgeben\r
+               cout << "Thread-ID " << currentThreadId << " ";\r
+               Sleep(0);\r
+               cout << "Result of fib(" << i << "): " << next;\r
+               cout << endl;\r
+       }\r
+\r
+       return 0;\r
+}\r
+\r
+//-------------------------\r
+// Gibt Thread ID Auf der\r
+// Konsole aus.\r
+//-------------------------\r
+void PrintThreadInfo(DWORD const &idThread)\r
+{\r
+       if (idThread != 0)\r
+       {\r
+               cout << "Worker Thread " << idThread << " created successfully!" << endl;\r
+       }\r
+       else\r
+       {\r
+               cerr << "Could not create Thread..." << endl;\r
+       }\r
+}\r
+\r
+//-------------------------\r
+// Organisiert die Worker\r
+// Threads.\r
+//-------------------------\r
+int main() {\r
+\r
+       //Thread ID Variablen anlegen\r
+       DWORD idThread1 = 0;\r
+       DWORD idThread2 = 0;\r
+       DWORD idThread3 = 0;\r
+       DWORD idThread4 = 0;\r
+\r
+       //Wert für die Fibonacci Funktion\r
+       size_t fibonaccival = 5;\r
+\r
+       //Worker Threads erzeugen\r
+       HANDLE hThread1 = CreateThread(0, 0, ThreadFunc, &fibonaccival, 0, &idThread1);\r
+       PrintThreadInfo(idThread1);\r
+       HANDLE hThread2 = CreateThread(0, 0, ThreadFunc, &fibonaccival, 0, &idThread2);\r
+       PrintThreadInfo(idThread2);\r
+       HANDLE hThread3 = CreateThread(0, 0, ThreadFunc, &fibonaccival, 0, &idThread3);\r
+       PrintThreadInfo(idThread3);\r
+       HANDLE hThread4 = CreateThread(0, 0, ThreadFunc, &fibonaccival, 0, &idThread4);\r
+       PrintThreadInfo(idThread4);\r
+\r
+       //Verhindere beenden des Main Threads\r
+       //(Einfacher Sync)\r
+       cout << "Press a key ..." << endl;\r
+       _getch(); \r
+\r
+       //Handles Schliessen\r
+       CloseHandle(hThread1);\r
+       CloseHandle(hThread2);\r
+       CloseHandle(hThread3);\r
+       CloseHandle(hThread4);\r
+}
\ No newline at end of file
diff --git a/src/tests/PSS4/Beispiel2/Threads/Threads.vcxproj b/src/tests/PSS4/Beispiel2/Threads/Threads.vcxproj
new file mode 100755 (executable)
index 0000000..60a4081
--- /dev/null
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup Label="ProjectConfigurations">\r
+    <ProjectConfiguration Include="Debug|Win32">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|Win32">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Debug|x64">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>x64</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|x64">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>x64</Platform>\r
+    </ProjectConfiguration>\r
+  </ItemGroup>\r
+  <PropertyGroup Label="Globals">\r
+    <ProjectGuid>{92AD0C8A-8219-4DDE-BAAD-C1CDC687BBAF}</ProjectGuid>\r
+    <Keyword>Win32Proj</Keyword>\r
+    <RootNamespace>Threads</RootNamespace>\r
+    <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <PlatformToolset>v140</PlatformToolset>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <PlatformToolset>v140</PlatformToolset>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <PlatformToolset>v140</PlatformToolset>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <PlatformToolset>v140</PlatformToolset>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+  <ImportGroup Label="ExtensionSettings">\r
+  </ImportGroup>\r
+  <ImportGroup Label="Shared">\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <PropertyGroup Label="UserMacros" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <LinkIncremental>true</LinkIncremental>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <LinkIncremental>true</LinkIncremental>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <LinkIncremental>false</LinkIncremental>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <LinkIncremental>false</LinkIncremental>\r
+  </PropertyGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <ClCompile>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <ClCompile>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+      <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="Threads.cpp" />\r
+  </ItemGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+  <ImportGroup Label="ExtensionTargets">\r
+  </ImportGroup>\r
+</Project>
\ No newline at end of file
diff --git a/src/tests/PSS4/Beispiel2/Threads/Threads.vcxproj.filters b/src/tests/PSS4/Beispiel2/Threads/Threads.vcxproj.filters
new file mode 100755 (executable)
index 0000000..47993bf
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup>\r
+    <Filter Include="Source Files">\r
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\r
+    </Filter>\r
+    <Filter Include="Header Files">\r
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r
+      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>\r
+    </Filter>\r
+    <Filter Include="Resource Files">\r
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\r
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\r
+    </Filter>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="Threads.cpp">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
+  </ItemGroup>\r
+</Project>
\ No newline at end of file
diff --git a/src/tests/PSS4/Beispiel3/MatrixMultiplikation.sln b/src/tests/PSS4/Beispiel3/MatrixMultiplikation.sln
new file mode 100755 (executable)
index 0000000..e79a844
--- /dev/null
@@ -0,0 +1,28 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Visual Studio 14\r
+VisualStudioVersion = 14.0.25420.1\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MatrixMultiplikation", "MatrixMultiplikation\MatrixMultiplikation.vcxproj", "{A6B5AA47-54F8-4DD9-B7DE-6EDEBF7FB98E}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|x64 = Debug|x64\r
+               Debug|x86 = Debug|x86\r
+               Release|x64 = Release|x64\r
+               Release|x86 = Release|x86\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {A6B5AA47-54F8-4DD9-B7DE-6EDEBF7FB98E}.Debug|x64.ActiveCfg = Debug|x64\r
+               {A6B5AA47-54F8-4DD9-B7DE-6EDEBF7FB98E}.Debug|x64.Build.0 = Debug|x64\r
+               {A6B5AA47-54F8-4DD9-B7DE-6EDEBF7FB98E}.Debug|x86.ActiveCfg = Debug|Win32\r
+               {A6B5AA47-54F8-4DD9-B7DE-6EDEBF7FB98E}.Debug|x86.Build.0 = Debug|Win32\r
+               {A6B5AA47-54F8-4DD9-B7DE-6EDEBF7FB98E}.Release|x64.ActiveCfg = Release|x64\r
+               {A6B5AA47-54F8-4DD9-B7DE-6EDEBF7FB98E}.Release|x64.Build.0 = Release|x64\r
+               {A6B5AA47-54F8-4DD9-B7DE-6EDEBF7FB98E}.Release|x86.ActiveCfg = Release|Win32\r
+               {A6B5AA47-54F8-4DD9-B7DE-6EDEBF7FB98E}.Release|x86.Build.0 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/src/tests/PSS4/Beispiel3/MatrixMultiplikation/Matrix.cpp b/src/tests/PSS4/Beispiel3/MatrixMultiplikation/Matrix.cpp
new file mode 100755 (executable)
index 0000000..2776dfc
--- /dev/null
@@ -0,0 +1,133 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Matrix.cpp
+// Author: Daniel Giritzer
+// Date: 23.03.2017
+// Description : Read, Print, * Operationen für Matritzen
+// Remarks: Verwendet Threads für die Multiplikation.
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include <iostream>
+#include "Matrix.h"
+#include <conio.h>
+
+using namespace std;
+
+
+//-------------------
+// Struktur zum Übergeben 
+// der einzelnen Parameter
+// an die Threads
+//-------------------
+struct ThreadHandover {
+       int i;
+       int ii;
+       const int (*A)[msize];
+       const int (*B)[msize];
+       int (*C)[msize];
+};
+
+//-------------------
+//Initialisiere eine 
+//Matrix mit 0en.
+//-------------------
+void initMatrix(matrix myMatrix){
+    for(int i=0; i<msize; i++)
+    {
+        for(int ii=0; ii<msize;ii++)
+        {
+            myMatrix[ii][i] = 0;
+        }
+    }
+}
+
+//-------------------
+// Matrix Benutzereingabe.
+//--------------------
+void readMatrix(matrix myMatrix){
+    for(int i=0; i<msize; i++)
+    {
+        for(int ii=0; ii<msize;ii++)
+        {
+           cout << "Matrix[" << ii << "][" << i << "]: ";
+           cin >> myMatrix[ii][i];
+        }
+    }
+}
+
+//-------------------
+// Gibt Matrix auf 
+// std::cout aus.
+//--------------------
+void printMatrix(const matrix myMatrix){
+
+    for(int i=0; i<msize; i++)
+    {
+        for(int ii=0; ii<msize;ii++)
+        {
+            cout << myMatrix[ii][i] << "\t";
+        }
+
+        cout << endl;
+    }
+
+}
+
+//-------------------
+// Interne Thread Funktion
+// zum Berechnen der 
+// Matrixmultiplikation
+//--------------------
+static DWORD WINAPI ThreadFunc(LPVOID funcArgs) {\r
+       ThreadHandover *ThreadArgs = (ThreadHandover*)funcArgs;\r
+\r
+       for (int iii = 0; iii<msize; iii++)
+       {
+               ThreadArgs->C[ThreadArgs->ii][ThreadArgs->i] = ThreadArgs->C[ThreadArgs->ii][ThreadArgs->i] +
+                                                                                                          ThreadArgs->A[iii][ThreadArgs->i] *
+                                                                                                          ThreadArgs->B[ThreadArgs->ii][iii];
+       }\r
+\r
+       return 0;\r
+}
+
+//-------------------
+// Hauptthread,
+// Verwaltet Threads zur
+// Matrixmultiplikation.
+//--------------------
+void multiplyMatrix(const matrix myMatrix1, const matrix myMatrix2, matrix resMatrix){
+       ThreadHandover ThreadArgs[msize][msize];
+       HANDLE hThread[msize][msize];
+       DWORD idThread[msize][msize];
+
+       initMatrix(resMatrix); // Initialisiere Ergebnismatrix
+
+       //Starte Threads für die Matrixmultiplikation
+    for(int i=0; i<msize; i++)
+    {
+        for(int ii=0; ii<msize; ii++)
+        {
+                       ThreadArgs[i][ii].A = myMatrix1;
+                       ThreadArgs[i][ii].B = myMatrix2;
+                       ThreadArgs[i][ii].C = resMatrix;
+                       ThreadArgs[i][ii].i = i;
+                       ThreadArgs[i][ii].ii = ii;
+                       hThread[i][ii] = CreateThread(0, 0, ThreadFunc, &ThreadArgs[i][ii], 0, &idThread[i][ii]);
+        }
+    }
+
+       //Warte auf Tastendruck
+       //(Einfache Synchronisation)
+       cout << "Press a key ..." << endl;\r
+       _getch();
+
+       //Handles wieder Schließen!
+       for (int i = 0; i<msize; i++)
+       {
+               for (int ii = 0; ii<msize; ii++)
+               {
+                       CloseHandle(hThread[i][ii]);
+               }
+       }
+
+}
\ No newline at end of file
diff --git a/src/tests/PSS4/Beispiel3/MatrixMultiplikation/Matrix.h b/src/tests/PSS4/Beispiel3/MatrixMultiplikation/Matrix.h
new file mode 100755 (executable)
index 0000000..407ee19
--- /dev/null
@@ -0,0 +1,39 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Matrix.h
+// Author: Daniel Giritzer
+// Date: 23.02.2017
+// Description: Header file für das Matrix Modul.
+// Remarks:
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#ifndef MATRIX_H_INCLUDED
+#define MATRIX_H_INCLUDED
+
+#include <Windows.h>
+int const  msize = 3; //Standardgröße der Matritzen
+typedef int matrix[msize][msize];
+
+//-------------------
+//Initialisiere eine 
+//Matrix mit 0en.
+//-------------------
+void initMatrix(matrix myMatrix);
+
+//-------------------
+// Matrix Benutzereingabe.
+//--------------------
+void readMatrix(matrix myMatrix);
+
+//-------------------
+// Gibt Matrix auf 
+// std::cout aus.
+//--------------------
+void printMatrix(const matrix myMatrix);
+
+//-------------------
+// Multipliziert zwei
+// Matritzen unter Verwendung
+// von Threads.
+//--------------------
+void multiplyMatrix(const matrix myMatrix1, const matrix myMatrix2, matrix resMatrix);
+#endif // MATRIX_H_INCLUDED
diff --git a/src/tests/PSS4/Beispiel3/MatrixMultiplikation/MatrixMultiplikation.vcxproj b/src/tests/PSS4/Beispiel3/MatrixMultiplikation/MatrixMultiplikation.vcxproj
new file mode 100755 (executable)
index 0000000..00bb244
--- /dev/null
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup Label="ProjectConfigurations">\r
+    <ProjectConfiguration Include="Debug|Win32">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|Win32">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Debug|x64">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>x64</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|x64">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>x64</Platform>\r
+    </ProjectConfiguration>\r
+  </ItemGroup>\r
+  <PropertyGroup Label="Globals">\r
+    <ProjectGuid>{A6B5AA47-54F8-4DD9-B7DE-6EDEBF7FB98E}</ProjectGuid>\r
+    <Keyword>Win32Proj</Keyword>\r
+    <RootNamespace>MatrixMultiplikation</RootNamespace>\r
+    <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <PlatformToolset>v140</PlatformToolset>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <PlatformToolset>v140</PlatformToolset>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <PlatformToolset>v140</PlatformToolset>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <PlatformToolset>v140</PlatformToolset>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+  <ImportGroup Label="ExtensionSettings">\r
+  </ImportGroup>\r
+  <ImportGroup Label="Shared">\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <PropertyGroup Label="UserMacros" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <LinkIncremental>true</LinkIncremental>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <LinkIncremental>true</LinkIncremental>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <LinkIncremental>false</LinkIncremental>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <LinkIncremental>false</LinkIncremental>\r
+  </PropertyGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <ClCompile>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <ClCompile>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+      <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="main.cpp" />\r
+    <ClCompile Include="Matrix.cpp" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="Matrix.h" />\r
+  </ItemGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+  <ImportGroup Label="ExtensionTargets">\r
+  </ImportGroup>\r
+</Project>
\ No newline at end of file
diff --git a/src/tests/PSS4/Beispiel3/MatrixMultiplikation/MatrixMultiplikation.vcxproj.filters b/src/tests/PSS4/Beispiel3/MatrixMultiplikation/MatrixMultiplikation.vcxproj.filters
new file mode 100755 (executable)
index 0000000..c382c13
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup>\r
+    <Filter Include="Source Files">\r
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\r
+    </Filter>\r
+    <Filter Include="Header Files">\r
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r
+      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>\r
+    </Filter>\r
+    <Filter Include="Resource Files">\r
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\r
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\r
+    </Filter>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="main.cpp">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="Matrix.cpp">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="Matrix.h">\r
+      <Filter>Header Files</Filter>\r
+    </ClInclude>\r
+  </ItemGroup>\r
+</Project>
\ No newline at end of file
diff --git a/src/tests/PSS4/Beispiel3/MatrixMultiplikation/main.cpp b/src/tests/PSS4/Beispiel3/MatrixMultiplikation/main.cpp
new file mode 100755 (executable)
index 0000000..cf53933
--- /dev/null
@@ -0,0 +1,37 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Matrix main.cpp
+// Author: Daniel Giritzer
+// Date: 23.03.2017
+// Description : Testdriver für das Matrix Modul
+// Remarks: -
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include <iostream>
+#include "Matrix.h"
+
+using namespace std;
+
+int main()
+{
+    matrix myMatrix1 = {};
+    matrix myMatrix2 = {};
+    matrix myMatrix3 = {};
+
+    cout << "Eingabe Matrix1:" << endl;
+    readMatrix(myMatrix1);cout << endl;
+
+    cout << "Eingabe Matrix2:" << endl;
+    readMatrix(myMatrix2);cout << endl;
+
+    cout << "Matrix1:" << endl;
+    printMatrix(myMatrix1);cout << endl;
+
+    cout << "Matrix2:" << endl;
+    printMatrix(myMatrix2);cout << endl;
+
+    cout << "Matrix1 * Matrix2:" << endl;
+    multiplyMatrix(myMatrix1, myMatrix2, myMatrix3);
+    printMatrix(myMatrix3);cout << endl;
+
+    return 0;
+}
diff --git a/src/tests/SDP3/Angabe.pdf b/src/tests/SDP3/Angabe.pdf
new file mode 100644 (file)
index 0000000..568049c
Binary files /dev/null and b/src/tests/SDP3/Angabe.pdf differ
diff --git a/src/tests/SDP3/src/Cesar.cpp b/src/tests/SDP3/src/Cesar.cpp
new file mode 100644 (file)
index 0000000..a4fbe67
--- /dev/null
@@ -0,0 +1,65 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Cesar.cpp
+// Author: Daniel Giritzer, Johannes Posch
+// Date: 03.11.2016
+// Description: Klasse zum ver- & entschlüsseln von ASCII Dateien.
+// Remarks: Erbt von HSECrypto
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include "Cesar.h"
+#include <algorithm>
+
+/////////////////////////////////////////////////
+/// \brief Verschlüsselt den in der Klasse
+///        gespeicherten StringStream mithilfe
+///        des Cesar Algorithmus.
+///        Wird der StringStream wieder auf
+///        eine Datei geschrieben, so hat diese die
+///        Dateiendung .Cesar.
+/////////////////////////////////////////////////
+void Cesar::Encrypt()
+{
+    //Dateiendung hinzufügen
+    this->mFname = this->mFname + this->mFileExtension;
+
+    //StringStream in einen String Kopieren
+    //damit man den STL Algorithmus transform
+    //verwenden kann.
+    std::string str = this->mBuffer.str();
+
+    //Alle Zeichen im String um den Key verschieben.
+    transform(str.cbegin(), str.cend(), str.begin(), bind2nd(std::plus<int>(),this->mKey));
+
+    //'Zeichen im String' mod 'Gesamtanzahl der Zeichen'
+    transform(str.cbegin(), str.cend(), str.begin(), bind2nd(std::modulus<int>(),this->mNumChar));
+
+    //Ergebnis in den internen StringStream schreiben.
+    this->mBuffer.str(std::string());
+    this->mBuffer << str;
+}
+
+/////////////////////////////////////////////////
+/// \brief Entschlüsselt den Internen StringStream
+///        mithilfe des Cesar Algorithmus.
+/////////////////////////////////////////////////
+void Cesar::Decrypt()
+{
+    //StringStream in einen String Kopieren
+    //damit man den STL Algorithmus transform
+    //verwenden kann.
+    std::string str = this->mBuffer.str();
+
+    //Alle Zeichen im String um den Key verringern.
+    transform(str.cbegin(), str.cend(), str.begin(), bind2nd(std::minus<int>(),this->mKey));
+
+    //Zeichenanzahl Addieren
+    transform(str.cbegin(), str.cend(), str.begin(), bind2nd(std::plus<int>(),this->mNumChar));
+
+    //Modulus Zeichenanzahl
+    transform(str.cbegin(), str.cend(), str.begin(), bind2nd(std::modulus<int>(),this->mNumChar));
+
+    //Ergebnis in den internen StringStream schreiben.
+    this->mBuffer.str(std::string());
+    this->mBuffer << str;
+}
+
diff --git a/src/tests/SDP3/src/Cesar.h b/src/tests/SDP3/src/Cesar.h
new file mode 100644 (file)
index 0000000..de7ca6c
--- /dev/null
@@ -0,0 +1,47 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Cesar.h
+// Author: Daniel Giritzer, Johannes Posch
+// Date: 03.11.2016
+// Description: Klasse zum ver- & entschlüsseln von ASCII Dateien.
+// Remarks: Erbt von HSECrypto
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#ifndef CESAR_H
+#define CESAR_H
+
+#include "HSECryptoIF.h"
+
+/////////////////////////////////////////////////
+/// \brief Diese Klasse ermöglicht verschlüsseln
+///        und entschlüsseln von ASCII Textdateien
+///        mithilfe des Cesar Algorithmus.
+///
+///        Die möglichkeit Dateien zu Lesen und
+///        zu Schreiben erbt diese Klasse von
+///        HSECrypto.
+/////////////////////////////////////////////////
+class Cesar : public HSECryptoIF
+{
+public:
+    /////////////////////////////////////////////////
+    /// \brief Verschlüsselt den in der Klasse
+    ///        gespeicherten StringStream mithilfe
+    ///        des Cesar Algorithmus.
+    ///        Wird der StringStream wieder auf
+    ///        eine Datei geschrieben, so hat diese die
+    ///        Dateiendung .Cesar.
+    /////////////////////////////////////////////////
+    virtual void Encrypt() override;
+
+    /////////////////////////////////////////////////
+    /// \brief Entschlüsselt den Internen StringStream
+    ///        mithilfe des Cesar Algorithmus.
+    /////////////////////////////////////////////////
+    virtual void Decrypt() override;
+
+private:
+    const size_t mKey = 29; ///<  Geheimer Schlüssel
+    const size_t mNumChar = 256; ///< Gesamtanzahl der Zeichen (ASCII = 256)
+    const std::string mFileExtension = ".Cesar"; ///< Dateiendung für Dateien die mit dieser Klasse verschlüsselt wurden.
+};
+#endif // CESAR_H
diff --git a/src/tests/SDP3/src/EpicosAdapter.cpp b/src/tests/SDP3/src/EpicosAdapter.cpp
new file mode 100644 (file)
index 0000000..4224e80
--- /dev/null
@@ -0,0 +1,46 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: EpicosAdapter.cpp
+// Author: Daniel Giritzer, Johannes Posch
+// Date: 24.11.2016
+// Description: Passt die HSECrypto Schnittstelle an die von Epicos benötigte
+//              Schnittstelle an.
+// Remarks: -
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include "EpicosAdapter.h"
+
+////////////////////////////////////////////////
+/// \brief Passt die EncryptRSA Methode des EpicosCrypto
+///        Interfaces an die Encrypt Methode
+///        von HSECrpto an.
+///
+///        Verschlüsselt eine Datei mit dem
+///        RSA Algorithmus.
+///
+/// \param fileName Pfad zu der Datei die
+///        Verschlüsselt werden soll.
+/////////////////////////////////////////////////
+void EpicosAdapter::EncryptRSA(std::string const & fileName)
+{
+    this->mCryptRsa.ReadFile(fileName);
+    this->mCryptRsa.Encrypt();
+    this->mCryptRsa.WriteFile();
+}
+
+/////////////////////////////////////////////////
+/// \brief Passt die DercyptRSA Methode des EpicosCrypto
+///        Interfaces an die Decrypt Methode
+///        von HSECrpto an.
+///
+///        Entschlüsselt eine Datei mit dem
+///        RSA Algorithmus.
+///
+/// \param fileName Pfad zu der Datei die
+///        Entschlüsselt werden soll.
+/////////////////////////////////////////////////
+void EpicosAdapter::DecryptRSA(std::string const & fileName)
+{
+    this->mCryptRsa.ReadFile(fileName);
+    this->mCryptRsa.Decrypt();
+    this->mCryptRsa.WriteFile();
+}
diff --git a/src/tests/SDP3/src/EpicosAdapter.h b/src/tests/SDP3/src/EpicosAdapter.h
new file mode 100644 (file)
index 0000000..091c9db
--- /dev/null
@@ -0,0 +1,54 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: EpicosAdapter.h
+// Author: Daniel Giritzer, Johannes Posch
+// Date: 24.11.2016
+// Description: Passt die HSECrypto Schnittstelle an die von Epicos benötigte
+//              Schnittstelle an.
+// Remarks: -
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#ifndef EPICOSADAPTER_H
+#define EPICOSADAPTER_H
+
+#include "Object.h"
+#include "EpicosCryptoIF.h"
+#include "Rsa.h"
+
+/////////////////////////////////////////////////
+/// \brief Passt die HSECrypto Schnittstelle
+///an die von Epicos benötigte Schnittstelle an.
+/////////////////////////////////////////////////
+class EpicosAdapter : public Object, public EpicosCryptoIF
+{
+public:
+    ////////////////////////////////////////////////
+    /// \brief Passt die EncryptRSA Methode des EpicosCrypto
+    ///        Interfaces an die Encrypt Methode
+    ///        von HSECrpto an.
+    ///
+    ///        Verschlüsselt eine Datei mit dem
+    ///        RSA Algorithmus.
+    ///
+    /// \param fileName Pfad zu der Datei die
+    ///        Verschlüsselt werden soll.
+    /////////////////////////////////////////////////
+    virtual void EncryptRSA(std::string const & fileName);
+
+    /////////////////////////////////////////////////
+    /// \brief Passt die DercyptRSA Methode des EpicosCrypto
+    ///        Interfaces an die Decrypt Methode
+    ///        von HSECrpto an.
+    ///
+    ///        Entschlüsselt eine Datei mit dem
+    ///        RSA Algorithmus.
+    ///
+    /// \param fileName Pfad zu der Datei die
+    ///        Entschlüsselt werden soll.
+    /////////////////////////////////////////////////
+    virtual void DecryptRSA(std::string const & fileName);
+
+private:
+    Rsa mCryptRsa;
+};
+
+#endif // EPICOSADAPTER_H
diff --git a/src/tests/SDP3/src/EpicosCrypto.cpp b/src/tests/SDP3/src/EpicosCrypto.cpp
new file mode 100644 (file)
index 0000000..31d03a2
--- /dev/null
@@ -0,0 +1,52 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: EpicosCrypto.cpp
+// Author: Daniel Giritzer, Johannes Posch
+// Date: 24.11.2016
+// Description: Testklasse für den EpicosCrypto Adapter.
+// Remarks: Testet die Funktionalität des EpicosCrypto Adapters.
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include "EpicosCrypto.h"
+
+static const std::string ERROR_NULLPTR = "No Pointer set";
+
+/////////////////////////////////////////////////
+/// \brief Setzt ein Objekt das EpicosCryptoIF
+///         implementiert vorraus.
+///
+/// \param mCrypt Objekt das EpicosCryptoIF
+///        implementiert (z.B. Adapter).
+/////////////////////////////////////////////////
+EpicosCrypto::EpicosCrypto(EpicosCryptoIF::SPtr const & mCrypt)
+{
+  if(mCrypt == nullptr)
+    throw ERROR_NULLPTR;
+
+  this->mCrypt = mCrypt;
+}
+
+/////////////////////////////////////////////////
+/// \brief Testet ob der Adapter die Epicos
+///        Schnittstelle zum Verschlüsseln richtig
+///        übersetzt.
+///
+/// \param fileName Pfad zu der Datei die
+///        Verschlüsselt werden soll.
+/////////////////////////////////////////////////
+void EpicosCrypto::Encrypt(std::string const & fileName)
+{
+  this->mCrypt->EncryptRSA(fileName);
+}
+
+/////////////////////////////////////////////////
+/// \brief Testet ob der Adapter die Epicos
+///        Schnittstelle zum Entschlüsseln richtig
+///        übersetzt.
+///
+/// \param fileName Pfad zu der Datei die
+///        Entschlüsselt werden soll.
+/////////////////////////////////////////////////
+void EpicosCrypto::Decrypt(std::string const & fileName)
+{
+  this->mCrypt->DecryptRSA(fileName);
+}
diff --git a/src/tests/SDP3/src/EpicosCrypto.h b/src/tests/SDP3/src/EpicosCrypto.h
new file mode 100644 (file)
index 0000000..c51ab12
--- /dev/null
@@ -0,0 +1,61 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: EpicosCrypto.h
+// Author: Daniel Giritzer, Johannes Posch
+// Date: 24.11.2016
+// Description: Testklasse für den EpicosCrypto Adapter.
+// Remarks: Testet die Funktionalität des EpicosCrypto Adapters.
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#ifndef EPICOSCRYPTO_H
+#define EPICOSCRYPTO_H
+
+#include "Object.h"
+#include "EpicosCryptoIF.h"
+
+/////////////////////////////////////////////////
+/// \brief Testklasse für den EpicosCrypto
+///        Adapter.
+///
+///        Verwendet zum verschlüsseln,
+///        über den EpicosAdapter, die
+///        HSECrypto Klasse.
+/////////////////////////////////////////////////
+class EpicosCrypto : public Object
+{
+public:
+    /////////////////////////////////////////////////
+    /// \brief Setzt ein Objekt das EpicosCryptoIF
+    ///         implementiert vorraus.
+    ///
+    /// \param mCrypt Objekt das EpicosCryptoIF
+    ///        implementiert (z.B. Adapter).
+    /////////////////////////////////////////////////
+    EpicosCrypto(EpicosCryptoIF::SPtr const & mCrypt);
+
+    /////////////////////////////////////////////////
+    /// \brief Testet ob der Adapter die Epicos
+    ///        Schnittstelle zum Verschlüsseln richtig
+    ///        übersetzt.
+    ///
+    /// \param fileName Pfad zu der Datei die
+    ///        Verschlüsselt werden soll.
+    /////////////////////////////////////////////////
+    void Encrypt(std::string const & fileName);
+
+    /////////////////////////////////////////////////
+    /// \brief Testet ob der Adapter die Epicos
+    ///        Schnittstelle zum Entschlüsseln richtig
+    ///        übersetzt.
+    ///
+    /// \param fileName Pfad zu der Datei die
+    ///        Entschlüsselt werden soll.
+    /////////////////////////////////////////////////
+    void Decrypt(std::string const & fileName);
+
+protected:
+
+private:
+    EpicosCryptoIF::SPtr mCrypt;
+};
+
+#endif //EPICOSCRYPTO_H
diff --git a/src/tests/SDP3/src/EpicosCryptoIF.h b/src/tests/SDP3/src/EpicosCryptoIF.h
new file mode 100644 (file)
index 0000000..8c05946
--- /dev/null
@@ -0,0 +1,44 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: EpicosCrypto.h
+// Author: Daniel Giritzer, Johannes Posch
+// Date: 9.11.2016
+// Description: Interface der Cryptoklasse von der Firma Epicos
+// Remarks: Copyright EPICOS GMBH
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#ifndef EPICOSCRYPTOIF_H
+#define EPICOSCRYPTOIF_H
+
+#include <string>
+#include <memory>
+
+/////////////////////////////////////////////////
+/// \brief Interface für die Epicos
+///        CryptoMethoden.
+/////////////////////////////////////////////////
+class EpicosCryptoIF
+{
+public:
+    /////////////////////////////////////////////////
+    /// \brief Interfacemethode:
+    ///        Verschlüsselt eine Datei mit dem
+    ///        RSA Algorithmus.
+    ///
+    /// \param fileName Pfad zu der Datei die
+    ///        Verschlüsselt werden soll.
+    /////////////////////////////////////////////////
+    virtual void EncryptRSA(std::string const & fileName) = 0;
+
+    /////////////////////////////////////////////////
+    /// \brief Interfacemethode:
+    ///        Entschlüsselt eine Datei mit dem
+    ///        RSA Algorithmus.
+    ///
+    /// \param fileName Pfad zu der Datei die
+    ///        Entschlüsselt werden soll.
+    /////////////////////////////////////////////////
+    virtual void DecryptRSA(std::string const & fileName) = 0;
+
+    typedef std::shared_ptr<EpicosCryptoIF> SPtr; ///< Shared Pointer auf EpicosCryptoIF
+};
+#endif // EPICOSCRYPTOIF_H
diff --git a/src/tests/SDP3/src/HSECrypto.cpp b/src/tests/SDP3/src/HSECrypto.cpp
new file mode 100644 (file)
index 0000000..8ff10c0
--- /dev/null
@@ -0,0 +1,69 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: HSECrypto.cpp
+// Author: Daniel Giritzer, Johannes Posch
+// Date: 24.11.2016
+// Description: Client Klasse des HSECrypto Strategy Pattern
+// Remarks: Verwendet ein Objekt das HSECryptoIF Implementiert.
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include "HSECrypto.h"
+
+
+static const std::string ERROR_NULLPTR = "No Pointer set";
+
+/////////////////////////////////////////////////
+/// \brief  Setzt ein Objekt das HSECryptoIF
+///         implementiert vorraus.
+///
+/// \param mCrypt Objekt das HSECryptoIF
+///        implementiert (z.B. Rsa, Cesar, ...).
+/////////////////////////////////////////////////
+HSECrypto::HSECrypto(HSECryptoIF::SPtr const & mCrypt)
+{
+  if(mCrypt == nullptr)
+    throw ERROR_NULLPTR;
+
+  this->mCrypt = mCrypt;
+}
+
+/////////////////////////////////////////////////
+/// \brief Verschlüsselt eine Datei mit dem
+///        vom intern gespeicherten HSECryptoIF
+///        Objekt implementierten Algorithmus.
+/// \param fileName Pfad zu der Datei die
+///        Verschlüsselt werden soll.
+/////////////////////////////////////////////////
+void HSECrypto::Encrypt(std::string const & fileName)
+{
+  this->mCrypt->ReadFile(fileName);
+  this->mCrypt->Encrypt();
+  this->mCrypt->WriteFile();
+}
+
+/////////////////////////////////////////////////
+/// \brief Entschlüsselt eine Datei mit dem
+///        vom intern gespeicherten HSECryptoIF
+///        Objekt implementierten Algorithmus.
+/// \param fileName Pfad zu der Datei die
+///        Verschlüsselt werden soll.
+/////////////////////////////////////////////////
+void HSECrypto::Decrypt(std::string const & fileName)
+{
+  this->mCrypt->ReadFile(fileName);
+  this->mCrypt->Decrypt();
+  this->mCrypt->WriteFile();
+}
+
+/////////////////////////////////////////////////
+/// \brief Setzt das Objekt welches HSECryptoIF
+///        implementiert.
+/// \param mCrypt Pointer auf ein Objekt das
+///        HSECryptoIF implementiert.
+/////////////////////////////////////////////////
+void HSECrypto::setCrypto(HSECryptoIF::SPtr const & mCrypt)
+{
+  if(mCrypt == nullptr)
+    throw ERROR_NULLPTR;
+
+  this->mCrypt = mCrypt;
+}
diff --git a/src/tests/SDP3/src/HSECrypto.h b/src/tests/SDP3/src/HSECrypto.h
new file mode 100644 (file)
index 0000000..9af5931
--- /dev/null
@@ -0,0 +1,66 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: HSECrypto.h
+// Author: Daniel Giritzer, Johannes Posch
+// Date: 24.11.2016
+// Description: Client Klasse des HSECrypto Strategy Pattern
+// Remarks: Verwendet ein Objekt das HSECryptoIF Implementiert.
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#ifndef HSECRYPTO_H
+#define HSECRYPTO_H
+
+#include "Object.h"
+#include "HSECryptoIF.h"
+
+/////////////////////////////////////////////////
+/// \brief Ermöglicht das Ver- und Entschlüsseln
+///        von Dateien.
+///
+///        Verwendet ein Objekt, dass HSECryptoIF
+///        Implementiert. Ver- und Entschlüsselt
+///        mit dem von diesem Objekt verwendeten
+///        Algorithmus.
+/////////////////////////////////////////////////
+class HSECrypto : public Object
+{
+public:
+    /////////////////////////////////////////////////
+    /// \brief  Setzt ein Objekt das HSECryptoIF
+    ///         implementiert vorraus.
+    ///
+    /// \param mCrypt Objekt das HSECryptoIF
+    ///        implementiert (z.B. Rsa, Cesar, ...).
+    /////////////////////////////////////////////////
+    HSECrypto(HSECryptoIF::SPtr const & mCrypt);
+
+    /////////////////////////////////////////////////
+    /// \brief Verschlüsselt eine Datei mit dem
+    ///        vom intern gespeicherten HSECryptoIF
+    ///        Objekt implementierten Algorithmus.
+    /// \param fileName Pfad zu der Datei die
+    ///        Verschlüsselt werden soll.
+    /////////////////////////////////////////////////
+    void Encrypt(std::string const & fileName);
+
+    /////////////////////////////////////////////////
+    /// \brief Entschlüsselt eine Datei mit dem
+    ///        vom intern gespeicherten HSECryptoIF
+    ///        Objekt implementierten Algorithmus.
+    /// \param fileName Pfad zu der Datei die
+    ///        Verschlüsselt werden soll.
+    /////////////////////////////////////////////////
+    void Decrypt(std::string const & fileName);
+
+    /////////////////////////////////////////////////
+    /// \brief Setzt das Objekt welches HSECryptoIF
+    ///        implementiert.
+    /// \param mCrypt Pointer auf ein Objekt das
+    ///        HSECryptoIF implementiert.
+    /////////////////////////////////////////////////
+    void setCrypto(HSECryptoIF::SPtr const & mCrypt);
+
+private:
+    HSECryptoIF::SPtr mCrypt;
+};
+
+#endif //HSECRYPTO_H
diff --git a/src/tests/SDP3/src/HSECryptoIF.cpp b/src/tests/SDP3/src/HSECryptoIF.cpp
new file mode 100644 (file)
index 0000000..248ffcc
--- /dev/null
@@ -0,0 +1,98 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: HSECryptoIF.cpp
+// Author: Daniel Giritzer, Johannes Posch
+// Date: 23.11.2016
+// Description: Interface des HSE Cryptomodul. Ver- und Entschlüsselt
+//              Dateien mit dem RSA und dem Cesar Algorithmus.
+// Remarks: Implementiert bereits das Einlesen und Schreiben von Dateien.
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include "HSECryptoIF.h"
+#include <fstream>
+#include <iostream>
+
+//Errortexte für Exceptions
+static std::string const FilenameError = "No filename defined";
+static std::string const OpeningError = "Could not open file";
+
+/////////////////////////////////////////////////
+/// \brief Liest eine Datei ein und speichert
+///        deren Inhalt in einen Internen
+///        StringStream ab.
+///        Beinhaltet der interne StringStram
+///        bereits Daten, so werden diese
+///        überschrieben.
+///        Tritt ein Fehler auf wird eine Exception
+///        geworfen.
+///
+/// \param  fileName Pfad zu der Datei, die
+///         eingelesen werden soll
+/// \return bool true oder false, je nachdem ob das
+///         lesen erfolgreich war oder nicht.
+///
+/////////////////////////////////////////////////
+bool HSECryptoIF::ReadFile(std::string const & fileName)
+{
+    std::ifstream iFstr;
+
+    //Überprüfe auf sinnvollen
+    //Dateinamen
+    if(!fileName.compare(""))
+    {
+        throw FilenameError;
+        return false;
+    }
+
+    iFstr.open(fileName);
+
+    //Dateistatus Prüfen
+    if(!iFstr.good())
+    {
+        throw OpeningError;
+        return false;
+    }
+
+    this->mFname = fileName;
+
+    //iFstr auf mBuffer schreiben
+    this->mBuffer.str(std::string()); //Verwerfe Inhalt des Buffers
+    this->mBuffer << iFstr.rdbuf();
+
+    return true;
+}
+
+/////////////////////////////////////////////////
+/// \brief Schreibt den Internen StringStream auf
+///        eine Datei.
+///        Tritt ein Fehler auf wird eine Exception
+///        geworfen.
+///
+/// \return bool true oder false, je nachdem ob das
+///         lesen erfolgreich war oder nicht.
+/////////////////////////////////////////////////
+bool HSECryptoIF::WriteFile() const
+{
+   std::ofstream oFstr;
+
+    //Überprüfe auf sinnvollen
+    //Dateinamen
+    if(!this->mFname.compare(""))
+    {
+        throw FilenameError;
+        return false;
+    }
+
+    oFstr.open(this->mFname);
+
+    //Dateistatus Prüfen
+    if(!oFstr.good())
+    {
+        throw OpeningError;
+        return false;
+    }
+
+    //Buffer auf oFstr schreiben
+    oFstr << this->mBuffer.str();
+
+    return true;
+}
diff --git a/src/tests/SDP3/src/HSECryptoIF.h b/src/tests/SDP3/src/HSECryptoIF.h
new file mode 100644 (file)
index 0000000..3ca60f7
--- /dev/null
@@ -0,0 +1,79 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: HSECryptoIF.h
+// Author: Daniel Giritzer, Johannes Posch
+// Date: 23.11.2016
+// Description: Interface des HSE Cryptomodul. Ver- und Entschlüsselt
+//              Dateien mit dem RSA und dem Cesar Algorithmus.
+// Remarks: Implementiert bereits das Einlesen und Schreiben von Dateien.
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#ifndef HSECRYPTOIF_H
+#define HSECRYPTOIF_H
+
+#include <sstream>
+#include "Object.h"
+#include "memory"
+
+/////////////////////////////////////////////////
+/// \brief Interface des HSE Cryptomodul.
+///
+///        Implementiert bereits das Einlesen
+///        und Schreiben von Dateien.
+/////////////////////////////////////////////////
+class HSECryptoIF : public Object
+{
+public:
+
+    /////////////////////////////////////////////////
+    /// \brief Liest eine Datei ein und speichert
+    ///        deren Inhalt in einen Internen
+    ///        StringStream ab.
+    ///        Beinhaltet der interne StringStram
+    ///        bereits Daten, so werden diese
+    ///        überschrieben.
+    ///        Tritt ein Fehler auf wird eine Exception
+    ///        geworfen.
+    ///
+    /// \param  fileName Pfad zu der Datei, die
+    ///         eingelesen werden soll
+    /// \return bool true oder false, je nachdem ob das
+    ///         lesen erfolgreich war oder nicht.
+    ///
+    /////////////////////////////////////////////////
+    bool ReadFile(std::string const & fileName);
+
+    /////////////////////////////////////////////////
+    /// \brief Schreibt den Internen StringStream auf
+    ///        eine Datei.
+    ///        Tritt ein Fehler auf wird eine Exception
+    ///        geworfen.
+    ///
+    /// \return bool true oder false, je nachdem ob das
+    ///         lesen erfolgreich war oder nicht.
+    /////////////////////////////////////////////////
+    bool WriteFile() const;
+
+    /////////////////////////////////////////////////
+    /// \brief Versclüsselt eine Datei mit dem in der
+    ///        Strategieklasse implementierten
+    ///        Algorithmus.
+    /////////////////////////////////////////////////
+    virtual void Encrypt() = 0;
+
+    /////////////////////////////////////////////////
+    /// \brief Entschlüsselt eine Datei mit dem in der
+    ///        Strategieklasse implementierten
+    ///        Algorithmus.
+    /////////////////////////////////////////////////
+    virtual void Decrypt() = 0;
+
+    typedef std::shared_ptr<HSECryptoIF> SPtr; ///< Pointer auf HSECryptoIF
+
+protected:
+    std::stringstream mBuffer;
+    std::string mFname;
+    HSECryptoIF() = default;
+
+};
+
+#endif // HSECRYPTOIF_H
diff --git a/src/tests/SDP3/src/Makefile b/src/tests/SDP3/src/Makefile
new file mode 100644 (file)
index 0000000..3cddd44
--- /dev/null
@@ -0,0 +1,129 @@
+############################################################################
+# Workfile: Makefile
+# Author: Daniel Giritzer, S1510306010
+#        daniel@giritzer.eu
+# Date: 06.04.2016
+# Description: Universal Makefile for Unix based Operating Systems
+#              Important CFLAGS:
+#              -std=c++98      - follow c++ 98 coding standard
+#              -std=c++11      - follow c++ 11 coding standard
+#              -std=c++0x      - follow coming c++ 0x standard
+#
+# Remarks:     Compatible with CodeBlocks (C::B)
+#              PROJNAME variable should match your project name!
+# Revision: 5.4
+# Usage: make debug            - builds debug version
+#               make release   - builds release version
+#               make all       - builds debug and release version
+#               make clean     - cleans project
+#               make rebuild   - builds release version from scratch
+############################################################################
+
+####################
+#GENERAL | EDIT 1/3
+####################
+WORKDIR = $(shell pwd)
+SOURCES := $(shell ls *.cpp)
+PROJNAME = Verschluesselung
+
+CC = gcc
+CXX = g++
+AR = ar
+LD = g++
+WINDRES = windres
+
+INC =
+CFLAGS = -Wall -fexceptions -std=c++11
+RESINC =
+LIBDIR =
+LIB =
+LDFLAGS =
+
+############################
+#DEBUG SETTINGS | EDIT: 2/3
+############################
+INC_DEBUG = $(INC)
+CFLAGS_DEBUG = $(CFLAGS) -g
+RESINC_DEBUG = $(RESINC)
+RCFLAGS_DEBUG = $(RCFLAGS)
+LIBDIR_DEBUG = $(LIBDIR)
+LIB_DEBUG = $(LIB)
+LDFLAGS_DEBUG = $(LDFLAGS)
+OBJDIR_DEBUG = obj/Debug
+DEP_DEBUG =
+OUT_DEBUG = bin/Debug/$(PROJNAME)
+
+
+##############################
+#RELEASE SETTINGS | EDIT: 3/3
+##############################
+INC_RELEASE = $(INC)
+CFLAGS_RELEASE = $(CFLAGS) -O2
+RESINC_RELEASE = $(RESINC)
+RCFLAGS_RELEASE = $(RCFLAGS)
+LIBDIR_RELEASE = $(LIBDIR)
+LIB_RELEASE = $(LIB)
+LDFLAGS_RELEASE = $(LDFLAGS) -s
+OBJDIR_RELEASE = obj/Release
+DEP_RELEASE =
+OUT_RELEASE = bin/Release/$(PROJNAME)
+
+############################
+#OBJECT LISTS | DO NOT EDIT!
+############################
+OBJ_DEBUG = $(addprefix $(OBJDIR_DEBUG)/,$(SOURCES:%.cpp=%.o))
+OBJ_RELEASE = $(addprefix $(OBJDIR_RELEASE)/,$(SOURCES:%.cpp=%.o))
+
+
+##########################
+#FUNCTIONS | DO NOT EDIT!
+##########################
+
+######## General
+all All: debug release
+clean Clean: cleanDebug cleanRelease
+rebuild Rebuild: clean debug release
+
+######## DEBUG
+before_debug:
+       test -d bin/Debug || mkdir -p bin/Debug
+       test -d $(OBJDIR_DEBUG) || mkdir -p $(OBJDIR_DEBUG)
+
+after_debug:
+
+debug Debug: before_debug out_debug after_debug
+
+out_debug: before_debug $(OBJ_DEBUG) $(DEP_DEBUG)
+       $(LD) $(LDFLAGS_DEBUG) $(LIBDIR_DEBUG) $(OBJ_DEBUG) $(LIB_DEBUG) -o $(OUT_DEBUG)
+
+$(OBJDIR_DEBUG)/%.o: %.cpp
+       $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c $< -D_DEBUG -o $@
+
+clean_debug cleanDebug:
+       rm -f $(OBJ_DEBUG) $(OUT_DEBUG)
+       rm -rf bin/Debug
+       rm -rf $(OBJDIR_DEBUG)
+
+
+######## RELEASE
+before_release:
+       test -d bin/Release || mkdir -p bin/Release
+       test -d $(OBJDIR_RELEASE) || mkdir -p $(OBJDIR_RELEASE)
+
+after_release:
+
+release Release: before_release out_release after_release
+
+out_release: before_release $(OBJ_RELEASE) $(DEP_RELEASE)
+       $(LD) $(LDFLAGS_RELEASE) $(LIBDIR_RELEASE) $(OBJ_RELEASE) $(LIB_RELEASE) -o $(OUT_RELEASE)
+
+$(OBJDIR_RELEASE)/%.o: %.cpp
+       $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c $< -o $@
+
+clean_release cleanRelease:
+       rm -f $(OBJ_RELEASE) $(OUT_RELEASE)
+       rm -rf bin/Release
+       rm -rf $(OBJDIR_RELEASE)
+
+.PHONY: before_debug after_debug clean_debug cleanDebug before_release after_release clean_release cleanRelease
+
diff --git a/src/tests/SDP3/src/NortelAdapter.cpp b/src/tests/SDP3/src/NortelAdapter.cpp
new file mode 100644 (file)
index 0000000..dfa8f1b
--- /dev/null
@@ -0,0 +1,77 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: NortelAdapter.cpp
+// Author: Daniel Giritzer, Johannes Posch
+// Date: 24.11.2016
+// Description: Passt die HSECrypto Schnittstelle an die von Nortel benötigte
+//              Schnittstelle an.
+// Remarks: -
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include "NortelAdapter.h"
+
+/////////////////////////////////////////////////
+/// \brief Passt die Encipher Methode des NortelCrypto
+///        Interfaces an die Encrypt Methode
+///        von HSECrpto an.
+///
+///        Verschlüsselt eine Datei mit dem
+///        gegebenen Algorithmus.
+///
+/// \param enc Enum der die Verschlüsselungsmethode
+///        angibt.
+/// \param fileName Pfad zu der Datei die
+///        Verschlüsselt werden soll.
+/////////////////////////////////////////////////
+void NortelAdapter::Encipher(TEncoding enc, std::string const & fileName)
+{
+    if(enc == eRSA)
+    {
+        this->mCryptRsa.ReadFile(fileName);
+        this->mCryptRsa.Encrypt();
+        this->mCryptRsa.WriteFile();
+    }
+    else if(enc == eCaesar)
+    {
+        this->mCryptCesar.ReadFile(fileName);
+        this->mCryptCesar.Encrypt();
+        this->mCryptCesar.WriteFile();
+    }
+    else
+    {
+        throw "Illegal Encipher Method!";
+    }
+
+}
+
+/////////////////////////////////////////////////
+/// \brief Passt die Decipher Methode des NortelCrypto
+///        Interfaces an die Decrypt Methode
+///        von HSECrpto an.
+///
+///        Entschlüsselt eine Datei mit dem
+///        gegebenen Algorithmus.
+///
+/// \param enc Enum der die Entschlüsselungsmethode
+///        angibt.
+/// \param fileName Pfad zu der Datei die
+///        Entschlüsselt werden soll.
+/////////////////////////////////////////////////
+void NortelAdapter::Decipher(TEncoding enc, std::string const & fileName)
+{
+    if(enc == eRSA)
+    {
+        this->mCryptRsa.ReadFile(fileName);
+        this->mCryptRsa.Decrypt();
+        this->mCryptRsa.WriteFile();
+    }
+    else if(enc == eCaesar)
+    {
+        this->mCryptCesar.ReadFile(fileName);
+        this->mCryptCesar.Decrypt();
+        this->mCryptCesar.WriteFile();
+    }
+    else
+    {
+        throw "Illegal Decipher Method!";
+    }
+}
diff --git a/src/tests/SDP3/src/NortelAdapter.h b/src/tests/SDP3/src/NortelAdapter.h
new file mode 100644 (file)
index 0000000..8a598fe
--- /dev/null
@@ -0,0 +1,61 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: NortelAdapter.h
+// Author: Daniel Giritzer, Johannes Posch
+// Date: 24.11.2016
+// Description: Passt die HSECrypto Schnittstelle an die von Nortel benötigte
+//              Schnittstelle an.
+// Remarks: -
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#ifndef NORTELADAPTER_H
+#define NORTELADAPTER_H
+
+#include "Object.h"
+#include "NortelCryptoIF.h"
+#include "Rsa.h"
+#include "Cesar.h"
+
+/////////////////////////////////////////////////
+/// \brief Passt die HSECrypto Schnittstelle
+///an die von Nortel benötigte Schnittstelle an.
+/////////////////////////////////////////////////
+class NortelAdapter : public Object, public NortelCryptoIF
+{
+public:
+    /////////////////////////////////////////////////
+    /// \brief Passt die Encipher Methode des NortelCrypto
+    ///        Interfaces an die Encrypt Methode
+    ///        von HSECrpto an.
+    ///
+    ///        Verschlüsselt eine Datei mit dem
+    ///        gegebenen Algorithmus.
+    ///
+    /// \param enc Enum der die Verschlüsselungsmethode
+    ///        angibt.
+    /// \param fileName Pfad zu der Datei die
+    ///        Verschlüsselt werden soll.
+    /////////////////////////////////////////////////
+    virtual void Encipher(TEncoding enc, std::string const & fileName) override;
+
+    /////////////////////////////////////////////////
+    /// \brief Passt die Decipher Methode des NortelCrypto
+    ///        Interfaces an die Decrypt Methode
+    ///        von HSECrpto an.
+    ///
+    ///        Entschlüsselt eine Datei mit dem
+    ///        gegebenen Algorithmus.
+    ///
+    /// \param enc Enum der die Entschlüsselungsmethode
+    ///        angibt.
+    /// \param fileName Pfad zu der Datei die
+    ///        Entschlüsselt werden soll.
+    /////////////////////////////////////////////////
+    virtual void Decipher(TEncoding enc, std::string const & fileName) override;
+
+private:
+    Cesar mCryptCesar;
+    Rsa mCryptRsa;
+
+};
+
+#endif // NORTELADAPTER_H
diff --git a/src/tests/SDP3/src/NortelCrypto.cpp b/src/tests/SDP3/src/NortelCrypto.cpp
new file mode 100644 (file)
index 0000000..a42eb79
--- /dev/null
@@ -0,0 +1,59 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: NortelCrypto.cpp
+// Author: Daniel Giritzer, Johannes Posch
+// Date: 24.11.2016
+// Description: Testklasse für den NortelCrypto Adapter.
+// Remarks: Testet die Funktionalität des NortelCrypto Adapters.
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+
+#include "NortelCrypto.h"
+
+static const std::string ERROR_NULLPTR = "No Pointer set";
+
+/////////////////////////////////////////////////
+/// \brief Setzt ein Objekt das NortelCryptoIF
+///         implementiert vorraus.
+///
+/// \param mCrypt Objekt das NortelCryptoIF
+///        implementiert (z.B. Adapter).
+/////////////////////////////////////////////////
+NortelCrypto::NortelCrypto(NortelCryptoIF::SPtr const & mCrypt)
+{
+  if(mCrypt == nullptr)
+    throw ERROR_NULLPTR;
+
+  this->mCrypt = mCrypt;
+}
+
+
+/////////////////////////////////////////////////
+/// \brief Testet ob der Adapter die Nortel
+///        Schnittstelle zum Verschlüsseln richtig
+///        übersetzt.
+///
+/// \param enc Enum der die Verschlüsselungsmethode
+///        angibt.
+/// \param fileName Pfad zu der Datei die
+///        Verschlüsselt werden soll.
+/////////////////////////////////////////////////
+void NortelCrypto::Encrypt(NortelCryptoIF::TEncoding enc,std::string const & fileName)
+{
+  this->mCrypt->Encipher(enc, fileName);
+}
+
+
+/////////////////////////////////////////////////
+/// \brief Testet ob der Adapter die Nortel
+///        Schnittstelle zum Entschlüsseln richtig
+///        übersetzt.
+///
+/// \param enc Enum der die Entschlüsselungsmethode
+///        angibt.
+/// \param fileName Pfad zu der Datei die
+///        Entschlüsselt werden soll.
+/////////////////////////////////////////////////
+void NortelCrypto::Decrypt(NortelCryptoIF::TEncoding enc,std::string const & fileName)
+{
+  this->mCrypt->Decipher(enc,fileName);
+}
diff --git a/src/tests/SDP3/src/NortelCrypto.h b/src/tests/SDP3/src/NortelCrypto.h
new file mode 100644 (file)
index 0000000..00be24f
--- /dev/null
@@ -0,0 +1,63 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: NortelCrypto.h
+// Author: Daniel Giritzer, Johannes Posch
+// Date: 24.11.2016
+// Description: Testklasse für den NortelCrypto Adapter.
+// Remarks: Testet die Funktionalität des NortelCrypto Adapters.
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#ifndef NORTELCRYPTO_H
+#define NORTELCRYPTO_H
+
+#include "Object.h"
+#include "NortelCryptoIF.h"
+
+/////////////////////////////////////////////////
+/// \brief Testklasse für den NortelCrypto
+///        Adapter.
+///
+///        Verwendet zum verschlüsseln,
+///        über den NortelAdapter, die
+///        HSECrypto Klasse.
+/////////////////////////////////////////////////
+class NortelCrypto : public Object
+{
+public:
+    /////////////////////////////////////////////////
+    /// \brief Setzt ein Objekt das NortelCryptoIF
+    ///         implementiert vorraus.
+    ///
+    /// \param mCrypt Objekt das NortelCryptoIF
+    ///        implementiert (z.B. Adapter).
+    /////////////////////////////////////////////////
+    NortelCrypto(NortelCryptoIF::SPtr const & mCrypt);
+
+    /////////////////////////////////////////////////
+    /// \brief Testet ob der Adapter die Nortel
+    ///        Schnittstelle zum Verschlüsseln richtig
+    ///        übersetzt.
+    ///
+    /// \param enc Enum der die Verschlüsselungsmethode
+    ///        angibt.
+    /// \param fileName Pfad zu der Datei die
+    ///        Verschlüsselt werden soll.
+    /////////////////////////////////////////////////
+    void Encrypt(NortelCryptoIF::TEncoding enc, std::string const & fileName);
+
+    /////////////////////////////////////////////////
+    /// \brief Testet ob der Adapter die Nortel
+    ///        Schnittstelle zum Entschlüsseln richtig
+    ///        übersetzt.
+    ///
+    /// \param enc Enum der die Entschlüsselungsmethode
+    ///        angibt.
+    /// \param fileName Pfad zu der Datei die
+    ///        Entschlüsselt werden soll.
+    /////////////////////////////////////////////////
+    void Decrypt(NortelCryptoIF::TEncoding enc, std::string const & fileName);
+
+private:
+    NortelCryptoIF::SPtr mCrypt;
+};
+
+#endif //NORTELCRYPTO_H
diff --git a/src/tests/SDP3/src/NortelCryptoIF.h b/src/tests/SDP3/src/NortelCryptoIF.h
new file mode 100644 (file)
index 0000000..2a1b0e0
--- /dev/null
@@ -0,0 +1,57 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: NortelCrypto.h
+// Author: Daniel Giritzer, Johannes Posch
+// Date: 9.11.2016
+// Description: Interface der Cryptoklasse von der Firma Nortel.
+// Remarks: Copyright NORTEL LTD
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#ifndef NORTELCRYPTOIF_H
+#define NORTELCRYPTOIF_H
+
+#include <string>
+#include <memory>
+
+/////////////////////////////////////////////////
+/// \brief Interface für die Nortel
+///        CryptoMethoden.
+/////////////////////////////////////////////////
+class NortelCryptoIF
+{
+public:
+    ///< Gibt an welche Verschlüsselung verwendet werden soll.
+    enum TEncoding { eRSA,
+                     eCaesar
+                   };
+
+    /////////////////////////////////////////////////
+    /// \brief Interfacemethode:
+    ///        Verschlüsselt eine Datei mit dem
+    ///        gegebenen Algorithmus.
+    ///
+    /// \param enc Enum der die Verschlüsselungsmethode
+    ///        angibt.
+    /// \param fileName Pfad zu der Datei die
+    ///        Verschlüsselt werden soll.
+    /////////////////////////////////////////////////
+    virtual void Encipher(TEncoding enc, std::string const & fileName) = 0;
+
+    /////////////////////////////////////////////////
+    /// \brief Interfacemethode:
+    ///        Entschlüsselt eine Datei mit dem
+    ///        gegebenen Algorithmus.
+    ///
+    /// \param enc Enum der die Entschlüsselungsmethode
+    ///        angibt.
+    /// \param fileName Pfad zu der Datei die
+    ///        Entschlüsselt werden soll.
+    /////////////////////////////////////////////////
+    virtual void Decipher(TEncoding enc, std::string const & fileName) = 0;
+
+    typedef std::shared_ptr<NortelCryptoIF> SPtr; ///< Pointer auf NortelCrypoIF
+
+protected:
+    NortelCryptoIF() = default;
+};
+
+#endif // NORTELCRYPTOIF_H
diff --git a/src/tests/SDP3/src/Object.h b/src/tests/SDP3/src/Object.h
new file mode 100644 (file)
index 0000000..f63dfac
--- /dev/null
@@ -0,0 +1,19 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Object.h
+// Author: Daniel Giritzer, Johannes Posch
+// Date: 09.11.2016
+// Description: Basisklasse aller Klassen.
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#ifndef OBJECT_H_INCLUDED
+#define OBJECT_H_INCLUDED
+
+/////////////////////////////////////////////////
+/// \brief Basisklasse aller Klassen.
+/////////////////////////////////////////////////
+class Object
+{
+public:
+    virtual ~Object() = default;
+};
+#endif // OBJECT_H_INCLUDED
diff --git a/src/tests/SDP3/src/Rsa.cpp b/src/tests/SDP3/src/Rsa.cpp
new file mode 100644 (file)
index 0000000..39b4484
--- /dev/null
@@ -0,0 +1,85 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Rsa.cpp
+// Author: Daniel Giritzer, Johannes Posch
+// Date: 23.11.2016
+// Description: Klasse zum ver- & entschlüsseln von ASCII Dateien.
+// Remarks: Erbt von HSECrypto
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include "Rsa.h"
+#include <vector>
+#include <algorithm>
+
+/////////////////////////////////////////////////
+/// \brief Verschlüsselt den in der Klasse
+///        gespeicherten StringStream mithilfe
+///        des RSA Algorithmus.
+///        Wird der StringStream wieder auf
+///        eine Datei geschrieben, so hat diese die
+///        Dateiendung .RSA.
+/////////////////////////////////////////////////
+void Rsa::Encrypt()
+{
+    //Dateiendung hinzufügen
+    this->mFname = this->mFname + this->mFileExtension;
+
+    //Zeichen als unsigned char einlesen damit die Zeichen
+    //nicht falsch interpretiert werden.
+    std::string rdstr = this->mBuffer.str();
+    Rsa::ustring str(rdstr.cbegin(), rdstr.cend());
+
+    //String als Integer Speichern um Informationsverlust Zu Vermeiden.
+    //(da größerer Datentyp)
+    std::vector<uint64_t> str_int(str.cbegin(), str.cend());
+    std::vector<uint64_t> str_orig_int(str.cbegin(), str.cend());
+
+
+    //Mit public Key 'e' modular Potenzieren
+    //(beim Modularen Potenzieren sind die Zahlen um ein
+    // vielfaches kleiner)
+    transform(str_orig_int.cbegin(), str_orig_int.cend(), str_orig_int.begin(), bind2nd(std::modulus<uint64_t>(), this->mN));
+    for(size_t i = 1; i < this->mE; i++)
+    {
+        transform(str_int.cbegin(), str_int.cend(), str_int.begin(), bind2nd(std::modulus<uint64_t>(),this->mN));
+        transform(str_orig_int.cbegin(), str_orig_int.cend(), str_int.begin(), str_int.begin(), std::multiplies<uint64_t>());
+    }
+    transform(str_int.cbegin(), str_int.cend(), str_int.begin(), bind2nd(std::modulus<uint64_t>(),this->mN));
+
+    //Ergebnis auf internen StringStream schreiben.
+    std::copy(str_int.cbegin(), str_int.cend(), rdstr.begin());
+    this->mBuffer.str(std::string());
+    this->mBuffer << rdstr;
+}
+
+/////////////////////////////////////////////////
+/// \brief Entschlüsselt den Internen StringStream
+///        mithilfe des RSA Algorithmus.
+/////////////////////////////////////////////////
+void Rsa::Decrypt()
+{
+    //Zeichen als unsigned char einlesen damit die Zeichen
+    //nicht falsch interpretiert werden.
+    std::string rdstr = this->mBuffer.str();
+    Rsa::ustring str(rdstr.cbegin(), rdstr.cend());
+
+    //Char Werte als Integer Speichern um Informationsverlust Zu Vermeiden.
+    //(da größerer Datentyp)
+    std::vector<uint64_t> str_int(str.cbegin(), str.cend());
+    std::vector<uint64_t> str_orig_int(str.cbegin(), str.cend());
+
+    //Mit private Key 'd' modular Potenzieren
+    //(beim Modularen Potenzieren sind die Zahlen um ein
+    // vielfaches kleiner)
+    transform(str_orig_int.cbegin(), str_orig_int.cend(), str_orig_int.begin(), bind2nd(std::modulus<uint64_t>(), this->mN));
+    for(size_t i = 1; i < this->mD; i++)
+    {
+        transform(str_int.cbegin(), str_int.cend(), str_int.begin(), bind2nd(std::modulus<uint64_t>(),this->mN));
+        transform(str_orig_int.cbegin(), str_orig_int.cend(), str_int.begin(), str_int.begin(), std::multiplies<uint64_t>());
+    }
+    transform(str_int.cbegin(), str_int.cend(), str_int.begin(), bind2nd(std::modulus<uint64_t>(),this->mN));
+
+    //Ergebnis auf internen StringStream schreiben.
+    std::copy(str_int.cbegin(), str_int.cend(), rdstr.begin());
+    this->mBuffer.str(std::string());
+    this->mBuffer << rdstr;
+}
diff --git a/src/tests/SDP3/src/Rsa.h b/src/tests/SDP3/src/Rsa.h
new file mode 100644 (file)
index 0000000..b9f1d28
--- /dev/null
@@ -0,0 +1,61 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Rsa.h
+// Author: Daniel Giritzer, Johannes Posch
+// Date: 23.11.2016
+// Description: Klasse zum ver- & entschlüsseln von ASCII Dateien.
+// Remarks: Erbt von HSECrypto
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#ifndef RSA_H
+#define RSA_H
+
+#include "HSECryptoIF.h"
+
+/////////////////////////////////////////////////
+/// \brief Diese Klasse ermöglicht verschlüsseln
+///        und entschlüsseln von ASCII Textdateien
+///        mithilfe des RSA Algorithmus.
+///
+///        Die möglichkeit Dateien zu Lesen und
+///        zu Schreiben erbt diese Klasse von
+///        HSECryptoIF.
+/////////////////////////////////////////////////
+class Rsa : public HSECryptoIF
+{
+public:
+    /////////////////////////////////////////////////
+    /// \brief Verschlüsselt den in der Klasse
+    ///        gespeicherten StringStream mithilfe
+    ///        des RSA Algorithmus.
+    ///        Wird der StringStream wieder auf
+    ///        eine Datei geschrieben, so hat diese die
+    ///        Dateiendung .RSA.
+    /////////////////////////////////////////////////
+    virtual void Encrypt() override;
+
+    /////////////////////////////////////////////////
+    /// \brief Entschlüsselt den Internen StringStream
+    ///        mithilfe des RSA Algorithmus.
+    /////////////////////////////////////////////////
+    virtual void Decrypt() override;
+
+private:
+    //Damit die gesamte ASCII Tabelle
+    //verschlüsselt werden kann, muss
+    //mN höher sein als der größte
+    //ASCII Wert (255) weil:
+    //(255 ^ mE) mod 255 = 0
+    //=> kann man nicht mehr entschlüsseln!
+    size_t const mN = 259;  //Public Key
+    size_t const mE = 31;   //Public Key
+    size_t const mD = 7;    //Private Key
+
+    //Dateiendung für Dateien die mit einem
+    //Objekt dieser Klasse geschrieben werden.
+    const std::string mFileExtension = ".RSA";
+
+    //String mit unsigned Chars
+    typedef std::basic_string<unsigned char> ustring;
+};
+
+#endif // RSA_H
diff --git a/src/tests/SDP3/src/main.cpp b/src/tests/SDP3/src/main.cpp
new file mode 100644 (file)
index 0000000..ec7cb54
--- /dev/null
@@ -0,0 +1,185 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: main.cpp
+// Author: Johannes Posch, Daniel Giritzer
+// Date: 24.11.2016
+// Description: Testtreiber für die verschiedenen Cryptomodule
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include "EpicosCrypto.h" // Klasse zum Testen des Epicos Adapters
+#include "NortelCrypto.h" // Klasse zum Testen des Nortel Adapters
+#include "EpicosAdapter.h"
+#include "NortelAdapter.h"
+#include "HSECrypto.h"
+#include "Cesar.h"
+#include "Rsa.h"
+#include <iostream>
+
+using namespace std;
+
+int main()
+{
+
+    try
+    {
+        //  Hier werden zum generellen Test die zwei encoder (Cesar & Rsa)
+        //  zum Überprüfen erzeugt
+        HSECryptoIF::SPtr cryptCesar { make_shared<Cesar>()};
+        HSECryptoIF::SPtr cryptRSA { make_shared<Rsa>()};
+
+        // Die Codierende Klasse brauch noch einen Encoder, dieser wird als Argument im
+        // Konstruktor mitgegeben
+        HSECrypto doCrypt(cryptCesar);
+
+        //Als erstes wird die Funktion ueberprueft. Damit man das verschluesselte File
+        //nicht verloren geht, wird es per Systemcommando kopiert. Danach wird das File wieder
+        //entschluesselt, wobei der verschluesselte Inhalt ueberschrieben wird.
+        try
+        {
+            doCrypt.Encrypt("test/secret.txt");
+            system("cp test/secret.txt.Cesar test/secret.txt.Cesar-backup");
+            doCrypt.Decrypt("test/secret.txt.Cesar");
+        }
+        catch(string& e)
+        {
+            cerr << e << endl;
+        }
+        catch(...)
+        {
+        }
+
+        // Desweiteren wird gleich ueberprueft, wie sich die Algorithmen mit
+        // Fehlangaben verhalten.
+        try
+        {
+            doCrypt.Encrypt("test/does_not_exist.txt");
+        }
+        catch(string& e)
+        {
+            cerr << e << endl;
+        }
+        catch(...)
+        {
+        }
+
+        // Die Cesar Tests wurden erfolgreich abgeschlossen also wird der
+        // Encoder gewechselt
+        try
+        {
+            doCrypt.setCrypto(cryptRSA);
+        }
+        catch(string& e)
+        {
+            cerr << e << endl;
+        }
+        catch(...)
+        {
+        }
+
+        //Ueberpruefen des Falles, dass ein Nullptr uebergeben wird
+        try
+        {
+            doCrypt.setCrypto(nullptr);
+        }
+        catch(string& e)
+        {
+            cerr << e << endl;
+        }
+        catch(...)
+        {
+        }
+
+        //Ueberpruefen der RSA verschluesselung mit anschliessendem kopieren in ein
+        //Backup und dann wieder Entschluesseln
+        try
+        {
+            doCrypt.Encrypt("test/secret.txt");
+            system("cp test/secret.txt.RSA test/secret.txt.RSA-backup");
+            doCrypt.Decrypt("test/secret.txt.RSA");
+        }
+        catch(string& e)
+        {
+            cerr << e << endl;
+        }
+        catch(...)
+        {
+        }
+
+        // Provozierter Fehler
+        try
+        {
+            doCrypt.Encrypt("test/does_not_exist.txt");
+        }
+        catch(string& e)
+        {
+            cerr << e << endl;
+        }
+        catch(...)
+        {
+        }
+
+        //Anlegen der Beiden FirmenAdapter
+        EpicosCryptoIF::SPtr epicosAdapter { make_shared<EpicosAdapter>()};
+        NortelCryptoIF::SPtr nortelAdapter { make_shared<NortelAdapter>()};
+
+        //Testen des Nortel Adapters
+        EpicosCrypto doCryptEpicos(epicosAdapter);
+        try
+        {
+            doCryptEpicos.Encrypt("test/secret.txt");
+            system("cp test/secret.txt.RSA test/secret.txt.RSA-Epicos-backup");
+            doCryptEpicos.Decrypt("test/secret.txt.RSA");
+        }
+        catch(string& e)
+        {
+            cerr << e << endl;
+        }
+        catch(...)
+        {
+        }
+
+
+        //Testen des Epicos Adapters
+        NortelCrypto doCryptNortel(nortelAdapter);
+        try
+        {
+            doCryptNortel.Encrypt(NortelCryptoIF::eCaesar, "test/secret.txt");
+            system("cp test/secret.txt.Cesar test/secret.txt.Cesar-Nortel-backup");
+            doCryptNortel.Decrypt(NortelCryptoIF::eCaesar, "test/secret.txt.Cesar");
+            doCryptNortel.Encrypt(NortelCryptoIF::eRSA, "test/secret.txt");
+            system("cp test/secret.txt.RSA test/secret.txt.RSA-Nortel-backup");
+            doCryptNortel.Decrypt(NortelCryptoIF::eRSA, "test/secret.txt.RSA");
+        }
+        catch(string& e)
+        {
+            cerr << e << endl;
+        }
+        catch(...)
+        {
+        }
+
+        // Provozierter Fehler mit einem falschen File
+        try
+        {
+            doCryptNortel.Encrypt(NortelCryptoIF::eCaesar, "test/der.txt");
+        }
+        catch(string& e)
+        {
+            cerr << e << endl;
+        }
+        catch(...)
+        {
+        }
+    }
+    catch(std::bad_alloc const& e)
+    {
+        // Spezielle Ausnahme: Speicherallokierung misslungen
+        std::cerr << "Exeption Caught: Bad memory allocation ( " << e.what() << " )" << std::endl;
+        return EXIT_FAILURE;    // main() mit Fehlerstatus beenden
+    }
+    catch(...)
+    {
+        cerr << "Unandled Exception Caught!" << endl;
+        return EXIT_FAILURE;
+    }
+    return EXIT_SUCCESS;
+}
diff --git a/src/tests/SDP3/src/test/secret.txt b/src/tests/SDP3/src/test/secret.txt
new file mode 100644 (file)
index 0000000..f629ec2
--- /dev/null
@@ -0,0 +1,9 @@
+abcdefghijklmnopqrstuvwxyz
+ABCDEFGHIJKLMNOPQRSTUVWXYZ
+1234567890
+!"§$%&/()=?ß
+ÄÖÜ
+äöü
+,.-;:_+*#'|<>´`^°~
+    Tabulator
+ Leerzeichen
diff --git a/src/tests/SDP3/src/test/secret.txt.Cesar b/src/tests/SDP3/src/test/secret.txt.Cesar
new file mode 100644 (file)
index 0000000..f629ec2
--- /dev/null
@@ -0,0 +1,9 @@
+abcdefghijklmnopqrstuvwxyz
+ABCDEFGHIJKLMNOPQRSTUVWXYZ
+1234567890
+!"§$%&/()=?ß
+ÄÖÜ
+äöü
+,.-;:_+*#'|<>´`^°~
+    Tabulator
+ Leerzeichen
diff --git a/src/tests/SDP3/src/test/secret.txt.Cesar-Nortel-backup b/src/tests/SDP3/src/test/secret.txt.Cesar-Nortel-backup
new file mode 100644 (file)
index 0000000..9dcc48b
--- /dev/null
@@ -0,0 +1 @@
+~\7f\80\81\82\83\84\85\86\87\88\89\8a\8b\8c\8d\8e\8f\90\91\92\93\94\95\96\97'^_`abcdefghijklmnopqrstuvw'NOPQRSTUVM'>?ßÄABCLEFZ\à¼'à¡à³à¹'àÁàÓàÙ'IKJXW|HG@D\99Y[ßÑ}{ßÍ\9b'====q~\7f\92\89~\91\8c\8f'=i\82\82\8f\97\82\86\80\85\82\8b'
\ No newline at end of file
diff --git a/src/tests/SDP3/src/test/secret.txt.Cesar-backup b/src/tests/SDP3/src/test/secret.txt.Cesar-backup
new file mode 100644 (file)
index 0000000..9dcc48b
--- /dev/null
@@ -0,0 +1 @@
+~\7f\80\81\82\83\84\85\86\87\88\89\8a\8b\8c\8d\8e\8f\90\91\92\93\94\95\96\97'^_`abcdefghijklmnopqrstuvw'NOPQRSTUVM'>?ßÄABCLEFZ\à¼'à¡à³à¹'àÁàÓàÙ'IKJXW|HG@D\99Y[ßÑ}{ßÍ\9b'====q~\7f\92\89~\91\8c\8f'=i\82\82\8f\97\82\86\80\85\82\8b'
\ No newline at end of file
diff --git a/src/tests/SDP3/src/test/secret.txt.RSA b/src/tests/SDP3/src/test/secret.txt.RSA
new file mode 100644 (file)
index 0000000..f629ec2
--- /dev/null
@@ -0,0 +1,9 @@
+abcdefghijklmnopqrstuvwxyz
+ABCDEFGHIJKLMNOPQRSTUVWXYZ
+1234567890
+!"§$%&/()=?ß
+ÄÖÜ
+äöü
+,.-;:_+*#'|<>´`^°~
+    Tabulator
+ Leerzeichen
diff --git a/src/tests/SDP3/src/test/secret.txt.RSA-Epicos-backup b/src/tests/SDP3/src/test/secret.txt.RSA-Epicos-backup
new file mode 100644 (file)
index 0000000..4d1b130
--- /dev/null
@@ -0,0 +1,9 @@
+}8©de\19R)\9a2ÛÀÈnop\16\1e\ 3¬Dµ\8cÅyz
+÷-\ 4u\r\9b£IJKôüá\87\1f\90g TU\10\81<6S
+î\\17\11\99Ù·0
+\91v\fE$%&/×¼\13\9f
\8bÃ;ñ
\9dÃ\aÃh
+k{B^Afýb~ϦX\84\f|\83Ü\fc[
+ëëëëT}8DÀ}¬o\1e
+ëôee\1eze\9a©)en
diff --git a/src/tests/SDP3/src/test/secret.txt.RSA-Nortel-backup b/src/tests/SDP3/src/test/secret.txt.RSA-Nortel-backup
new file mode 100644 (file)
index 0000000..4d1b130
--- /dev/null
@@ -0,0 +1,9 @@
+}8©de\19R)\9a2ÛÀÈnop\16\1e\ 3¬Dµ\8cÅyz
+÷-\ 4u\r\9b£IJKôüá\87\1f\90g TU\10\81<6S
+î\\17\11\99Ù·0
+\91v\fE$%&/×¼\13\9f
\8bÃ;ñ
\9dÃ\aÃh
+k{B^Afýb~ϦX\84\f|\83Ü\fc[
+ëëëëT}8DÀ}¬o\1e
+ëôee\1eze\9a©)en
diff --git a/src/tests/SDP3/src/test/secret.txt.RSA-backup b/src/tests/SDP3/src/test/secret.txt.RSA-backup
new file mode 100644 (file)
index 0000000..4d1b130
--- /dev/null
@@ -0,0 +1,9 @@
+}8©de\19R)\9a2ÛÀÈnop\16\1e\ 3¬Dµ\8cÅyz
+÷-\ 4u\r\9b£IJKôüá\87\1f\90g TU\10\81<6S
+î\\17\11\99Ù·0
+\91v\fE$%&/×¼\13\9f
\8bÃ;ñ
\9dÃ\aÃh
+k{B^Afýb~ϦX\84\f|\83Ü\fc[
+ëëëëT}8DÀ}¬o\1e
+ëôee\1eze\9a©)en
diff --git a/src/tests/SEN1/Angabe.pdf b/src/tests/SEN1/Angabe.pdf
new file mode 100644 (file)
index 0000000..bd26abd
Binary files /dev/null and b/src/tests/SEN1/Angabe.pdf differ
diff --git a/src/tests/SEN1/Beispiel1/LeetSpeak.cpp b/src/tests/SEN1/Beispiel1/LeetSpeak.cpp
new file mode 100644 (file)
index 0000000..4f90810
--- /dev/null
@@ -0,0 +1,102 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: LeetSpeak.cpp
+// Author: Daniel Giritzer
+// Date: 15.12.2015
+// Description: The LeetSpeak module converts an given String into L33t
+// Remarks:
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+
+#include "LeetSpeak.h"
+
+//////////////////////////////////////////
+// Converts given string into leetspeak
+// Call by Reverence
+//////////////////////////////////////////
+void ToLeet(std::string & str)
+{
+
+    const size_t del = 1;
+    char signtoleet = ' ';
+
+    for(int i = 0; i < str.length(); i++)
+    {
+        signtoleet = toupper(str[i]);
+        switch(signtoleet)
+        {
+        case 'A':
+            str.erase(i, del);
+            str.insert(i,"4");
+            break;
+        case 'C':
+            str.erase(i, del);
+            str.insert(i,"<");
+            break;
+        case 'E':
+            str.erase(i, del);
+            str.insert(i,"[-");
+            i = i + 1;
+            break;
+        case 'G':
+            str.erase(i, del);
+            str.insert(i,"(_+");
+            i = i + 2;
+            break;
+        case 'I':
+            str.erase(i, del);
+            str.insert(i,"!");
+            break;
+        case 'K':
+            str.erase(i, del);
+            str.insert(i,"|{");
+            i = i + 1;
+            break;
+        case 'M':
+            str.erase(i, del);
+            str.insert(i,"|V|");
+            i = i + 2;
+            break;
+        case 'O':
+            str.erase(i, del);
+            str.insert(i,"0");
+            break;
+        case 'P':
+            str.erase(i, del);
+            str.insert(i,"|*");
+            i = i + 1;
+            break;
+        case 'R':
+            str.erase(i, del);
+            str.insert(i,"12");
+            i = i + 1;
+            break;
+        case 'S':
+            str.erase(i, del);
+            str.insert(i,"$");
+            break;
+        case 'T':
+            str.erase(i, del);
+            str.insert(i,"']['");
+            i = i + 3;
+            break;
+        case 'V':
+            str.erase(i, del);
+            str.insert(i,"\\/");
+            i = i + 1;
+            break;
+        case 'X':
+            str.erase(i, del);
+            str.insert(i,"><");
+            i = i + 1;
+            break;
+        case 'Z':
+            str.erase(i, del);
+            str.insert(i,"2");
+            break;
+        default:
+            break;
+        }
+    }
+
+
+}
diff --git a/src/tests/SEN1/Beispiel1/LeetSpeak.h b/src/tests/SEN1/Beispiel1/LeetSpeak.h
new file mode 100644 (file)
index 0000000..93b3c60
--- /dev/null
@@ -0,0 +1,21 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: LeetSpeak.h
+// Author: Daniel Giritzer
+// Date: 15.12.2015
+// Description: The LeetSpeak module converts an given String into L33t
+// Remarks:
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+
+#ifndef LEETSPEAK_H_INCLUDED
+#define LEETSPEAK_H_INCLUDED
+
+#include <locale>
+
+//////////////////////////////////////////
+// Converts given string into leetspeak
+// Call by Reverence
+//////////////////////////////////////////
+void ToLeet(std::string & str);
+
+#endif // LEETSPEAK_H_INCLUDED
diff --git a/src/tests/SEN1/Beispiel1/Makefile b/src/tests/SEN1/Beispiel1/Makefile
new file mode 100644 (file)
index 0000000..444162c
--- /dev/null
@@ -0,0 +1,129 @@
+############################################################################
+# Workfile: Makefile
+# Author: Daniel Giritzer, S1510306010
+#        daniel@giritzer.eu
+# Date: 06.04.2016
+# Description: Universal Makefile for Unix based Operating Systems
+#              Important CFLAGS:
+#              -std=c++98      - follow c++ 98 coding standard
+#              -std=c++11      - follow c++ 11 coding standard
+#              -std=c++0x      - follow coming c++ 0x standard
+#
+# Remarks:     Compatible with CodeBlocks (C::B)
+#              PROJNAME variable should match your project name!
+# Revision: 5.4
+# Usage: make debug            - builds debug version
+#               make release   - builds release version
+#               make all       - builds debug and release version
+#               make clean     - cleans project
+#               make rebuild   - builds release version from scratch
+############################################################################
+
+####################
+#GENERAL | EDIT 1/3
+####################
+WORKDIR = $(shell pwd)
+SOURCES := $(shell ls *.cpp)
+PROJNAME = LeetSpeak
+
+CC = gcc
+CXX = g++
+AR = ar
+LD = g++
+WINDRES = windres
+
+INC =
+CFLAGS = -Wall -fexceptions -std=c++11
+RESINC =
+LIBDIR =
+LIB =
+LDFLAGS =
+
+############################
+#DEBUG SETTINGS | EDIT: 2/3
+############################
+INC_DEBUG = $(INC)
+CFLAGS_DEBUG = $(CFLAGS) -g
+RESINC_DEBUG = $(RESINC)
+RCFLAGS_DEBUG = $(RCFLAGS)
+LIBDIR_DEBUG = $(LIBDIR)
+LIB_DEBUG = $(LIB)
+LDFLAGS_DEBUG = $(LDFLAGS)
+OBJDIR_DEBUG = obj/Debug
+DEP_DEBUG =
+OUT_DEBUG = bin/Debug/$(PROJNAME)
+
+
+##############################
+#RELEASE SETTINGS | EDIT: 3/3
+##############################
+INC_RELEASE = $(INC)
+CFLAGS_RELEASE = $(CFLAGS) -O2
+RESINC_RELEASE = $(RESINC)
+RCFLAGS_RELEASE = $(RCFLAGS)
+LIBDIR_RELEASE = $(LIBDIR)
+LIB_RELEASE = $(LIB)
+LDFLAGS_RELEASE = $(LDFLAGS) -s
+OBJDIR_RELEASE = obj/Release
+DEP_RELEASE =
+OUT_RELEASE = bin/Release/$(PROJNAME)
+
+############################
+#OBJECT LISTS | DO NOT EDIT!
+############################
+OBJ_DEBUG = $(addprefix $(OBJDIR_DEBUG)/,$(SOURCES:%.cpp=%.o))
+OBJ_RELEASE = $(addprefix $(OBJDIR_RELEASE)/,$(SOURCES:%.cpp=%.o))
+
+
+##########################
+#FUNCTIONS | DO NOT EDIT!
+##########################
+
+######## General
+all All: debug release
+clean Clean: cleanDebug cleanRelease
+rebuild Rebuild: clean debug release
+
+######## DEBUG
+before_debug:
+       test -d bin/Debug || mkdir -p bin/Debug
+       test -d $(OBJDIR_DEBUG) || mkdir -p $(OBJDIR_DEBUG)
+
+after_debug:
+
+debug Debug: before_debug out_debug after_debug
+
+out_debug: before_debug $(OBJ_DEBUG) $(DEP_DEBUG)
+       $(LD) $(LDFLAGS_DEBUG) $(LIBDIR_DEBUG) $(OBJ_DEBUG) $(LIB_DEBUG) -o $(OUT_DEBUG)
+
+$(OBJDIR_DEBUG)/%.o: %.cpp
+       $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c $< -D_DEBUG -o $@
+
+clean_debug cleanDebug:
+       rm -f $(OBJ_DEBUG) $(OUT_DEBUG)
+       rm -rf bin/Debug
+       rm -rf $(OBJDIR_DEBUG)
+
+
+######## RELEASE
+before_release:
+       test -d bin/Release || mkdir -p bin/Release
+       test -d $(OBJDIR_RELEASE) || mkdir -p $(OBJDIR_RELEASE)
+
+after_release:
+
+release Release: before_release out_release after_release
+
+out_release: before_release $(OBJ_RELEASE) $(DEP_RELEASE)
+       $(LD) $(LDFLAGS_RELEASE) $(LIBDIR_RELEASE) $(OBJ_RELEASE) $(LIB_RELEASE) -o $(OUT_RELEASE)
+
+$(OBJDIR_RELEASE)/%.o: %.cpp
+       $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c $< -o $@
+
+clean_release cleanRelease:
+       rm -f $(OBJ_RELEASE) $(OUT_RELEASE)
+       rm -rf bin/Release
+       rm -rf $(OBJDIR_RELEASE)
+
+.PHONY: before_debug after_debug clean_debug cleanDebug before_release after_release clean_release cleanRelease
+
diff --git a/src/tests/SEN1/Beispiel1/main.cpp b/src/tests/SEN1/Beispiel1/main.cpp
new file mode 100644 (file)
index 0000000..fa41199
--- /dev/null
@@ -0,0 +1,27 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: main.cpp
+// Author: Daniel Giritzer
+// Date: 15.12.2015
+// Description: Testdriver for the LeetSpeak module
+// Remarks: -
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include <iostream>
+#include "LeetSpeak.h"
+
+using namespace std;
+
+int main()
+{
+    //Panagram => All letters of the alphabet are in this sentece.
+    string LeetIt = "The quick brown fox jumps over the lazy dog.";
+
+    //Print original sentence.
+    cout << LeetIt << endl;
+
+    ToLeet(LeetIt); //Convert
+    //Print LeetSpeak sentence
+    cout << LeetIt;
+
+    return 0;
+}
diff --git a/src/tests/SEN1/Beispiel2/Makefile b/src/tests/SEN1/Beispiel2/Makefile
new file mode 100644 (file)
index 0000000..f73225a
--- /dev/null
@@ -0,0 +1,129 @@
+############################################################################
+# Workfile: Makefile
+# Author: Daniel Giritzer, S1510306010
+#        daniel@giritzer.eu
+# Date: 06.04.2016
+# Description: Universal Makefile for Unix based Operating Systems
+#              Important CFLAGS:
+#              -std=c++98      - follow c++ 98 coding standard
+#              -std=c++11      - follow c++ 11 coding standard
+#              -std=c++0x      - follow coming c++ 0x standard
+#
+# Remarks:     Compatible with CodeBlocks (C::B)
+#              PROJNAME variable should match your project name!
+# Revision: 5.4
+# Usage: make debug            - builds debug version
+#               make release   - builds release version
+#               make all       - builds debug and release version
+#               make clean     - cleans project
+#               make rebuild   - builds release version from scratch
+############################################################################
+
+####################
+#GENERAL | EDIT 1/3
+####################
+WORKDIR = $(shell pwd)
+SOURCES := $(shell ls *.cpp)
+PROJNAME = Wetterstation
+
+CC = gcc
+CXX = g++
+AR = ar
+LD = g++
+WINDRES = windres
+
+INC =
+CFLAGS = -Wall -fexceptions -std=c++11
+RESINC =
+LIBDIR =
+LIB =
+LDFLAGS =
+
+############################
+#DEBUG SETTINGS | EDIT: 2/3
+############################
+INC_DEBUG = $(INC)
+CFLAGS_DEBUG = $(CFLAGS) -g
+RESINC_DEBUG = $(RESINC)
+RCFLAGS_DEBUG = $(RCFLAGS)
+LIBDIR_DEBUG = $(LIBDIR)
+LIB_DEBUG = $(LIB)
+LDFLAGS_DEBUG = $(LDFLAGS)
+OBJDIR_DEBUG = obj/Debug
+DEP_DEBUG =
+OUT_DEBUG = bin/Debug/$(PROJNAME)
+
+
+##############################
+#RELEASE SETTINGS | EDIT: 3/3
+##############################
+INC_RELEASE = $(INC)
+CFLAGS_RELEASE = $(CFLAGS) -O2
+RESINC_RELEASE = $(RESINC)
+RCFLAGS_RELEASE = $(RCFLAGS)
+LIBDIR_RELEASE = $(LIBDIR)
+LIB_RELEASE = $(LIB)
+LDFLAGS_RELEASE = $(LDFLAGS) -s
+OBJDIR_RELEASE = obj/Release
+DEP_RELEASE =
+OUT_RELEASE = bin/Release/$(PROJNAME)
+
+############################
+#OBJECT LISTS | DO NOT EDIT!
+############################
+OBJ_DEBUG = $(addprefix $(OBJDIR_DEBUG)/,$(SOURCES:%.cpp=%.o))
+OBJ_RELEASE = $(addprefix $(OBJDIR_RELEASE)/,$(SOURCES:%.cpp=%.o))
+
+
+##########################
+#FUNCTIONS | DO NOT EDIT!
+##########################
+
+######## General
+all All: debug release
+clean Clean: cleanDebug cleanRelease
+rebuild Rebuild: clean debug release
+
+######## DEBUG
+before_debug:
+       test -d bin/Debug || mkdir -p bin/Debug
+       test -d $(OBJDIR_DEBUG) || mkdir -p $(OBJDIR_DEBUG)
+
+after_debug:
+
+debug Debug: before_debug out_debug after_debug
+
+out_debug: before_debug $(OBJ_DEBUG) $(DEP_DEBUG)
+       $(LD) $(LDFLAGS_DEBUG) $(LIBDIR_DEBUG) $(OBJ_DEBUG) $(LIB_DEBUG) -o $(OUT_DEBUG)
+
+$(OBJDIR_DEBUG)/%.o: %.cpp
+       $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c $< -D_DEBUG -o $@
+
+clean_debug cleanDebug:
+       rm -f $(OBJ_DEBUG) $(OUT_DEBUG)
+       rm -rf bin/Debug
+       rm -rf $(OBJDIR_DEBUG)
+
+
+######## RELEASE
+before_release:
+       test -d bin/Release || mkdir -p bin/Release
+       test -d $(OBJDIR_RELEASE) || mkdir -p $(OBJDIR_RELEASE)
+
+after_release:
+
+release Release: before_release out_release after_release
+
+out_release: before_release $(OBJ_RELEASE) $(DEP_RELEASE)
+       $(LD) $(LDFLAGS_RELEASE) $(LIBDIR_RELEASE) $(OBJ_RELEASE) $(LIB_RELEASE) -o $(OUT_RELEASE)
+
+$(OBJDIR_RELEASE)/%.o: %.cpp
+       $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c $< -o $@
+
+clean_release cleanRelease:
+       rm -f $(OBJ_RELEASE) $(OUT_RELEASE)
+       rm -rf bin/Release
+       rm -rf $(OBJDIR_RELEASE)
+
+.PHONY: before_debug after_debug clean_debug cleanDebug before_release after_release clean_release cleanRelease
+
diff --git a/src/tests/SEN1/Beispiel2/main.cpp b/src/tests/SEN1/Beispiel2/main.cpp
new file mode 100644 (file)
index 0000000..1535c22
--- /dev/null
@@ -0,0 +1,64 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: main.cpp
+// Author: Daniel Giritzer
+// Date: 16.12.2015
+// Description: Testdriver for the weatherstations module
+// Remarks:
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include <iostream>
+#include "weatherstations.h"
+
+using namespace std;
+
+int main()
+{
+    TWeatherStations Stations = {};
+    cout << boolalpha;
+    cout << "Testing empty TWeatherStations:" << endl;
+    cout << "Is empty?: " << IsEmpty(Stations) << endl;
+    cout << "Is full?: "<< IsFull(Stations) << endl;
+    cout << "Number Of Entries: "<< GetNumberOfEntries(Stations) << endl;
+    cout << "Print coldest: "<< PrintColdestStation(Stations) << endl;
+    cout << "Print warmest: "<< PrintWarmestStation(Stations) << endl;
+    cout << "Print all avaiable Stations:" << endl;
+    PrintAllStations(Stations);
+    cout << "------------------------------------" << endl;
+
+
+    cout << "Fill TWeatherStations:" << endl;
+    cout << "Insert 1: " << Insert(Stations, "Linz", 12, 5) << endl;
+    cout << "Insert 2: " << Insert(Stations, "Bregenz", 13, 7) << endl;
+    cout << "Insert 3: " << Insert(Stations, "Graz", 1, 1) << endl;
+    cout << "Insert 4: " << Insert(Stations, "Innsbruck", 5, 3) << endl;
+    cout << "Insert 5: " << Insert(Stations, "St. Poelten", 9, 9) << endl;
+    cout << "Insert 6: " << Insert(Stations, "Wien", 20, 4) << endl;
+    cout << "Insert 6 again: " << Insert(Stations, "Wien", 20, 4) << endl;
+    cout << "Insert 7: " << Insert(Stations, "Klagenfurt", 1, 2) << endl;
+    cout << "Insert 8: " << Insert(Stations, "Salzburg", 20, 1) << endl;
+    cout << "Insert 9: " << Insert(Stations, "Eisenstadt", 23, 1) << endl;
+    cout << "------------------------------------" << endl;
+
+    cout << "Testing Full TWeatherStations:" << endl;
+    cout << "Is empty?: " << IsEmpty(Stations) << endl;
+    cout << "Is full?: "<< IsFull(Stations) << endl;
+    cout << "Number Of Entries: "<< GetNumberOfEntries(Stations) << endl << endl;
+    cout << "+++ Print coldest: "<< PrintColdestStation(Stations) << endl << endl;
+    cout << "+++ Print warmest: "<< PrintWarmestStation(Stations) << endl << endl;
+    cout << "+++ Print all avaiable Stations:" << endl;
+    PrintAllStations(Stations);
+    cout << "------------------------------------" << endl;
+
+    cout << "+++ Print one Station: " << PrintStation(Stations, "Wien") << endl;
+    cout << "------------------------------------" << endl;
+
+    cout << "Test Removing:" << endl;
+    cout << "remove: " << Remove(Stations, "Wien") << endl;
+    cout << "Try remove again: " << Remove(Stations, "Wien") << endl;
+    cout << "Try printing Removed Station: "<< PrintStation(Stations, "Wien") << endl;
+    cout << "Is empty?: " << IsEmpty(Stations) << endl;
+    cout << "Is full?: "<< IsFull(Stations) << endl;
+    cout << "Number Of Entries: "<< GetNumberOfEntries(Stations) << endl;
+
+    return 0;
+}
diff --git a/src/tests/SEN1/Beispiel2/weatherstations.cpp b/src/tests/SEN1/Beispiel2/weatherstations.cpp
new file mode 100644 (file)
index 0000000..ecb8ba3
--- /dev/null
@@ -0,0 +1,247 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: weatherstations.cpp
+// Author: Daniel Giritzer
+// Date: 16.12.2015
+// Description: Saves up to 8 weatherstations with temperature + airpressure
+// Remarks:
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include "weatherstations.h"
+
+
+// -----------------------------------------------------------
+// Fügt eine neue Station in die Verwaltung 'Stations'
+// ein. Liefert Funktionswert 'true' zurück, wenn dies
+// möglich war, und 'false' sonst.
+// Werden nach Temperatur sortiert gespeichert.
+// -----------------------------------------------------------
+bool Insert (TWeatherStations & Stations, string const & Name, int const Celsius, size_t const Pressure)
+{
+    bool returnvalue = false;
+    // Exisitiert die Station bereits oder ist Stations -> return false
+    if(!IsFull(Stations) && !CheckStationExistence(Stations, Name))
+    {
+        if(IsEmpty(Stations) || Celsius >= Stations.Station[Stations.NumberOfStations-1].Celsius)
+        {
+            Stations.Station[Stations.NumberOfStations].Name = Name;
+            Stations.Station[Stations.NumberOfStations].Celsius = Celsius;
+            Stations.Station[Stations.NumberOfStations].Pressure = Pressure;
+        }
+        //Sations werden nach Temperatur aufsteigend sortiert gespeichert
+        else if(Celsius <= Stations.Station[0].Celsius)
+        {
+            for(int ii = Stations.NumberOfStations - 1; ii >= 0 ; ii--)
+            {
+                Stations.Station[ii + 1].Name = Stations.Station[ii].Name;
+                Stations.Station[ii + 1].Celsius = Stations.Station[ii].Celsius;
+                Stations.Station[ii + 1].Pressure = Stations.Station[ii].Pressure;
+            }
+            Stations.Station[0].Name = Name;
+            Stations.Station[0].Celsius = Celsius;
+            Stations.Station[0].Pressure = Pressure;
+        }
+        else
+        {
+
+            for(int i = Stations.NumberOfStations - 1; i >= 0; i--)
+            {
+                if(Celsius >= Stations.Station[i].Celsius)
+                {
+                    for(int ii = Stations.NumberOfStations - 1; ii > i ; ii--)
+                    {
+                        Stations.Station[ii + 1].Name = Stations.Station[ii].Name;
+                        Stations.Station[ii + 1].Celsius = Stations.Station[ii].Celsius;
+                        Stations.Station[ii + 1].Pressure = Stations.Station[ii].Pressure;
+                    }
+                    Stations.Station[i + 1].Name = Name;
+                    Stations.Station[i + 1].Celsius = Celsius;
+                    Stations.Station[i + 1].Pressure = Pressure;
+                    i = 0;
+                }
+            }
+
+        }
+
+        Stations.NumberOfStations++;
+        returnvalue = true;
+    }
+    return returnvalue;
+}
+
+// -----------------------------------------------------------
+// Entfernt die Station mit Standort 'Name' aus der
+// Verwaltung. Die entstehende 'Lücke' in der Verwaltung ist
+// zu schließen, sodass die Stationen fortlaufend sind.
+// Liefert 'true' zurück, wenn die Station entfernt werden
+// konnte; 'false' sonst.
+// -----------------------------------------------------------
+bool Remove (TWeatherStations & Stations, string const & Name)
+{
+    bool returnvalue = false;
+    if(!IsEmpty(Stations) && CheckStationExistence(Stations, Name))
+    {
+        for(int i = 0; i < Stations.NumberOfStations; i++)
+        {
+            if(Stations.Station[i].Name == Name)
+            {   //Überschreibt die übergebene Station und rückt alle anderen nach.
+                for(i; i < Stations.NumberOfStations - 1; i++)
+                {
+                    Stations.Station[i].Name = Stations.Station[i + 1].Name;
+                    Stations.Station[i].Celsius = Stations.Station[i + 1].Celsius;
+                    Stations.Station[i].Pressure = Stations.Station[i + 1].Pressure;
+                }
+                //Löscht die Station an NumberOfStations - 1
+                //(Nicht zwingend notwendig)
+                Stations.Station[Stations.NumberOfStations - 1].Name = "";
+                Stations.Station[Stations.NumberOfStations - 1].Celsius = 0;
+                Stations.Station[Stations.NumberOfStations - 1].Pressure = 0;
+                Stations.NumberOfStations--;
+            }
+        }
+
+        returnvalue = true;
+    }
+    return returnvalue;
+}
+
+// -----------------------------------------------------------
+// Liefert als Funktionswert 'true', wenn keine Station
+// enthalten ist; sonst 'false'
+// -----------------------------------------------------------
+bool IsEmpty (TWeatherStations const & Stations)
+{
+    return (Stations.NumberOfStations == 0);
+}
+
+// -----------------------------------------------------------
+// Liefert als Funktionswert 'true',
+// wenn die Verwaltung vollständig belegt ist;
+// sonst 'false'
+// -----------------------------------------------------------
+bool IsFull (TWeatherStations const & Stations)
+{
+    return (Stations.NumberOfStations == 8);
+}
+
+// -----------------------------------------------------------
+// Liefert die Anzahl der enthaltenen Stationen der
+// Verwaltung zurück.
+// -----------------------------------------------------------
+size_t GetNumberOfEntries (TWeatherStations const & Stations)
+{
+    return Stations.NumberOfStations;
+}
+
+// -----------------------------------------------------------
+// Gibt alle Stationen der Reihe nach formatiert am
+// Bildschirm aus.
+// -----------------------------------------------------------
+void PrintAllStations (TWeatherStations const & Stations)
+{
+    if(!IsEmpty(Stations))
+    {
+
+        for(int i = 0; i < Stations.NumberOfStations; i++)
+        {
+            cout << "Station: " << Stations.Station[i].Name << endl;
+            cout << "Temperature: " << Stations.Station[i].Celsius << " Grad" << endl;
+            cout << "Pressure: " << Stations.Station[i].Pressure << " mBar" << endl << endl;
+        }
+
+
+    }
+
+}
+
+// -----------------------------------------------------------
+// Gibt nur die Station vom Standort 'Name' am Bildschirm
+// aus. Liefert 'true', wenn die Station enthalten ist,
+// 'false' sonst.
+// -----------------------------------------------------------
+bool PrintStation (TWeatherStations const & Stations, string const & Name)
+{
+    bool returnvalue = false;
+
+    if(CheckStationExistence(Stations, Name))
+    {
+
+        for(int i = 0; i < Stations.NumberOfStations; i++)
+        {
+            if(Stations.Station[i].Name == Name)
+            {
+                cout << "Station: " << Stations.Station[i].Name << endl;
+                cout << "Temperature: " << Stations.Station[i].Celsius << " Grad" << endl;
+                cout << "Pressure: " << Stations.Station[i].Pressure << " mBar" << endl << endl;
+            }
+        }
+        returnvalue = true;
+    }
+    return returnvalue;
+}
+
+
+// -----------------------------------------------------------
+// Gibt jene Station(en) inkl. Daten am Bildschirm aus, wo es
+// am kältesten ist. Liefert 'false', wenn die Verwaltung leer
+// ist; 'true' sonst.
+// -----------------------------------------------------------
+bool PrintColdestStation (TWeatherStations const & Stations)
+{
+    const size_t pos_coldest = 0;
+
+    bool returnvalue = false;
+    for(int i = 0; i < Stations.NumberOfStations; i++)
+    {
+        if(Stations.Station[i].Celsius == Stations.Station[pos_coldest].Celsius)
+        {
+            returnvalue = PrintStation(Stations, Stations.Station[i].Name);
+        }
+    }
+
+    return returnvalue;
+}
+
+
+// -----------------------------------------------------------
+// Gibt jene Station(en) inkl. Daten am Bildschirm aus, wo es
+// am wärmsten ist. Liefert 'false', wenn die Verwaltung leer
+// ist; 'true' sonst.
+// -----------------------------------------------------------
+bool PrintWarmestStation (TWeatherStations const & Stations)
+{
+    bool returnvalue = false;
+    for(int i = 0; i < Stations.NumberOfStations; i++)
+    {
+        if(Stations.Station[i].Celsius == Stations.Station[Stations.NumberOfStations - 1].Celsius)
+        {
+            returnvalue = PrintStation(Stations, Stations.Station[i].Name);
+        }
+    }
+
+    return returnvalue;
+}
+
+
+// -----------------------------------------------------------
+// Testet ob die Station vom Standort 'Name' exisitiert.
+// Liefert 'true', wenn die Station enthalten ist,
+// 'false' sonst.
+// -----------------------------------------------------------
+bool CheckStationExistence (TWeatherStations const & Stations, string const & Name)
+{
+    bool returnvalue = false;
+
+    if(!IsEmpty(Stations))
+    {
+        for(int i = 0; i < Stations.NumberOfStations; i++)
+        {
+            if(Stations.Station[i].Name == Name)
+            {
+                returnvalue=true;
+            }
+        }
+
+    }
+
+    return returnvalue;
+}
diff --git a/src/tests/SEN1/Beispiel2/weatherstations.h b/src/tests/SEN1/Beispiel2/weatherstations.h
new file mode 100644 (file)
index 0000000..bc03433
--- /dev/null
@@ -0,0 +1,105 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: weatherstations.cpp
+// Author: Daniel Giritzer
+// Date: 16.12.2015
+// Description: Saves up to 8 weatherstations with temperature + airpressure
+// Remarks:
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#ifndef WEATHERSTATIONS_H_INCLUDED
+#define WEATHERSTATIONS_H_INCLUDED
+
+#include <iostream>
+using namespace std;
+
+struct TElement {
+     string Name;        // Standort der Wetterstation.
+     int Celsius;        // Temperatur in Grad Celsius.
+     size_t Pressure;    // Luftdruck in mBar.
+};
+
+// Maximal zu verwaltende Stationen.
+int const MaxLen = 8;
+
+// Array zum Ablegen der Struktur.
+typedef TElement TElementArray [MaxLen];
+
+struct TWeatherStations {
+    TElementArray Station;  // Array mit den Stationen.
+    size_t NumberOfStations;// Anzahl der Stationen
+                            // im Array.
+};
+
+
+// -----------------------------------------------------------
+// Fügt eine neue Station in die Verwaltung 'Stations'
+// ein. Liefert Funktionswert 'true' zurück, wenn dies
+// möglich war, und 'false' sonst.
+// Werden nach Temperatur sortiert gespeichert.
+// -----------------------------------------------------------
+bool Insert (TWeatherStations & Stations, string const & Name, int const Celsius, size_t const Pressure);
+
+// -----------------------------------------------------------
+// Entfernt die Station mit Standort 'Name' aus der
+// Verwaltung. Die entstehende 'Lücke' in der Verwaltung ist
+// zu schließen, sodass die Stationen fortlaufend sind.
+// Liefert 'true' zurück, wenn die Station entfernt werden
+// konnte; 'false' sonst.
+// -----------------------------------------------------------
+bool Remove (TWeatherStations & Stations, string const & Name);
+
+// -----------------------------------------------------------
+// Liefert als Funktionswert 'true', wenn keine Station
+// enthalten ist; sonst 'false'
+// -----------------------------------------------------------
+bool IsEmpty (TWeatherStations const & Stations);
+
+// -----------------------------------------------------------
+// Liefert als Funktionswert 'true',
+// wenn die Verwaltung vollständig belegt ist;
+// sonst false
+// -----------------------------------------------------------
+bool IsFull (TWeatherStations const & Stations);
+
+// -----------------------------------------------------------
+// Liefert die Anzahl der enthaltenen Stationen der
+// Verwaltung zurück.
+// -----------------------------------------------------------
+size_t GetNumberOfEntries (TWeatherStations const & Stations);
+
+// -----------------------------------------------------------
+// Gibt alle Stationen der Reihe nach formatiert am
+// Bildschirm aus.
+// -----------------------------------------------------------
+void PrintAllStations (TWeatherStations const & Stations);
+
+// -----------------------------------------------------------
+// Gibt nur die Station vom Standort 'Name' am Bildschirm
+// aus. Liefert 'true', wenn die Station enthalten ist,
+// 'false' sonst.
+// -----------------------------------------------------------
+bool PrintStation (TWeatherStations const & Stations, string const & Name);
+
+// -----------------------------------------------------------
+// Gibt jene Station(en) inkl. Daten am Bildschirm aus, wo es
+// am kältesten ist. Liefert 'false', wenn die Verwaltung leer
+// ist; 'true' sonst.
+// -----------------------------------------------------------
+bool PrintColdestStation (TWeatherStations const & Stations);
+
+// -----------------------------------------------------------
+// Gibt jene Station(en) inkl. Daten am Bildschirm aus, wo es
+// am wärmsten ist. Liefert 'false', wenn die Verwaltung leer
+// ist; 'true' sonst.
+// -----------------------------------------------------------
+bool PrintWarmestStation (TWeatherStations const & Stations);
+
+
+// -----------------------------------------------------------
+// Testet ob die Station vom Standort 'Name' exisitiert.
+// Liefert 'true', wenn die Station enthalten ist,
+// 'false' sonst.
+// -----------------------------------------------------------
+bool CheckStationExistence (TWeatherStations const & Stations, string const & Name);
+
+#endif // WEATHERSTATIONS_H_INCLUDED
diff --git a/src/tests/SEN1/Beispiel3/Makefile b/src/tests/SEN1/Beispiel3/Makefile
new file mode 100644 (file)
index 0000000..8e9ab65
--- /dev/null
@@ -0,0 +1,129 @@
+############################################################################
+# Workfile: Makefile
+# Author: Daniel Giritzer, S1510306010
+#        daniel@giritzer.eu
+# Date: 06.04.2016
+# Description: Universal Makefile for Unix based Operating Systems
+#              Important CFLAGS:
+#              -std=c++98      - follow c++ 98 coding standard
+#              -std=c++11      - follow c++ 11 coding standard
+#              -std=c++0x      - follow coming c++ 0x standard
+#
+# Remarks:     Compatible with CodeBlocks (C::B)
+#              PROJNAME variable should match your project name!
+# Revision: 5.4
+# Usage: make debug            - builds debug version
+#               make release   - builds release version
+#               make all       - builds debug and release version
+#               make clean     - cleans project
+#               make rebuild   - builds release version from scratch
+############################################################################
+
+####################
+#GENERAL | EDIT 1/3
+####################
+WORKDIR = $(shell pwd)
+SOURCES := $(shell ls *.cpp)
+PROJNAME = Motorsteuerung
+
+CC = gcc
+CXX = g++
+AR = ar
+LD = g++
+WINDRES = windres
+
+INC =
+CFLAGS = -Wall -fexceptions -std=c++11
+RESINC =
+LIBDIR =
+LIB =
+LDFLAGS =
+
+############################
+#DEBUG SETTINGS | EDIT: 2/3
+############################
+INC_DEBUG = $(INC)
+CFLAGS_DEBUG = $(CFLAGS) -g
+RESINC_DEBUG = $(RESINC)
+RCFLAGS_DEBUG = $(RCFLAGS)
+LIBDIR_DEBUG = $(LIBDIR)
+LIB_DEBUG = $(LIB)
+LDFLAGS_DEBUG = $(LDFLAGS)
+OBJDIR_DEBUG = obj/Debug
+DEP_DEBUG =
+OUT_DEBUG = bin/Debug/$(PROJNAME)
+
+
+##############################
+#RELEASE SETTINGS | EDIT: 3/3
+##############################
+INC_RELEASE = $(INC)
+CFLAGS_RELEASE = $(CFLAGS) -O2
+RESINC_RELEASE = $(RESINC)
+RCFLAGS_RELEASE = $(RCFLAGS)
+LIBDIR_RELEASE = $(LIBDIR)
+LIB_RELEASE = $(LIB)
+LDFLAGS_RELEASE = $(LDFLAGS) -s
+OBJDIR_RELEASE = obj/Release
+DEP_RELEASE =
+OUT_RELEASE = bin/Release/$(PROJNAME)
+
+############################
+#OBJECT LISTS | DO NOT EDIT!
+############################
+OBJ_DEBUG = $(addprefix $(OBJDIR_DEBUG)/,$(SOURCES:%.cpp=%.o))
+OBJ_RELEASE = $(addprefix $(OBJDIR_RELEASE)/,$(SOURCES:%.cpp=%.o))
+
+
+##########################
+#FUNCTIONS | DO NOT EDIT!
+##########################
+
+######## General
+all All: debug release
+clean Clean: cleanDebug cleanRelease
+rebuild Rebuild: clean debug release
+
+######## DEBUG
+before_debug:
+       test -d bin/Debug || mkdir -p bin/Debug
+       test -d $(OBJDIR_DEBUG) || mkdir -p $(OBJDIR_DEBUG)
+
+after_debug:
+
+debug Debug: before_debug out_debug after_debug
+
+out_debug: before_debug $(OBJ_DEBUG) $(DEP_DEBUG)
+       $(LD) $(LDFLAGS_DEBUG) $(LIBDIR_DEBUG) $(OBJ_DEBUG) $(LIB_DEBUG) -o $(OUT_DEBUG)
+
+$(OBJDIR_DEBUG)/%.o: %.cpp
+       $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c $< -D_DEBUG -o $@
+
+clean_debug cleanDebug:
+       rm -f $(OBJ_DEBUG) $(OUT_DEBUG)
+       rm -rf bin/Debug
+       rm -rf $(OBJDIR_DEBUG)
+
+
+######## RELEASE
+before_release:
+       test -d bin/Release || mkdir -p bin/Release
+       test -d $(OBJDIR_RELEASE) || mkdir -p $(OBJDIR_RELEASE)
+
+after_release:
+
+release Release: before_release out_release after_release
+
+out_release: before_release $(OBJ_RELEASE) $(DEP_RELEASE)
+       $(LD) $(LDFLAGS_RELEASE) $(LIBDIR_RELEASE) $(OBJ_RELEASE) $(LIB_RELEASE) -o $(OUT_RELEASE)
+
+$(OBJDIR_RELEASE)/%.o: %.cpp
+       $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c $< -o $@
+
+clean_release cleanRelease:
+       rm -f $(OBJ_RELEASE) $(OUT_RELEASE)
+       rm -rf bin/Release
+       rm -rf $(OBJDIR_RELEASE)
+
+.PHONY: before_debug after_debug clean_debug cleanDebug before_release after_release clean_release cleanRelease
+
diff --git a/src/tests/SEN1/Beispiel3/main.cpp b/src/tests/SEN1/Beispiel3/main.cpp
new file mode 100644 (file)
index 0000000..b10434e
--- /dev/null
@@ -0,0 +1,80 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: main.cpp
+// Author: Daniel Giritzer
+// Date: 16.12.2015
+// Description: Bonusbeispiel
+// Remarks:
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+
+#include <iostream>
+
+using namespace std;
+
+struct InjectionSpecs
+{
+    float inj_quant;    // Injection quantity
+    float inj_time;     // Injection time
+};
+
+// Maximum number of pairs
+// 31*501*91*101 = 142745421
+// CodeBlocks has to be started in an shell an big enough call stack!
+// => ulimit -s unlimited && codeblocks
+size_t const pedal_pos = 31;
+size_t const engine_speed = 501;
+size_t const coolant_temp = 91;
+size_t const engine_load = 101;
+
+// 4 dimensional array for storing the structure
+typedef InjectionSpecs InjectionArray [pedal_pos][engine_speed][coolant_temp][engine_load];
+
+//////////////////////////////////////////////
+// Adds Injection Time and Injection Quantity
+// for the given parameters
+//////////////////////////////////////////////
+void addData(InjectionArray Data, size_t pedal_pos, size_t engine_speed, int coolant_temp, size_t engine_load, const float inj_time, const float inj_quant);
+
+///////////////////////////////////////////////
+// Reads Injection Time and Injection Quantity
+// for the given parameters
+///////////////////////////////////////////////
+void readData(InjectionArray Data, size_t pedal_pos, size_t engine_speed, int coolant_temp, size_t engine_load, float & inj_time, float & inj_quant);
+
+int main()
+{
+    InjectionArray Data = {};
+
+    float inj_quant = 0;
+    float inj_time = 0;
+
+    addData(Data, 46, 2200, -20, 15, 40, 8);
+    readData(Data, 46, 2200, -20, 15, inj_time, inj_quant);
+
+    cout << "Injection Time: " << inj_time << " Injection Quantity: " << inj_quant;
+
+    return 0;
+}
+
+
+void addData(InjectionArray Data, size_t pedal_pos, size_t engine_speed, int coolant_temp, size_t engine_load, const float inj_time, const float inj_quant)
+{
+    pedal_pos = pedal_pos / 2;
+    engine_speed = engine_speed / 10;
+    coolant_temp = (coolant_temp + 30) / 2;
+
+    Data[pedal_pos][engine_speed][coolant_temp][engine_load].inj_quant = inj_quant;
+    Data[pedal_pos][engine_speed][coolant_temp][engine_load].inj_time = inj_time;
+
+}
+
+void readData(InjectionArray Data, size_t pedal_pos, size_t engine_speed, int coolant_temp, size_t engine_load, float & inj_time, float & inj_quant)
+{
+    pedal_pos = pedal_pos / 2;
+    engine_speed = engine_speed / 10;
+    coolant_temp = (coolant_temp + 30) / 2;
+
+    inj_quant = Data[pedal_pos][engine_speed][coolant_temp][engine_load].inj_quant;
+    inj_time = Data[pedal_pos][engine_speed][coolant_temp][engine_load].inj_time;
+
+}
diff --git a/src/tests/SEN2/Angabe.pdf b/src/tests/SEN2/Angabe.pdf
new file mode 100644 (file)
index 0000000..9698cb7
Binary files /dev/null and b/src/tests/SEN2/Angabe.pdf differ
diff --git a/src/tests/SEN2/Beispiel1/GenCoordinates.cpp b/src/tests/SEN2/Beispiel1/GenCoordinates.cpp
new file mode 100644 (file)
index 0000000..277287b
--- /dev/null
@@ -0,0 +1,61 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: GenCoordinates.cpp
+// Author: Daniel Giritzer
+// Date: 06.04.2016
+// Description: Genertiert eine Datei welche num_points 3D Koordinaten
+//              beinhaltet. Der Wert der Koordinaten wird zufällig
+//              generiert und liegt zwischen coord_range_min und
+//              coord_range_max.
+//
+// Remarks: -
+// Revision: 1.1
+///////////////////////////////////////////////////////////////////////////
+
+#include "GenCoordinates.h"
+#include <fstream>
+
+//---------------------------------
+//Generiert Datei und befüllt sie mit
+//den Koordinaten.
+//---------------------------------
+bool Generate(std::string const fname)
+{
+    //Generiert Datei mit übergebenen Namen
+    //Existiert die Datei wird sie überschrieben
+    std::ofstream file(fname.c_str(), std::ios::out | std::ios::trunc);
+    int const num_coordinates = 3; //Anzahl der Koordinaten pro Punkt
+
+    //Stream Prüfen
+    if(file)
+    {
+        file << "COUNT=" << num_points;
+
+        for(int i = 0; i<num_points; i++)
+        {
+            file << "(";
+            for(int ii = 0; ii<num_coordinates; ii++)
+            {
+                file << RandomGen::GetRandVal(coord_range_min, coord_range_max);
+
+                //Beistrichsetzung
+                if(ii < num_coordinates - 1)
+                {
+                    file << ", ";
+                }
+            }
+            file << ")";
+        }
+    }
+    //stream schließen
+    file.close();
+    return file;
+}
+
+//---------------------------------
+//Zufälligen Seed für die RandomGen
+//Funktion erzeugen.
+//---------------------------------
+void Init()
+{
+    RandomGen::Init();
+}
diff --git a/src/tests/SEN2/Beispiel1/GenCoordinates.h b/src/tests/SEN2/Beispiel1/GenCoordinates.h
new file mode 100644 (file)
index 0000000..7eafc27
--- /dev/null
@@ -0,0 +1,38 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: GenCoordinates.h
+// Author: Daniel Giritzer
+// Date: 06.04.2016
+// Description: Genertiert eine Datei welche num_points 3D Koordinaten
+//              beinhaltet. Der Wert der Koordinaten wird zufällig
+//              generiert und liegt zwischen coord_range_min und
+//              coord_range_max.
+//
+// Remarks: -
+// Revision: 1.1
+///////////////////////////////////////////////////////////////////////////
+
+#ifndef GENCOORDINATES_H_INCLUDED
+#define GENCOORDINATES_H_INCLUDED
+
+#include "RandomGen.h"
+#include <string>
+
+//Anzahl der Zu generierenden Punkte.
+const int num_points = 10;
+
+//Koordinaten Wertebereich
+const int coord_range_min = 0;
+const int coord_range_max = 10;
+
+//---------------------------------
+//Generiert Datei und befüllt sie mit
+//den Koordinaten.
+//---------------------------------
+bool Generate(std::string fname);
+
+//---------------------------------
+//Zufälligen Seed für die RandomGen
+//Funktion erzeugen.
+//---------------------------------
+void Init();
+#endif // GENCOORDINATES_H_INCLUDED
diff --git a/src/tests/SEN2/Beispiel1/Makefile b/src/tests/SEN2/Beispiel1/Makefile
new file mode 100644 (file)
index 0000000..beb1fca
--- /dev/null
@@ -0,0 +1,128 @@
+############################################################################
+# Workfile: Makefile.mak
+# Author: Daniel Giritzer
+# Date: 06.04.2016
+# Description: Makefile for Unix based Operating Systems
+#                              Important CFLAGS:
+#                              -std=c++98      - follow c++ 98 coding standard
+#                              -std=c++11      - follow c++ 11 coding standard
+#                              -std=c++0x      - follow coming c++ 0x standard
+#
+# Remarks:     Compatible with CodeBlocks (C::B)
+#                      PROJNAME variable should match your project name!
+# Revision: 5.4
+# Usage: make debug            - builds debug version
+#               make release   - builds release version
+#               make all               - builds debug and release version
+#               make clean             - cleans project
+#               make rebuild   - builds release version from scratch
+############################################################################
+
+####################
+#GENERAL | EDIT 1/3
+####################
+WORKDIR = $(shell pwd)
+SOURCES := $(shell ls *.cpp)
+PROJNAME = Beispiel1
+
+CC = gcc
+CXX = g++
+AR = ar
+LD = g++
+WINDRES = windres
+
+INC =
+CFLAGS = -Wall -fexceptions -std=c++98
+RESINC =
+LIBDIR =
+LIB =
+LDFLAGS =
+
+############################
+#DEBUG SETTINGS | EDIT: 2/3
+############################
+INC_DEBUG = $(INC)
+CFLAGS_DEBUG = $(CFLAGS) -g
+RESINC_DEBUG = $(RESINC)
+RCFLAGS_DEBUG = $(RCFLAGS)
+LIBDIR_DEBUG = $(LIBDIR)
+LIB_DEBUG = $(LIB)
+LDFLAGS_DEBUG = $(LDFLAGS)
+OBJDIR_DEBUG = obj/Debug
+DEP_DEBUG =
+OUT_DEBUG = bin/Debug/$(PROJNAME)
+
+
+##############################
+#RELEASE SETTINGS | EDIT: 3/3
+##############################
+INC_RELEASE = $(INC)
+CFLAGS_RELEASE = $(CFLAGS) -O2
+RESINC_RELEASE = $(RESINC)
+RCFLAGS_RELEASE = $(RCFLAGS)
+LIBDIR_RELEASE = $(LIBDIR)
+LIB_RELEASE = $(LIB)
+LDFLAGS_RELEASE = $(LDFLAGS) -s
+OBJDIR_RELEASE = obj/Release
+DEP_RELEASE =
+OUT_RELEASE = bin/Release/$(PROJNAME)
+
+############################
+#OBJECT LISTS | DO NOT EDIT!
+############################
+OBJ_DEBUG = $(addprefix $(OBJDIR_DEBUG)/,$(SOURCES:%.cpp=%.o))
+OBJ_RELEASE = $(addprefix $(OBJDIR_RELEASE)/,$(SOURCES:%.cpp=%.o))
+
+
+##########################
+#FUNCTIONS | DO NOT EDIT!
+##########################
+
+######## General
+all All: debug release
+clean Clean: cleanDebug cleanRelease
+rebuild Rebuild: clean release
+
+######## DEBUG
+before_debug:
+       test -d bin/Debug || mkdir -p bin/Debug
+       test -d $(OBJDIR_DEBUG) || mkdir -p $(OBJDIR_DEBUG)
+
+after_debug:
+
+debug Debug: before_debug out_debug after_debug
+
+out_debug: before_debug $(OBJ_DEBUG) $(DEP_DEBUG)
+       $(LD) $(LDFLAGS_DEBUG) $(LIBDIR_DEBUG) $(OBJ_DEBUG) $(LIB_DEBUG) -o $(OUT_DEBUG)
+
+$(OBJDIR_DEBUG)/%.o: %.cpp
+       $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c $< -D_DEBUG -o $@
+
+cleanDebug:
+       rm -f $(OBJ_DEBUG) $(OUT_DEBUG)
+       rm -rf bin/Debug
+       rm -rf $(OBJDIR_DEBUG)
+
+
+######## RELEASE
+before_release:
+       test -d bin/Release || mkdir -p bin/Release
+       test -d $(OBJDIR_RELEASE) || mkdir -p $(OBJDIR_RELEASE)
+
+after_release:
+
+release Release: before_release out_release after_release
+
+out_release: before_release $(OBJ_RELEASE) $(DEP_RELEASE)
+       $(LD) $(LDFLAGS_RELEASE) $(LIBDIR_RELEASE) $(OBJ_RELEASE) $(LIB_RELEASE) -o $(OUT_RELEASE)
+
+$(OBJDIR_RELEASE)/%.o: %.cpp
+       $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c $< -o $@
+
+cleanRelease:
+       rm -f $(OBJ_RELEASE) $(OUT_RELEASE)
+       rm -rf bin/Release
+       rm -rf $(OBJDIR_RELEASE)
+
+.PHONY: before_debug after_debug clean_debug before_release after_release clean_release
+
diff --git a/src/tests/SEN2/Beispiel1/RandomGen.cpp b/src/tests/SEN2/Beispiel1/RandomGen.cpp
new file mode 100644 (file)
index 0000000..f3065fb
--- /dev/null
@@ -0,0 +1,18 @@
+#include <ctime>
+#include <cstdlib>\r
+#include <iostream>\r
+#include "RandomGen.h"\r
+\r
+\r
+int RandomGen::GetRandVal(int const Lo, int const Hi) {\r
+       int Range = Hi - Lo + 1;\r
+   //rand returns a pseudo-random integral number in the range between 0 and RAND_MAX\r
+       int Num   = (int)(rand() / (RAND_MAX + 1.0) * Range);\r
+       return Lo + Num;\r
+}\r
+\r
+void RandomGen::Init()\r
+{\r
+   //initialize random number generator with system time\r
+   srand((unsigned)time(0));\r
+}\r
diff --git a/src/tests/SEN2/Beispiel1/RandomGen.h b/src/tests/SEN2/Beispiel1/RandomGen.h
new file mode 100644 (file)
index 0000000..8f87c91
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef RANDOMGEN_Included\r
+#define RANDOMGEN_Included\r
+\r
+namespace RandomGen {\r
+\r
+       // returns a random value between Lo and Hi\r
+       int GetRandVal(int const Lo, int const Hi);\r
+\r
+   // initialize random seed\r
+   void Init();\r
+}\r
+\r
+#endif
diff --git a/src/tests/SEN2/Beispiel1/main.cpp b/src/tests/SEN2/Beispiel1/main.cpp
new file mode 100644 (file)
index 0000000..de45cdb
--- /dev/null
@@ -0,0 +1,23 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: main.cpp
+// Author: Daniel Giritzer
+// Date: 02.01.2016
+// Description: Testtreiber für das GenCoordinates Modul
+// Remarks:-
+// Revision:1
+///////////////////////////////////////////////////////////////////////////
+#include <iostream>
+#include "GenCoordinates.h"
+
+using namespace std;
+
+int main()
+{
+    Init(); //Seed erzeugen
+    Generate("test1.txt");
+    Generate("test2.txt");
+    Generate("test3.txt");
+    cout << "Dateien wurden Generiert!";
+
+    return 0;
+}
diff --git a/src/tests/SEN2/Beispiel2/Makefile b/src/tests/SEN2/Beispiel2/Makefile
new file mode 100644 (file)
index 0000000..a105e3b
--- /dev/null
@@ -0,0 +1,128 @@
+############################################################################
+# Workfile: Makefile.mak
+# Author: Daniel Giritzer
+# Date: 06.04.2016
+# Description: Makefile for Unix based Operating Systems
+#                              Important CFLAGS:
+#                              -std=c++98      - follow c++ 98 coding standard
+#                              -std=c++11      - follow c++ 11 coding standard
+#                              -std=c++0x      - follow coming c++ 0x standard
+#
+# Remarks:     Compatible with CodeBlocks (C::B)
+#                      PROJNAME variable should match your project name!
+# Revision: 5.4
+# Usage: make debug            - builds debug version
+#               make release   - builds release version
+#               make all               - builds debug and release version
+#               make clean             - cleans project
+#               make rebuild   - builds release version from scratch
+############################################################################
+
+####################
+#GENERAL | EDIT 1/3
+####################
+WORKDIR = $(shell pwd)
+SOURCES := $(shell ls *.cpp)
+PROJNAME = Beispiel2
+
+CC = gcc
+CXX = g++
+AR = ar
+LD = g++
+WINDRES = windres
+
+INC =
+CFLAGS = -Wall -fexceptions -std=c++98
+RESINC =
+LIBDIR =
+LIB =
+LDFLAGS =
+
+############################
+#DEBUG SETTINGS | EDIT: 2/3
+############################
+INC_DEBUG = $(INC)
+CFLAGS_DEBUG = $(CFLAGS) -g
+RESINC_DEBUG = $(RESINC)
+RCFLAGS_DEBUG = $(RCFLAGS)
+LIBDIR_DEBUG = $(LIBDIR)
+LIB_DEBUG = $(LIB)
+LDFLAGS_DEBUG = $(LDFLAGS)
+OBJDIR_DEBUG = obj/Debug
+DEP_DEBUG =
+OUT_DEBUG = bin/Debug/$(PROJNAME)
+
+
+##############################
+#RELEASE SETTINGS | EDIT: 3/3
+##############################
+INC_RELEASE = $(INC)
+CFLAGS_RELEASE = $(CFLAGS) -O2
+RESINC_RELEASE = $(RESINC)
+RCFLAGS_RELEASE = $(RCFLAGS)
+LIBDIR_RELEASE = $(LIBDIR)
+LIB_RELEASE = $(LIB)
+LDFLAGS_RELEASE = $(LDFLAGS) -s
+OBJDIR_RELEASE = obj/Release
+DEP_RELEASE =
+OUT_RELEASE = bin/Release/$(PROJNAME)
+
+############################
+#OBJECT LISTS | DO NOT EDIT!
+############################
+OBJ_DEBUG = $(addprefix $(OBJDIR_DEBUG)/,$(SOURCES:%.cpp=%.o))
+OBJ_RELEASE = $(addprefix $(OBJDIR_RELEASE)/,$(SOURCES:%.cpp=%.o))
+
+
+##########################
+#FUNCTIONS | DO NOT EDIT!
+##########################
+
+######## General
+all All: debug release
+clean Clean: cleanDebug cleanRelease
+rebuild Rebuild: clean release
+
+######## DEBUG
+before_debug:
+       test -d bin/Debug || mkdir -p bin/Debug
+       test -d $(OBJDIR_DEBUG) || mkdir -p $(OBJDIR_DEBUG)
+
+after_debug:
+
+debug Debug: before_debug out_debug after_debug
+
+out_debug: before_debug $(OBJ_DEBUG) $(DEP_DEBUG)
+       $(LD) $(LDFLAGS_DEBUG) $(LIBDIR_DEBUG) $(OBJ_DEBUG) $(LIB_DEBUG) -o $(OUT_DEBUG)
+
+$(OBJDIR_DEBUG)/%.o: %.cpp
+       $(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c $< -D_DEBUG -o $@
+
+clean_debug cleanDebug:
+       rm -f $(OBJ_DEBUG) $(OUT_DEBUG)
+       rm -rf bin/Debug
+       rm -rf $(OBJDIR_DEBUG)
+
+
+######## RELEASE
+before_release:
+       test -d bin/Release || mkdir -p bin/Release
+       test -d $(OBJDIR_RELEASE) || mkdir -p $(OBJDIR_RELEASE)
+
+after_release:
+
+release Release: before_release out_release after_release
+
+out_release: before_release $(OBJ_RELEASE) $(DEP_RELEASE)
+       $(LD) $(LDFLAGS_RELEASE) $(LIBDIR_RELEASE) $(OBJ_RELEASE) $(LIB_RELEASE) -o $(OUT_RELEASE)
+
+$(OBJDIR_RELEASE)/%.o: %.cpp
+       $(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c $< -o $@
+
+clean_release cleanRelease:
+       rm -f $(OBJ_RELEASE) $(OUT_RELEASE)
+       rm -rf bin/Release
+       rm -rf $(OBJDIR_RELEASE)
+
+.PHONY: before_debug after_debug clean_debug cleanDebug before_release after_release clean_release cleanRelease
+
diff --git a/src/tests/SEN2/Beispiel2/Output_Testdriver.tex b/src/tests/SEN2/Beispiel2/Output_Testdriver.tex
new file mode 100644 (file)
index 0000000..02844f0
--- /dev/null
@@ -0,0 +1,36 @@
+Test1: 
+(2,4,3)(3,4,4)(2,1,1)(2,0,0)(2,1,3)
+(1,0,2)(1,0,5)(3,0,1)(2,0,0)
+(4,5,1)(2,1,1)(3,0,1)(0,5,4)
+(3,4,4)(2,4,3)(3,0,1)(0,5,4)
+(1,0,5)(1,0,2)(3,0,1)(2,0,0)
+(2,1,1)(2,4,3)(4,5,1)(3,0,1)(2,0,0)(2,1,3)
+(3,0,1)(1,0,2)(4,5,1)(3,4,4)(1,0,5)(2,1,1)(2,0,0)
+(2,0,0)(2,4,3)(1,0,2)(1,0,5)(2,1,1)(3,0,1)(2,1,3)
+(2,1,3)(2,4,3)(2,1,1)(2,0,0)
+(0,5,4)(4,5,1)(3,4,4)
+: true
+
+Test2: Fehlende ')'
+: false
+
+Test3: Fehlende '('
+: false
+
+Test4: Falscher Header
+: false
+
+Test5: Zu wenig Elemente
+: false
+
+Test6: Zu viele Elemente
+: false
+
+Test7: Leere Datei
+: false
+
+Test8: Falsche Beistrichsetzung
+: false
+
+Test9: Datei Existiert nicht
+: false
\ No newline at end of file
diff --git a/src/tests/SEN2/Beispiel2/SameDimension.cpp b/src/tests/SEN2/Beispiel2/SameDimension.cpp
new file mode 100644 (file)
index 0000000..7c2ce31
--- /dev/null
@@ -0,0 +1,237 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: SameDimension.cpp
+// Author: Daniel Giritzer
+// Date: 06.04.2016
+// Description: Lest Koordinaten aus Einer Datei ein. Überprüft die
+//              Datei auf passenden Syntax und Gibt die Daten sortiert
+//              in der Kosole aus.
+// Remarks:-
+// Revision: 1.1
+///////////////////////////////////////////////////////////////////////////
+#include "SameDimension.h"
+
+//Forward declarations interner funktionen
+void PrintError();
+bool isHeader(scanner& scan);
+bool isPointBeginning(scanner const& scan);
+bool isPointEnd(scanner const& scan);
+bool isCoordinateLimiter(scanner const& scan);
+int ScanCoordinate(scanner& scan, bool &error);
+Point3D ScanPoint(scanner& scan, bool &error);
+bool ScanPoints(scanner& scan, Point3D points[], int const num_points);
+void PrintPoint(Point3D const point);
+void PrintPointArray(Point3D const points[], const int num_points);
+
+//---------------------------------
+//Gibt den Error Text in der Konsole
+//aus.
+//---------------------------------
+void PrintError()
+{
+    cerr << "unknown file format!";
+}
+
+//---------------------------------
+//Überprüft den Header und lässt den
+//scanner auf den Integerwert zeigen.
+//Der Integerwert wird hier noch nicht
+//ausgelesen.
+//---------------------------------
+bool isHeader(scanner& scan)
+{
+    if(scan.get_string()=="COUNT")
+    {
+        scan.next_symbol();
+        if(scan.get_string()=="=")
+        {
+            scan.next_symbol();
+            if(scan.symbol_is_integer())
+            {
+                return true;
+            }
+        }
+    }
+    return false;
+}
+
+//---------------------------------
+//Überprüft ob der Scanner auf den
+//Anfang eines Punktes Zeigt. -> "("
+//---------------------------------
+bool isPointBeginning(scanner const& scan)
+{
+    return scan.symbol_is_lpar();
+}
+
+//---------------------------------
+//Überprüft ob der Scanner auf das
+//Ende eines Punktes Zeigt. -> ")"
+//---------------------------------
+bool isPointEnd(scanner const& scan)
+{
+    return scan.symbol_is_rpar();
+}
+
+//---------------------------------
+//Überprüft ob der Scanner auf das
+//Trennsymbol 2er Koordinaten zeigt.
+//-> ","
+//---------------------------------
+bool isCoordinateLimiter(scanner const& scan)
+{
+    return scan.get_string() == ",";
+}
+
+//---------------------------------
+//Scannt eine Koordinate und gibt
+//sie zurrück. Falls ein Syntaxfehler
+//vorliegt wird eine Fehlermeldung ausgegeben.
+//---------------------------------
+int ScanCoordinate(scanner& scan, bool &error)
+{
+    int val = 0;
+    //Vor einer Koordinate Steht immer
+    //eines der folgenden Zeichen:
+    //'(', ',', ')'
+    if(isPointBeginning(scan) || isCoordinateLimiter(scan) || isPointEnd(scan))
+    {
+        scan.next_symbol();
+        //Koordinate muss Integerwert Sein
+        if(scan.symbol_is_integer())
+        {
+            val = scan.get_integer();
+            scan.next_symbol();
+        }
+        else
+        {
+            error = true;
+        }
+    }
+    else
+    {
+        error = true;
+    }
+    return val;
+}
+
+//---------------------------------
+//Scannt einen Punkt ein. Und gibt
+//diesen Zurrück.
+//---------------------------------
+Point3D ScanPoint(scanner& scan, bool &error)
+{
+    Point3D point;
+    point.x = ScanCoordinate(scan, error);
+    point.y = ScanCoordinate(scan, error);
+    point.z = ScanCoordinate(scan, error);
+    return point;
+}
+
+//---------------------------------
+//Scannt alle Punkte und gibt diese
+//per Referenz zurrück.
+//---------------------------------
+bool ScanPoints(scanner& scan, Point3D points[], int const num_points)
+{
+    bool return_val = true;
+    for(int i = 0; i < num_points; i++)
+    {
+        points[i] = ScanPoint(scan, return_val);
+
+        //Nach Scannen der Letzten Koordinate
+        //muss sich der Scanner auf ')' befinden
+        if(isPointEnd(scan))
+        {
+            scan.next_symbol();
+        }
+        else
+        {
+            return false;
+        }
+
+    }
+    //Sind Mehr Punkte als num_points in der Datei
+    //->Fehler!
+    if(!scan.eof())
+    {
+        return false;
+    }
+    return return_val;
+}
+
+//---------------------------------
+//Gibt einen Punkt formatiert
+//in der Konsole aus.
+//---------------------------------
+void PrintPoint(Point3D const point)
+{
+    cout << "(" << point.x << "," << point.y << "," << point.z << ")";
+}
+
+//---------------------------------
+//Gibt alle Punkte Sortiert in der
+//Konsole aus.
+//---------------------------------
+void PrintPointArray(Point3D const points[], const int num_points)
+{
+    for(int i = 0; i < num_points; i++)
+    {
+        PrintPoint(points[i]);
+        for(int ii = 0; ii < num_points; ii++)
+        {
+            if((points[i].x == points[ii].x ||
+                    points[i].y == points[ii].y ||
+                    points[i].z == points[ii].z) && i != ii)
+            {
+                PrintPoint(points[ii]);
+            }
+        }
+        cout << endl;
+    }
+}
+
+//---------------------------------
+//Scannt alle Punkte einer Datei mit dem
+//Namen fname ein, und gibt diese Falls
+//der Syntax stimmt in der Konsole aus.
+//---------------------------------
+bool PrintSameDimension(std::string const fname)
+{
+    std::ifstream file(fname.c_str(), std::ios::in);
+
+    if(file)
+    {
+        scanner scan(file);
+
+        if(isHeader(scan))
+        {
+            //Anzahl der Punkte auslesen
+            int const num_points = scan.get_integer();
+            scan.next_symbol();
+
+            //Punkttearray mit richtiger größe
+            //Initialisieren.
+            Point3D points[num_points];
+
+            //Punkte Scannen
+            if(ScanPoints(scan, points, num_points))
+            {
+                //Punkte ausgeben
+                PrintPointArray(points, num_points);
+            }
+            else
+            {
+                PrintError();
+                return false;
+            }
+        }
+        else
+        {
+            PrintError();
+            return false;
+        }
+    }
+    //Filestream Schließen
+    file.close();
+    return file;
+}
diff --git a/src/tests/SEN2/Beispiel2/SameDimension.h b/src/tests/SEN2/Beispiel2/SameDimension.h
new file mode 100644 (file)
index 0000000..138c39c
--- /dev/null
@@ -0,0 +1,32 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: SameDimension.h
+// Author: Daniel Giritzer
+// Date: 06.04.2016
+// Description: Lest Koordinaten aus Einer Datei ein. Überprüft die
+//              Datei auf passenden Syntax und Gibt die Daten sortiert
+//              in der Kosole aus.
+// Remarks:-
+// Revision: 1.1
+///////////////////////////////////////////////////////////////////////////
+#ifndef SAMEDIMENSION_H_INCLUDED
+#define SAMEDIMENSION_H_INCLUDED
+
+#include <fstream>
+#include <iostream>
+#include "scanner.h"
+using namespace std;
+
+//Datenstructur der Punkte
+struct Point3D
+{
+    int x, y, z;
+};
+
+//---------------------------------
+//Scannt alle Punkte einer Datei mit dem
+//Namen fname ein, und gibt diese Falls
+//der Syntax stimmt in der Konsole aus.
+//---------------------------------
+bool PrintSameDimension(std::string const fname);
+
+#endif // SAMEDIMENSION_H_INCLUDED
diff --git a/src/tests/SEN2/Beispiel2/base.h b/src/tests/SEN2/Beispiel2/base.h
new file mode 100644 (file)
index 0000000..9cd38a8
--- /dev/null
@@ -0,0 +1,18 @@
+//       $Id: base.h 3024 2006-12-06 20:59:07Z kulczyck $\r
+//      $URL: file:///C:/Documents%20and%20Settings/kulczyck/Desktop/Desktop/SVN-Repository/Hochschule/Lehre/FH/BIN/SWE3/Programme/Scanner-II/trunk/src/base.h $\r
+// $Revision: 3024 $\r
+//     $Date: 2006-12-06 21:59:07 +0100 (Mi, 06 Dez 2006) $\r
+//   Creator: peter.kulczycki<AT>fh-hagenberg.at\r
+//   $Author: kulczyck $\r
+\r
+#if !defined BASE_SCANNER_II_H\r
+#define      BASE_SCANNER_II_H\r
+\r
+#include <iosfwd>\r
+#include <string>\r
+\r
+class scanner;\r
+class scanner_impl;\r
+class symbol;\r
+\r
+#endif   // BASE_SCANNER_II_H\r
diff --git a/src/tests/SEN2/Beispiel2/main.cpp b/src/tests/SEN2/Beispiel2/main.cpp
new file mode 100644 (file)
index 0000000..4613869
--- /dev/null
@@ -0,0 +1,44 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: main.cpp
+// Author: Daniel Giritzer
+// Date: 05.04.2016
+// Description: Testtreiber für das SameDimension Modul.
+// Remarks: -
+// Revision: 1
+///////////////////////////////////////////////////////////////////////////
+#include <iostream>
+#include "SameDimension.h"
+
+using namespace std;
+
+int main()
+{
+
+    cout << boolalpha << "Test1: " << endl;
+    cout << ": " << PrintSameDimension("test1.txt");
+
+    cout << endl << endl <<"Test2: Fehlende ')'" << endl;
+    cout << ": "<< PrintSameDimension("test2.txt");
+
+    cout << endl << endl << "Test3: Fehlende '('" << endl;
+    cout << ": "<< PrintSameDimension("test3.txt");
+
+    cout << endl << endl << "Test4: Falscher Header" << endl;
+    cout << ": " << PrintSameDimension("test4.txt");
+
+    cout << endl << endl << "Test5: Zu wenig Elemente" << endl;
+    cout << ": " << PrintSameDimension("test5.txt");
+
+    cout << endl << endl << "Test6: Zu viele Elemente" << endl;
+    cout << ": " << PrintSameDimension("test6.txt");
+
+    cout << endl << endl << "Test7: Leere Datei" << endl;
+    cout << ": " << PrintSameDimension("test7.txt");
+
+    cout << endl << endl << "Test8: Falsche Beistrichsetzung" << endl;
+    cout << ": " << PrintSameDimension("test8.txt");
+
+    cout << endl << endl << "Test9: Datei Existiert nicht" << endl;
+    cout << ": " << PrintSameDimension("test9.txt");
+    return 0;
+}
diff --git a/src/tests/SEN2/Beispiel2/scanner.cpp b/src/tests/SEN2/Beispiel2/scanner.cpp
new file mode 100644 (file)
index 0000000..d316c14
--- /dev/null
@@ -0,0 +1,193 @@
+//       $Id: scanner.cpp 2920 2006-11-30 18:10:30Z kulczyck $\r
+//      $URL: file:///C:/Documents%20and%20Settings/kulczyck/Desktop/Desktop/SVN-Repository/Hochschule/Lehre/FH/BIN/SWE3/Programme/Scanner-II/src/scanner.cpp $\r
+// $Revision: 2920 $\r
+//     $Date: 2006-11-30 19:10:30 +0100 (Do, 30 Nov 2006) $\r
+//   Creator: peter.kulczycki<AT>fh-hagenberg.at\r
+//   $Author: kulczyck $\r
+//\r
+//   Remarks: rearrange the methods according to the header file\r
+\r
+#include "scanner.h"\r
+#include "scanner_impl.h"\r
+\r
+#include <cassert>\r
+#include <iostream>\r
+\r
+using std::istream;\r
+using std::string;\r
+\r
+scanner::scanner () {\r
+   m_pimpl = new scanner_impl (); assert (m_pimpl != 0);\r
+}\r
+\r
+scanner::scanner (istream & in) {\r
+   m_pimpl = new scanner_impl (&in); assert (m_pimpl != 0);\r
+}\r
+\r
+scanner::~scanner () {\r
+   delete m_pimpl;\r
+}\r
+\r
+size_t scanner::add_keyword (string const & keyword, int const code) {\r
+   return m_pimpl->add_keyword (keyword, code);\r
+}\r
+\r
+bool scanner::eof () const {\r
+   return m_pimpl->eof ();\r
+}\r
+\r
+int const & scanner::get_integer () const {\r
+   return m_pimpl->get_integer ();\r
+}\r
+\r
+istream * scanner::get_istream () const {\r
+   return m_pimpl->get_istream ();\r
+}\r
+\r
+scanner::position_type scanner::get_position () const {\r
+   return m_pimpl->get_position ();\r
+}\r
+\r
+double const & scanner::get_real () const {\r
+   return m_pimpl->get_real ();\r
+}\r
+\r
+string const & scanner::get_string () const {\r
+   return m_pimpl->get_string ();\r
+}\r
+\r
+symbol const & scanner::get_symbol () const {\r
+   return m_pimpl->get_symbol ();\r
+}\r
+\r
+symbol const &  scanner::next_symbol () {\r
+   return m_pimpl->next_symbol ();\r
+}\r
+\r
+void scanner::remove_all_keywords () {\r
+   return m_pimpl->remove_all_keywords ();\r
+}\r
+\r
+size_t scanner::remove_keyword (string const & keyword) {\r
+   return m_pimpl->remove_keyword (keyword);\r
+}\r
+\r
+void scanner::set_istream () {\r
+   m_pimpl->set_istream ();\r
+}\r
+\r
+void scanner::set_istream (istream & in) {\r
+   m_pimpl->set_istream (&in);\r
+}\r
+\r
+string scanner::symbol_as_string () const {\r
+   return m_pimpl->symbol_as_string ();\r
+}\r
+\r
+bool scanner::symbol_is_assign () const {\r
+   return m_pimpl->symbol_is_assign ();\r
+}\r
+\r
+bool scanner::symbol_is_colon () const {\r
+   return m_pimpl->symbol_is_colon ();\r
+}\r
+\r
+bool scanner::symbol_is_comma () const {\r
+   return m_pimpl->symbol_is_comma ();\r
+}\r
+\r
+bool scanner::symbol_is_division () const {\r
+   return m_pimpl->symbol_is_division ();\r
+}\r
+\r
+bool scanner::symbol_is_eof () const {\r
+   return m_pimpl->symbol_is_eof ();\r
+}\r
+\r
+bool scanner::symbol_is_identifier () const {\r
+   return m_pimpl->symbol_is_identifier ();\r
+}\r
+\r
+bool scanner::symbol_is_integer () const {\r
+   return m_pimpl->symbol_is_integer ();\r
+}\r
+\r
+bool scanner::symbol_is_keyword (int const code) const {\r
+   return m_pimpl->symbol_is_keyword (code);\r
+}\r
+\r
+bool scanner::symbol_is_keyword (string const & keyword) const {\r
+   return m_pimpl->symbol_is_keyword (keyword);\r
+}\r
+\r
+bool scanner::symbol_is_lpar () const {\r
+   return m_pimpl->symbol_is_lpar ();\r
+}\r
+\r
+bool scanner::symbol_is_minus () const {\r
+   return m_pimpl->symbol_is_minus ();\r
+}\r
+\r
+bool scanner::symbol_is_multiply () const {\r
+   return m_pimpl->symbol_is_multiply ();\r
+}\r
+\r
+bool scanner::symbol_is_number () const {\r
+   return m_pimpl->symbol_is_number ();\r
+}\r
+\r
+bool scanner::symbol_is_period () const {\r
+   return m_pimpl->symbol_is_period ();\r
+}\r
+\r
+bool scanner::symbol_is_plus () const {\r
+   return m_pimpl->symbol_is_plus ();\r
+}\r
+\r
+bool scanner::symbol_is_power () const {\r
+   return m_pimpl->symbol_is_power ();\r
+}\r
+\r
+bool scanner::symbol_is_real () const {\r
+   return m_pimpl->symbol_is_real ();\r
+}\r
+\r
+bool scanner::symbol_is_rpar () const {\r
+   return m_pimpl->symbol_is_rpar ();\r
+}\r
+\r
+bool scanner::symbol_is_semicolon () const {\r
+   return m_pimpl->symbol_is_semicolon ();\r
+}\r
+\r
+bool scanner::symbol_is_string () const {\r
+   return m_pimpl->symbol_is_string ();\r
+}\r
+\r
+bool scanner::symbol_is_value () const {\r
+   return m_pimpl->symbol_is_value ();\r
+}\r
+\r
+scanner::operator double () const {\r
+   return m_pimpl->operator double ();\r
+}\r
+\r
+scanner::operator int () const {\r
+   return m_pimpl->operator int ();\r
+}\r
+\r
+scanner::operator position_type () const {\r
+   return m_pimpl->operator position_type ();\r
+}\r
+\r
+scanner::operator istream * () const {\r
+   return m_pimpl->operator istream * ();\r
+}\r
+\r
+scanner::operator string () const {\r
+   return m_pimpl->operator string ();\r
+}\r
+\r
+scanner::operator symbol () const {\r
+   return m_pimpl->operator symbol ();\r
+}\r
diff --git a/src/tests/SEN2/Beispiel2/scanner.h b/src/tests/SEN2/Beispiel2/scanner.h
new file mode 100644 (file)
index 0000000..8806b7f
--- /dev/null
@@ -0,0 +1,74 @@
+//       $Id: scanner.h 3053 2006-12-09 13:07:29Z kulczyck $\r
+//      $URL: file:///C:/Documents%20and%20Settings/kulczyck/Desktop/Desktop/SVN-Repository/Hochschule/Lehre/FH/BIN/SWE3/Programme/Scanner-II/trunk/src/scanner.h $\r
+// $Revision: 3053 $\r
+//     $Date: 2006-12-09 14:07:29 +0100 (Sa, 09 Dez 2006) $\r
+//   Creator: peter.kulczycki<AT>fh-hagenberg.at\r
+//   $Author: kulczyck $\r
+\r
+#if !defined SCANNER_H\r
+#define      SCANNER_H\r
+\r
+#include "symbol.h"\r
+\r
+class scanner {\r
+   public:\r
+      typedef std::pair <int, int> position_type;\r
+\r
+      scanner ();\r
+      scanner (std::istream & in);   // implicit conversions allowed\r
+     ~scanner ();\r
+\r
+      std::istream * get_istream () const;\r
+      void           set_istream ();\r
+      void           set_istream (std::istream & in);\r
+\r
+      size_t add_keyword         (std::string const & keyword, int const code);\r
+      void   remove_all_keywords ();\r
+      size_t remove_keyword      (std::string const & keyword);\r
+\r
+      bool                eof              () const;\r
+      int const &         get_integer      () const;\r
+      position_type       get_position     () const;\r
+      double const &      get_real         () const;\r
+      std::string const & get_string       () const;\r
+      symbol const &      get_symbol       () const;\r
+      symbol const &      next_symbol      ();\r
+      std::string         symbol_as_string () const;\r
+\r
+      bool symbol_is_assign     () const;\r
+      bool symbol_is_colon      () const;\r
+      bool symbol_is_comma      () const;\r
+      bool symbol_is_division   () const;\r
+      bool symbol_is_eof        () const;\r
+      bool symbol_is_identifier () const;\r
+      bool symbol_is_integer    () const;\r
+      bool symbol_is_keyword    (int const code) const;\r
+      bool symbol_is_keyword    (std::string const & keyword) const;\r
+      bool symbol_is_lpar       () const;\r
+      bool symbol_is_minus      () const;\r
+      bool symbol_is_multiply   () const;\r
+      bool symbol_is_number     () const;\r
+      bool symbol_is_period     () const;\r
+      bool symbol_is_plus       () const;\r
+      bool symbol_is_power      () const;\r
+      bool symbol_is_real       () const;\r
+      bool symbol_is_rpar       () const;\r
+      bool symbol_is_semicolon  () const;\r
+      bool symbol_is_string     () const;\r
+      bool symbol_is_value      () const;\r
+\r
+      operator double         () const;\r
+      operator int            () const;\r
+      operator position_type  () const;\r
+      operator std::istream * () const;\r
+      operator std::string    () const;\r
+      operator symbol         () const;\r
+\r
+   private:\r
+                scanner    (scanner const &);\r
+      scanner & operator = (scanner const &);\r
+\r
+      scanner_impl * m_pimpl;\r
+};\r
+\r
+#endif   // SCANNER_H\r
diff --git a/src/tests/SEN2/Beispiel2/scanner_impl.cpp b/src/tests/SEN2/Beispiel2/scanner_impl.cpp
new file mode 100644 (file)
index 0000000..db7cc6d
--- /dev/null
@@ -0,0 +1,406 @@
+//       $Id: scanner.cpp 2920 2006-11-30 18:10:30Z kulczyck $\r
+//      $URL: file:///C:/Documents%20and%20Settings/kulczyck/Desktop/Desktop/SVN-Repository/Hochschule/Lehre/FH/BIN/SWE3/Programme/Scanner-II/src/scanner.cpp $\r
+// $Revision: 2920 $\r
+//     $Date: 2006-11-30 19:10:30 +0100 (Do, 30 Nov 2006) $\r
+//   Creator: peter.kulczycki<AT>fh-hagenberg.at\r
+//   $Author: kulczyck $\r
+//\r
+//   Remarks: rearrange the methods according to the header file\r
+\r
+#include "scanner_impl.h"\r
+\r
+#include <cassert>\r
+#include <sstream>
+#include <cstring> //korr: giri\r
+\r
+using std::istream;\r
+using std::ostringstream;\r
+using std::string;\r
+\r
+bool scanner_impl::is_alpha (char const c) {\r
+   return (isalpha (c) != 0) || (c == '_');\r
+}\r
+\r
+bool scanner_impl::is_alphanum (char const c) {\r
+   return is_alpha (c) || (isdigit (c) != 0);\r
+}\r
+\r
+bool scanner_impl::is_whitespace (char const c) {\r
+   return isspace (c) != 0;\r
+}\r
+\r
+scanner_impl::scanner_impl (istream * const pin) {\r
+   m_buffer = new char [c_size]; assert (m_buffer != 0);\r
+   m_pin    = pin;\r
+\r
+   on_new_istream ();\r
+}\r
+\r
+scanner_impl::~scanner_impl () {\r
+   delete [] m_buffer;\r
+}\r
+\r
+size_t scanner_impl::add_keyword (string const & keyword, int const code) {\r
+   m_keywords[keyword] = static_cast <symbol_type> (symbol::ts_user + code);\r
+\r
+   if ((m_symbol.get_type () == symbol::tc_identifier) && (m_symbol.get_string () == keyword)) {\r
+      morph_identifier (keyword);\r
+   }\r
+\r
+   return m_keywords.size ();\r
+}\r
+\r
+bool scanner_impl::eof () const {\r
+   return m_symbol.eof ();\r
+}\r
+\r
+int const & scanner_impl::get_integer () const {\r
+   return m_symbol.get_integer ();\r
+}\r
+\r
+istream * scanner_impl::get_istream () const {\r
+   return m_pin;\r
+}\r
+\r
+scanner_impl::position_type scanner_impl::get_position () const {\r
+   position_type p = (m_pos_t.first <= 0) ? m_pos_t_p : m_pos_t; p.first -= m_symbol.get_length_int (); return p;\r
+}\r
+\r
+double const & scanner_impl::get_real () const {\r
+   return m_symbol.get_real ();\r
+}\r
+\r
+string const & scanner_impl::get_string () const {\r
+   return m_symbol.get_string ();\r
+}\r
+\r
+symbol const & scanner_impl::get_symbol () const {\r
+   return m_symbol;\r
+}\r
+\r
+symbol const & scanner_impl::next_symbol () {\r
+   m_symbol = symbol (); bool scanned = false;\r
+\r
+   while (!scanned) {\r
+      if (is_alpha (m_chr)) {\r
+         scan_identifier (); scanned = true;\r
+\r
+      } else if (isdigit (m_chr)) {\r
+         scan_number (+1, 0); scanned = true;\r
+\r
+      } else if (m_chr == '"') {\r
+         next_char (); scan_string (); scanned = true;\r
+\r
+      } else if (m_chr == '+') {\r
+         m_symbol = symbol (symbol::ts_plus, 1, "+"); next_char ();\r
+\r
+                //korr: wies - Variante\r
+                /*\r
+         if (isdigit (m_chr)) {\r
+            scan_number (+1, 1);\r
+         }\r
+                */\r
+\r
+         scanned = true;\r
+\r
+      } else if (m_chr == '-') {\r
+         m_symbol = symbol (symbol::ts_minus, 1, "-"); next_char ();\r
+\r
+                //korr: wies - Variante\r
+                /*\r
+         if (isdigit (m_chr)) {\r
+            scan_number (-1, 1);\r
+         }\r
+                */\r
+\r
+         scanned = true;\r
+\r
+      } else if (m_chr == '/') {\r
+         m_symbol = symbol (symbol::ts_division, 1, "/"); next_char ();\r
+\r
+         if (m_chr == '/') {\r
+            next_char (); scan_comment_sl ();\r
+\r
+         } else if (m_chr == '*') {\r
+            next_char (); scan_comment_ml ();\r
+\r
+         } else {\r
+            scanned = true;\r
+         }\r
+\r
+      } else if (m_chr == '\0') {\r
+         scanned = true;\r
+\r
+      } else {\r
+         switch (m_chr) {\r
+            case '(': m_symbol = symbol (symbol::ts_lpar,      1, "("); scanned = true; break;\r
+            case ')': m_symbol = symbol (symbol::ts_rpar,      1, ")"); scanned = true; break;\r
+            case '*': m_symbol = symbol (symbol::ts_multiply,  1, "*"); scanned = true; break;\r
+            case ',': m_symbol = symbol (symbol::ts_comma,     1, ","); scanned = true; break;\r
+            case '.': m_symbol = symbol (symbol::ts_period,    1, "."); scanned = true; break;\r
+            case ':': m_symbol = symbol (symbol::ts_colon,     1, ":"); scanned = true; break;\r
+            case ';': m_symbol = symbol (symbol::ts_semicolon, 1, ";"); scanned = true; break;\r
+            case '=': m_symbol = symbol (symbol::ts_assign,    1, "="); scanned = true; break;\r
+            case '^': m_symbol = symbol (symbol::ts_power,     1, "^"); scanned = true; break;\r
+         }\r
+\r
+         next_char ();\r
+      }\r
+   }\r
+\r
+   return m_symbol;\r
+}\r
+\r
+void scanner_impl::remove_all_keywords () {\r
+   m_keywords.clear ();\r
+}\r
+\r
+size_t scanner_impl::remove_keyword (string const & keyword) {\r
+   m_keywords.erase (keyword); return m_keywords.size ();\r
+}\r
+\r
+void scanner_impl::set_istream (istream * const pin) {\r
+   m_pin = pin; on_new_istream ();\r
+}\r
+\r
+string scanner_impl::symbol_as_string () const {\r
+   return m_symbol.as_string ();\r
+}\r
+\r
+bool scanner_impl::symbol_is_assign () const {\r
+   return m_symbol.is_assign ();\r
+}\r
+\r
+bool scanner_impl::symbol_is_colon () const {\r
+   return m_symbol.is_colon ();\r
+}\r
+\r
+bool scanner_impl::symbol_is_comma () const {\r
+   return m_symbol.is_comma ();\r
+}\r
+\r
+bool scanner_impl::symbol_is_division () const {\r
+   return m_symbol.is_division ();\r
+}\r
+\r
+bool scanner_impl::symbol_is_eof () const {\r
+   return m_symbol.is_eof ();\r
+}\r
+\r
+bool scanner_impl::symbol_is_identifier () const {\r
+   return m_symbol.is_identifier ();\r
+}\r
+\r
+bool scanner_impl::symbol_is_integer () const {\r
+   return m_symbol.is_integer ();\r
+}\r
+\r
+bool scanner_impl::symbol_is_keyword (int const code) const {\r
+   return m_symbol.is_keyword (code);\r
+}\r
+\r
+bool scanner_impl::symbol_is_keyword (string const & keyword) const {\r
+   return m_symbol.is_keyword (keyword);\r
+}\r
+\r
+bool scanner_impl::symbol_is_lpar () const {\r
+   return m_symbol.is_lpar ();\r
+}\r
+\r
+bool scanner_impl::symbol_is_minus () const {\r
+   return m_symbol.is_minus ();\r
+}\r
+\r
+bool scanner_impl::symbol_is_multiply () const {\r
+   return m_symbol.is_multiply ();\r
+}\r
+\r
+bool scanner_impl::symbol_is_number () const {\r
+   return m_symbol.is_number ();\r
+}\r
+\r
+bool scanner_impl::symbol_is_period () const {\r
+   return m_symbol.is_period ();\r
+}\r
+\r
+bool scanner_impl::symbol_is_plus () const {\r
+   return m_symbol.is_plus ();\r
+}\r
+\r
+bool scanner_impl::symbol_is_power () const {\r
+   return m_symbol.is_power ();\r
+}\r
+\r
+bool scanner_impl::symbol_is_real () const {\r
+   return m_symbol.is_real ();\r
+}\r
+\r
+bool scanner_impl::symbol_is_rpar () const {\r
+   return m_symbol.is_rpar ();\r
+}\r
+\r
+bool scanner_impl::symbol_is_semicolon () const {\r
+   return m_symbol.is_semicolon ();\r
+}\r
+\r
+bool scanner_impl::symbol_is_string () const {\r
+   return m_symbol.is_string ();\r
+}\r
+\r
+bool scanner_impl::symbol_is_value () const {\r
+   return m_symbol.is_value ();\r
+}\r
+\r
+scanner_impl::operator double () const {\r
+   return m_symbol.operator double ();\r
+}\r
+\r
+scanner_impl::operator int () const {\r
+   return m_symbol.operator int ();\r
+}\r
+\r
+scanner_impl::operator position_type () const {\r
+   return get_position ();\r
+}\r
+\r
+scanner_impl::operator istream * () const {\r
+   return m_pin;\r
+}\r
+\r
+scanner_impl::operator string () const {\r
+   return m_symbol.operator string ();\r
+}\r
+\r
+scanner_impl::operator symbol () const {\r
+   return m_symbol;\r
+}\r
+\r
+void scanner_impl::morph_identifier (string const & keyword) {\r
+   m_symbol = symbol (to_type (keyword), m_symbol.get_length (), m_symbol.get_string (), m_symbol.get_integer (), m_symbol.get_real ());\r
+}\r
+\r
+void scanner_impl::next_char () {\r
+   if ((m_pin != 0) && m_pin->good () && (m_pos >= m_length)) {\r
+      m_pin->get (m_buffer, c_size, 0);\r
+\r
+      m_length = strlen (m_buffer);\r
+      m_pos    = 0;\r
+   }\r
+\r
+   if (m_pos < m_length) {\r
+      m_chr     = m_buffer[m_pos++];\r
+      m_pos_t_p = m_pos_t;\r
+\r
+      if (m_chr == '\n') {\r
+         m_pos_t.first    = 0;\r
+         m_pos_t.second  += 1;\r
+         m_pos_t_p.first += 1;\r
+      } else {\r
+         m_pos_t.first += 1;\r
+      }\r
+   } else {\r
+      m_chr = '\0';\r
+   }\r
+}\r
+\r
+void scanner_impl::on_new_istream () {\r
+  *m_buffer  = 0;\r
+   m_length  = 0;\r
+   m_pos     = 0;\r
+   m_pos_t   = position_type (0, 1);\r
+   m_pos_t_p = position_type (0, 0);\r
+\r
+   next_char   ();\r
+   next_symbol ();\r
+}\r
+\r
+void scanner_impl::scan_comment_ml () {\r
+   size_t scanned = 0;\r
+\r
+   while (scanned < 2) {\r
+      if (m_chr == '\0') {\r
+         scanned = 2;\r
+\r
+      } else if (m_chr == '*') {\r
+         scanned = (scanned == 0) ? 1 : 0;\r
+\r
+      } else if (m_chr == '/') {\r
+         scanned = (scanned == 1) ? 2 : 0;\r
+\r
+      } else {\r
+         scanned = 0;\r
+      }\r
+\r
+      next_char ();\r
+   }\r
+}\r
+\r
+void scanner_impl::scan_comment_sl () {\r
+   while ((m_chr != '\n') && (m_chr != '\0')) {\r
+      next_char ();\r
+   }\r
+\r
+   next_char ();\r
+}\r
+\r
+void scanner_impl::scan_identifier () {\r
+   string value;\r
+\r
+   while (is_alphanum (m_chr)) {\r
+      value += m_chr; next_char ();\r
+   }\r
+\r
+   m_symbol = symbol (to_type (value), value.size (), value);\r
+}\r
+\r
+void scanner_impl::scan_number (int const sign, size_t const sign_length) {\r
+   int    vorkomma        = 0;\r
+   size_t vorkomma_length = sign_length;\r
+\r
+   while (isdigit (m_chr)) {\r
+      vorkomma         = vorkomma * 10 + (m_chr - '0');\r
+      vorkomma_length += 1;\r
+\r
+      next_char ();\r
+   }\r
+\r
+   if (m_chr == '.') {\r
+      next_char ();\r
+\r
+      double exponent         = 1;\r
+      int    nachkomma        = 0;\r
+      size_t nachkomma_length = 1;\r
+\r
+      while (isdigit (m_chr)) {\r
+         nachkomma         = nachkomma * 10 + (m_chr - '0');\r
+         nachkomma_length +=  1;\r
+         exponent         /= 10;\r
+\r
+         next_char ();\r
+      }\r
+\r
+      ostringstream o;\r
+      double const  v = sign * (vorkomma + exponent * nachkomma); o << v;\r
+\r
+      m_symbol = symbol (symbol::tc_real, vorkomma_length + nachkomma_length, o.str (), static_cast <int> (v), v);\r
+   } else {\r
+      ostringstream o;\r
+      int const     v = sign * vorkomma; o << v;\r
+\r
+      m_symbol = symbol (symbol::tc_integer, vorkomma_length, o.str (), v, v);\r
+   }\r
+}\r
+\r
+void scanner_impl::scan_string () {\r
+   string value;\r
+\r
+   while ((m_chr != '"') && (m_chr != '\n') && (m_chr != '\0')) {\r
+      value += m_chr; next_char ();\r
+   }\r
+\r
+   m_symbol = symbol (symbol::tc_string, value.size () + 2, value); next_char ();\r
+}\r
+\r
+scanner_impl::symbol_type scanner_impl::to_type (string const & name) const {\r
+   keyword_itor const p = m_keywords.find (name); return (p != m_keywords.end ()) ? p->second : symbol::tc_identifier;\r
+}\r
diff --git a/src/tests/SEN2/Beispiel2/scanner_impl.h b/src/tests/SEN2/Beispiel2/scanner_impl.h
new file mode 100644 (file)
index 0000000..6b3469a
--- /dev/null
@@ -0,0 +1,104 @@
+//       $Id: scanner_impl.h 3053 2006-12-09 13:07:29Z kulczyck $\r
+//      $URL: file:///C:/Documents%20and%20Settings/kulczyck/Desktop/Desktop/SVN-Repository/Hochschule/Lehre/FH/BIN/SWE3/Programme/Scanner-II/trunk/src/scanner_impl.h $\r
+// $Revision: 3053 $\r
+//     $Date: 2006-12-09 14:07:29 +0100 (Sa, 09 Dez 2006) $\r
+//   Creator: peter.kulczycki<AT>fh-hagenberg.at\r
+//   $Author: kulczyck $\r
+\r
+#if !defined SCANNER_IMPL_H\r
+#define      SCANNER_IMPL_H\r
+\r
+#include "scanner.h"\r
+#include "symbol.h"\r
+\r
+#include <map>\r
+\r
+class scanner_impl {\r
+   friend class scanner;\r
+\r
+   private:\r
+      typedef scanner::position_type position_type;\r
+      typedef symbol::symbol_type    symbol_type;\r
+\r
+      static bool is_alpha     (char const c);\r
+      static bool is_alphanum   (char const c);\r
+      static bool is_whitespace (char const c);\r
+\r
+      scanner_impl (std::istream * const pin = 0);\r
+     ~scanner_impl ();\r
+\r
+      std::istream * get_istream () const;\r
+      void           set_istream (std::istream * const pin = 0);\r
+\r
+      size_t add_keyword         (std::string const & keyword, int const code);\r
+      void   remove_all_keywords ();\r
+      size_t remove_keyword      (std::string const & keyword);\r
+\r
+      bool                eof              () const;\r
+      int const &         get_integer      () const;\r
+      position_type       get_position     () const;\r
+      double const &      get_real         () const;\r
+      std::string const & get_string       () const;\r
+      symbol const &      get_symbol       () const;\r
+      symbol const &      next_symbol      ();\r
+      std::string         symbol_as_string () const;\r
+\r
+      bool symbol_is_assign     () const;\r
+      bool symbol_is_colon      () const;\r
+      bool symbol_is_comma      () const;\r
+      bool symbol_is_division   () const;\r
+      bool symbol_is_eof        () const;\r
+      bool symbol_is_identifier () const;\r
+      bool symbol_is_integer    () const;\r
+      bool symbol_is_keyword    (int const code) const;\r
+      bool symbol_is_keyword    (std::string const & keyword) const;\r
+      bool symbol_is_lpar       () const;\r
+      bool symbol_is_minus      () const;\r
+      bool symbol_is_multiply   () const;\r
+      bool symbol_is_number     () const;\r
+      bool symbol_is_period     () const;\r
+      bool symbol_is_plus       () const;\r
+      bool symbol_is_power      () const;\r
+      bool symbol_is_real       () const;\r
+      bool symbol_is_rpar       () const;\r
+      bool symbol_is_semicolon  () const;\r
+      bool symbol_is_string     () const;\r
+      bool symbol_is_value      () const;\r
+\r
+      operator double         () const;\r
+      operator int            () const;\r
+      operator position_type  () const;\r
+      operator std::istream * () const;\r
+      operator std::string    () const;\r
+      operator symbol         () const;\r
+\r
+      void        morph_identifier (std::string const & keyword);\r
+      void        next_char        ();\r
+      void        on_new_istream   ();\r
+      void        scan_comment_ml  ();\r
+      void        scan_comment_sl  ();\r
+      void        scan_identifier  ();\r
+      void        scan_number      (int const sign, size_t const sign_length);\r
+      void        scan_string      ();\r
+      symbol_type to_type          (std::string const & name) const;\r
+\r
+                     scanner_impl (scanner_impl const &);\r
+      scanner_impl & operator =   (scanner_impl const &);\r
+\r
+      typedef std::map <std::string, symbol_type> keyword_list;\r
+      typedef keyword_list::const_iterator        keyword_itor;\r
+\r
+      static size_t const c_size = 513;\r
+\r
+      char *         m_buffer;\r
+      char           m_chr;\r
+      keyword_list   m_keywords;\r
+      size_t         m_length;\r
+      std::istream * m_pin;\r
+      size_t         m_pos;\r
+      position_type  m_pos_t;\r
+      position_type  m_pos_t_p;\r
+      symbol         m_symbol;\r
+};\r
+\r
+#endif   // SCANNER_IMPL_H\r
diff --git a/src/tests/SEN2/Beispiel2/symbol.cpp b/src/tests/SEN2/Beispiel2/symbol.cpp
new file mode 100644 (file)
index 0000000..1bd0a8c
--- /dev/null
@@ -0,0 +1,177 @@
+//       $Id: symbol.h 2924 2006-11-30 21:11:23Z kulczyck $\r
+//      $URL: file:///C:/Documents%20and%20Settings/kulczyck/Desktop/Desktop/SVN-Repository/Hochschule/Lehre/FH/BIN/SWE3/Programme/Scanner-II/src/symbol.h $\r
+// $Revision: 2924 $\r
+//     $Date: 2006-11-30 22:11:23 +0100 (Do, 30 Nov 2006) $\r
+//   Creator: peter.kulczycki<AT>fh-hagenberg.at\r
+//   $Author: kulczyck $\r
+\r
+#include "symbol.h"\r
+\r
+#include <sstream>\r
+\r
+using std::dec;\r
+using std::hex;\r
+using std::ostringstream;\r
+using std::string;\r
+\r
+symbol::symbol (symbol_type const & type, size_t const length, string const & str, int const integer, double const real) {\r
+   m_integer = integer;\r
+   m_length  = length;\r
+   m_real    = real;\r
+   m_string  = str;\r
+   m_type    = type;\r
+}\r
+\r
+symbol::~symbol () {\r
+}\r
+\r
+string symbol::as_string () const {\r
+   ostringstream o;\r
+\r
+   switch (m_type) {\r
+      case tc_identifier: o << "identifier";  break;\r
+      case tc_integer:    o << "integer";     break;\r
+      case tc_real:       o << "real";        break;\r
+      case tc_string:     o << "string";      break;\r
+      case ts_assign:     o << "assign";      break;\r
+      case ts_colon:      o << "colon";       break;\r
+      case ts_comma:      o << "comma";       break;\r
+      case ts_division:   o << "division";    break;\r
+      case ts_eof:        o << "eof";         break;\r
+      case ts_lpar:       o << "lpar";        break;\r
+      case ts_minus:      o << "minus";       break;\r
+      case ts_multiply:   o << "multiply";    break;\r
+      case ts_period:     o << "period";      break;\r
+      case ts_plus:       o << "plus";        break;\r
+      case ts_power:      o << "power";       break;\r
+      case ts_rpar:       o << "rpar";        break;\r
+      case ts_semicolon:  o << "semicolon";   break;\r
+      default:            o << "userdefined"; break;\r
+   }\r
+\r
+   o << " (0x" << hex << m_type << ", " << dec << m_length << ", '" << m_string << "')"; return o.str ();\r
+}\r
+\r
+bool symbol::eof () const {\r
+   return is_eof ();\r
+}\r
+\r
+int const & symbol::get_integer () const {\r
+   return m_integer;\r
+}\r
+\r
+size_t const & symbol::get_length () const {\r
+   return m_length;\r
+}\r
+\r
+int symbol::get_length_int () const {\r
+   return static_cast <int> (get_length ());\r
+}\r
+\r
+double const & symbol::get_real () const {\r
+   return m_real;\r
+}\r
+\r
+string const & symbol::get_string () const {\r
+   return m_string;\r
+}\r
+\r
+symbol::symbol_type const & symbol::get_type () const {\r
+   return m_type;\r
+}\r
+\r
+bool symbol::is_assign () const {\r
+   return m_type == ts_assign;\r
+}\r
+\r
+bool symbol::is_colon () const {\r
+   return m_type == ts_colon;\r
+}\r
+\r
+bool symbol::is_comma () const {\r
+   return m_type == ts_comma;\r
+}\r
+\r
+bool symbol::is_division () const {\r
+   return m_type == ts_division;\r
+}\r
+\r
+bool symbol::is_eof () const {\r
+   return m_type == ts_eof;\r
+}\r
+\r
+bool symbol::is_identifier () const {\r
+   return m_type == tc_identifier;\r
+}\r
+\r
+bool symbol::is_integer () const {\r
+   return m_type == tc_integer;\r
+}\r
+\r
+bool symbol::is_keyword (int const code) const {\r
+   return m_type == ts_user + code;\r
+}\r
+\r
+bool symbol::is_keyword (string const & keyword) const {\r
+   return (m_type >= ts_user) && (m_string == keyword);\r
+}\r
+\r
+bool symbol::is_lpar () const {\r
+   return m_type == ts_lpar;\r
+}\r
+\r
+bool symbol::is_minus () const {\r
+   return m_type == ts_minus;\r
+}\r
+\r
+bool symbol::is_multiply () const {\r
+   return m_type == ts_multiply;\r
+}\r
+\r
+bool symbol::is_number () const {\r
+   return is_integer () || is_real ();\r
+}\r
+\r
+bool symbol::is_period () const {\r
+   return m_type == ts_period;\r
+}\r
+\r
+bool symbol::is_plus () const {\r
+   return m_type == ts_plus;\r
+}\r
+\r
+bool symbol::is_power () const {\r
+   return m_type == ts_power;\r
+}\r
+\r
+bool symbol::is_real () const {\r
+   return m_type == tc_real;\r
+}\r
+\r
+bool symbol::is_rpar () const {\r
+   return m_type == ts_rpar;\r
+}\r
+\r
+bool symbol::is_semicolon () const {\r
+   return m_type == ts_semicolon;\r
+}\r
+\r
+bool symbol::is_string () const {\r
+   return m_type == tc_string;\r
+}\r
+\r
+bool symbol::is_value () const {\r
+   return is_number () || is_string ();\r
+}\r
+\r
+symbol::operator double () const {\r
+   return m_real;\r
+}\r
+\r
+symbol::operator int () const {\r
+   return m_integer;\r
+}\r
+\r
+symbol::operator string () const {\r
+   return m_string;\r
+}\r
diff --git a/src/tests/SEN2/Beispiel2/symbol.h b/src/tests/SEN2/Beispiel2/symbol.h
new file mode 100644 (file)
index 0000000..4eddc2d
--- /dev/null
@@ -0,0 +1,68 @@
+//       $Id: symbol.h 3035 2006-12-07 18:09:21Z kulczyck $\r
+//      $URL: file:///C:/Documents%20and%20Settings/kulczyck/Desktop/Desktop/SVN-Repository/Hochschule/Lehre/FH/BIN/SWE3/Programme/Scanner-II/trunk/src/symbol.h $\r
+// $Revision: 3035 $\r
+//     $Date: 2006-12-07 19:09:21 +0100 (Do, 07 Dez 2006) $\r
+//   Creator: peter.kulczycki<AT>fh-hagenberg.at\r
+//   $Author: kulczyck $\r
+\r
+#if !defined SYMBOL_H\r
+#define      SYMBOL_H\r
+\r
+#include "base.h"\r
+\r
+class symbol {\r
+   public:\r
+      enum symbol_type {\r
+         ts_eof        = 0x0000,\r
+         ts_assign     = 0x2000, ts_colon   = 0x2001, ts_comma = 0x2002, ts_division = 0x2003, ts_lpar = 0x2004, ts_minus = 0x2005, ts_multiply = 0x2006, ts_period = 0x2007, ts_plus = 0x2008, ts_power = 0x2009, ts_rpar = 0x200A, ts_semicolon = 0x200B,\r
+         tc_identifier = 0x4000, tc_integer = 0x4001, tc_real  = 0x4002, tc_string   = 0x4003,\r
+         ts_user       = 0x6000\r
+      };\r
+\r
+      symbol (symbol_type const & type = ts_eof, size_t const length = 0, std::string const & str = "", int const integer = 0, double const real = 0);\r
+     ~symbol ();\r
+\r
+      std::string         as_string      () const;\r
+      bool                eof            () const;\r
+      int const &         get_integer    () const;\r
+      size_t const &      get_length     () const;\r
+      int                 get_length_int () const;\r
+      double const &      get_real       () const;\r
+      std::string const & get_string     () const;\r
+      symbol_type const & get_type       () const;\r
+\r
+      bool is_assign     () const;\r
+      bool is_colon      () const;\r
+      bool is_comma      () const;\r
+      bool is_division   () const;\r
+      bool is_eof        () const;\r
+      bool is_identifier () const;\r
+      bool is_integer    () const;\r
+      bool is_keyword    (int const code) const;\r
+      bool is_keyword    (std::string const & keyword) const;\r
+      bool is_lpar       () const;\r
+      bool is_minus      () const;\r
+      bool is_multiply   () const;\r
+      bool is_number     () const;\r
+      bool is_period     () const;\r
+      bool is_plus       () const;\r
+      bool is_power      () const;\r
+      bool is_real       () const;\r
+      bool is_rpar       () const;\r
+      bool is_semicolon  () const;\r
+      bool is_string     () const;\r
+      bool is_value      () const;\r
+\r
+      operator double      () const;\r
+      operator int         () const;\r
+      operator std::string () const;\r
+\r
+   private:\r
+      int         m_integer;\r
+      size_t      m_length;\r
+      double      m_real;\r
+      std::string m_string;\r
+      symbol_type m_type;\r
+};\r
+\r
+#endif   // SYMBOL_H\r