From ae5d6c91241ff76e29429c03463b9b2d937b063f Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Mon, 25 Feb 2019 14:28:47 +0100
Subject: [PATCH] improve and fix interface of rte elements

---
 .../src/rte/formal/FormalRTEAlternation.h     |  4 +-
 alib2data/src/rte/formal/FormalRTEIteration.h |  2 +-
 .../src/rte/formal/FormalRTESubstitution.h    |  4 +-
 .../src/rte/formal/FormalRTESymbolAlphabet.h  | 50 +++++++++++++++++++
 4 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/alib2data/src/rte/formal/FormalRTEAlternation.h b/alib2data/src/rte/formal/FormalRTEAlternation.h
index cedd459f6f..53b3f6d199 100644
--- a/alib2data/src/rte/formal/FormalRTEAlternation.h
+++ b/alib2data/src/rte/formal/FormalRTEAlternation.h
@@ -221,7 +221,7 @@ void FormalRTEAlternation < SymbolType, RankType >::setLeftElement ( const Forma
 
 template < class SymbolType, class RankType >
 void FormalRTEAlternation < SymbolType, RankType >::setLeftElement ( FormalRTEElement < SymbolType, RankType > && element ) {
-	setLeft ( std::move ( element ) );
+	this->setLeft ( std::move ( element ) );
 }
 
 template < class SymbolType, class RankType >
@@ -231,7 +231,7 @@ void FormalRTEAlternation < SymbolType, RankType >::setRightElement ( const Form
 
 template < class SymbolType, class RankType >
 void FormalRTEAlternation < SymbolType, RankType >::setRightElement ( FormalRTEElement < SymbolType, RankType > && element ) {
-	setRight ( std::move ( element ) );
+	this->setRight ( std::move ( element ) );
 }
 
 template < class SymbolType, class RankType >
diff --git a/alib2data/src/rte/formal/FormalRTEIteration.h b/alib2data/src/rte/formal/FormalRTEIteration.h
index 75f84d3b4a..07149c048e 100644
--- a/alib2data/src/rte/formal/FormalRTEIteration.h
+++ b/alib2data/src/rte/formal/FormalRTEIteration.h
@@ -221,7 +221,7 @@ void FormalRTEIteration < SymbolType, RankType >::setElement ( const FormalRTEEl
 
 template < class SymbolType, class RankType >
 void FormalRTEIteration < SymbolType, RankType >::setElement ( FormalRTEElement < SymbolType, RankType > && elementParam ) {
-	setChild ( std::move ( elementParam ) );
+	this->setChild ( std::move ( elementParam ) );
 }
 
 template < class SymbolType, class RankType >
diff --git a/alib2data/src/rte/formal/FormalRTESubstitution.h b/alib2data/src/rte/formal/FormalRTESubstitution.h
index a3bad01953..aefb4a13cc 100644
--- a/alib2data/src/rte/formal/FormalRTESubstitution.h
+++ b/alib2data/src/rte/formal/FormalRTESubstitution.h
@@ -260,7 +260,7 @@ void FormalRTESubstitution < SymbolType, RankType >::setLeftElement ( const Form
 
 template < class SymbolType, class RankType >
 void FormalRTESubstitution < SymbolType, RankType >::setLeftElement ( FormalRTEElement < SymbolType, RankType > && element ) {
-	setLeft ( std::move ( element ) );
+	this->setLeft ( std::move ( element ) );
 }
 
 template < class SymbolType, class RankType >
@@ -270,7 +270,7 @@ void FormalRTESubstitution < SymbolType, RankType >::setRightElement ( const For
 
 template < class SymbolType, class RankType >
 void FormalRTESubstitution < SymbolType, RankType >::setRightElement ( FormalRTEElement < SymbolType, RankType > && element ) {
-	setRight ( std::move ( element ) );
+	this->setRight ( std::move ( element ) );
 }
 
 template < class SymbolType, class RankType >
diff --git a/alib2data/src/rte/formal/FormalRTESymbolAlphabet.h b/alib2data/src/rte/formal/FormalRTESymbolAlphabet.h
index 0e7965b478..60b5f35052 100644
--- a/alib2data/src/rte/formal/FormalRTESymbolAlphabet.h
+++ b/alib2data/src/rte/formal/FormalRTESymbolAlphabet.h
@@ -99,6 +99,36 @@ public:
 	 */
 	const ext::ptr_vector < FormalRTEElement < SymbolType, RankType > > & getElements ( );
 
+	/**
+	 * Getter of child node on n-th position
+	 *
+	 * \return child node
+	 */
+	const FormalRTEElement < SymbolType, RankType > & getElement ( unsigned index ) const;
+
+	/**
+	 * Getter of child node on n-th position
+	 *
+	 * \return child node
+	 */
+	FormalRTEElement < SymbolType, RankType > & getElement ( unsigned index );
+
+	/**
+	 * Setter of the n-th child
+	 *
+	 * \param index the index of child to change
+	 * \param element the iterated tree
+	 */
+	void setElement ( unsigned index, const FormalRTEElement < SymbolType, RankType > & element );
+
+	/**
+	 * Setter of the n-th child
+	 *
+	 * \param index the index of child to change
+	 * \param element the iterated tree
+	 */
+	void setElement ( unsigned index, FormalRTEElement < SymbolType, RankType > && element );
+
 	/**
 	 * @copydoc base::CommonBase < FormalRTEElement < SymbolType, RankType > >::compare ( const FormalRTEElement < SymbolType, RankType > & ) const
 	 */
@@ -166,6 +196,26 @@ const ext::ptr_vector < FormalRTEElement < SymbolType, RankType > > & FormalRTES
 	return this->getChildren ( );
 }
 
+template < class SymbolType, class RankType >
+const FormalRTEElement < SymbolType, RankType > & FormalRTESymbolAlphabet < SymbolType, RankType >::getElement ( unsigned index ) const {
+	return this->getChild ( index );
+}
+
+template < class SymbolType, class RankType >
+FormalRTEElement < SymbolType, RankType > & FormalRTESymbolAlphabet < SymbolType, RankType >::getElement ( unsigned index ) {
+	return this->getChild ( index );
+}
+
+template < class SymbolType, class RankType >
+void FormalRTESymbolAlphabet < SymbolType, RankType >::setElement ( unsigned index, const FormalRTEElement < SymbolType, RankType > & element ) {
+	setElement ( index, ext::move_copy ( element ) );
+}
+
+template < class SymbolType, class RankType >
+void FormalRTESymbolAlphabet < SymbolType, RankType >::setElement ( unsigned index, FormalRTEElement < SymbolType, RankType > && elementParam ) {
+	this->setChild ( std::move ( elementParam ), index );
+}
+
 template < class SymbolType, class RankType >
 int FormalRTESymbolAlphabet < SymbolType, RankType >::compare ( const FormalRTESymbolAlphabet < SymbolType, RankType > & other ) const {
 	auto first = ext::tie ( this->getSymbol ( ), this->getChildren ( ) );
-- 
GitLab