Initial Commit
authorDaniel G <giri@nwrk.biz>
Mon, 1 Oct 2018 00:50:38 +0000 (02:50 +0200)
committerDaniel G <giri@nwrk.biz>
Mon, 1 Oct 2018 00:50:38 +0000 (02:50 +0200)
32 files changed:
_template/_template.workspace [new file with mode: 0644]
_template/packages/fltk/.gitignore [new file with mode: 0644]
_template/packages/fltk/fltk-1.3.4-1-source.tar.gz [new file with mode: 0644]
_template/packages/fltk/fltk.cbp [new file with mode: 0644]
_template/packages/tinyxml/.gitignore [new file with mode: 0644]
_template/packages/tinyxml/tinyxml-2.src.zip [new file with mode: 0644]
_template/packages/tinyxml/tinyxml.cbp [new file with mode: 0644]
_template/scripts/7zWin32SelfExtractorGui.sfx [new file with mode: 0644]
_template/scripts/copydeps.sh [new file with mode: 0755]
_template/scripts/gen_package_linux.sh [new file with mode: 0755]
_template/scripts/gen_package_windows.sh [new file with mode: 0755]
_template/src/Controller.cxx [new file with mode: 0644]
_template/src/Controller.h [new file with mode: 0644]
_template/src/ControllerIF.h [new file with mode: 0644]
_template/src/FSHelper.cxx [new file with mode: 0644]
_template/src/FSHelper.h [new file with mode: 0644]
_template/src/Model.cxx [new file with mode: 0644]
_template/src/Model.h [new file with mode: 0644]
_template/src/ModelIF.h [new file with mode: 0644]
_template/src/Object.h [new file with mode: 0644]
_template/src/Observer.cxx [new file with mode: 0644]
_template/src/Observer.h [new file with mode: 0644]
_template/src/Subject.cxx [new file with mode: 0644]
_template/src/Subject.h [new file with mode: 0644]
_template/src/View.cxx [new file with mode: 0644]
_template/src/View.h [new file with mode: 0644]
_template/src/ViewFluid.cxx [new file with mode: 0644]
_template/src/ViewFluid.fld [new file with mode: 0644]
_template/src/ViewFluid.h [new file with mode: 0644]
_template/src/_template.cbp [new file with mode: 0644]
_template/src/main.cxx [new file with mode: 0644]
setup.sh [new file with mode: 0755]

