Ph.D. - geht es zur Homepage der Informatik des Fachbereiches 3 ...
Ph.D. - geht es zur Homepage der Informatik des Fachbereiches 3 ...
Ph.D. - geht es zur Homepage der Informatik des Fachbereiches 3 ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
9.5. Implementation<br />
The openETCS generator application is implemented corr<strong>es</strong>pondingly to the methodology<br />
of the domain framework implementation. Hence, the general implementation strategy in<br />
Section 8.6, the programming language, and target platform in Subsection 8.6.1 are the same<br />
and not explicitly discussed here.<br />
9.5.1. libGOPPRR Implementation<br />
Although the structural d<strong>es</strong>ign of the GOPPRR C++ abstract syntax model was already<br />
introduced in Chapter 4, its implementation is discussed in this chapter because it is used by<br />
the generator application.<br />
All elements for defining a GOPPRR C++ abstract syntax model are declared as structs,<br />
which can be observed in Figure 4.4. In C++, the only difference between class<strong>es</strong> and structs is<br />
that in a class all elements are by default private visible [79]. For structs, the default visibility<br />
is public [79]. Since for the GOPPRR C++ abstract syntax model mainly a tree of data<br />
structur<strong>es</strong> has to be built, those are declared as structs to provide an easy and direct acc<strong>es</strong>s to<br />
their attribut<strong>es</strong> 2 . Hence, no methods need to be implemented for their acc<strong>es</strong>s.<br />
The only methods implemented in those structs are the on<strong>es</strong> used for abstraction, which<br />
were already mentioned in Section 4.2. Those are mainly located in the CGraph class 3 . Since<br />
they mainly focus on the abstraction of graph bindings (see Section 4.2), they are implemented<br />
by iterating over the local bindings m_BindingSet and the corr<strong>es</strong>ponding sub-structur<strong>es</strong>. As<br />
already exemplary introduced in Section 4.2 for the ::GOPPRR::CGraph:Rol<strong>es</strong>() method, the<br />
abstraction methods mainly use a certain GOPPRR C++ abstract syntax element instance<br />
(e.g. of ::GOPPRR::CObject) and the literal name of connected type that should be found.<br />
Generally, such search<strong>es</strong> can provide more than one object 4 . Hence, the abstraction methods<br />
always return a map of pointers to the matching instanc<strong>es</strong>. To facilitate the usage in the<br />
generator class<strong>es</strong>, which typically iterate over the returned map or use just the first element,<br />
an optional exception was introduced to handle situations if the returned map is empty. The<br />
usage of exceptions can be defined in all abstraction methods by the bUseException parameter.<br />
This means the generator do<strong>es</strong> not have to be implemented by an if-branch for each returned<br />
map to check it for non-emptin<strong>es</strong>s. Otherwise, the acc<strong>es</strong>s to an element of any empty map<br />
always caus<strong>es</strong> a segmentation fault [77, pp. 353-453]. Since in the most cas<strong>es</strong> the absence of<br />
an element type in a connection means a fault in the model, this is not manageable by the<br />
generator class<strong>es</strong> and the r<strong>es</strong>ulting error can be easily propagated by an exception.<br />
Unfortunately, until the end of this work, no general OCL parser and checker was available<br />
as OSS or FLOSS library that could have been directly integrated in the CConstraintChecker<br />
class implementation. As a work-around for the case study, some exemplary constraints for the<br />
static semantics in Section 7.5 were directly implemented in C++. Of course, those are only<br />
meaningful for openETCS meta model instanc<strong>es</strong>. For other meta models, the static semantics<br />
would have to be implemented additionally in C++.<br />
2 aggregations, compositions, and properti<strong>es</strong> from the d<strong>es</strong>ign<br />
3 C++ structs will be also called class<strong>es</strong> in this document because of the only small difference in C++.<br />
4 GOPPRR instance<br />
169