diff --git a/_template/_template.workspace b/_template/_template.workspace
new file mode 100644 (file)
index 0000000..3d573fb
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<CodeBlocks_workspace_file>
+       <Workspace title="Workspace">
+               <Project filename="src/_template.cbp" />
+               <Project filename="packages/fltk/fltk.cbp" />
+               <Project filename="packages/tinyxml/tinyxml.cbp" />
+       </Workspace>
+</CodeBlocks_workspace_file>
diff --git a/_template/packages/fltk/.gitignore b/_template/packages/fltk/.gitignore
new file mode 100644 (file)
index 0000000..c8e489f
--- /dev/null
@@ -0,0 +1,7 @@
+# Ignore everything
+*
+
+# But not these files...
+!.gitignore
+!fltk-1.3.4-1-source.tar.gz
+!fltk.cbp
\ No newline at end of file
diff --git a/_template/packages/fltk/fltk-1.3.4-1-source.tar.gz b/_template/packages/fltk/fltk-1.3.4-1-source.tar.gz
new file mode 100644 (file)
index 0000000..c2fabc0
Binary files /dev/null and b/_template/packages/fltk/fltk-1.3.4-1-source.tar.gz differ
diff --git a/_template/packages/fltk/fltk.cbp b/_template/packages/fltk/fltk.cbp
new file mode 100644 (file)
index 0000000..80b021b
--- /dev/null
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<CodeBlocks_project_file>
+       <FileVersion major="1" minor="6" />
+       <Project>
+               <Option title="fltk" />
+               <Option pch_mode="2" />
+               <Option compiler="gcc" />
+               <Build>
+                       <Target title="fltk_linux64">
+                               <Option output="bin/Debug/fltk" prefix_auto="1" extension_auto="1" />
+                               <Option object_output="obj/Debug/" />
+                               <Option type="1" />
+                               <Option compiler="gcc" />
+                               <Compiler>
+                                       <Add option="-g" />
+                               </Compiler>
+                               <ExtraCommands>
+                                       <Add before="mkdir -p ../../include" />
+                                       <Add before="mkdir -p ../../lib/linux64" />
+                                       <Add before="cp -rf ./FL ../../include" />
+                                       <Add before='./configure LDFLAGS=&quot;&quot; --enable-localjpeg --enable-localzlib --enable-localpng --enable-x11=no --disable-xcursor --disable-xinerama --disable-xft --disable-xdbe --disable-xrender --disable-xfixes --disable-threads' />
+                                       <Add before="make clean" />
+                                       <Add before="make -j5" />
+                                       <Add before="cp -rf ./lib/* ../../lib/linux64/" />
+                               </ExtraCommands>
+                       </Target>
+                       <Target title="fltk_linux32">
+                               <Option output="bin/Debug/fltk" prefix_auto="1" extension_auto="1" />
+                               <Option object_output="obj/Debug/" />
+                               <Option type="1" />
+                               <Option compiler="gcc" />
+                               <Compiler>
+                                       <Add option="-g" />
+                               </Compiler>
+                               <ExtraCommands>
+                                       <Add before="mkdir -p ../../include" />
+                                       <Add before="mkdir -p ../../lib/linux32" />
+                                       <Add before="cp -rf ./FL ../../include" />
+                                       <Add before='./configure &quot;CFLAGS=-m32&quot; &quot;CXXFLAGS=-m32&quot; &quot;LDFLAGS=-m32&quot; --enable-localjpeg --enable-localzlib --enable-localpng --enable-x11=no --disable-xcursor --disable-xinerama --disable-xft --disable-xdbe --disable-xrender --disable-xfixes --disable-threads' />
+                                       <Add before="make clean" />
+                                       <Add before="make -j5" />
+                                       <Add before="cp -rf ./lib/* ../../lib/linux32/" />
+                               </ExtraCommands>
+                       </Target>
+                       <Target title="fltk_windows">
+                               <Option output="bin/Debug/fltk" prefix_auto="1" extension_auto="1" />
+                               <Option object_output="obj/Debug/" />
+                               <Option type="1" />
+                               <Option compiler="gcc" />
+                               <Compiler>
+                                       <Add option="-g" />
+                               </Compiler>
+                               <ExtraCommands>
+                                       <Add before="mkdir -p ../../include" />
+                                       <Add before="mkdir -p ../../lib/mingw32" />
+                                       <Add before="cp -rf ./FL ../../include" />
+                                       <Add before='./configure LDFLAGS=&quot;-static-libgcc -static-libstdc++&quot; --enable-cygwin --enable-threads --enable-localjpeg --enable-localzlib --enable-localpng --enable-x11 --disable-xcursor --disable-xinerama --disable-xft --disable-xdbe --disable-xrender --disable-xfixes --disable-threads --host=i686-w64-mingw32' />
+                                       <Add before="make clean" />
+                                       <Add before="make -j5" />
+                                       <Add before="cp -rf ./lib/* ../../lib/mingw32/" />
+                               </ExtraCommands>
+                       </Target>
+                       <Target title="fltk_unpack">
+                               <Option output="bin/Debug/fltk" prefix_auto="1" extension_auto="1" />
+                               <Option object_output="obj/Debug/" />
+                               <Option type="1" />
+                               <Option compiler="gcc" />
+                               <Compiler>
+                                       <Add option="-g" />
+                               </Compiler>
+                               <ExtraCommands>
+                                       <Add before="tar xvzf fltk-1.3.4-1-source.tar.gz" />
+                                       <Add before="cp -rf ./fltk-1.3.4-1/* ./" />
+                                       <Add before="rm -rf ./fltk-1.3.4-1/" />
+                               </ExtraCommands>
+                       </Target>
+               </Build>
+               <Compiler>
+                       <Add option="-Wall" />
+               </Compiler>
+               <Extensions>
+                       <envvars />
+                       <code_completion />
+                       <debugger />
+                       <lib_finder disable_auto="1" />
+               </Extensions>
+       </Project>
+</CodeBlocks_project_file>
diff --git a/_template/packages/tinyxml/.gitignore b/_template/packages/tinyxml/.gitignore
new file mode 100644 (file)
index 0000000..3466ad1
--- /dev/null
@@ -0,0 +1,7 @@
+# Ignore everything
+*
+
+# But not these files...
+!.gitignore
+!tinyxml-2.src.zip
+!tinyxml.cbp
\ No newline at end of file
diff --git a/_template/packages/tinyxml/tinyxml-2.src.zip b/_template/packages/tinyxml/tinyxml-2.src.zip
new file mode 100644 (file)
index 0000000..0c92ffa
Binary files /dev/null and b/_template/packages/tinyxml/tinyxml-2.src.zip differ
diff --git a/_template/packages/tinyxml/tinyxml.cbp b/_template/packages/tinyxml/tinyxml.cbp
new file mode 100644 (file)
index 0000000..c3e555b
--- /dev/null
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<CodeBlocks_project_file>
+       <FileVersion major="1" minor="6" />
+       <Project>
+               <Option title="tinyxml" />
+               <Option pch_mode="2" />
+               <Option compiler="gcc" />
+               <Build>
+                       <Target title="tinyxml_linux64">
+                               <Option output="bin/Release/tinyxml" prefix_auto="1" extension_auto="1" />
+                               <Option object_output="obj/Release/" />
+                               <Option type="1" />
+                               <Option compiler="gcc" />
+                               <Compiler>
+                                       <Add option="-O2" />
+                               </Compiler>
+                               <Linker>
+                                       <Add option="-s" />
+                               </Linker>
+                               <ExtraCommands>
+                                       <Add before="mkdir -p ../../include" />
+                                       <Add before="mkdir -p ../../lib/linux64" />
+                                       <Add before="cp ./tinyxml2.h ../../include" />
+                                       <Add before="g++ -c -o tinyxml2.o tinyxml2.cpp" />
+                                       <Add before="ar rvs libtinyxml2.a tinyxml2.o" />
+                                       <Add before="cp ./libtinyxml2.a ../../lib/linux64" />
+                               </ExtraCommands>
+                       </Target>
+                       <Target title="tinyxml_linux32">
+                               <Option output="bin/Release/tinyxml" prefix_auto="1" extension_auto="1" />
+                               <Option object_output="obj/Release/" />
+                               <Option type="1" />
+                               <Option compiler="gcc" />
+                               <Compiler>
+                                       <Add option="-O2" />
+                               </Compiler>
+                               <Linker>
+                                       <Add option="-s" />
+                               </Linker>
+                               <ExtraCommands>
+                                       <Add before="mkdir -p ../../include" />
+                                       <Add before="mkdir -p ../../lib/linux32" />
+                                       <Add before="cp ./tinyxml2.h ../../include" />
+                                       <Add before="g++ -m32 -c -o tinyxml2.o tinyxml2.cpp" />
+                                       <Add before="ar rvs libtinyxml2.a tinyxml2.o" />
+                                       <Add before="cp ./libtinyxml2.a ../../lib/linux32" />
+                               </ExtraCommands>
+                       </Target>
+                       <Target title="tinyxml_windows">
+                               <Option output="bin/Release/tinyxml" prefix_auto="1" extension_auto="1" />
+                               <Option object_output="obj/Release/" />
+                               <Option type="1" />
+                               <Option compiler="gcc" />
+                               <Compiler>
+                                       <Add option="-O2" />
+                               </Compiler>
+                               <Linker>
+                                       <Add option="-s" />
+                               </Linker>
+                               <ExtraCommands>
+                                       <Add before="mkdir -p ../../include" />
+                                       <Add before="mkdir -p ../../lib/mingw32" />
+                                       <Add before="cp ./tinyxml2.h ../../include" />
+                                       <Add before="i686-w64-mingw32-g++    -c -o tinyxml2.o tinyxml2.cpp" />
+                                       <Add before="i686-w64-mingw32-ar rvs libtinyxml2.a tinyxml2.o" />
+                                       <Add before="cp ./libtinyxml2.a ../../lib/mingw32" />
+                               </ExtraCommands>
+                       </Target>
+                       <Target title="tinyxml_unpack">
+                               <Option output="bin/Release/tinyxml" prefix_auto="1" extension_auto="1" />
+                               <Option object_output="obj/Release/" />
+                               <Option type="1" />
+                               <Option compiler="gcc" />
+                               <Compiler>
+                                       <Add option="-O2" />
+                               </Compiler>
+                               <Linker>
+                                       <Add option="-s" />
+                               </Linker>
+                               <ExtraCommands>
+                                       <Add before="rm -rf ./tinyxml2-master/" />
+                                       <Add before="unzip tinyxml-2.src.zip" />
+                                       <Add before="cp -rf ./tinyxml2-master/* ./" />
+                                       <Add before="rm -rf ./tinyxml2-master/" />
+                               </ExtraCommands>
+                       </Target>
+               </Build>
+               <Compiler>
+                       <Add option="-Wall" />
+               </Compiler>
+               <Extensions>
+                       <envvars />
+                       <code_completion />
+                       <debugger />
+                       <lib_finder disable_auto="1" />
+               </Extensions>
+       </Project>
+</CodeBlocks_project_file>
diff --git a/_template/scripts/7zWin32SelfExtractorGui.sfx b/_template/scripts/7zWin32SelfExtractorGui.sfx
new file mode 100644 (file)
index 0000000..8145654
Binary files /dev/null and b/_template/scripts/7zWin32SelfExtractorGui.sfx differ
diff --git a/_template/scripts/copydeps.sh b/_template/scripts/copydeps.sh
new file mode 100755 (executable)
index 0000000..747af3b
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash 
+
+function useage()
+{
+    cat << EOU
+Useage: bash $0 <path to the binary> <path to copy the dependencies>
+EOU
+exit 1
+}
+
+#Validate the inputs
+[[ $# < 2 ]] && useage
+
+#Check if the paths are vaild
+[[ ! -e $1 ]] && echo "Not a vaild input $1" && exit 1 
+[[ -d $2 ]] || echo "No such directory $2 creating..."&& mkdir -p "$2"
+
+#Get the library dependencies
+echo "Collecting the shared library dependencies for $1..."
+deps=$(ldd $1 | awk 'BEGIN{ORS=" "}$1\
+~/^\//{print $1}$3~/^\//{print $3}'\
+ | sed 's/,$/\n/')
+echo "Copying the dependencies to $2"
+
+#Copy the deps
+for dep in $deps
+do
+    echo "Copying $dep to $2"
+    cp "$dep" "$2"
+done
+
+echo "Done!"
\ No newline at end of file
diff --git a/_template/scripts/gen_package_linux.sh b/_template/scripts/gen_package_linux.sh
new file mode 100755 (executable)
index 0000000..b9c6eee
--- /dev/null
@@ -0,0 +1,97 @@
+#!/bin/sh
+#Script that creates self extracting executable script from tar.gz file. 
+if [ $# -eq 0 ] || [ ! -f $1 ]; then
+        echo "This script creates self extractable executable"
+        echo Usage: $0 [/path/to/*.tar.gz]
+        exit;
+fi
+if [ $# -gt 0 ]; then
+        TAR_FILE=$1
+fi
+EXIT_COMMAND=exit
+if [ $# -gt 1 ]; then
+        EXIT_COMMAND="exec $2"
+fi
+FILECOUNT=$(tar -tzf $TAR_FILE | wc -l)
+SELF_EXTRACTABLE="$TAR_FILE.run"
+
+cat > ${SELF_EXTRACTABLE} << EOL
+#!/bin/bash
+if [ -f '/usr/bin/xmessage' ] || [ -f '/usr/bin/gxmessage' ]; then
+    XMESSAGE=\$(which gxmessage) || XMESSAGE=xmessage
+    PWD=\$(pwd)
+    ans=\$(\$XMESSAGE -nearmouse -title 'Extract?' -buttons yes,no Extract to: [ \$PWD ] ? -print)
+else
+    ans=yes
+fi
+if [ "\$ans" == "yes" ]; then
+    TOSKIP=\$(awk '/^#----- ARCHIVE STARTS HERE -----#/ {print NR + 1; exit 0; }' \$0)
+    COUNT=$FILECOUNT
+    echo "Installing Doc Tool: "& 
+    PID=\$!
+    LINE="                                                  "
+    LINENUM=0
+
+    # Extract
+    tail -n+\$TOSKIP \$0  | tar -xzvp 2>&1 | 
+    while read line; do
+        x=\$((x+1))
+
+        # calculate percentage
+       PERCENTAGE_NUM=\$(((x*100)/COUNT))
+       PERCENTAGE=\$(printf '%03d' \$PERCENTAGE_NUM)   
+
+        # create gauge line
+        if [ "\$PERCENTAGE_NUM" -ge "\$LINENUM" ]; then
+               LINE=\${LINE/ />}
+
+                if [ "\$PERCENTAGE_NUM" -ge "100" ]; then
+                        LINE=\${LINE// />}
+                fi
+       fi
+
+        # display gauge line
+        if [ -z \${XMESSAGE+x} ]; then
+              echo -en "[\$LINE] \$x / \$COUNT extracted (\$PERCENTAGE%)\r"
+                if [ "\$PERCENTAGE_NUM" -ge "\$LINENUM" ]; then
+                     LINENUM=\$((PERCENTAGE_NUM+2))
+               fi
+        else
+               if [ "\$PERCENTAGE_NUM" -ge "\$LINENUM" ]; then
+                     LINENUM=\$((PERCENTAGE_NUM+2))
+                      if ps -p \$PID > /dev/null 
+                      then
+                            kill \$PID 2> /dev/null 
+                      fi
+                      \$XMESSAGE -center -title 'Progress' "[\$LINE] \$x / \$COUNT extracted! (\$PERCENTAGE%)" &
+                       PID=\$!
+               fi
+        fi
+    done
+
+    # check if untar was successful
+    if [ "\${PIPESTATUS[1]}" != "0" ]; then
+        if [ -z \${XMESSAGE+x} ]; then
+            echo 'Failed to extract package!'
+        else
+             \$XMESSAGE -nearmouse -title 'Error!' 'Failed to extract package!'
+        fi
+        exit 1
+    fi
+
+    # display success message
+    if [ -z \${XMESSAGE+x} ]; then
+       echo ''
+        echo 'Finished extracting!'
+    else
+        \$XMESSAGE -nearmouse -title 'Success' 'Finished extracting!'
+    fi
+   exit
+else
+   exit
+fi
+#----- ARCHIVE STARTS HERE -----#
+EOL
+
+cat $TAR_FILE >> $SELF_EXTRACTABLE
+chmod a+x $SELF_EXTRACTABLE
\ No newline at end of file
diff --git a/_template/scripts/gen_package_windows.sh b/_template/scripts/gen_package_windows.sh
new file mode 100755 (executable)
index 0000000..31a573e
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+#Script that creates self extracting executable script from tar.gz file.
+if [ $# -eq 0 ]; then
+        echo "This script creates self extractable executable"
+        echo Usage: $0 data_to_compress
+        exit;
+fi
+
+7z a -sfx7zWin32SelfExtractorGui.sfx install.exe ${@}
diff --git a/_template/src/Controller.cxx b/_template/src/Controller.cxx
new file mode 100644 (file)
index 0000000..a98caf1
--- /dev/null
@@ -0,0 +1,21 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Controller.cxx
+// Author: Daniel Giritzer <daniel@giritzer.eu>
+// Date:
+// Description: Diese Klasse implementiert das Controller Interface und stellt
+//              einem Vier alle Funktionen, um Daten an ein Model zu senden,
+//              zur Verfügung.
+// Remarks: -
+///////////////////////////////////////////////////////////////////////////
+#include "Controller.h"
+
+Controller::Controller(std::shared_ptr<Model> model)
+{
+    mModel = model;
+}
+
+void Controller::throwException()
+{
+    mModel->throwException();
+    mModel->notifyObservers();
+}
diff --git a/_template/src/Controller.h b/_template/src/Controller.h
new file mode 100644 (file)
index 0000000..bd534dd
--- /dev/null
@@ -0,0 +1,31 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Controller.h
+// Author: Daniel Giritzer <daniel@giritzer.eu>
+// Date:
+// Description: Diese Klasse implementiert das Controller Interface und stellt
+//              einem Vier alle Funktionen, um Daten an ein Model zu senden,
+//              zur Verfügung.
+// Remarks: -
+///////////////////////////////////////////////////////////////////////////
+#ifndef CONTROLLER_H
+#define CONTROLLER_H
+
+#include "ControllerIF.h"
+#include "Model.h"
+
+/////////////////////////////////////////////////
+/// \brief Implementierung des Controller
+///        Interfaces. Implementiert alle
+///        im Interface definierten funktionen.
+/////////////////////////////////////////////////
+class Controller: public ControllerIF
+{
+public:
+    Controller(std::shared_ptr<Model> model);
+    void throwException() override;
+
+private:
+    std::shared_ptr<Model> mModel;
+};
+
+#endif // CONTROLLER_H
diff --git a/_template/src/ControllerIF.h b/_template/src/ControllerIF.h
new file mode 100644 (file)
index 0000000..b442c53
--- /dev/null
@@ -0,0 +1,39 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Chapter.h
+// Author: Daniel Giritzer <daniel@giritzer.eu>
+// Date:
+// Description: Interface für die Controller Klasse.
+// Remarks: Dieses Interface definiert alle von einem View
+//          benötigten Funktionen.
+///////////////////////////////////////////////////////////////////////////
+#ifndef CONTROLLERIF_H_INCLUDED
+#define CONTROLLERIF_H_INCLUDED
+
+#include <memory>
+#include "Object.h"
+
+/////////////////////////////////////////////////
+/// \brief Interface für die Controller Klasse.
+///        Dieses Interface definiert alle von einem View
+///        benötigten Funktionen.
+/////////////////////////////////////////////////
+class ControllerIF : public Object
+{
+public:
+
+    /////////////////////////////////////////////////
+    /// \brief Wirft eine std::string eine Exception.
+    /////////////////////////////////////////////////
+    virtual void throwException() = 0;
+
+    /////////////////////////////////////////////////
+    /// \brief Typedef für einen shared Pointer auf
+    ///        ein Objekt dieser Klasse oder deren
+    ///        Implementierung.
+    /////////////////////////////////////////////////
+    using SPtr = std::shared_ptr<ControllerIF>;
+
+protected:
+    ControllerIF() = default;
+};
+#endif // CONTROLLERIF_H_INCLUDED
diff --git a/_template/src/FSHelper.cxx b/_template/src/FSHelper.cxx
new file mode 100644 (file)
index 0000000..b727d35
--- /dev/null
@@ -0,0 +1,513 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: FSHelper.cxx
+// Author: Daniel Giritzer <daniel@giritzer.eu>
+// Date: 26.04.2018
+// Description: Diese Klasse stellt plattformunabhängige funktionen auf das
+//              Dateisystem zur verfügung. Bei fehler werden exeptions
+//              des Typs std::string geworfen.
+// Remarks: -
+///////////////////////////////////////////////////////////////////////////
+#include "FSHelper.h"
+#include <fstream>
+#include <dirent.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <cstring>
+#include <sstream>
+#include <algorithm>
+
+#ifndef _WIN32
+#include <sys/wait.h>
+#endif
+
+std::vector<FSHelper::File> FSHelper::listFiles(const std::string &src)
+{
+    std::vector<File> retVal;
+    DIR *dir;
+    struct dirent *ent;
+
+    if((dir = opendir(src.c_str())) != nullptr)
+    {
+        while((ent = readdir(dir)) != nullptr)
+        {
+            File curFile;
+            curFile.first = addDirLastSlash(std::string(src));
+            curFile.second = std::string(ent->d_name);
+            retVal.push_back(curFile);
+        }
+        closedir(dir);
+    }
+    else
+        throw std::string("Directory could not be opened: " + src);
+
+    return retVal;
+}
+
+void FSHelper::copyFile(const std::string &src, const std::string &dest)
+{
+    std::ifstream srcStream(src, std::ios::in | std::ios_base::binary);
+
+    if(!srcStream.good())
+        throw std::string("Failed to open input file: " + src);
+
+    std::ofstream destStream(dest, std::ios::out |std::ios_base::binary);
+
+    if(!destStream.good())
+        throw std::string("Failed to open output file: " + dest);
+
+    destStream << srcStream.rdbuf();
+
+    destStream.close();
+    srcStream.close();
+
+}
+
+void FSHelper::makeDir(const std::string &dir)
+{
+    if(!dirExists(dir))
+#if defined(_WIN32)
+        if(mkdir(dir.c_str()) < 0)
+#else
+        if(mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0)
+#endif
+            throw std::string("Failed to create directory: " + dir);
+
+}
+
+void FSHelper::createFile(const std::string &path)
+{
+    std::ofstream file(path, std::ios::out);
+
+    if(!file.good())
+        throw std::string("Failed to create file: " + path);
+
+    file.close();
+}
+
+void FSHelper::removeFile(const std::string &path)
+{
+    if(!fileExists(path))
+        return;
+
+    remove(path.c_str());
+}
+
+void FSHelper::copyDir(const std::string &src, const std::string &dest)
+{
+    std::string from = addDirLastSlash(src);
+    std::string to = addDirLastSlash(dest);
+
+    if(!dirExists(addDirLastSlash(from)))
+        throw std::string("Source folder does not exist: " + from);
+
+    try
+    {
+        makeDir(to);
+    }
+    catch(std::string& e)
+    {
+        throw std::string("Could not create destination folder: " + to);
+    }
+
+    std::vector<File> files;
+    if(!listFilesRecursive(from, files, true))
+        throw std::string("Could not fetch source folder content: " + from);
+
+    std::vector<std::string> folders;
+    if(!listDirsRecursive(from, folders, true))
+        throw std::string("Could not fetch source folder directory tree: " + from);
+
+    // Erstelle Ordnerbaum
+    for(auto folder : folders)
+    {
+        folder.replace(folder.find(from), from.length(), to);
+        try
+        {
+            makeDir(addDirLastSlash(folder));
+        }
+        catch(std::string& e)
+        {
+            throw std::string("Could not create directory tree in destination directory! Failed on: " + folder);
+        }
+
+    }
+
+    // Kopiere Dateien
+    for(auto inFile : files)
+    {
+        File outFile = inFile;
+        unsigned int idx = 0;
+
+        // ersetze Qellordner mit zielordner
+        outFile.first.replace(outFile.first.find(from), from.length(), to);
+        try
+        {
+            makeDir(addDirLastSlash(outFile.first));
+        }
+        catch(std::string& e)
+        {
+            throw std::string("Could not create subfolder in destination directory! Failed on: " + outFile.first);
+        }
+
+        try
+        {
+            copyFile(inFile.first + inFile.second, outFile.first + outFile.second);
+        }
+        catch(std::string& e)
+        {
+            throw std::string("Could not copy file: " + inFile.first + inFile.second);
+        }
+
+    }
+}
+
+
+bool FSHelper::validFileName(const std::string &fName)
+{
+    char invalidChars[] = { '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '~', '`', ' ', '\\',
+                            ';', ':', '+', '=', '*', '/', '<', '>', '?', ',', '[', ']', '{', '}'
+                          };
+
+    int pos = fName.find_first_of(invalidChars, 0, sizeof(invalidChars));
+    if (pos != std::string::npos)
+        return false;
+
+    return true;
+}
+
+bool FSHelper::dirExists(const std::string &directory)
+{
+    std::string dir = rmDirLastSlash(directory);
+
+    // überprüfe existenz
+    struct stat info;
+    if( stat( dir.c_str(), &info ) != 0 )
+        return false;
+    if( info.st_mode & S_IFDIR )
+        return true;
+    else
+        return false;
+}
+
+bool FSHelper::fileExists(const std::string &file)
+{
+    std::ifstream f(file);
+    bool retVal = f.good();
+    f.close();
+    return retVal;
+}
+
+std::string FSHelper::addDirLastSlash(const std::string &dir)
+{
+    if(dir.back() != '\\' && dir.back() != '/')
+#if defined(_WIN32)
+        return dir + "\\";
+#else
+        return dir + "/";
+#endif
+    else
+        return dir;
+}
+
+std::string FSHelper::rmDirLastSlash(const std::string &dir)
+{
+    if(dir.back() == '\\' || dir.back() == '/')
+        return dir.substr(0, dir.size()-1);
+    else
+        return dir;
+}
+
+bool FSHelper::listFilesRecursive(const std::string& path, std::vector<FSHelper::File>& files,const bool showHiddenDirs)
+{
+    std::string dir = addDirLastSlash(path);
+    DIR *dpdf;
+    struct dirent *epdf;
+    dpdf = opendir(dir.c_str());
+    if(dpdf != nullptr)
+    {
+        while((epdf = readdir(dpdf)) != nullptr)
+        {
+            struct stat s;
+
+
+            if(stat((dir + std::string(epdf->d_name)).c_str(), &s) < 0)
+                return false;
+
+            if(S_ISREG(s.st_mode))
+            {
+                File curFile;
+
+                curFile.first = std::string(addDirLastSlash(dir));
+                curFile.second = std::string(epdf->d_name);
+                files.push_back(curFile);
+            }
+            else if(showHiddenDirs ? (S_ISDIR(s.st_mode) && std::string(epdf->d_name) != ".." && std::string(epdf->d_name) != "." ) :
+                    (S_ISDIR(s.st_mode) && strstr(epdf->d_name,"..") == NULL && strstr(epdf->d_name,".") == NULL ))
+            {
+                listFilesRecursive(dir+epdf->d_name,files, showHiddenDirs);
+            }
+        }
+    }
+    closedir(dpdf);
+    return true;
+}
+
+
+bool FSHelper::listDirsRecursive(const std::string &path, std::vector<std::string> &folders,const bool showHiddenDirs)
+{
+    std::string dir = addDirLastSlash(path);
+    DIR *dpdf;
+    struct dirent *epdf;
+    dpdf = opendir(dir.c_str());
+    if(dpdf != nullptr)
+    {
+        while((epdf = readdir(dpdf)) != nullptr)
+        {
+            struct stat s;
+
+            if(stat((dir + std::string(epdf->d_name)).c_str(), &s) < 0)
+                return false;
+
+            else if(showHiddenDirs ? (S_ISDIR(s.st_mode) && std::string(epdf->d_name) != ".." && std::string(epdf->d_name) != "." ) :
+                    (S_ISDIR(s.st_mode) && strstr(epdf->d_name,"..") == NULL && strstr(epdf->d_name,".") == NULL ))
+            {
+                if(!(std::find(folders.begin(), folders.end(), dir+epdf->d_name) != folders.end()))
+                    folders.push_back(addDirLastSlash(dir+epdf->d_name));
+                listDirsRecursive(dir+epdf->d_name,folders, showHiddenDirs);
+            }
+        }
+    }
+    closedir(dpdf);
+    return true;
+}
+
+std::string FSHelper::getCurrentWorkingDir()
+{
+    char temp[PATH_MAX];
+
+    if(getcwd(temp, PATH_MAX))
+#if defined(_WIN32)
+        return convertPathToWindows(temp);
+#else
+        return convertPathToUnix(temp);
+#endif
+
+    // leerer string bei fehler
+    return std::string("");
+}
+
+std::string FSHelper::convertPathToWindows(const std::string &dir)
+{
+    std::string retDir = dir;
+    std::replace(retDir.begin(), retDir.end(), '/', '\\');
+    return retDir;
+}
+
+std::string FSHelper::convertPathToUnix(const std::string &dir)
+{
+    std::string retDir = dir;
+    std::replace(retDir.begin(), retDir.end(), '\\', '/');
+    return retDir;
+}
+
+std::string FSHelper::findExecutableInPath(const std::string &executable)
+{
+    std::string path = getenv("PATH");
+
+#if defined(_WIN32)
+    char delim = ';';
+#else
+    char delim = ':';
+#endif
+
+    std::vector<std::string> tokens;
+    std::string token;
+    std::istringstream tokenStream(path);
+    while (std::getline(tokenStream, token, delim))
+    {
+        if(fileExists(addDirLastSlash(token) + executable))
+            return addDirLastSlash(token) + executable;
+
+        if(fileExists(addDirLastSlash(token) + executable + ".exe"))
+            return addDirLastSlash(token) + executable + ".exe";
+    }
+    throw std::string("Executable not found in PATH!: " + executable);
+}
+
+std::string FSHelper::getFileName(const std::string &file)
+{
+    std::string retFile = "";
+    unsigned int ind = file.find_last_of("/");
+    if(ind !=  std::string::npos)
+        retFile = file.substr(ind + 1, file.size());
+
+    ind = file.find_last_of("\\");
+    if(ind !=  std::string::npos)
+        retFile = file.substr(ind + 1, file.size());
+
+    return retFile;
+}
+
+std::string FSHelper::getPath(const std::string &file)
+{
+    std::string retFile = "";
+    unsigned int ind = file.find_last_of("/");
+    if(ind !=  std::string::npos)
+        retFile = file.substr(0, ind + 1);
+
+    ind = file.find_last_of("\\");
+    if(ind !=  std::string::npos)
+        retFile = file.substr(0, ind + 1);
+
+    return retFile;
+}
+
+void FSHelper::executeCommand(const std::string &path, const std::string &command, std::vector<std::string> params,const std::string &log)
+{
+
+    if((!path.empty()) && !dirExists(path))
+        throw std::string("Path does not exist: " + path);
+
+    std::string execCommand = findExecutableInPath(command);
+
+    if(!log.empty() && !fileExists(log))
+        createFile(log);
+
+
+#if defined(_WIN32)
+    std::string paramString;
+
+    for(auto curParam : params)
+        paramString = curParam + " ";
+
+    if(!log.empty())
+        paramString = paramString + " >> " + log;
+
+    // Benutze System, da CreateProcess nicht POSIX standardkonform ist
+    if(!path.empty())
+    {
+        // Laufwerkbuchstaben ermitteln
+        unsigned int ind = path.find_first_of(":");
+        if(ind ==  std::string::npos)
+            throw std::string("Illegal Path! Path does not cointain drive letter! :" + path);
+
+        std::string driveLetter = path.substr(0, ind+1);
+        system(std::string(driveLetter + " && cd " + path + " && " + execCommand + " " + paramString).c_str());
+    }
+    else
+        system(std::string(execCommand + " " + paramString).c_str());
+#else
+    // String vector zu char array
+    std::vector<char*> charParams;
+
+
+
+    if(!log.empty())
+        FILE* logFile = freopen(log.c_str(),"a",stdout);
+
+    // Param Array muss wie folgt aufgebaut sein:
+    // 0 -> command
+    // 1 -> param 1
+    // x -> param x
+    // last -> nullptr
+
+    // Falls DynLoader gesetzt ist dynloader erster parameter
+    // im array (weil command)
+    if(!mLinuxDynLoader.empty())
+    {
+        char *pc = new char[mLinuxDynLoader.size()+1];
+        std::strcpy(pc, mLinuxDynLoader.c_str());
+        charParams.emplace_back(pc);
+        execCommand = mLinuxDynLoader; //Auszuführender befehl ist dynloader, kommando
+        //ist dann erster parameter (= zweites element im array)
+    }
+
+    // Kommando zu array
+    char *pc = new char[findExecutableInPath(command).size()+1];
+    std::strcpy(pc, findExecutableInPath(command).c_str());
+    charParams.emplace_back(pc);
+
+    // param vector zu char array convertieren
+    std::transform(params.begin(), params.end(), std::back_inserter(charParams),
+                   [](const std::string & s)
+
+    {
+        char *pc = new char[s.size()+1];
+        std::strcpy(pc, s.c_str());
+        return pc;
+        ;
+    });
+    charParams.emplace_back(nullptr); //Letztes element muss ein nullpointer sein
+
+    int status;
+    pid_t parent_pid;
+    pid_t child_pid;
+    parent_pid = getpid();
+
+    child_pid = fork();
+    switch(child_pid)
+    {
+    case -1:
+        //Fork Fehler
+        std::exit(EXIT_FAILURE);
+        break;
+
+    case 0:
+        if(!path.empty())
+            if(chdir(path.c_str())!=0)
+                std::exit(EXIT_FAILURE);
+
+        execvp(execCommand.c_str(), &charParams[0]);
+
+        // bei fehler Char array im Child freigeben
+        for(auto curParam : charParams)
+            delete [] curParam;
+
+        // Soll nicht erreicht werden. Falls ja
+        // Child prozess beenden
+        std::exit(EXIT_FAILURE);
+        break;
+
+    default:
+        // OK
+        break;
+    }
+
+    // Auf child warten
+    wait(&status);
+
+    // Char array freigeben
+    for(auto curParam : charParams)
+        delete [] curParam;
+
+    // Logfile schliessen
+    fcloseall();
+
+    if(!WIFEXITED(status))
+        throw std::string("Could not execute command: " + command);
+#endif
+}
+
+
+void FSHelper::setLinuxDynLoader(const std::string &Loader)
+{
+#ifndef _WIN32
+    if(!fileExists(Loader))
+        throw std::string("Specified Loader does not exist: " + Loader);
+#endif
+
+    mLinuxDynLoader = Loader;
+}
+
+
+std::string FSHelper::getLinuxDynLoader()
+{
+    return mLinuxDynLoader;
+}
+
+
+void FSHelper::removeLinuxDynLoader()
+{
+    mLinuxDynLoader.clear();
+}
diff --git a/_template/src/FSHelper.h b/_template/src/FSHelper.h
new file mode 100644 (file)
index 0000000..45d93fd
--- /dev/null
@@ -0,0 +1,225 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: FSHelper.h
+// Author: Daniel Giritzer <daniel@giritzer.eu>
+// Date: 26.04.2018
+// Description: Diese Klasse stellt plattformunabhängige funktionen auf das
+//              Dateisystem zur verfügung. Bei fehler werden exeptions
+//              des Typs std::string geworfen.
+// Remarks: -
+///////////////////////////////////////////////////////////////////////////
+#ifndef FSHELPER_H_INCLUDED
+#define FSHELPER_H_INCLUDED
+
+#include <iostream>
+#include <vector>
+#include "Object.h"
+
+
+/////////////////////////////////////////////////
+/// \brief Diese Klasse beinhaltet Dateisystemfunktionen
+///        Basierend auf C++11 und POSIX-1 standart und funktinieren
+///        somit auf Windows und Linux.
+/////////////////////////////////////////////////
+class FSHelper : public Object
+{
+public:
+/////////////////////////////////////////////////
+/// \brief Typedef für eine Datei. String Paar
+///        für Ordner und Dateiname.
+/////////////////////////////////////////////////
+    using File = std::pair<std::string, std::string>;
+
+/////////////////////////////////////////////////
+/// \brief Diese funktion gibt alle Deteien eines
+///        Ordners zurück.
+/// \param src Ordner dessen Dateien zurückgegeben
+///        werden sollen.
+/// \return Vector mit string Paaren der Dateien im
+///         gegebenen Verzeichnis beinhaltet.
+/////////////////////////////////////////////////
+    std::vector<File> listFiles(const std::string &src);
+
+/////////////////////////////////////////////////
+/// \brief Überprüft ob Ordner existiert
+/// \param dir Ordner
+/// \return bool true wenn Ordner existiert,
+///         ansonsten false.
+/////////////////////////////////////////////////
+    bool dirExists(const std::string &dir);
+
+/////////////////////////////////////////////////
+/// \brief Überprüft ob Datei existiert
+/// \param file Datei
+/// \return bool true wenn Datei existiert,
+///         ansonsten false.
+/////////////////////////////////////////////////
+    bool fileExists(const std::string &file);
+
+/////////////////////////////////////////////////
+/// \brief Diese funktion kopiert eine Datei.
+/// \param src Quelldatei
+/// \param dest Zieldatei
+/////////////////////////////////////////////////
+    void copyFile(const std::string &src,const std::string &dest);
+
+/////////////////////////////////////////////////
+/// \brief Diese funktion kopiert einen Ordner.
+/// \param src Quellordner
+/// \param dest Zielordner
+/////////////////////////////////////////////////
+    void copyDir(const std::string &src, const std::string &dest);
+
+/////////////////////////////////////////////////
+/// \brief Gibt aktuelles Arbeitsverzeichnis zurück.
+/// \return aktuelles Arbeitsverzeichnis.
+/////////////////////////////////////////////////
+    std::string getCurrentWorkingDir();
+
+/////////////////////////////////////////////////
+/// \brief Strenge Dateinamenüberprüfung. Überprüft
+///        Dateinamen auf untypische zeichen.
+/// \param src Dateiname
+/// \return bool true wenn Dateiname kein untypisches
+///         Zeichen beinhaltet, ansonsten false.
+/////////////////////////////////////////////////
+    bool validFileName(const std::string &fName);
+
+/////////////////////////////////////////////////
+/// \brief Ersetzt alle / mit \\
+/// \param dir Zu verarbeitender pfad
+/// \return pfad mit ersetzten Zeichen
+/////////////////////////////////////////////////
+    std::string convertPathToWindows(const std::string &dir);
+
+/////////////////////////////////////////////////
+/// \brief Ersetzt alle \\ mit /
+/// \param dir Zu verarbeitender pfad
+/// \return pfad mit ersetzten Zeichen
+/////////////////////////////////////////////////
+    std::string convertPathToUnix(const std::string &dir);
+
+/////////////////////////////////////////////////
+/// \brief Fügt, falls fehlend, einen Slash an
+///        das ende eines Pfades.
+/// \param dir pfad
+/// \return pfad garantiert mit slash am ende
+/////////////////////////////////////////////////
+    std::string addDirLastSlash(const std::string &dir);
+
+/////////////////////////////////////////////////
+/// \brief Entfernt, falls existent, einen Slash
+///        am ende eines Pfades.
+/// \param dir Pfad
+/// \return Pfad garantiert ohne slash am ende
+/////////////////////////////////////////////////
+    std::string rmDirLastSlash(const std::string &dir);
+
+/////////////////////////////////////////////////
+/// \brief Erstellt einen Ordner.
+/// \param dir pfad des zu erstellenden Ordners.
+/////////////////////////////////////////////////
+    void makeDir(const std::string &dir);
+
+/////////////////////////////////////////////////
+/// \brief Erstellt eine Datei.
+/// \param path Pfad + Dateiname der zu erstellenden Datei.
+/////////////////////////////////////////////////
+    void createFile(const std::string &path);
+
+/////////////////////////////////////////////////
+/// \brief Löscht eine Datei.
+/// \param path Pfad + Dateiname der zu löschenden Datei.
+/////////////////////////////////////////////////
+    void removeFile(const std::string &path);
+
+/////////////////////////////////////////////////
+/// \brief Diese funktion gibt alle Deteien eines
+///        Ordners und dessen Unterordner zurück.
+/// \param [IN] src Ordner dessen Dateien zurückgegeben
+///        werden sollen.
+/// \param [OUT] files Vektor mit String Paaren aller gefundenen Dateien
+///              und deren Pfad.
+/// \param [IN] Optional, Gibt an ob auch versteckte Unterordner
+///        durchsucht werden sollen. (true ja,
+///        false nein)
+/// \return true bei erfolg, false bei fehler
+/////////////////////////////////////////////////
+    bool listFilesRecursive(const std::string &path, std::vector<FSHelper::File> &files,const bool showHiddenDirs);
+
+/////////////////////////////////////////////////
+/// \brief Diese funktion gibt rekursiv alle Unterordner eines
+///        Ordners zurück.
+/// \param [IN] src Ordner dessen Dateien zurückgegeben
+///        werden sollen.
+/// \param [OUT] string Vektor mit allen gefundenen Ordnern
+/// \param [IN] Optional, Gibt an ob auch versteckte Unterordner
+///        durchsucht werden sollen. (true ja,
+///        false nein)
+/// \return true bei erfolg, false bei fehler
+/////////////////////////////////////////////////
+    bool listDirsRecursive(const std::string &path, std::vector<std::string>& dirs,const bool showHiddenDirs);
+
+/////////////////////////////////////////////////
+/// \brief Diese funktion führt einen Befehl/ein Programm
+///        aus.
+/// \param path Pfad in dem der Befehl ausgeführt werden soll
+/// \param command Auszuführender Befehl
+/// \param params Bafehlsparameter
+/// \param log optional, Pfad zu einer datei, in der die Konsolenausgabe
+///        des Befehls geschrieben werden soll.
+/////////////////////////////////////////////////
+    void executeCommand(const std::string &path, const std::string &command, std::vector<std::string> params,const std::string &log = "");
+
+/////////////////////////////////////////////////
+/// \brief Diese funktion setzt einen Dynamischen
+///        Loader, der für das ausführen von Programmen
+///        mit executeCommand auf Linux Systemen
+///        verwendet werden soll.
+/// \param Loader Pfad zum Loader
+/////////////////////////////////////////////////
+    void setLinuxDynLoader(const std::string &Loader);
+
+/////////////////////////////////////////////////
+/// \brief Diese funktion gibt den gesetzten Loader
+///        retour.
+/// \return gesetzter Loader
+/////////////////////////////////////////////////
+    std::string getLinuxDynLoader();
+
+/////////////////////////////////////////////////
+/// \brief Diese funktion entfernt einen gesetzten Loader.
+///        Programme die mit executeCommand ausgeführt
+///        werden, verwenden dann den standard Loader
+///        des Systems.
+/////////////////////////////////////////////////
+    void removeLinuxDynLoader();
+
+/////////////////////////////////////////////////
+/// \brief Durchsucht PATH nach übergebenem Kommando.
+///        Gibt vollständigen Pfad zur Datei des Kommandos
+///        retour.
+/// \param executable Kommando dessen executable gesucht werden soll
+/// \return vollständiger Pfad zur executable.
+/////////////////////////////////////////////////
+    std::string findExecutableInPath(const std::string &executable);
+
+/////////////////////////////////////////////////
+/// \brief Gibt Dateinamen einer Datei mit Pfad retour.
+/// \param file Dateiname mit Pfad
+/// \return Dateiname
+/////////////////////////////////////////////////
+    std::string getFileName(const std::string &file);
+
+/////////////////////////////////////////////////
+/// \brief Gibt Pfad einer Datei mit Pfad retour.
+/// \param file Dateiname mit Pfad
+/// \return Pfad
+/////////////////////////////////////////////////
+    std::string getPath(const std::string &file);
+
+private:
+    std::string mLinuxDynLoader;
+
+};
+
+#endif // FSHELPER_H_INCLUDED
diff --git a/_template/src/Model.cxx b/_template/src/Model.cxx
new file mode 100644 (file)
index 0000000..ca0874b
--- /dev/null
@@ -0,0 +1,14 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Model.cxx
+// Author: Daniel Giritzer <daniel@giritzer.eu>
+// Date:
+// Description: Diese Klasse stellt die Daten und Programmlogik dieses
+//              Programmes dar.
+// Remarks:
+///////////////////////////////////////////////////////////////////////////
+#include "Model.h"
+void Model::throwException()
+{
+    throw std::string("Exception!!");
+}
+
diff --git a/_template/src/Model.h b/_template/src/Model.h
new file mode 100644 (file)
index 0000000..6cfb2a1
--- /dev/null
@@ -0,0 +1,29 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Model.h
+// Author: Daniel Giritzer <daniel@giritzer.eu>
+// Date:
+// Description: Diese Klasse stellt die Daten und Programmlogik dieses
+//              Programmes dar.
+// Remarks:
+///////////////////////////////////////////////////////////////////////////
+#ifndef MODEL_H
+#define MODEL_H
+
+#include "ModelIF.h"
+/////////////////////////////////////////////////
+/// \brief Implementierung des Model
+///        Interfaces. Implementiert alle
+///        im Interface definierten funktionen.
+///        Diese Klasse stellt die Daten und Programmlogik dieses
+///        Programmes dar und stellt neben den Interface Funktionen
+///        auch Funktionen zum erhalt von Daten und Befehlen von
+///        einem Controller zur verfügung.
+/////////////////////////////////////////////////
+class Model : public ModelIF
+{
+public:
+    // --- Implementierung Interface
+    void throwException() override;
+};
+
+#endif // MODEL_H
diff --git a/_template/src/ModelIF.h b/_template/src/ModelIF.h
new file mode 100644 (file)
index 0000000..d5d1d64
--- /dev/null
@@ -0,0 +1,38 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: ModelIF.h
+// Author: Daniel Giritzer <daniel@giritzer.eu>
+// Date:
+// Description: Interface für die Model Klasse.
+// Remarks: Dieses Interface definiert alle von einem View
+//          benötigten Funktionen.
+///////////////////////////////////////////////////////////////////////////
+#ifndef MODELIF_H_INCLUDED
+#define MODELIF_H_INCLUDED
+
+#include <memory>
+#include "Subject.h"
+
+/////////////////////////////////////////////////
+/// \brief Interface für die Model Klasse.
+///        Dieses Interface definiert alle von einem View
+///        benötigten Funktionen um Daten abzufragen.
+/////////////////////////////////////////////////
+class ModelIF : public Subject
+{
+public:
+    /////////////////////////////////////////////////
+    /// \brief Typedef für einen shared Pointer auf
+    ///        ein Objekt dieser Klasse.
+    /////////////////////////////////////////////////
+    using SPtr = std::shared_ptr<ModelIF>;
+
+    /////////////////////////////////////////////////
+    /// \brief Wirft eine std::string eine Exception.
+    /////////////////////////////////////////////////
+    virtual void throwException() = 0;
+
+protected:
+    ModelIF() = default;
+};
+
+#endif // MODELIF_H_INCLUDED
diff --git a/_template/src/Object.h b/_template/src/Object.h
new file mode 100644 (file)
index 0000000..779884a
--- /dev/null
@@ -0,0 +1,24 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Object.h
+// Author: Daniel Giritzer <daniel@giritzer.eu>
+// Date: 23.11.2016
+// Description: Basisklasse aller Klassen.
+// Remarks: Alle Klassen leiten von Object ab.
+///////////////////////////////////////////////////////////////////////////
+
+#ifndef OBJECT_H
+#define OBJECT_H
+
+/////////////////////////////////////////////////
+/// \brief Basisklasse aller Klassen.
+/////////////////////////////////////////////////
+class Object
+{
+
+public:
+    virtual ~Object() = default;
+protected:
+    Object() = default;
+};
+
+#endif //OBJECT_H
diff --git a/_template/src/Observer.cxx b/_template/src/Observer.cxx
new file mode 100644 (file)
index 0000000..e16c4e1
--- /dev/null
@@ -0,0 +1,68 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Observer.cpp
+// Author: Daniel Giritzer <daniel@giritzer.eu>
+// Date: 25.03.2018
+// Description: Interface für eine Observer Klasse.
+// Remarks: -
+///////////////////////////////////////////////////////////////////////////
+
+#include "Observer.h"
+#include "Subject.h"
+#include <algorithm>
+
+/////////////////////////////////////////////////
+/// \brief Füge ein zu überwachendes Objekt hinzu.
+/// \param s Zu überwachendes Objekt.
+/////////////////////////////////////////////////
+void Observer::subscribeSubject(Subject* s)
+{
+    if(s == nullptr)
+        throw std::string("Nullpointer given as Subject!");
+
+    mSubjects.push_back(s);
+    s->subscribeObserver(this);
+}
+
+/////////////////////////////////////////////////
+/// \brief Entferne ein überwachtes Objekt.
+/// \param s Bereits überwachetes Objekt.
+/////////////////////////////////////////////////
+void Observer::unsubscribeSubject(Subject* s)
+{
+    if(s == nullptr)
+        throw std::string("Nullpointer given as Subject!");
+
+    if(!(std::find(mSubjects.begin(), mSubjects.end(), s) != mSubjects.end()))
+        throw std::string("Not subscribed to this subject!");
+
+
+    mSubjects.remove(s);
+    s->unsubscribeObserver(this);
+}
+
+/////////////////////////////////////////////////
+/// \brief Von Subject Klassen verwendete funktion
+///        um Observer über änderungen zu
+///        benachrichtigen.
+/// \param s Objekt mit änderungen.
+/////////////////////////////////////////////////
+void Observer::updateObserver(Subject* s)
+{
+    bool found = false;
+    if(s == nullptr)
+        throw std::string("Nullpointer given as Subject!");
+
+    for(auto curSub : mSubjects)
+    {
+        if(curSub == s)
+        {
+            //Funktionsaufruf der Observer
+            //Implementierung
+            updatedBySubject(curSub);
+            found = true;
+        }
+    }
+
+    if(!found)
+        throw std::string("Update called by unknown Subject!");
+}
diff --git a/_template/src/Observer.h b/_template/src/Observer.h
new file mode 100644 (file)
index 0000000..57797b5
--- /dev/null
@@ -0,0 +1,57 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Observer.h
+// Author: Daniel Giritzer <daniel@giritzer.eu>
+// Date: 25.03.2018
+// Description: Interface für eine Observer Klasse.
+// Remarks: -
+///////////////////////////////////////////////////////////////////////////
+#ifndef OBSERVER_H_INCLUDED
+#define OBSERVER_H_INCLUDED
+
+#include <memory>
+#include <list>
+#include "Object.h"
+
+class Subject;
+
+/////////////////////////////////////////////////
+/// \brief Interface fuer einen Observer.
+/////////////////////////////////////////////////
+class Observer : public Object
+{
+public:
+    /////////////////////////////////////////////////
+    /// \brief Diese Funktion wird in der Implementierung
+    ///        bei änderungen eines überwachten Objektes
+    ///        aufgerufen.
+    /// \param s Objekt mit änderungen.
+    /////////////////////////////////////////////////
+    virtual void updatedBySubject(Subject* s) = 0;
+
+    /////////////////////////////////////////////////
+    /// \brief Füge ein zu überwachendes Objekt hinzu.
+    /// \param s Zu überwachendes Objekt.
+    /////////////////////////////////////////////////
+    void subscribeSubject(Subject* s);
+
+    /////////////////////////////////////////////////
+    /// \brief Entferne ein überwachtes Objekt.
+    /// \param s Bereits überwachetes Objekt.
+    /////////////////////////////////////////////////
+    void unsubscribeSubject(Subject* s);
+
+    /////////////////////////////////////////////////
+    /// \brief Von Subject Klassen verwendete funktion
+    ///        um Observer über änderungen zu
+    ///        benachrichtigen.
+    /// \param s Objekt mit änderungen.
+    /////////////////////////////////////////////////
+    void updateObserver(Subject* s);
+
+protected:
+    Observer() = default;
+    std::list<Subject*> mSubjects;
+
+};
+
+#endif // OBSERVER_H_INCLUDED
diff --git a/_template/src/Subject.cxx b/_template/src/Subject.cxx
new file mode 100644 (file)
index 0000000..4335833
--- /dev/null
@@ -0,0 +1,48 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Subject.cxx
+// Author: Daniel Giritzer <daniel@giritzer.eu>
+// Date: 25.03.2018
+// Description: Interface für von Observer zu überwachende Objekte.
+// Remarks: -
+///////////////////////////////////////////////////////////////////////////
+#include "Subject.h"
+#include <algorithm>
+
+/////////////////////////////////////////////////
+/// \brief Füge einen Observer hinzu.
+/// \param o Shared Pointer auf ein Observer Objekt.
+/////////////////////////////////////////////////
+void Subject::subscribeObserver(Observer* o)
+{
+    if(o == nullptr)
+        throw std::string("Nullpointer given as Observer!");
+
+    mObservers.push_back(o);
+}
+
+/////////////////////////////////////////////////
+/// \brief Entferne ein Observer Objekt.
+/// \param o Shared Pointer auf zu entfernendes Observer
+///        Objekt.
+/////////////////////////////////////////////////
+void Subject::unsubscribeObserver(Observer* o)
+{
+    if(o == nullptr)
+        throw std::string("Nullpointer given as Observer!");
+
+    if(!(std::find(mObservers.begin(), mObservers.end(), o) != mObservers.end()))
+        throw std::string("Given Observer has not subscribed!");
+
+    mObservers.remove(o);
+}
+
+/////////////////////////////////////////////////
+/// \brief Benachrichtige alle Observer.
+/////////////////////////////////////////////////
+void Subject::notifyObservers()
+{
+    for(auto o : mObservers)
+    {
+        o->updateObserver(this);
+    }
+}
diff --git a/_template/src/Subject.h b/_template/src/Subject.h
new file mode 100644 (file)
index 0000000..8c6af11
--- /dev/null
@@ -0,0 +1,51 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: Subject.h
+// Author: Daniel Giritzer <daniel@giritzer.eu>
+// Date: 25.03.2018
+// Description: Interface für von Observer zu überwachende Objekte.
+// Remarks: -
+///////////////////////////////////////////////////////////////////////////
+#ifndef SUBJECT_H_INCLUDED
+#define SUBJECT_H_INCLUDED
+
+#include <memory>
+#include <list>
+#include "Observer.h"
+#include "Object.h"
+
+/////////////////////////////////////////////////
+/// \brief Interface für ein von einem Observer
+///        zu überwachendes Objekt.
+/////////////////////////////////////////////////
+class Subject : public Object
+{
+public:
+
+    /////////////////////////////////////////////////
+    /// \brief Füge einen Observer hinzu.
+    /// \param o Pointer auf ein Observer Objekt.
+    /////////////////////////////////////////////////
+    virtual void subscribeObserver(Observer* o);
+
+    /////////////////////////////////////////////////
+    /// \brief Entferne ein Observer Objekt.
+    /// \param o Pointer auf zu entfernendes Observer
+    ///        Objekt.
+    /////////////////////////////////////////////////
+    virtual void unsubscribeObserver(Observer* o);
+
+    /////////////////////////////////////////////////
+    /// \brief Benachrichtige alle Observer.
+    /////////////////////////////////////////////////
+    virtual void notifyObservers();
+
+
+protected:
+    Subject() = default;
+
+private:
+    //Liste alle Observer
+    std::list<Observer*> mObservers;
+};
+
+#endif // SUBJECT_H_INCLUDED
diff --git a/_template/src/View.cxx b/_template/src/View.cxx
new file mode 100644 (file)
index 0000000..96371e6
--- /dev/null
@@ -0,0 +1,79 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: View.cxx
+// Author: Daniel Giritzer <daniel@giritzer.eu>
+// Date:
+// Description: Diese Klasse stellt eine platformunabhängige Visualisierung
+//              des Models zur verfügung.
+// Remarks: -
+///////////////////////////////////////////////////////////////////////////
+#include "View.h"
+#include <iostream>
+#include <FL/fl_ask.H>
+
+View::View(ControllerIF::SPtr contr, ModelIF::SPtr model)
+{
+    mController = contr;
+    mModel = model;
+    subscribeSubject(mModel.get());
+}
+
+View::~View()
+{
+    win_exmpl->hide();
+
+    // Ressourcen freigeben
+    Fl::delete_widget(win_exmpl);
+    unsubscribeSubject(mModel.get());
+}
+
+void View::updatedBySubject(Subject* s)
+{
+    if(s == nullptr)
+        throw std::string("Nullpointer given as Subject!");
+
+        try
+        {
+
+            // Lade Daten von Model hier implementieren
+
+            win_exmpl->redraw();
+        }
+        // ----------- Exception Handling ------------
+        catch(std::string& e)
+        {
+            std::cerr << e << std::endl;
+            fl_alert(e.c_str()); //Textbox mit fehlermeldung
+        }
+}
+
+void View::show()
+{
+    // Setze fenster style global
+    Fl::scheme("gtk+");
+
+    // definiere callback funktionen
+    btn_exception->callback((Fl_Callback*)btn_exception_cb, (void*)(this) );
+
+    win_exmpl->show();
+}
+
+
+void View::btn_exception_cb(Fl_Button* btn, void* view)
+{
+    try
+    {
+        View* thisView = static_cast<View*>(view);
+        thisView->mController->throwException();
+    }
+    // ----------- Exception Handling ------------
+    catch(const std::string &e)
+    {
+        std::cerr << e << std::endl;
+        fl_alert(e.c_str()); //Textbox mit fehlermeldung
+    }
+    catch(...)
+    {
+        fl_alert("Unknown error occured!");
+        std::cerr << "Unknown error occured!" << std::endl;
+    }
+}
diff --git a/_template/src/View.h b/_template/src/View.h
new file mode 100644 (file)
index 0000000..1614128
--- /dev/null
@@ -0,0 +1,63 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: View.h
+// Author: Daniel Giritzer <daniel@giritzer.eu>
+// Date:
+// Description: Diese Klasse stellt eine platformunabhängige Visualisierung
+//              des Models zur verfügung.
+// Remarks: -
+///////////////////////////////////////////////////////////////////////////
+#ifndef VIEW_H
+#define VIEW_H
+
+#include "ViewFluid.h" //Generierte GUI Klasse
+#include "Observer.h"
+#include "ModelIF.h"
+#include "ControllerIF.h"
+/////////////////////////////////////////////////
+/// \brief Diese Klasse stellt eine platformunabhängige
+///        Visualisierung des Models zur verfügung
+///        und erweitert ViewFluid um funktionalität.
+///        View leitet von ViewFluid ab. ViewFluid
+///        ist eine mit fluid generierte Klasse
+///        und stellt die reine Visualisierung
+///        ohne Funktionalität dar.
+/////////////////////////////////////////////////
+class View : public ViewFluid, public Observer
+{
+public:
+
+    View(ControllerIF::SPtr contr, ModelIF::SPtr model);
+
+    /////////////////////////////////////////////////
+    /// \brief Destruktor. Beende überwachung von
+    ///        Model, gebe ressourcen frei.
+    /////////////////////////////////////////////////
+    ~View();
+
+    /////////////////////////////////////////////////
+    /// \brief Initialisiere GUI Callback funktionen
+    ///        und GUI elemente.
+    ///        Danach wird die View angezeigt.
+    /////////////////////////////////////////////////
+    void show();
+
+
+    /////////////////////////////////////////////////
+    /// \brief Ein überwachtes Objekt (Model) benachrichtigt
+    ///        bei änderungen diese Klasse über diese
+    ///        Funktion.
+    /// \param s Objekt mit änderungen.
+    /////////////////////////////////////////////////
+    void updatedBySubject(Subject* s);
+
+private:
+    ControllerIF::SPtr mController;
+    ModelIF::SPtr mModel;
+
+    // -------------------------------------------------
+    // ----------- FLTK Callback Funktionen ------------
+    // -------------------------------------------------
+    static void btn_exception_cb(Fl_Button* btn, void* view);
+};
+
+#endif //VIEW:H
diff --git a/_template/src/ViewFluid.cxx b/_template/src/ViewFluid.cxx
new file mode 100644 (file)
index 0000000..8d76f38
--- /dev/null
@@ -0,0 +1,16 @@
+// generated by Fast Light User Interface Designer (fluid) version 1.0304
+
+#include "ViewFluid.h"
+
+ViewFluid::ViewFluid() {
+  { win_exmpl = new Fl_Double_Window(340, 150, "Example");
+    win_exmpl->box(FL_GTK_DOWN_BOX);
+    win_exmpl->user_data((void*)(this));
+    win_exmpl->hotspot(win_exmpl);
+    { btn_exception = new Fl_Button(100, 45, 135, 45, "Throw Exception");
+    } // Fl_Button* btn_exception
+    win_exmpl->size_range(585, 555);
+    win_exmpl->end();
+    win_exmpl->resizable(win_exmpl);
+  } // Fl_Double_Window* win_exmpl
+}
diff --git a/_template/src/ViewFluid.fld b/_template/src/ViewFluid.fld
new file mode 100644 (file)
index 0000000..4cefb23
--- /dev/null
@@ -0,0 +1,19 @@
+# data file for the Fltk User Interface Designer (fluid)
+version 1.0304
+header_name {.h}
+code_name {.cxx}
+class ViewFluid {open
+} {
+  Function {ViewFluid()} {open protected
+  } {
+    Fl_Window win_exmpl {
+      label Example open selected
+      protected xywh {634 239 340 150} type Double box GTK_DOWN_BOX resizable hotspot size_range {585 555 0 0} visible
+    } {
+      Fl_Button btn_exception {
+        label {Throw Exception}
+        xywh {100 45 135 45}
+      }
+    }
+  }
+}
diff --git a/_template/src/ViewFluid.h b/_template/src/ViewFluid.h
new file mode 100644 (file)
index 0000000..ae437a5
--- /dev/null
@@ -0,0 +1,16 @@
+// generated by Fast Light User Interface Designer (fluid) version 1.0304
+
+#ifndef ViewFluid_h
+#define ViewFluid_h
+#include <FL/Fl.H>
+#include <FL/Fl_Double_Window.H>
+#include <FL/Fl_Button.H>
+
+class ViewFluid {
+protected:
+  ViewFluid();
+  Fl_Double_Window *win_exmpl;
+public:
+  Fl_Button *btn_exception;
+};
+#endif
diff --git a/_template/src/_template.cbp b/_template/src/_template.cbp
new file mode 100644 (file)
index 0000000..58c7374
--- /dev/null
@@ -0,0 +1,210 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<CodeBlocks_project_file>
+       <FileVersion major="1" minor="6" />
+       <Project>
+               <Option title="_template" />
+               <Option pch_mode="2" />
+               <Option compiler="gcc" />
+               <Build>
+                       <Target title="Release_Linux64">
+                               <Option output="bin/Release_Linux64/doc_tool" prefix_auto="1" extension_auto="1" />
+                               <Option object_output="obj/Release_Linux64/" />
+                               <Option type="0" />
+                               <Option compiler="gcc" />
+                               <Compiler>
+                                       <Add option="-O2" />
+                                       <Add option="-s" />
+                                       <Add directory="../src" />
+                               </Compiler>
+                               <Linker>
+                                       <Add option="-static-libstdc++" />
+                                       <Add option="-static-libgcc" />
+                                       <Add option="../lib/linux64/libfltk.a" />
+                                       <Add option="../lib/linux64/libtinyxml2.a" />
+                                       <Add option="-ldl" />
+                                       <Add option="-lm" />
+                                       <Add option="-lX11" />
+                                       <Add directory="../lib/linux64" />
+                               </Linker>
+                               <ExtraCommands>
+                                       <Add before="fluid -c ./ViewFluid.fld" />
+                               </ExtraCommands>
+                       </Target>
+                       <Target title="Release_Linux32">
+                               <Option output="bin/Release_Linux32/doc_tool" prefix_auto="1" extension_auto="1" />
+                               <Option object_output="obj/Release_Linux32/" />
+                               <Option type="0" />
+                               <Option compiler="gcc" />
+                               <Compiler>
+                                       <Add option="-O2" />
+                                       <Add option="-m32" />
+                                       <Add directory="../src" />
+                               </Compiler>
+                               <Linker>
+                                       <Add option="-m32" />
+                                       <Add option="-static-libstdc++" />
+                                       <Add option="-static-libgcc" />
+                                       <Add option="../lib/linux32/libfltk.a" />
+                                       <Add option="../lib/linux32/libtinyxml2.a" />
+                                       <Add option="-ldl" />
+                                       <Add option="-lm" />
+                                       <Add option="-lX11" />
+                                       <Add directory="../lib/linux32" />
+                               </Linker>
+                               <ExtraCommands>
+                                       <Add before="fluid -c ./ViewFluid.fld" />
+                               </ExtraCommands>
+                       </Target>
+                       <Target title="Release_Windows">
+                               <Option output="bin/Release_Windows/doc_tool" prefix_auto="1" extension_auto="1" />
+                               <Option object_output="obj/Release_Windows/" />
+                               <Option type="0" />
+                               <Option compiler="mingw32_compiler" />
+                               <Compiler>
+                                       <Add option="-O2" />
+                                       <Add option="-m32" />
+                                       <Add option="-mwindows" />
+                                       <Add option="-DWIN32" />
+                                       <Add option="-DUSE_OPENGL32" />
+                                       <Add option="-D_LARGEFILE_SOURCE" />
+                                       <Add option="-D_LARGEFILE64_SOURCE" />
+                                       <Add option="-D_FILE_OFFSET_BITS=64" />
+                                       <Add directory="../src" />
+                               </Compiler>
+                               <Linker>
+                                       <Add option="-m32" />
+                                       <Add option="-mwindows" />
+                                       <Add option="-static-libgcc" />
+                                       <Add option="-static-libstdc++" />
+                                       <Add option="../lib/mingw32/libfltk.a" />
+                                       <Add option="../lib/mingw32/libtinyxml2.a" />
+                                       <Add option="-lole32" />
+                                       <Add option="-luuid" />
+                                       <Add option="-lcomctl32" />
+                                       <Add directory="../lib/mingw32" />
+                               </Linker>
+                               <ExtraCommands>
+                                       <Add before="fluid -c ./ViewFluid.fld" />
+                               </ExtraCommands>
+                       </Target>
+                       <Target title="Debug_Linux64">
+                               <Option output="bin/Debug_Linux64/doc_tool" prefix_auto="1" extension_auto="1" />
+                               <Option object_output="obj/Debug_Linux64/" />
+                               <Option type="0" />
+                               <Option compiler="gcc" />
+                               <Compiler>
+                                       <Add option="-g" />
+                                       <Add directory="../src" />
+                               </Compiler>
+                               <Linker>
+                                       <Add option="-static-libstdc++" />
+                                       <Add option="-static-libgcc" />
+                                       <Add option="../lib/linux64/libfltk.a" />
+                                       <Add option="../lib/linux64/libtinyxml2.a" />
+                                       <Add option="-ldl" />
+                                       <Add option="-lm" />
+                                       <Add option="-lX11" />
+                                       <Add directory="../lib/linux64" />
+                               </Linker>
+                               <ExtraCommands>
+                                       <Add before="fluid -c ./ViewFluid.fld" />
+                               </ExtraCommands>
+                       </Target>
+                       <Target title="Debug_Linux32">
+                               <Option output="bin/Debug_Linux32/doc_tool" prefix_auto="1" extension_auto="1" />
+                               <Option object_output="obj/Debug_Linux32/" />
+                               <Option type="0" />
+                               <Option compiler="gcc" />
+                               <Compiler>
+                                       <Add option="-m32" />
+                                       <Add option="-g" />
+                                       <Add directory="../src" />
+                               </Compiler>
+                               <Linker>
+                                       <Add option="-m32" />
+                                       <Add option="-static-libstdc++" />
+                                       <Add option="-static-libgcc" />
+                                       <Add option="../lib/linux32/libfltk.a" />
+                                       <Add option="../lib/linux32/libtinyxml2.a" />
+                                       <Add option="-ldl" />
+                                       <Add option="-lm" />
+                                       <Add option="-lX11" />
+                                       <Add directory="../lib/linux32" />
+                               </Linker>
+                               <ExtraCommands>
+                                       <Add before="fluid -c ./ViewFluid.fld" />
+                               </ExtraCommands>
+                       </Target>
+                       <Target title="Debug_Windows">
+                               <Option output="bin/Debug_Windows/doc_tool" prefix_auto="1" extension_auto="1" />
+                               <Option object_output="obj/Debug_Windows/" />
+                               <Option type="0" />
+                               <Option compiler="mingw32_compiler" />
+                               <Compiler>
+                                       <Add option="-m32" />
+                                       <Add option="-g" />
+                                       <Add option="-mwindows" />
+                                       <Add option="-DWIN32" />
+                                       <Add option="-DUSE_OPENGL32" />
+                                       <Add option="-D_LARGEFILE_SOURCE" />
+                                       <Add option="-D_LARGEFILE64_SOURCE" />
+                                       <Add option="-D_FILE_OFFSET_BITS=64" />
+                                       <Add directory="../src" />
+                               </Compiler>
+                               <Linker>
+                                       <Add option="-m32" />
+                                       <Add option="-mwindows" />
+                                       <Add option="-static-libgcc" />
+                                       <Add option="-static-libstdc++" />
+                                       <Add option="../lib/mingw32/libfltk.a" />
+                                       <Add option="../lib/mingw32/libtinyxml2.a" />
+                                       <Add option="-lole32" />
+                                       <Add option="-luuid" />
+                                       <Add option="-lcomctl32" />
+                                       <Add directory="../lib/mingw32" />
+                               </Linker>
+                               <ExtraCommands>
+                                       <Add before="fluid -c ./ViewFluid.fld" />
+                               </ExtraCommands>
+                       </Target>
+               </Build>
+               <Compiler>
+                       <Add option="-std=c++11" />
+                       <Add directory="../include" />
+               </Compiler>
+               <Unit filename="Controller.cxx" />
+               <Unit filename="Controller.h" />
+               <Unit filename="ControllerIF.h" />
+               <Unit filename="FSHelper.cxx" />
+               <Unit filename="FSHelper.h" />
+               <Unit filename="Model.cxx" />
+               <Unit filename="Model.h" />
+               <Unit filename="ModelIF.h" />
+               <Unit filename="Object.h" />
+               <Unit filename="Observer.cxx" />
+               <Unit filename="Observer.h" />
+               <Unit filename="Subject.cxx" />
+               <Unit filename="Subject.h" />
+               <Unit filename="View.cxx" />
+               <Unit filename="View.h" />
+               <Unit filename="ViewFluid.cxx" />
+               <Unit filename="ViewFluid.fld" />
+               <Unit filename="ViewFluid.h" />
+               <Unit filename="main.cxx" />
+               <Extensions>
+                       <envvars />
+                       <code_completion />
+                       <debugger />
+                       <lib_finder disable_auto="1" />
+                       <DoxyBlocks>
+                               <comment_style block="5" line="0" />
+                               <doxyfile_project />
+                               <doxyfile_build />
+                               <doxyfile_warnings />
+                               <doxyfile_output />
+                               <doxyfile_dot />
+                               <general />
+                       </DoxyBlocks>
+               </Extensions>
+       </Project>
+</CodeBlocks_project_file>
diff --git a/_template/src/main.cxx b/_template/src/main.cxx
new file mode 100644 (file)
index 0000000..8515ba8
--- /dev/null
@@ -0,0 +1,67 @@
+///////////////////////////////////////////////////////////////////////////
+// Workfile: main.cxx
+// Author: Daniel Giritzer <daniel@giritzer.eu>
+// Date:
+// Description: Hauptprogramm initialisiert und instanziert alle Klassen.
+// Remarks:
+///////////////////////////////////////////////////////////////////////////
+#include <cstdlib>
+#include <iostream>
+#include "View.h"
+#include "Controller.h"
+#include "Model.h"
+#include "FSHelper.h"
+#include <FL/fl_ask.H>
+
+/////////////////////////////////////////////////
+/// \brief Hauptprogramm, Initialisiere Model,
+///        View und Controller.
+/////////////////////////////////////////////////
+int main()
+{
+    try
+    {
+        FSHelper FShelp;
+        std::string curDir = FShelp.getCurrentWorkingDir();
+        std::string confDir = FShelp.addDirLastSlash(curDir) + "etc";
+
+        try
+        {
+            // Benutze eigenen Loader
+            FShelp.setLinuxDynLoader(FShelp.addDirLastSlash(curDir) + "lib/ld-linux.so.2");
+        }
+        catch(std::string& e)
+        {
+            // Benutze Loader des Linux Betriebsystems
+            FShelp.removeLinuxDynLoader();
+        }
+
+        std::shared_ptr<Model> myModel {std::make_shared<Model>()};
+        Controller::SPtr myController {std::make_shared<Controller>(myModel)};
+
+        View myView(myController, myModel);
+        myView.show();
+
+        return Fl::run();
+    }
+
+    // ----------- Exception Handling ------------
+    catch(std::string& e)
+    {
+        std::cerr << e << std::endl;
+        fl_alert(e.c_str()); //Textbox mit fehlermeldung
+        return EXIT_FAILURE;
+    }
+    catch (std::bad_alloc const& e)
+    {
+        // Spezielle Ausnahme: Speicherallokierung misslungen
+        std::cerr << "Exeption Caught: Bad memory allocation ( " << e.what() << " )" << std::endl;
+        return EXIT_FAILURE;
+    }
+    catch (...)
+    {
+        std::cerr << "Unhandled exeption caught!" << std::endl;
+        return EXIT_FAILURE;
+    }
+
+}
diff --git a/setup.sh b/setup.sh
new file mode 100755 (executable)
index 0000000..d6bcdd2
--- /dev/null
+++ b/setup.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+if [ "$#" -ne 1 ]; then
+    echo "Usage: setup.sh name_of_project"
+    exit 1
+fi
+
+cp -rf ./_template ./$1
+find ./$1 -type f -exec sed -i 's/_template/'"$1"'/g' {} \;
+find ./$1 -depth -name '*_template*' -exec rename 's/_template/'"$1"'/' {} ";"
+