diff --git a/alib2aux/src/access/common/AccessHelpers.hpp b/alib2aux/src/access/common/AccessHelpers.hpp index ee32d1b95ce276d6c0b1d3428ccf9fd1b525850f..d1a9b9e71cbc996a49b017835c83363ad9413d35 100644 --- a/alib2aux/src/access/common/AccessHelpers.hpp +++ b/alib2aux/src/access/common/AccessHelpers.hpp @@ -12,16 +12,16 @@ namespace dataAccess { template < class Element, class DataType > void handleElement ( DataType & data, const OperationSettings::Settings & operation, ext::deque < sax::Token > & argument ) { - typedef typename std::remove_const < typename std::remove_reference < decltype ( data.template accessElement < Element > ( ).get ( ) ) >::type >::type ElementDataType; + typedef typename std::remove_const < typename std::remove_reference < decltype ( data.template accessComponent < Element > ( ).get ( ) ) >::type >::type ElementDataType; if ( operation == OperationSettings::Settings::GET ) { - alib::XmlDataFactory::toStdout ( data.template accessElement < Element > ( ).get ( ) ); + alib::XmlDataFactory::toStdout ( data.template accessComponent < Element > ( ).get ( ) ); } if ( operation == OperationSettings::Settings::SET ) { ElementDataType symbols = alib::XmlDataFactory::fromTokens ( std::move ( argument ) ); - data.template accessElement < Element > ( ).set ( std::move ( symbols ) ); + data.template accessComponent < Element > ( ).set ( std::move ( symbols ) ); alib::XmlDataFactory::toStdout ( data ); } diff --git a/alib2common/src/core/components.hpp b/alib2common/src/core/components.hpp index 63c2fe0a5667d88ae6b72e6e4ac211de13bbf723..e2b2956fb6f338f6f4a4ff6bc66ab4cd6f88d5b5 100644 --- a/alib2common/src/core/components.hpp +++ b/alib2common/src/core/components.hpp @@ -5,199 +5,28 @@ * Author: Jan Travnicek */ -#ifndef COMPONENTS_HPP_ -#define COMPONENTS_HPP_ +#ifndef _COMPONENTS_HPP_ +#define _COMPONENTS_HPP_ -#include <set> -#include <algorithm> -#include <utility> -#include <tuple> #include <typeinfo> -#include "../exception/CommonException.h" +#include <exception/CommonException.h> -namespace alib { +namespace component { -template < class Derived, class DataType, class SetType > -class ComponentConstraint { -public: - /** - * Checks whether a concrete element is used in context of the datatype where the set is used - * - * To be implemented by all template instantiations explicitly - * - * @param element to check - * @return true if element is used - * false if element is not used - */ - static bool used ( const Derived & object, const DataType & symbol ); +class Value; - /** - * Checks whether a concrete element is available in context of the datatype where the set is used - * - * To be implemented by all template instantiations explicitly - * - * @param element to check - * @return true if element is available - * false if element is not available - */ - static bool available ( const Derived & object, const DataType & symbol ); +} /* namespace component */ - /** - * Checks whether a concrete element is valid in context of the datatype where the set is used - * - * To be implemented by all template instantiations explicitly - * - * @param element to check - * @throw CommonException if the element in any way invalid - */ - static void valid ( const Derived & object, const DataType & symbol ); -}; +namespace alib { /** - * Represents a set of elements. - * @param Derived class representing datatype using this set. - * @param DataType underlying type of symbols in the set. - * @param SetType arbitrary type used to distinguish different sets. + * Pack of containt check functions for element component */ -template < class Derived, class DataType, class SetType > -class Component { - /** - * The set. - */ - ext::set < DataType > m_data; - - /** - * Checks whether symbol can be added to the set. Calls valid and available functions. - * @throws CommonException if symbol cannot be added. - */ - void checkAdd ( const DataType & symbol ) { - ComponentConstraint < Derived, DataType, SetType >::valid ( static_cast < const Derived & > ( * this ), symbol ); - - if ( !ComponentConstraint < Derived, DataType, SetType >::available ( static_cast < const Derived & > ( * this ), symbol ) ) { - std::string elementTypeName ( ext::to_string < SetType * > ( ) ); - elementTypeName.back ( ) = ' '; - throw::exception::CommonException ( elementTypeName + "element " + ext::to_string ( symbol ) + " is not available." ); - } - } - - /** - * Checks whether symbol can be removed from the set. Calls used function. - * @throws CommonException if symbol cannot be removed. - */ - void checkRemove ( const DataType & symbol ) { - if ( ComponentConstraint < Derived, DataType, SetType >::used ( static_cast < const Derived & > ( * this ), symbol ) ) { - std::string elementTypeName ( ext::to_string < SetType * > ( ) ); - elementTypeName.back ( ) = ' '; - throw::exception::CommonException ( elementTypeName + "element " + ext::to_string ( symbol ) + " is used." ); - } - } - -protected: - /** Checks the state of the set. - */ - void checkState ( ) { - for ( const DataType & symbol : m_data ) - checkAdd ( symbol ); - } - -public: - /** - * Constructs a set containing given elements. - * @throw CommonException if elements are not available in context of datatype where the set is used - */ - Component ( ext::set < DataType > symbols ) : m_data ( std::move ( symbols ) ) { - } - - /** - * Adds an elements to the set. - * @param element to add to the set - * @throw CommonException if element is not available in context of datatype where the set is used - * @return true if element was indeed added - * false if element was present in the set - */ - bool add ( DataType symbol ) { - checkAdd ( symbol ); - return m_data.insert ( std::move ( symbol ) ).second; - } - - /** - * Adds a set of elements to the set. - * @param elements to add to the set - * @throw CommonException if one of the elements is not available in context of datatype where the set is used - */ - void add ( ext::set < DataType > symbols ) { - for ( DataType symbol : ext::make_moveable_set ( symbols ) ) - add ( std::move ( symbol ) ); - } - - /** - * Changes the set. - * @param elements by which to replace those currently in the set - * @throw CommonException if one of the removed elements is used in context of datatype where the set is used - * CommonException if one of the added elements is not available in context of datatype where the set is used - */ - void set ( ext::set < DataType > symbols ) { - ext::set < DataType > removed; - std::set_difference ( m_data.begin ( ), m_data.end ( ), symbols.begin ( ), symbols.end ( ), std::inserter ( removed, removed.end ( ) ) ); - - for ( const DataType & symbol : removed ) - checkRemove ( symbol ); - - for ( const DataType & symbol : symbols ) - checkAdd ( symbol ); - - m_data = std::move ( symbols ); - } - - /** - * @return the set. - */ - ext::set < DataType > & get ( ) { - return m_data; - } - - /** - * @return the set. - */ - const ext::set < DataType > & get ( ) const { - return m_data; - } - - /** - * Removes an element from the set if not used. - * @throw CommonException if element is used in context of datatype where the set is used - * @return true if element was indeed removed - * false if element was not present in the set - */ - bool remove ( const DataType & symbol ) { - checkRemove ( symbol ); - return m_data.erase ( symbol ); - } - - /** - * Removes a set of elements from alphabet if not used. - * @throw CommonException if element is used in context of datatype where the set is used - */ - void remove ( const ext::set < DataType > & symbols ) { - for ( const DataType & symbol : symbols ) - remove ( symbol ); - } - - /** - * Component emptiness checker. - * @return true if set is an empty - */ - bool empty ( ) const { - return m_data.empty ( ); - } - -}; - -template < class Derived, class DataType, class ElementType > +template < class Derived, class ComponentType, class ComponentName > class ElementConstraint { public: /** - * Checks whether a concrete symbol is available in context of the datatype instance using this class + * Checks whether a concrete element is available in context of the datatype instance using this class * * To be implemented by all template instantiations explicitly * @@ -205,48 +34,52 @@ public: * @return true if element is available * false if element is not available */ - static bool available ( const Derived & object, const DataType & symbol ); + static bool available ( const Derived & object, const ComponentType & element ); /** - * Checks whether a concrete symbol is valid in context of the datatype instance using this class + * Checks whether a concrete element is valid in context of the datatype instance using this class * * To be implemented by all template instantiations explicitly * * @param element to check * @throw CommonException if the element in any way invalid */ - static void valid ( const Derived & object, const DataType & symbol ); + static void valid ( const Derived & object, const ComponentType & element ); }; +template < class Derived, class ComponentType, class ComponentCategory, class ComponentName > +class Component; + /** - * Represents an notable element. - * @param Derived class representing datatype using this notable element. - * @param DataType underlying type of element. - * @param ElementType arbitrary type used to distinguish different notable elements. + * Represents an element. + * @param Derived class representing datatype using this set. + * @param ComponentType the type of element. + * @param ComponentName arbitrary type used to distinguish different components. */ -template < class Derived, class DataType, class ElementType > -class Element { +template < class Derived, class ComponentType, class ComponentName > +class Component < Derived, ComponentType, component::Value, ComponentName > { /** * The element. */ - DataType m_data; + ComponentType m_data; /** * Checks whether element can be set. Calls valid and available functions. * @throws CommonException if element cannot be added. */ - void checkSet ( const DataType & symbol ) { - ElementConstraint < Derived, DataType, ElementType >::valid ( static_cast < const Derived & > ( * this ), symbol ); + void checkSet ( const ComponentType & element ) { + ElementConstraint < Derived, ComponentType, ComponentName >::valid ( static_cast < const Derived & > ( * this ), element ); - if ( !ElementConstraint < Derived, DataType, ElementType >::available ( static_cast < const Derived & > ( * this ), symbol ) ) { - std::string elementTypeName ( ext::to_string < ElementType * > ( ) ); + if ( ! ElementConstraint < Derived, ComponentType, ComponentName >::available ( static_cast < const Derived & > ( * this ), element ) ) { + std::string elementTypeName ( ext::to_string < ComponentName * > ( ) ); elementTypeName.back ( ) = ' '; - throw::exception::CommonException ( elementTypeName + ext::to_string ( symbol ) + " is not available." ); + throw exception::CommonException ( elementTypeName + ext::to_string ( element ) + " is not available." ); } } protected: - /** Checks the state of the element. + /** + * Checks the state of the element. */ void checkState ( ) { checkSet ( m_data ); @@ -257,7 +90,7 @@ public: * Constructs a notable element. * @throw CommonException if element is not available in context of datatype where the class is used */ - Element ( DataType symbol ) : m_data ( std::move ( symbol ) ) { + Component ( ComponentType element ) : m_data ( std::move ( element ) ) { } /** @@ -267,234 +100,146 @@ public: * false if the element was the same as already present * @throw CommonException if the new element is not available in context of datatype where the class is used */ - bool set ( DataType symbol ) { - checkSet ( symbol ); + bool set ( ComponentType element ) { + checkSet ( element ); - if ( m_data == symbol ) return false; + if ( m_data == element ) return false; - m_data = std::move ( symbol ); + m_data = std::move ( element ); return true; } /** - * Returns the current notable element of ElementType. + * Returns the current notable element of ComponentName. * @return the notable element */ - DataType & get ( ) { + ComponentType & get ( ) { return m_data; } /** - * Returns the current notable element of ElementType. + * Returns the current notable element of ComponentName. * @return the notable element */ - const DataType & get ( ) const { + const ComponentType & get ( ) const { return m_data; } -}; - -/** - * Auxiliary base handling all sets of elements from components - */ -template < class Derived, class DataType, class ... SetTypes > -struct ComponentAux; - -/** - * Specialisation for tuple. - */ -template < class Derived, class DataType, class ... SetTypes > -struct ComponentAux < Derived, DataType, ext::tuple < SetTypes ... > > : public Component < Derived, DataType, SetTypes > ... { - - /** - * Constructor - */ - template < class ... RealSetTypes, size_t ... Indexes > - ComponentAux ( ext::tuple < RealSetTypes ... > params, std::index_sequence < Indexes ... > ) : Component < Derived, DataType, SetTypes > ( std::move ( std::get < Indexes > ( params ) ) ) ... { - ( void ) params; // No-op - } - /** - * Allows access to sub-component using its type. - * @param SetType alphabet type used to distinguish different sub alphabets - * @return sub-component + * Allows access to this sub-component using its name. + * @param AccessedComponentName type used to distinguish different elements + * @return this */ - template < class SetType, typename std::enable_if < ext::is_in < SetType, SetTypes ... >::value >::type * = nullptr > - const Component < Derived, DataType, SetType > & accessComponent ( ) const { - return static_cast < const Component < Derived, DataType, SetType > & > ( * this ); + template < class AccessedComponentName, typename std::enable_if < std::is_same < AccessedComponentName, ComponentName >::value >::type * = nullptr > + const Component < Derived, ComponentType, component::Value, ComponentName > & accessComponent ( ) const { + return * this; } /** - * Allows access to sub-component using its type. - * @param SetType alphabet type used to distinguish different sub alphabets - * @return sub-component + * Allows access to this sub-component using its name. + * @param AccessedComponentName type used to distinguish different elements + * @return this */ - template < class SetType, typename std::enable_if < ext::is_in < SetType, SetTypes ... >::value >::type * = nullptr > - Component < Derived, DataType, SetType > & accessComponent ( ) { - return static_cast < Component < Derived, DataType, SetType > & > ( * this ); - } - -protected: - /** - * postponed checker function - */ - void checkState ( ) { - ( void ) std::initializer_list < int > { ( Component < Derived, DataType, SetTypes >::checkState ( ), 0 ) ... }; + template < class AccessedComponentName, typename std::enable_if < std::is_same < AccessedComponentName, ComponentName >::value >::type * = nullptr > + Component < Derived, ComponentType, component::Value, ComponentName > & accessComponent ( ) { + return * this; } }; /** - * Auxiliary base handling all notable elements from components + * Auxiliary class allowing simple access to the alphabets. */ -template < class Derived, class DataType, class ... ElementTypes > -struct ElementAux; +template < class ... Data > +class Components { +public: + /** + * To silent the compiler about nonexistent access method in Components base + */ + template < class T, typename std::enable_if < ! std::is_same < T, T >::value >::type * = nullptr > + void accessComponent ( ); +}; /** - * Specialisation for tuple. + * Auxiliary class allowing simple access to the alphabets. */ -template < class Derived, class DataType, class ... ElementTypes > -struct ElementAux < Derived, DataType, ext::tuple < ElementTypes ... > > : public Element < Derived, DataType, ElementTypes > ... { - - /** - * Constructor - */ - template < class ... RealElementTypes, size_t ... Indexes > - ElementAux ( ext::tuple < RealElementTypes ... > params, std::index_sequence < Indexes ... > ) : Element < Derived, DataType, ElementTypes > ( std::move ( std::get < Indexes > ( params ) ) ) ... { - ( void ) params; // No-op +template < class Derived, class ComponentType, class ComponentCategory, class ComponentName, class ... Next > +class Components < Derived, ComponentType, ComponentCategory, ComponentName, Next ... > : public Component < Derived, ComponentType, ComponentCategory, ComponentName >, public Components < Derived, Next ... > { +public: + Components ( ) { } /** - * Allows access to sub-component using its type. - * @param ElementType alphabet type used to distinguish different sub alphabets - * @return sub-component + * Construct an alphabet pack from two alphabets. */ - template < class ElementType, typename std::enable_if < ext::is_in < ElementType, ElementTypes ... >::value >::type * = nullptr > - const Element < Derived, DataType, ElementType > & accessElement ( ) const { - return static_cast < const Element < Derived, DataType, ElementType > & > ( * this ); + template < class ComponentValue, class ... NextValues > + Components ( ComponentValue param, NextValues ... nextParams ) : Component < Derived, ComponentType, ComponentCategory, ComponentName > ( std::move ( param ) ), Components < Derived, Next ... > ( std::move ( nextParams ) ... ) { + Component < Derived, ComponentType, ComponentCategory, ComponentName >::checkState ( ); } /** - * Allows access to sub-component using its type. - * @param ElementType alphabet type used to distinguish different sub alphabets - * @return sub-component + * Make access method from Component class part of methods set of Components class */ - template < class ElementType, typename std::enable_if < ext::is_in < ElementType, ElementTypes ... >::value >::type * = nullptr > - Element < Derived, DataType, ElementType > & accessElement ( ) { - return static_cast < Element < Derived, DataType, ElementType > & > ( * this ); - } + using Component < Derived, ComponentType, ComponentCategory, ComponentName >::accessComponent; -protected: /** - * postponed checker function + * Make access method from Components base class part of methods set of this Components class */ - void checkState ( ) { - ( void ) std::initializer_list < int > { ( Element < Derived, DataType, ElementTypes >::checkState ( ), 0 ) ... }; - } - + using Components < Derived, Next ... >::accessComponent; }; -template < class ... Types > -class Components; - /** * Auxiliary class allowing simple access to the alphabets. */ -template < class Derived > -class Components < Derived > { +template < class Derived, class ComponentType, class ComponentCategory, class ComponentName, class ... ComponentNames, class ... Next > +class Components < Derived, ComponentType, ComponentCategory, std::tuple < ComponentName, ComponentNames ... >, Next ... > : public Component < Derived, ComponentType, ComponentCategory, ComponentName >, public Components < Derived, ComponentType, ComponentCategory, std::tuple < ComponentNames ... >, Next ... > { public: - /** - * Construct an alphabet pack from two alphabets. - */ Components ( ) { } - template < class T, typename std::enable_if < ! std::is_same < T, T >::value >::type * = nullptr > - void accessComponent ( ); - template < class T, typename std::enable_if < ! std::is_same < T, T >::value >::type * = nullptr > - void accessElement ( ); -}; - -/** - * Auxiliary class allowing simple access to the alphabets. - */ -template < class Derived, class DataType, class SetTypesPack, class ElementTypesPack, class ... NextGroup > -class Components < Derived, DataType, SetTypesPack, ElementTypesPack, NextGroup ... > : public ComponentAux < Derived, DataType, SetTypesPack >, public ElementAux < Derived, DataType, ElementTypesPack >, public Components < Derived, NextGroup ... > { -public: /** * Construct an alphabet pack from two alphabets. */ - template < class RealSetTypes, class RealElementTypes, class ... NextRealTypes > - Components ( RealSetTypes params1, RealElementTypes params2, NextRealTypes ... nextParams ) : ComponentAux < Derived, DataType, SetTypesPack > ( std::move ( params1 ), std::make_index_sequence < ext::tuple_size < SetTypesPack >::value > { } ), ElementAux < Derived, DataType, ElementTypesPack > ( std::move ( params2 ), std::make_index_sequence < ext::tuple_size < ElementTypesPack >::value > { } ), Components < Derived, NextGroup ... > ( std::move ( nextParams ) ... ) { - ComponentAux < Derived, DataType, SetTypesPack >::checkState ( ); - - ElementAux < Derived, DataType, ElementTypesPack >::checkState ( ); + template < class ComponentValue, class ... NextValues > + Components ( ComponentValue param, NextValues ... nextParams ) : Component < Derived, ComponentType, ComponentCategory, ComponentName > ( std::move ( param ) ), Components < Derived, ComponentType, ComponentCategory, std::tuple < ComponentNames ... >, Next ... > ( std::move ( nextParams ) ... ) { + Component < Derived, ComponentType, ComponentCategory, ComponentName >::checkState ( ); } - using ComponentAux < Derived, DataType, SetTypesPack >::accessComponent; - using ElementAux < Derived, DataType, ElementTypesPack >::accessElement; - - using Components < Derived, NextGroup ... >::accessComponent; - using Components < Derived, NextGroup ... >::accessElement; -}; - -/** - * Auxiliary class allowing simple access to the alphabets. - */ -template < class Derived, class DataType, class ElementTypesPack, class ... NextGroup > -class Components < Derived, DataType, ext::tuple < >, ElementTypesPack, NextGroup ... > : public ElementAux < Derived, DataType, ElementTypesPack >, public Components < Derived, NextGroup ... > { -public: /** - * Construct an alphabet pack from two alphabets. + * Make access method from Component class part of methods set of Components class */ - template < class RealElementTypes, class ... NextRealTypes > - Components ( const ext::tuple < > & , RealElementTypes params2, NextRealTypes ... nextParams ) : ElementAux < Derived, DataType, ElementTypesPack > ( std::move ( params2 ), std::make_index_sequence < ext::tuple_size < ElementTypesPack >::value > { } ), Components < Derived, NextGroup ... > ( std::move ( nextParams ) ... ) { - ElementAux < Derived, DataType, ElementTypesPack >::checkState ( ); - } - - using ElementAux < Derived, DataType, ElementTypesPack >::accessElement; + using Component < Derived, ComponentType, ComponentCategory, ComponentName >::accessComponent; - using Components < Derived, NextGroup ... >::accessComponent; - using Components < Derived, NextGroup ... >::accessElement; -}; - -/** - * Auxiliary class allowing simple access to the alphabets. - */ -template < class Derived, class DataType, class SetTypesPack, class ... NextGroup > -class Components < Derived, DataType, SetTypesPack, ext::tuple < >, NextGroup ... > : public ComponentAux < Derived, DataType, SetTypesPack >, public Components < Derived, NextGroup ... > { -public: /** - * Construct an alphabet pack from two alphabets. + * Make access method from Components base class part of methods set of this Components class */ - template < class RealSetTypes, class ... NextRealTypes > - Components ( RealSetTypes params1, const ext::tuple < > & , NextRealTypes ... nextParams ) : ComponentAux < Derived, DataType, SetTypesPack > ( std::move ( params1 ), std::make_index_sequence < ext::tuple_size < SetTypesPack >::value > { } ), Components < Derived, NextGroup ... > ( std::move ( nextParams ) ... ) { - ComponentAux < Derived, DataType, SetTypesPack >::checkState ( ); - } - - using ComponentAux < Derived, DataType, SetTypesPack >::accessComponent; - - using Components < Derived, NextGroup ... >::accessComponent; - using Components < Derived, NextGroup ... >::accessElement; + using Components < Derived, ComponentType, ComponentCategory, std::tuple < ComponentNames ... >, Next ... >::accessComponent; }; /** * Auxiliary class allowing simple access to the alphabets. */ -template < class Derived, class DataType, class ... NextGroup > -class Components < Derived, DataType, ext::tuple < >, ext::tuple < >, NextGroup ... > : public Components < Derived, NextGroup ... > { +template < class Derived, class ComponentType, class ComponentCategory, class ... Next > +class Components < Derived, ComponentType, ComponentCategory, std::tuple < >, Next ... > : public Components < Derived, Next ... > { public: + Components ( ) { + } + /** * Construct an alphabet pack from two alphabets. */ - template < class ... NextRealTypes > - Components ( const ext::tuple < > & , const ext::tuple < > & , NextRealTypes ... nextParams ) : Components < Derived, NextGroup ... > ( std::move ( nextParams ) ... ) { + template < class ... NextValues > + Components ( NextValues ... nextParams ) : Components < Derived, Next ... > ( std::move ( nextParams ) ... ) { } - using Components < Derived, NextGroup ... >::accessComponent; - using Components < Derived, NextGroup ... >::accessElement; + /** + * Make access method from Components base class part of methods set of this Components class + */ + using Components < Derived, Next ... >::accessComponent; }; } /* namespace alib */ -#endif /* COMPONENTS2_HPP_ */ +#include <core/components/setComponents.hpp> + +#endif /* _COMPONENTS_HPP_ */ diff --git a/alib2common/src/core/components/setComponents.hpp b/alib2common/src/core/components/setComponents.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9ed8756684f653942fa60c4f1c2d2c3b0b41c95f --- /dev/null +++ b/alib2common/src/core/components/setComponents.hpp @@ -0,0 +1,238 @@ +/* + * Components.hpp + * + * Created on: Mar 16, 2016 + * Author: Jan Travnicek + */ + +#ifndef _SET_COMPONENT_HPP_ +#define _SET_COMPONENT_HPP_ + +#include <algorithm> +#include <typeinfo> +#include <exception/CommonException.h> + +namespace component { + +class Set; + +} /* namespace component */ + +namespace alib { + +/** + * Pack of containt check functions for set component + */ +template < class Derived, class ComponentType, class ComponentName > +class SetConstraint { +public: + /** + * Checks whether a concrete element is used in context of the datatype where the set is used + * + * To be implemented by all template instantiations explicitly + * + * @param element to check + * @return true if element is used + * false if element is not used + */ + static bool used ( const Derived & object, const ComponentType & element ); + + /** + * Checks whether a concrete element is available in context of the datatype where the set is used + * + * To be implemented by all template instantiations explicitly + * + * @param element to check + * @return true if element is available + * false if element is not available + */ + static bool available ( const Derived & object, const ComponentType & element ); + + /** + * Checks whether a concrete element is valid in context of the datatype where the set is used + * + * To be implemented by all template instantiations explicitly + * + * @param element to check + * @throw CommonException if the element in any way invalid + */ + static void valid ( const Derived & object, const ComponentType & element ); +}; + +/** + * Represents a set of elements. + * @param Derived class representing datatype using this set. + * @param ComponentType underlying type of data in the set. + * @param ComponentName arbitrary type used to distinguish different components. + */ +template < class Derived, class SetComponentType, class ComponentType, class ComponentName > +class SetComponent { + /** + * The set. + */ + SetComponentType m_data; + + /** + * Checks whether element can be added to the set. Calls valid and available functions. + * @throws CommonException if element cannot be added. + */ + void checkAdd ( const ComponentType & element ) { + SetConstraint < Derived, ComponentType, ComponentName >::valid ( static_cast < const Derived & > ( * this ), element ); + + if ( ! SetConstraint < Derived, ComponentType, ComponentName >::available ( static_cast < const Derived & > ( * this ), element ) ) { + std::string elementTypeName ( ext::to_string < ComponentName * > ( ) ); + elementTypeName.back ( ) = ' '; + throw exception::CommonException ( elementTypeName + "element " + ext::to_string ( element ) + " is not available." ); + } + } + + /** + * Checks whether element can be removed from the set. Calls used function. + * @throws CommonException if element cannot be removed. + */ + void checkRemove ( const ComponentType & element ) { + if ( SetConstraint < Derived, ComponentType, ComponentName >::used ( static_cast < const Derived & > ( * this ), element ) ) { + std::string elementTypeName ( ext::to_string < ComponentName * > ( ) ); + elementTypeName.back ( ) = ' '; + throw exception::CommonException ( elementTypeName + "element " + ext::to_string ( element ) + " is used." ); + } + } + +protected: + /** + * Checks the state of the set. + */ + void checkState ( ) { + for ( const ComponentType & element : m_data ) + checkAdd ( element ); + } + +public: + /** + * Constructs a set containing given elements. + * @throw CommonException if elements are not available in context of datatype where the set is used + */ + SetComponent ( SetComponentType data ) : m_data ( std::move ( data ) ) { + } + + SetComponent ( ) { + } + + /** + * Adds an elements to the set. + * @param element to add to the set + * @throw CommonException if element is not available in context of datatype where the set is used + * @return true if element was indeed added + * false if element was present in the set + */ + bool add ( ComponentType element ) { + checkAdd ( element ); + return m_data.insert ( std::move ( element ) ).second; + } + + /** + * Adds a set of elements to the set. + * @param elements to add to the set + * @throw CommonException if one of the elements is not available in context of datatype where the set is used + */ + void add ( SetComponentType data ) { + for ( ComponentType element : ext::make_moveable_set ( data ) ) + add ( std::move ( element ) ); + } + + /** + * Changes the set. + * @param elements by which to replace those currently in the set + * @throw CommonException if one of the removed elements is used in context of datatype where the set is used + * CommonException if one of the added elements is not available in context of datatype where the set is used + */ + void set ( SetComponentType data ) { + SetComponentType removed; + std::set_difference ( m_data.begin ( ), m_data.end ( ), data.begin ( ), data.end ( ), std::inserter ( removed, removed.end ( ) ) ); + + for ( const ComponentType & element : removed ) + checkRemove ( element ); + + for ( const ComponentType & element : data ) + checkAdd ( element ); + + m_data = std::move ( data ); + } + + /** + * @return the set. + */ + SetComponentType & get ( ) { + return m_data; + } + + /** + * @return the set. + */ + const SetComponentType & get ( ) const { + return m_data; + } + + /** + * Removes an element from the set if not used. + * @throw CommonException if element is used in context of datatype where the set is used + * @return true if element was indeed removed + * false if element was not present in the set + */ + bool remove ( const ComponentType & element ) { + checkRemove ( element ); + return m_data.erase ( element ); + } + + /** + * Removes a set of elements from alphabet if not used. + * @throw CommonException if element is used in context of datatype where the set is used + */ + void remove ( const SetComponentType & data ) { + for ( const ComponentType & element : data ) + remove ( element ); + } + + /** + * Component emptiness checker. + * @return true if set is an empty + */ + bool empty ( ) const { + return m_data.empty ( ); + } + + /** + * Allows access to this sub-component using its name. + * @param AccessedComponentName type used to distinguish different components + * @return this + */ + template < class AccessedComponentName, typename std::enable_if < std::is_same < AccessedComponentName, ComponentName >::value >::type * = nullptr > + const Component < Derived, SetComponentType, component::Set, ComponentName > & accessComponent ( ) const { + return static_cast < const Component < Derived, SetComponentType, component::Set, ComponentName > & > ( * this ); + } + + /** + * Allows access to this sub-component using its name. + * @param AccessedComponentName type used to distinguish different components + * @return this + */ + template < class AccessedComponentName, typename std::enable_if < std::is_same < AccessedComponentName, ComponentName >::value >::type * = nullptr > + Component < Derived, SetComponentType, component::Set, ComponentName > & accessComponent ( ) { + return static_cast < Component < Derived, SetComponentType, component::Set, ComponentName > & > ( * this ); + } + +}; + +template < class Derived, class ComponentType, class ComponentName > +class Component < Derived, ComponentType, component::Set, ComponentName > : public SetComponent < Derived, ComponentType, typename ComponentType::value_type, ComponentName > { +public: + Component ( ComponentType data ) : SetComponent < Derived, ComponentType, typename ComponentType::value_type, ComponentName > ( std::move ( data ) ) { + } + + Component ( ) { + } +}; + +} /* namespace alib */ + +#endif /* SET_COMPONENT_HPP_ */ diff --git a/alib2common/test-src/core/ComponentsTest.cpp b/alib2common/test-src/core/ComponentsTest.cpp index 238889ac7ae4cce6b4213d725a79317afd4bfd0b..65b7c91ce8cd7a7c5363344cdfca5a9a8c0b6349 100644 --- a/alib2common/test-src/core/ComponentsTest.cpp +++ b/alib2common/test-src/core/ComponentsTest.cpp @@ -1,6 +1,9 @@ #include "ComponentsTest.h" #include <core/components.hpp> +#include <set> +#include <linear_set> + CPPUNIT_TEST_SUITE_NAMED_REGISTRATION ( ComponentsTest, "alphabet" ); CPPUNIT_TEST_SUITE_REGISTRATION ( ComponentsTest ); @@ -13,19 +16,19 @@ struct NonlinearAlphabet { struct SubtreeWildcard { }; -class A : public alib::Components < A, std::string, ext::tuple < GeneralAlphabet, NonlinearAlphabet >, ext::tuple < SubtreeWildcard > > { +class A : public alib::Components < A, ext::linear_set < std::string >, component::Set, std::tuple < GeneralAlphabet, NonlinearAlphabet >, std::string, component::Value, SubtreeWildcard > { public: - A ( std::string string ) : alib::Components < A, std::string, ext::tuple < GeneralAlphabet, NonlinearAlphabet >, ext::tuple < SubtreeWildcard > > ( ext::make_tuple ( ext::set < std::string > { string, "aaa" }, ext::set < std::string > { "aaa" } ), ext::make_tuple ( string ) ) { + A ( std::string string ) : alib::Components < A, ext::linear_set < std::string >, component::Set, std::tuple < GeneralAlphabet, NonlinearAlphabet >, std::string, component::Value, SubtreeWildcard > ( ext::linear_set < std::string > { string, "aaa" }, ext::linear_set < std::string > { "aaa" }, string ) { } }; namespace alib { template < > -class ComponentConstraint< A, std::string, GeneralAlphabet > { +class SetConstraint< A, std::string, GeneralAlphabet > { public: static bool used ( const A & a, const std::string & str ) { - return a.accessComponent < NonlinearAlphabet > ( ).get ( ).count ( str ) || a.accessElement < SubtreeWildcard > ( ).get ( ) == str; + return a.accessComponent < NonlinearAlphabet > ( ).get ( ).count ( str ) || a.accessComponent < SubtreeWildcard > ( ).get ( ) == str; } static bool available ( const A &, const std::string & ) { @@ -37,7 +40,7 @@ public: }; template < > -class ComponentConstraint< A, std::string, NonlinearAlphabet > { +class SetConstraint< A, std::string, NonlinearAlphabet > { public: static bool used ( const A &, const std::string & ) { return false; @@ -48,7 +51,7 @@ public: } static void valid ( const A & a, const std::string & str ) { - if ( a.accessElement < SubtreeWildcard > ( ).get ( ) == str ) + if ( a.accessComponent < SubtreeWildcard > ( ).get ( ) == str ) throw::exception::CommonException ( "Symbol " + ( std::string ) str + "cannot be set as nonlinear variable since it is already a subtree wildcard" ); } }; @@ -68,13 +71,13 @@ public: } /* namespace alib */ -class B : public alib::Components < B, std::string, ext::tuple < GeneralAlphabet, NonlinearAlphabet >, ext::tuple < > > { +class B : public alib::Components < B, ext::set < std::string >, component::Set, GeneralAlphabet, ext::set < std::string >, component::Set, NonlinearAlphabet > { }; namespace alib { template < > -class ComponentConstraint< B, std::string, GeneralAlphabet > { +class SetConstraint< B, std::string, GeneralAlphabet > { public: static bool used ( const B &, const std::string & ) { return false; @@ -89,7 +92,7 @@ public: }; template < > -class ComponentConstraint< B, std::string, NonlinearAlphabet > { +class SetConstraint< B, std::string, NonlinearAlphabet > { public: static bool used ( const B &, const std::string & ) { return false; @@ -117,6 +120,8 @@ void ComponentsTest::testAdd ( ) { CPPUNIT_ASSERT_THROW ( tmp.accessComponent < NonlinearAlphabet > ( ).add ( "1" ), exception::CommonException ); tmp.accessComponent < GeneralAlphabet > ( ).add ( "1" ); tmp.accessComponent < NonlinearAlphabet > ( ).add ( "1" ); + + B tmp2 = B ( ); } void ComponentsTest::testRemove ( ) { diff --git a/alib2data/src/automaton/FSM/CompactNFA.h b/alib2data/src/automaton/FSM/CompactNFA.h index f312a21c7c76dcce88f0e31ba78fc91a52d5ea86..caaee9f44a77f756bbbb47f5b3b32eabbf1a69b2 100644 --- a/alib2data/src/automaton/FSM/CompactNFA.h +++ b/alib2data/src/automaton/FSM/CompactNFA.h @@ -25,6 +25,7 @@ #define COMPACT_DFA_H_ #include <map> +#include <set> #include <ostream> #include <algorithm> #include <sstream> @@ -69,7 +70,7 @@ class InitialState; * \tparam StateType used to the states, and the initial state of the automaton. */ template < class SymbolType, class StateType > -class CompactNFA final : public AutomatonBase, public alib::Components < CompactNFA < SymbolType, StateType >, SymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > { +class CompactNFA final : public AutomatonBase, public alib::Components < CompactNFA < SymbolType, StateType >, ext::set < SymbolType >, component::Set, InputAlphabet, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > { /** * Transition function as mapping from a state times a list of input symbols on the left hand side to a set of states. */ @@ -140,7 +141,7 @@ public: * \returns the initial state of the automaton */ const StateType & getInitialState ( ) const & { - return this->template accessElement < InitialState > ( ).get ( ); + return this->template accessComponent < InitialState > ( ).get ( ); } /** @@ -149,7 +150,7 @@ public: * \returns the initial state of the automaton */ StateType && getInitialState ( ) && { - return std::move ( this->template accessElement < InitialState > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialState > ( ).get ( ) ); } /** @@ -160,7 +161,7 @@ public: * \returns true if the initial state was indeed changed */ bool setInitialState ( StateType state ) { - return this->template accessElement < InitialState > ( ).set ( std::move ( state ) ); + return this->template accessComponent < InitialState > ( ).set ( std::move ( state ) ); } /** @@ -487,7 +488,7 @@ public: namespace automaton { template < class SymbolType, class StateType > -CompactNFA < SymbolType, StateType >::CompactNFA ( ext::set < StateType > states, ext::set < SymbolType > inputAlphabet, StateType initialState, ext::set < StateType > finalStates ) : alib::Components < CompactNFA, SymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > ( ext::make_tuple ( std::move ( inputAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( states ), std::move ( finalStates ) ), ext::make_tuple ( std::move ( initialState ) ) ) { +CompactNFA < SymbolType, StateType >::CompactNFA ( ext::set < StateType > states, ext::set < SymbolType > inputAlphabet, StateType initialState, ext::set < StateType > finalStates ) : alib::Components < CompactNFA, ext::set < SymbolType >, component::Set, InputAlphabet, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > ( std::move ( inputAlphabet ), std::move ( states ), std::move ( finalStates ), std::move ( initialState ) ) { } template < class SymbolType, class StateType > @@ -735,7 +736,7 @@ namespace alib { * \tparam StateType used for the terminal alphabet of the automaton. */ template < class SymbolType, class StateType > -class ComponentConstraint< automaton::CompactNFA < SymbolType, StateType >, SymbolType, automaton::InputAlphabet > { +class SetConstraint< automaton::CompactNFA < SymbolType, StateType >, SymbolType, automaton::InputAlphabet > { public: /** * Returns true if the symbol is still used in some transition of the automaton. @@ -784,7 +785,7 @@ public: * \tparam StateType used for the terminal alphabet of the automaton. */ template < class SymbolType, class StateType > -class ComponentConstraint< automaton::CompactNFA < SymbolType, StateType >, StateType, automaton::States > { +class SetConstraint< automaton::CompactNFA < SymbolType, StateType >, StateType, automaton::States > { public: /** * Returns true if the state is still used in some transition of the automaton. @@ -837,7 +838,7 @@ public: * \tparam StateType used for the terminal alphabet of the automaton. */ template < class SymbolType, class StateType > -class ComponentConstraint< automaton::CompactNFA < SymbolType, StateType >, StateType, automaton::FinalStates > { +class SetConstraint< automaton::CompactNFA < SymbolType, StateType >, StateType, automaton::FinalStates > { public: /** * Returns true if the state is still used in some transition of the automaton. diff --git a/alib2data/src/automaton/FSM/DFA.h b/alib2data/src/automaton/FSM/DFA.h index dbe5c056bbd6edb32f2e0789107cb500608f7e59..62cf4139a49705ad695aeef166afce1330bbfca3 100644 --- a/alib2data/src/automaton/FSM/DFA.h +++ b/alib2data/src/automaton/FSM/DFA.h @@ -25,6 +25,7 @@ #define DFA_H_ #include <map> +#include <set> #include <ostream> #include <sstream> #include <range> @@ -69,7 +70,7 @@ class InitialState; * \tparam StateType used to the states, and the initial state of the automaton. */ template<class SymbolType, class StateType > -class DFA final : public AutomatonBase, public alib::Components < DFA < SymbolType, StateType >, SymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > { +class DFA final : public AutomatonBase, public alib::Components < DFA < SymbolType, StateType >, ext::set < SymbolType >, component::Set, InputAlphabet, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > { /** * Transition function as mapping from a state times an input symbol on the left hand side to a state. */ @@ -109,7 +110,7 @@ public: * \returns the initial state of the automaton */ const StateType & getInitialState ( ) const & { - return this-> template accessElement < InitialState > ( ).get ( ); + return this-> template accessComponent < InitialState > ( ).get ( ); } /** @@ -118,7 +119,7 @@ public: * \returns the initial state of the automaton */ StateType && getInitialState ( ) && { - return std::move ( this-> template accessElement < InitialState > ( ).get ( ) ); + return std::move ( this-> template accessComponent < InitialState > ( ).get ( ) ); } /** @@ -129,7 +130,7 @@ public: * \returns true if the initial state was indeed changed */ bool setInitialState ( StateType state ) { - return this-> template accessElement < InitialState > ( ).set ( std::move ( state ) ); + return this-> template accessComponent < InitialState > ( ).set ( std::move ( state ) ); } /** @@ -444,7 +445,7 @@ public: }; template<class SymbolType, class StateType > -DFA<SymbolType, StateType>::DFA ( ext::set < StateType > states, ext::set < SymbolType > inputAlphabet, StateType initialState, ext::set < StateType > finalStates ) : alib::Components < DFA, SymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > ( ext::make_tuple ( std::move ( inputAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( states ), std::move ( finalStates ) ), ext::make_tuple ( std::move ( initialState ) ) ) { +DFA<SymbolType, StateType>::DFA ( ext::set < StateType > states, ext::set < SymbolType > inputAlphabet, StateType initialState, ext::set < StateType > finalStates ) : alib::Components < DFA, ext::set < SymbolType >, component::Set, InputAlphabet, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > ( std::move ( inputAlphabet ), std::move ( states ), std::move ( finalStates ), std::move ( initialState ) ) { } template<class SymbolType, class StateType > @@ -666,7 +667,7 @@ namespace alib { * \tparam StateType used for the terminal alphabet of the automaton. */ template<class SymbolType, class StateType > -class ComponentConstraint< automaton::DFA<SymbolType, StateType>, SymbolType, automaton::InputAlphabet > { +class SetConstraint< automaton::DFA<SymbolType, StateType>, SymbolType, automaton::InputAlphabet > { public: /** * Returns true if the symbol is still used in some transition of the automaton. @@ -714,7 +715,7 @@ public: * \tparam StateType used for the terminal alphabet of the automaton. */ template<class SymbolType, class StateType > -class ComponentConstraint< automaton::DFA<SymbolType, StateType>, StateType, automaton::States > { +class SetConstraint< automaton::DFA<SymbolType, StateType>, StateType, automaton::States > { public: /** * Returns true if the state is still used in some transition of the automaton. @@ -768,7 +769,7 @@ public: * \tparam StateType used for the terminal alphabet of the automaton. */ template<class SymbolType, class StateType > -class ComponentConstraint< automaton::DFA<SymbolType, StateType>, StateType, automaton::FinalStates > { +class SetConstraint< automaton::DFA<SymbolType, StateType>, StateType, automaton::FinalStates > { public: /** * Returns true if the state is still used in some transition of the automaton. diff --git a/alib2data/src/automaton/FSM/EpsilonNFA.h b/alib2data/src/automaton/FSM/EpsilonNFA.h index daa04c6765dbb29fb2afe2b4024a99fa262ef1ad..a32e0e6c440b98412ecdea2455ab78a8156a43d9 100644 --- a/alib2data/src/automaton/FSM/EpsilonNFA.h +++ b/alib2data/src/automaton/FSM/EpsilonNFA.h @@ -25,6 +25,7 @@ #define EPSILON_NFA_H_ #include <map> +#include <set> #include <variant> #include <ostream> #include <sstream> @@ -70,7 +71,7 @@ class InitialState; * \tparam StateType used to the states, and the initial state of the automaton. */ template<class SymbolType, class EpsilonType, class StateType > -class EpsilonNFA final : public AutomatonBase, public alib::Components < EpsilonNFA < SymbolType, EpsilonType, StateType >, SymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > { +class EpsilonNFA final : public AutomatonBase, public alib::Components < EpsilonNFA < SymbolType, EpsilonType, StateType >, ext::set < SymbolType >, component::Set, InputAlphabet, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > { /** * Transition function as mapping from a state times an input symbol or epsilon on the left hand side to a set of states. */ @@ -131,7 +132,7 @@ public: * \returns the initial state of the automaton */ const StateType & getInitialState ( ) const & { - return this->template accessElement < InitialState > ( ).get ( ); + return this->template accessComponent < InitialState > ( ).get ( ); } /** @@ -140,7 +141,7 @@ public: * \returns the initial state of the automaton */ StateType && getInitialState ( ) && { - return std::move ( this->template accessElement < InitialState > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialState > ( ).get ( ) ); } /** @@ -151,7 +152,7 @@ public: * \returns true if the initial state was indeed changed */ bool setInitialState ( StateType state ) { - return this->template accessElement < InitialState > ( ).set ( std::move ( state ) ); + return this->template accessComponent < InitialState > ( ).set ( std::move ( state ) ); } /** @@ -622,7 +623,7 @@ public: namespace automaton { template<class SymbolType, class EpsilonType, class StateType > -EpsilonNFA < SymbolType, EpsilonType, StateType >::EpsilonNFA ( ext::set < StateType > states, ext::set < SymbolType > inputAlphabet, StateType initialState, ext::set < StateType > finalStates ) : alib::Components < EpsilonNFA, SymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > ( ext::make_tuple ( std::move ( inputAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( states ), std::move ( finalStates ) ), ext::make_tuple ( std::move ( initialState ) ) ) { +EpsilonNFA < SymbolType, EpsilonType, StateType >::EpsilonNFA ( ext::set < StateType > states, ext::set < SymbolType > inputAlphabet, StateType initialState, ext::set < StateType > finalStates ) : alib::Components < EpsilonNFA, ext::set < SymbolType >, component::Set, InputAlphabet, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > ( std::move ( inputAlphabet ), std::move ( states ), std::move ( finalStates ), std::move ( initialState ) ) { } template<class SymbolType, class EpsilonType, class StateType > @@ -993,7 +994,7 @@ namespace alib { * \tparam StateType used for the terminal alphabet of the automaton. */ template<class SymbolType, class EpsilonType, class StateType > -class ComponentConstraint< automaton::EpsilonNFA < SymbolType, EpsilonType, StateType >, SymbolType, automaton::InputAlphabet > { +class SetConstraint< automaton::EpsilonNFA < SymbolType, EpsilonType, StateType >, SymbolType, automaton::InputAlphabet > { public: /** * Returns true if the symbol is still used in some transition of the automaton. @@ -1041,7 +1042,7 @@ public: * \tparam StateType used for the terminal alphabet of the automaton. */ template<class SymbolType, class EpsilonType, class StateType > -class ComponentConstraint< automaton::EpsilonNFA < SymbolType, EpsilonType, StateType >, StateType, automaton::States > { +class SetConstraint< automaton::EpsilonNFA < SymbolType, EpsilonType, StateType >, StateType, automaton::States > { public: /** * Returns true if the state is still used in some transition of the automaton. @@ -1095,7 +1096,7 @@ public: * \tparam StateType used for the terminal alphabet of the automaton. */ template<class SymbolType, class EpsilonType, class StateType > -class ComponentConstraint< automaton::EpsilonNFA < SymbolType, EpsilonType, StateType >, StateType, automaton::FinalStates > { +class SetConstraint< automaton::EpsilonNFA < SymbolType, EpsilonType, StateType >, StateType, automaton::FinalStates > { public: /** * Returns true if the state is still used in some transition of the automaton. diff --git a/alib2data/src/automaton/FSM/ExtendedNFA.h b/alib2data/src/automaton/FSM/ExtendedNFA.h index b89f7af2764f83cca6610afd6c50d859606ac628..4af473ce75dade2446ac930e4d543d6cc4faeb90 100644 --- a/alib2data/src/automaton/FSM/ExtendedNFA.h +++ b/alib2data/src/automaton/FSM/ExtendedNFA.h @@ -25,6 +25,7 @@ #define EXTENDED_NFA_H_ #include <map> +#include <set> #include <ostream> #include <algorithm> #include <sstream> @@ -72,7 +73,7 @@ class InitialState; * \tparam StateType used to the states, and the initial state of the automaton. */ template<class SymbolType, class StateType > -class ExtendedNFA final : public AutomatonBase, public alib::Components < ExtendedNFA < SymbolType, StateType >, SymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > { +class ExtendedNFA final : public AutomatonBase, public alib::Components < ExtendedNFA < SymbolType, StateType >, ext::set < SymbolType >, component::Set, InputAlphabet, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > { /** * Transition function as mapping from a state times a regular expression on the left hand side to a set of states. */ @@ -150,7 +151,7 @@ public: * \returns the initial state of the automaton */ const StateType & getInitialState ( ) const & { - return this->template accessElement < InitialState > ( ).get ( ); + return this->template accessComponent < InitialState > ( ).get ( ); } /** @@ -159,7 +160,7 @@ public: * \returns the initial state of the automaton */ StateType && getInitialState ( ) && { - return std::move ( this->template accessElement < InitialState > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialState > ( ).get ( ) ); } /** @@ -170,7 +171,7 @@ public: * \returns true if the initial state was indeed changed */ bool setInitialState ( StateType state ) { - return this->template accessElement < InitialState > ( ).set ( std::move ( state ) ); + return this->template accessComponent < InitialState > ( ).set ( std::move ( state ) ); } /** @@ -498,7 +499,7 @@ public: namespace automaton { template<class SymbolType, class StateType > -ExtendedNFA < SymbolType, StateType >::ExtendedNFA ( ext::set < StateType > states, ext::set < SymbolType > inputAlphabet, StateType initialState, ext::set < StateType > finalStates ) : alib::Components < ExtendedNFA, SymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > ( ext::make_tuple ( std::move ( inputAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( states ), std::move ( finalStates ) ), ext::make_tuple ( std::move ( initialState ) ) ) { +ExtendedNFA < SymbolType, StateType >::ExtendedNFA ( ext::set < StateType > states, ext::set < SymbolType > inputAlphabet, StateType initialState, ext::set < StateType > finalStates ) : alib::Components < ExtendedNFA, ext::set < SymbolType >, component::Set, InputAlphabet, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > ( std::move ( inputAlphabet ), std::move ( states ), std::move ( finalStates ), std::move ( initialState ) ) { } template<class SymbolType, class StateType > @@ -759,7 +760,7 @@ namespace alib { * \tparam StateType used for the terminal alphabet of the automaton. */ template<class SymbolType, class StateType > -class ComponentConstraint< automaton::ExtendedNFA < SymbolType, StateType >, SymbolType, automaton::InputAlphabet > { +class SetConstraint< automaton::ExtendedNFA < SymbolType, StateType >, SymbolType, automaton::InputAlphabet > { public: /** * Returns true if the symbol is still used in some transition of the automaton. @@ -808,7 +809,7 @@ public: * \tparam StateType used for the terminal alphabet of the automaton. */ template<class SymbolType, class StateType > -class ComponentConstraint< automaton::ExtendedNFA < SymbolType, StateType >, StateType, automaton::States > { +class SetConstraint< automaton::ExtendedNFA < SymbolType, StateType >, StateType, automaton::States > { public: /** * Returns true if the state is still used in some transition of the automaton. @@ -861,7 +862,7 @@ public: * \tparam StateType used for the terminal alphabet of the automaton. */ template<class SymbolType, class StateType > -class ComponentConstraint< automaton::ExtendedNFA < SymbolType, StateType >, StateType, automaton::FinalStates > { +class SetConstraint< automaton::ExtendedNFA < SymbolType, StateType >, StateType, automaton::FinalStates > { public: /** * Returns true if the state is still used in some transition of the automaton. diff --git a/alib2data/src/automaton/FSM/MultiInitialStateNFA.h b/alib2data/src/automaton/FSM/MultiInitialStateNFA.h index ba93598b812decb89d7f0585427c4b74ebe5aa2a..7892e7f41ff5ba879b95eec819fbc15922a3e575 100644 --- a/alib2data/src/automaton/FSM/MultiInitialStateNFA.h +++ b/alib2data/src/automaton/FSM/MultiInitialStateNFA.h @@ -25,6 +25,7 @@ #define MULTI_INITIAL_STATE_NFA_H_ #include <map> +#include <set> #include <ostream> #include <sstream> @@ -65,7 +66,7 @@ class InitialStates; * \tparam StateType used to the states, and the initial state of the automaton. */ template < class SymbolType, class StateType > -class MultiInitialStateNFA final : public AutomatonBase, public alib::Components < MultiInitialStateNFA < SymbolType, StateType >, SymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, StateType, ext::tuple < States, InitialStates, FinalStates >, ext::tuple < > > { +class MultiInitialStateNFA final : public AutomatonBase, public alib::Components < MultiInitialStateNFA < SymbolType, StateType >, ext::set < SymbolType >, component::Set, InputAlphabet, ext::set < StateType >, component::Set, std::tuple < States, InitialStates, FinalStates > > { /** * Transition function as mapping from a state times an input symbol on the left hand side to a set of states. */ @@ -513,7 +514,7 @@ public: namespace automaton { template < class SymbolType, class StateType > -MultiInitialStateNFA < SymbolType, StateType >::MultiInitialStateNFA ( ext::set < StateType > states, ext::set < SymbolType > inputAlphabet, ext::set < StateType > initialStates, ext::set < StateType > finalStates ) : alib::Components < MultiInitialStateNFA, SymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, StateType, ext::tuple < States, InitialStates, FinalStates >, ext::tuple < > > ( ext::make_tuple ( std::move ( inputAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( states ), std::move ( initialStates ), std::move ( finalStates ) ), ext::tuple < > ( ) ) { +MultiInitialStateNFA < SymbolType, StateType >::MultiInitialStateNFA ( ext::set < StateType > states, ext::set < SymbolType > inputAlphabet, ext::set < StateType > initialStates, ext::set < StateType > finalStates ) : alib::Components < MultiInitialStateNFA, ext::set < SymbolType >, component::Set, InputAlphabet, ext::set < StateType >, component::Set, std::tuple < States, InitialStates, FinalStates > > ( std::move ( inputAlphabet ), std::move ( states ), std::move ( initialStates ), std::move ( finalStates ) ) { } template < class SymbolType, class StateType > @@ -751,7 +752,7 @@ namespace alib { * \tparam StateType used for the terminal alphabet of the automaton. */ template < class SymbolType, class StateType > -class ComponentConstraint< automaton::MultiInitialStateNFA < SymbolType, StateType >, SymbolType, automaton::InputAlphabet > { +class SetConstraint< automaton::MultiInitialStateNFA < SymbolType, StateType >, SymbolType, automaton::InputAlphabet > { public: /** * Returns true if the symbol is still used in some transition of the automaton. @@ -798,7 +799,7 @@ public: * \tparam StateType used for the terminal alphabet of the automaton. */ template < class SymbolType, class StateType > -class ComponentConstraint< automaton::MultiInitialStateNFA < SymbolType, StateType >, StateType, automaton::States > { +class SetConstraint< automaton::MultiInitialStateNFA < SymbolType, StateType >, StateType, automaton::States > { public: /** * Returns true if the state is still used in some transition of the automaton. @@ -851,7 +852,7 @@ public: * \tparam StateType used for the terminal alphabet of the automaton. */ template < class SymbolType, class StateType > -class ComponentConstraint< automaton::MultiInitialStateNFA < SymbolType, StateType >, StateType, automaton::FinalStates > { +class SetConstraint< automaton::MultiInitialStateNFA < SymbolType, StateType >, StateType, automaton::FinalStates > { public: /** * Returns true if the state is still used in some transition of the automaton. @@ -894,7 +895,7 @@ public: * \tparam StateType used for the terminal alphabet of the automaton. */ template < class SymbolType, class StateType > -class ComponentConstraint< automaton::MultiInitialStateNFA < SymbolType, StateType >, StateType, automaton::InitialStates > { +class SetConstraint< automaton::MultiInitialStateNFA < SymbolType, StateType >, StateType, automaton::InitialStates > { public: /** * Returns true if the state is still used in some transition of the automaton. diff --git a/alib2data/src/automaton/FSM/NFA.h b/alib2data/src/automaton/FSM/NFA.h index 38595a6fa92c357aece4822589165a77d0cbf146..6ae338fc9d7e7d046e79209ae5fa1db60cd8ee7f 100644 --- a/alib2data/src/automaton/FSM/NFA.h +++ b/alib2data/src/automaton/FSM/NFA.h @@ -25,6 +25,7 @@ #define NFA_H_ #include <map> +#include <set> #include <core/components.hpp> #include <sax/FromXMLParserHelper.h> @@ -63,7 +64,7 @@ class InitialState; * \tparam StateType used to the states, and the initial state of the automaton. */ template<class SymbolType, class StateType > -class NFA final : public AutomatonBase, public alib::Components < NFA < SymbolType, StateType >, SymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > { +class NFA final : public AutomatonBase, public alib::Components < NFA < SymbolType, StateType >, ext::set < SymbolType >, component::Set, InputAlphabet, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > { /** * Transition function as mapping from a state times an input symbol on the left hand side to a set of states. */ @@ -110,7 +111,7 @@ public: * \returns the initial state of the automaton */ const StateType & getInitialState ( ) const & { - return this->template accessElement < InitialState > ( ).get ( ); + return this->template accessComponent < InitialState > ( ).get ( ); } /** @@ -119,7 +120,7 @@ public: * \returns the initial state of the automaton */ StateType && getInitialState ( ) && { - return std::move ( this->template accessElement < InitialState > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialState > ( ).get ( ) ); } /** @@ -130,7 +131,7 @@ public: * \returns true if the initial state was indeed changed */ bool setInitialState ( StateType state ) { - return this->template accessElement < InitialState > ( ).set ( std::move ( state ) ); + return this->template accessComponent < InitialState > ( ).set ( std::move ( state ) ); } /** @@ -482,7 +483,7 @@ public: namespace automaton { template<class SymbolType, class StateType > -NFA < SymbolType, StateType >::NFA ( ext::set < StateType > states, ext::set < SymbolType > inputAlphabet, StateType initialState, ext::set < StateType > finalStates ) : alib::Components < NFA < SymbolType, StateType >, SymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > ( ext::make_tuple ( std::move ( inputAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( states ), std::move ( finalStates ) ), ext::make_tuple ( std::move ( initialState ) ) ) { +NFA < SymbolType, StateType >::NFA ( ext::set < StateType > states, ext::set < SymbolType > inputAlphabet, StateType initialState, ext::set < StateType > finalStates ) : alib::Components < NFA, ext::set < SymbolType >, component::Set, InputAlphabet, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > ( std::move ( inputAlphabet ), std::move ( states ), std::move ( finalStates ), std::move ( initialState ) ) { } template<class SymbolType, class StateType > @@ -713,7 +714,7 @@ namespace alib { * \tparam StateType used for the terminal alphabet of the automaton. */ template<class SymbolType, class StateType > -class ComponentConstraint< automaton::NFA < SymbolType, StateType >, SymbolType, automaton::InputAlphabet > { +class SetConstraint< automaton::NFA < SymbolType, StateType >, SymbolType, automaton::InputAlphabet > { public: /** * Returns true if the symbol is still used in some transition of the automaton. @@ -760,7 +761,7 @@ public: * \tparam StateType used for the terminal alphabet of the automaton. */ template<class SymbolType, class StateType > -class ComponentConstraint< automaton::NFA < SymbolType, StateType >, StateType, automaton::States > { +class SetConstraint< automaton::NFA < SymbolType, StateType >, StateType, automaton::States > { public: /** * Returns true if the state is still used in some transition of the automaton. @@ -813,7 +814,7 @@ public: * \tparam StateType used for the terminal alphabet of the automaton. */ template<class SymbolType, class StateType > -class ComponentConstraint< automaton::NFA < SymbolType, StateType >, StateType, automaton::FinalStates > { +class SetConstraint< automaton::NFA < SymbolType, StateType >, StateType, automaton::FinalStates > { public: /** * Returns true if the state is still used in some transition of the automaton. diff --git a/alib2data/src/automaton/PDA/DPDA.h b/alib2data/src/automaton/PDA/DPDA.h index 18aafbb22fe8dc769239d49b309c7b398f474c85..27bf43c36de97cd31f4515e79861da9eed9d2573 100644 --- a/alib2data/src/automaton/PDA/DPDA.h +++ b/alib2data/src/automaton/PDA/DPDA.h @@ -46,7 +46,7 @@ class InitialState; * if $\delta(q, a, \alpha) \neq \emptyset$, $\delta (q, \varepsilon, \beta) \neq \emptyset$, then $\alpha$ is not suffix of $\beta$ and $\beta$ is not suffix of $\alpha$ (fornally $\gamma \alpha \neq \beta and \alpha \neq \gamma \beta$). */ template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class DPDA final : public AutomatonBase, public alib::Components < DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, ext::tuple < InputAlphabet>, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < InitialSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > { +class DPDA final : public AutomatonBase, public alib::Components < DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, ext::set < InputSymbolType >, component::Set, InputAlphabet, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, InitialSymbol, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > { protected: ext::map < ext::tuple < StateType, ext::variant < EpsilonType, InputSymbolType >, ext::vector < PushdownStoreSymbolType > >, ext::pair < StateType, ext::vector < PushdownStoreSymbolType > > > transitions; @@ -59,15 +59,15 @@ public: virtual AutomatonBase * plunder ( ) &&; const StateType & getInitialState ( ) const & { - return this->template accessElement < InitialState > ( ).get ( ); + return this->template accessComponent < InitialState > ( ).get ( ); } StateType && getInitialState ( ) && { - return std::move ( this->template accessElement < InitialState > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialState > ( ).get ( ) ); } bool setInitialState ( StateType state ) { - return this->template accessElement < InitialState > ( ).set ( std::move ( state ) ); + return this->template accessComponent < InitialState > ( ).set ( std::move ( state ) ); } const ext::set < StateType > & getStates ( ) const & { @@ -135,15 +135,15 @@ public: } const PushdownStoreSymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } PushdownStoreSymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } bool setInitialSymbol ( PushdownStoreSymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < InputSymbolType > & getInputAlphabet ( ) const & { @@ -243,7 +243,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >::DPDA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType initialSymbol, ext::set < StateType > finalStates ) : alib::Components < DPDA, InputSymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < InitialSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > ( ext::make_tuple ( std::move ( inputAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( pushdownStoreAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ), ext::make_tuple ( std::move ( states ), std::move ( finalStates ) ), ext::make_tuple ( std::move ( initialState ) ) ) { +DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >::DPDA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType initialSymbol, ext::set < StateType > finalStates ) : alib::Components < DPDA, ext::set < InputSymbolType >, component::Set, InputAlphabet, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, InitialSymbol, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > ( std::move ( inputAlphabet ), std::move ( pushdownStoreAlphabet ), std::move ( initialSymbol ), std::move ( states ), std::move ( finalStates ), std::move ( initialState ) ) { } template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > @@ -533,7 +533,7 @@ alib::ObjectBase* DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, namespace alib { template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > { +class SetConstraint< automaton::DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > { public: static bool used ( const automaton::DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const InputSymbolType & symbol ) { for ( const std::pair<const ext::tuple<StateType, ext::variant<EpsilonType, InputSymbolType>, ext::vector<PushdownStoreSymbolType> >, ext::pair<StateType, ext::vector<PushdownStoreSymbolType> > >& transition : automaton.getTransitions()) @@ -552,7 +552,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { +class SetConstraint< automaton::DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { public: static bool used ( const automaton::DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const PushdownStoreSymbolType & symbol ) { if(automaton.getInitialSymbol() == symbol) @@ -588,7 +588,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { +class SetConstraint< automaton::DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { public: static bool used ( const automaton::DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const StateType & state ) { if ( automaton.getInitialState ( ) == state ) @@ -613,7 +613,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { +class SetConstraint< automaton::DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { public: static bool used ( const automaton::DPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > &, const StateType & ) { return false; diff --git a/alib2data/src/automaton/PDA/InputDrivenDPDA.h b/alib2data/src/automaton/PDA/InputDrivenDPDA.h index 97b6e4308af706fe0a9b7ea4e06a902458212a11..756a8258bafbe0bb394e79d65c1b33030357f0f6 100644 --- a/alib2data/src/automaton/PDA/InputDrivenDPDA.h +++ b/alib2data/src/automaton/PDA/InputDrivenDPDA.h @@ -9,6 +9,7 @@ #define INPUT_DRIVEN_DPDA_H_ #include <map> +#include <set> #include <vector> #include <ostream> #include <sstream> @@ -42,7 +43,7 @@ class InitialState; * Can store nondeterministic finite automaton without epsilon transitions. */ template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class InputDrivenDPDA final : public AutomatonBase, public alib::Components < InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < InitialSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > { +class InputDrivenDPDA final : public AutomatonBase, public alib::Components < InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, ext::set < InputSymbolType >, component::Set, InputAlphabet, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, InitialSymbol, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > { protected: ext::map < ext::pair < StateType, InputSymbolType >, StateType > transitions; ext::map < InputSymbolType, ext::pair < ext::vector < PushdownStoreSymbolType >, ext::vector < PushdownStoreSymbolType > > > inputSymbolToPushdownStoreOperation; @@ -58,15 +59,15 @@ public: virtual AutomatonBase * plunder ( ) &&; const StateType & getInitialState ( ) const & { - return this->template accessElement < InitialState > ( ).get ( ); + return this->template accessComponent < InitialState > ( ).get ( ); } StateType && getInitialState ( ) && { - return std::move ( this->template accessElement < InitialState > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialState > ( ).get ( ) ); } bool setInitialState ( StateType state ) { - return this->template accessElement < InitialState > ( ).set ( std::move ( state ) ); + return this->template accessComponent < InitialState > ( ).set ( std::move ( state ) ); } const ext::set < StateType > & getStates ( ) const & { @@ -134,15 +135,15 @@ public: } const PushdownStoreSymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } PushdownStoreSymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } bool setInitialSymbol ( PushdownStoreSymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < InputSymbolType > & getInputAlphabet ( ) const & { @@ -246,7 +247,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >::InputDrivenDPDA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType initialSymbol, ext::set < StateType > finalStates ) : alib::Components < InputDrivenDPDA, InputSymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < InitialSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > ( ext::make_tuple ( std::move ( inputAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( pushdownStoreAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ), ext::make_tuple ( std::move ( states ), std::move ( finalStates ) ), ext::make_tuple ( std::move ( initialState ) ) ) { +InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >::InputDrivenDPDA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType initialSymbol, ext::set < StateType > finalStates ) : alib::Components < InputDrivenDPDA, ext::set < InputSymbolType >, component::Set, InputAlphabet, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, InitialSymbol, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > ( std::move ( inputAlphabet ), std::move ( pushdownStoreAlphabet ), std::move ( initialSymbol ), std::move ( states ), std::move ( finalStates ), std::move ( initialState ) ) { } template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > @@ -512,7 +513,7 @@ alib::ObjectBase* InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, St namespace alib { template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > { +class SetConstraint< automaton::InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > { public: static bool used ( const automaton::InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & automaton, const InputSymbolType & symbol ) { for ( const std::pair<const ext::pair<StateType, InputSymbolType>, StateType>& transition : automaton.getTransitions()) @@ -531,7 +532,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { +class SetConstraint< automaton::InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { public: static bool used ( const automaton::InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & automaton, const PushdownStoreSymbolType & symbol ) { for (const auto& pushdownStoreOperation : automaton.getPushdownStoreOperations()) { @@ -567,7 +568,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { +class SetConstraint< automaton::InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { public: static bool used ( const automaton::InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & automaton, const StateType & state ) { if ( automaton.getInitialState ( ) == state ) @@ -592,7 +593,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { +class SetConstraint< automaton::InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { public: static bool used ( const automaton::InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType > &, const StateType & ) { return false; diff --git a/alib2data/src/automaton/PDA/InputDrivenNPDA.h b/alib2data/src/automaton/PDA/InputDrivenNPDA.h index af0981b80af286254f9be13b7af008a66d4d7ab2..f91439a14296700d65022535141ce66ae8858a08 100644 --- a/alib2data/src/automaton/PDA/InputDrivenNPDA.h +++ b/alib2data/src/automaton/PDA/InputDrivenNPDA.h @@ -9,6 +9,7 @@ #define INPUT_DRIVEN_NPDA_H_ #include <map> +#include <set> #include <vector> #include <ostream> #include <sstream> @@ -42,7 +43,7 @@ class InitialState; * Can store nondeterministic finite automaton without epsilon transitions. */ template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class InputDrivenNPDA final : public AutomatonBase, public alib::Components < InputDrivenNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < InitialSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > { +class InputDrivenNPDA final : public AutomatonBase, public alib::Components < InputDrivenNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, ext::set < InputSymbolType >, component::Set, InputAlphabet, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, InitialSymbol, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > { protected: ext::map < ext::pair < StateType, InputSymbolType >, ext::set < StateType > > transitions; ext::map < InputSymbolType, ext::pair < ext::vector < PushdownStoreSymbolType >, ext::vector < PushdownStoreSymbolType > > > inputSymbolToPushdownStoreOperation; @@ -58,15 +59,15 @@ public: virtual AutomatonBase * plunder ( ) &&; const StateType & getInitialState ( ) const & { - return this->template accessElement < InitialState > ( ).get ( ); + return this->template accessComponent < InitialState > ( ).get ( ); } StateType && getInitialState ( ) && { - return std::move ( this->template accessElement < InitialState > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialState > ( ).get ( ) ); } bool setInitialState ( StateType state ) { - return this->template accessElement < InitialState > ( ).set ( std::move ( state ) ); + return this->template accessComponent < InitialState > ( ).set ( std::move ( state ) ); } const ext::set < StateType > & getStates ( ) const & { @@ -134,15 +135,15 @@ public: } const PushdownStoreSymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } PushdownStoreSymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } bool setInitialSymbol ( PushdownStoreSymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < InputSymbolType > & getInputAlphabet ( ) const & { @@ -255,7 +256,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -InputDrivenNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >::InputDrivenNPDA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType initialSymbol, ext::set < StateType > finalStates ) : alib::Components < InputDrivenNPDA, InputSymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < InitialSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > ( ext::make_tuple ( std::move ( inputAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( pushdownStoreAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ), ext::make_tuple ( std::move ( states ), std::move ( finalStates ) ), ext::make_tuple ( std::move ( initialState ) ) ) { +InputDrivenNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >::InputDrivenNPDA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType initialSymbol, ext::set < StateType > finalStates ) : alib::Components < InputDrivenNPDA, ext::set < InputSymbolType >, component::Set, InputAlphabet, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, InitialSymbol, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > ( std::move ( inputAlphabet ), std::move ( pushdownStoreAlphabet ), std::move ( initialSymbol ), std::move ( states ), std::move ( finalStates ), std::move ( initialState ) ) { } template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > @@ -537,7 +538,7 @@ alib::ObjectBase* InputDrivenNPDA < InputSymbolType, PushdownStoreSymbolType, St namespace alib { template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::InputDrivenNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > { +class SetConstraint< automaton::InputDrivenNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > { public: static bool used ( const automaton::InputDrivenNPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & automaton, const InputSymbolType & symbol ) { for ( const std::pair<const ext::pair<StateType, InputSymbolType>, ext::set<StateType >>& transition : automaton.getTransitions()) @@ -556,7 +557,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::InputDrivenNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { +class SetConstraint< automaton::InputDrivenNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { public: static bool used ( const automaton::InputDrivenNPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & automaton, const PushdownStoreSymbolType & symbol ) { for (const auto& pushdownStoreOperation : automaton.getPushdownStoreOperations()) { @@ -592,7 +593,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::InputDrivenNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { +class SetConstraint< automaton::InputDrivenNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { public: static bool used ( const automaton::InputDrivenNPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & automaton, const StateType & state ) { if ( automaton.getInitialState ( ) == state ) @@ -617,7 +618,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::InputDrivenNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { +class SetConstraint< automaton::InputDrivenNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { public: static bool used ( const automaton::InputDrivenNPDA < InputSymbolType, PushdownStoreSymbolType, StateType > &, const StateType & ) { return false; diff --git a/alib2data/src/automaton/PDA/NPDA.h b/alib2data/src/automaton/PDA/NPDA.h index d648367082f3b9bc4a3d8b288ef94ffc411bf799..b9099467fee04d4be53a6346b76162b7b6ddfad5 100644 --- a/alib2data/src/automaton/PDA/NPDA.h +++ b/alib2data/src/automaton/PDA/NPDA.h @@ -42,7 +42,7 @@ class InitialState; * Push Down Automaton */ template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class NPDA final : public AutomatonBase, public alib::Components < NPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < InitialSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > { +class NPDA final : public AutomatonBase, public alib::Components < NPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, ext::set < InputSymbolType >, component::Set, InputAlphabet, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, InitialSymbol, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > { protected: ext::map < ext::tuple < StateType, ext::variant < EpsilonType, InputSymbolType >, ext::vector < PushdownStoreSymbolType > >, ext::set < ext::pair < StateType, ext::vector < PushdownStoreSymbolType > > > > transitions; @@ -55,15 +55,15 @@ public: virtual AutomatonBase * plunder ( ) &&; const StateType & getInitialState ( ) const & { - return this->template accessElement < InitialState > ( ).get ( ); + return this->template accessComponent < InitialState > ( ).get ( ); } StateType && getInitialState ( ) && { - return std::move ( this->template accessElement < InitialState > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialState > ( ).get ( ) ); } bool setInitialState ( StateType state ) { - return this->template accessElement < InitialState > ( ).set ( std::move ( state ) ); + return this->template accessComponent < InitialState > ( ).set ( std::move ( state ) ); } const ext::set < StateType > & getStates ( ) const & { @@ -131,15 +131,15 @@ public: } const PushdownStoreSymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } PushdownStoreSymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } bool setInitialSymbol ( PushdownStoreSymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < InputSymbolType > & getInputAlphabet ( ) const & { @@ -241,7 +241,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -NPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >::NPDA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType initialSymbol, ext::set < StateType > finalStates ) : alib::Components < NPDA, InputSymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < InitialSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > ( ext::make_tuple ( std::move ( inputAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( pushdownStoreAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ), ext::make_tuple ( std::move ( states ), std::move ( finalStates ) ), ext::make_tuple ( std::move ( initialState ) ) ) { +NPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >::NPDA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType initialSymbol, ext::set < StateType > finalStates ) : alib::Components < NPDA, ext::set < InputSymbolType >, component::Set, InputAlphabet, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, InitialSymbol, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > ( std::move ( inputAlphabet ), std::move ( pushdownStoreAlphabet ), std::move ( initialSymbol ), std::move ( states ), std::move ( finalStates ), std::move ( initialState ) ) { } template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > @@ -473,7 +473,7 @@ alib::ObjectBase* NPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, namespace alib { template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::NPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > { +class SetConstraint< automaton::NPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > { public: static bool used ( const automaton::NPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const InputSymbolType & symbol ) { for ( const std::pair<const ext::tuple<StateType, ext::variant < EpsilonType, InputSymbolType >, ext::vector<PushdownStoreSymbolType> >, ext::set<ext::pair<StateType, ext::vector<PushdownStoreSymbolType> > > >& transition : automaton.getTransitions()) @@ -492,7 +492,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::NPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { +class SetConstraint< automaton::NPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { public: static bool used ( const automaton::NPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const PushdownStoreSymbolType & symbol ) { if(automaton.getInitialSymbol() == symbol) @@ -531,7 +531,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::NPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { +class SetConstraint< automaton::NPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { public: static bool used ( const automaton::NPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const StateType & state ) { if ( automaton.getInitialState ( ) == state ) @@ -560,7 +560,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::NPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { +class SetConstraint< automaton::NPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { public: static bool used ( const automaton::NPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > &, const StateType & ) { return false; diff --git a/alib2data/src/automaton/PDA/NPDTA.h b/alib2data/src/automaton/PDA/NPDTA.h index a94d7e8353ebc1a6eba976e87b18a53fef3197e3..09c5ff7467ebb6aa7de1b3bebda7d73707fbf408 100644 --- a/alib2data/src/automaton/PDA/NPDTA.h +++ b/alib2data/src/automaton/PDA/NPDTA.h @@ -43,7 +43,7 @@ class InitialState; * Push Down Translation Automaton */ template < class InputSymbolType, class OutputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class NPDTA final : public AutomatonBase, public alib::Components < NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, OutputSymbolType, ext::tuple < OutputAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < InitialSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > { +class NPDTA final : public AutomatonBase, public alib::Components < NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, ext::set < InputSymbolType >, component::Set, InputAlphabet, ext::set < OutputSymbolType >, component::Set, OutputAlphabet, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, InitialSymbol, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > { protected: ext::map < ext::tuple < StateType, ext::variant < EpsilonType, InputSymbolType >, ext::vector < PushdownStoreSymbolType > >, ext::set < ext::tuple < StateType, ext::vector < PushdownStoreSymbolType >, ext::vector < OutputSymbolType > > > > transitions; @@ -56,15 +56,15 @@ public: virtual AutomatonBase * plunder ( ) &&; const StateType & getInitialState ( ) const & { - return this->template accessElement < InitialState > ( ).get ( ); + return this->template accessComponent < InitialState > ( ).get ( ); } StateType && getInitialState ( ) && { - return std::move ( this->template accessElement < InitialState > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialState > ( ).get ( ) ); } bool setInitialState ( StateType state ) { - return this->template accessElement < InitialState > ( ).set ( std::move ( state ) ); + return this->template accessComponent < InitialState > ( ).set ( std::move ( state ) ); } const ext::set < StateType > & getStates ( ) const & { @@ -132,15 +132,15 @@ public: } const PushdownStoreSymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } PushdownStoreSymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } bool setInitialSymbol ( PushdownStoreSymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < InputSymbolType > & getInputAlphabet ( ) const & { @@ -265,7 +265,7 @@ public: }; template < class InputSymbolType, class OutputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >::NPDTA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < OutputSymbolType > outputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType initialSymbol, ext::set < StateType > finalStates ) : alib::Components < NPDTA, InputSymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, OutputSymbolType, ext::tuple < OutputAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < InitialSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > ( ext::make_tuple ( std::move ( inputAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( outputAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( pushdownStoreAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ), ext::make_tuple ( std::move ( states ), std::move ( finalStates ) ), ext::make_tuple ( std::move ( initialState ) ) ) { +NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >::NPDTA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < OutputSymbolType > outputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType initialSymbol, ext::set < StateType > finalStates ) : alib::Components < NPDTA, ext::set < InputSymbolType >, component::Set, InputAlphabet, ext::set < OutputSymbolType >, component::Set, OutputAlphabet, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, InitialSymbol, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > ( std::move ( inputAlphabet ), std::move ( outputAlphabet ), std::move ( pushdownStoreAlphabet ), std::move ( initialSymbol ), std::move ( states ), std::move ( finalStates ), std::move ( initialState ) ) { } template < class InputSymbolType, class OutputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > @@ -538,7 +538,7 @@ alib::ObjectBase* NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, Pushdo namespace alib { template < class InputSymbolType, class OutputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > { +class SetConstraint< automaton::NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > { public: static bool used ( const automaton::NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const InputSymbolType & symbol ) { for ( const std::pair<const ext::tuple<StateType, ext::variant < EpsilonType, InputSymbolType >, ext::vector<PushdownStoreSymbolType> >, ext::set<ext::tuple<StateType, ext::vector<PushdownStoreSymbolType>, ext::vector < OutputSymbolType > > > >& transition : automaton.getTransitions()) @@ -557,7 +557,7 @@ public: }; template < class InputSymbolType, class OutputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, OutputSymbolType, automaton::OutputAlphabet > { +class SetConstraint< automaton::NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, OutputSymbolType, automaton::OutputAlphabet > { public: static bool used ( const automaton::NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const OutputSymbolType & symbol ) { for ( const std::pair<const ext::tuple<StateType, ext::variant < EpsilonType, InputSymbolType >, ext::vector<PushdownStoreSymbolType> >, ext::set<ext::tuple<StateType, ext::vector<PushdownStoreSymbolType>, ext::vector < OutputSymbolType > > > >& transition : automaton.getTransitions()) @@ -577,7 +577,7 @@ public: }; template < class InputSymbolType, class OutputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { +class SetConstraint< automaton::NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { public: static bool used ( const automaton::NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const PushdownStoreSymbolType & symbol ) { if(automaton.getInitialSymbol() == symbol) @@ -616,7 +616,7 @@ public: }; template < class InputSymbolType, class OutputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { +class SetConstraint< automaton::NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { public: static bool used ( const automaton::NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const StateType & state ) { if ( automaton.getInitialState ( ) == state ) @@ -646,7 +646,7 @@ public: }; template < class InputSymbolType, class OutputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { +class SetConstraint< automaton::NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { public: static bool used ( const automaton::NPDTA < InputSymbolType, OutputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > &, const StateType & ) { return false; diff --git a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.h b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.h index ee57638c2a4c334abdc9804676acc2ae5d4007eb..3db198d960364275d10e8d5d3aa8e6c504c0e57a 100644 --- a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.h +++ b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.h @@ -9,6 +9,7 @@ #define REAL_TIME_HEIGHT_DETERMINISTIC_DPDA_H_ #include <map> +#include <set> #include <vector> #include <variant> #include <algorithm> @@ -42,7 +43,7 @@ class InitialState; * Can store nondeterministic finite automaton without epsilon transitions. */ template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class RealTimeHeightDeterministicDPDA final : public AutomatonBase, public alib::Components < RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < BottomOfTheStackSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > { +class RealTimeHeightDeterministicDPDA final : public AutomatonBase, public alib::Components < RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, ext::set < InputSymbolType >, component::Set, InputAlphabet, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, BottomOfTheStackSymbol, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > { protected: ext::map < ext::pair < StateType, ext::variant < EpsilonType, InputSymbolType > >, ext::pair < StateType, PushdownStoreSymbolType > > callTransitions; ext::map < ext::tuple < StateType, ext::variant < EpsilonType, InputSymbolType >, PushdownStoreSymbolType >, StateType > returnTransitions; @@ -57,15 +58,15 @@ public: virtual AutomatonBase * plunder ( ) &&; const StateType & getInitialState ( ) const & { - return this->template accessElement < InitialState > ( ).get ( ); + return this->template accessComponent < InitialState > ( ).get ( ); } StateType && getInitialState ( ) && { - return std::move ( this->template accessElement < InitialState > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialState > ( ).get ( ) ); } bool setInitialState ( StateType state ) { - return this->template accessElement < InitialState > ( ).set ( std::move ( state ) ); + return this->template accessComponent < InitialState > ( ).set ( std::move ( state ) ); } const ext::set < StateType > & getStates ( ) const & { @@ -133,15 +134,15 @@ public: } const PushdownStoreSymbolType & getBottomOfTheStackSymbol ( ) const & { - return this->template accessElement < BottomOfTheStackSymbol > ( ).get ( ); + return this->template accessComponent < BottomOfTheStackSymbol > ( ).get ( ); } PushdownStoreSymbolType && getBottomOfTheStackSymbol ( ) && { - return std::move ( this->template accessElement < BottomOfTheStackSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < BottomOfTheStackSymbol > ( ).get ( ) ); } bool setBottomOfTheStackSymbol ( PushdownStoreSymbolType symbol ) { - return this->template accessElement < BottomOfTheStackSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < BottomOfTheStackSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < InputSymbolType > & getInputAlphabet ( ) const & { @@ -270,7 +271,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >::RealTimeHeightDeterministicDPDA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType bottomOfTheStackSymbol, ext::set < StateType > finalStates ) : alib::Components < RealTimeHeightDeterministicDPDA, InputSymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < BottomOfTheStackSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > ( ext::make_tuple ( std::move ( inputAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( pushdownStoreAlphabet ) ), ext::make_tuple ( std::move ( bottomOfTheStackSymbol ) ), ext::make_tuple ( std::move ( states ), std::move ( finalStates ) ), ext::make_tuple ( std::move ( initialState ) ) ) { +RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >::RealTimeHeightDeterministicDPDA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType bottomOfTheStackSymbol, ext::set < StateType > finalStates ) : alib::Components < RealTimeHeightDeterministicDPDA, ext::set < InputSymbolType >, component::Set, InputAlphabet, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, BottomOfTheStackSymbol, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > ( std::move ( inputAlphabet ), std::move ( pushdownStoreAlphabet ), std::move ( bottomOfTheStackSymbol ), std::move ( states ), std::move ( finalStates ), std::move ( initialState ) ) { } template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > @@ -736,7 +737,7 @@ alib::ObjectBase* RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType namespace alib { template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > { +class SetConstraint< automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > { public: static bool used ( const automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const InputSymbolType & symbol ) { for ( const std::pair<const ext::pair<StateType, ext::variant < EpsilonType, InputSymbolType >>, ext::pair<StateType, PushdownStoreSymbolType> >& callTransition : automaton.getCallTransitions()) @@ -763,7 +764,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { +class SetConstraint< automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { public: static bool used ( const automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const PushdownStoreSymbolType & symbol ) { for ( const std::pair<const ext::pair<StateType, ext::variant < EpsilonType, InputSymbolType >>, ext::pair<StateType, PushdownStoreSymbolType> >& callTransition : automaton.getCallTransitions()) @@ -800,7 +801,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { +class SetConstraint< automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { public: static bool used ( const automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const StateType & state ) { if ( automaton.getInitialState ( ) == state ) @@ -833,7 +834,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { +class SetConstraint< automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { public: static bool used ( const automaton::RealTimeHeightDeterministicDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > &, const StateType & ) { return false; diff --git a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.h b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.h index 1f3a398a60b50333df958429d1c2c2ec7673144a..1ccfd5cc3bc4b5b07e4fa40344323929c61f5670 100644 --- a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.h +++ b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.h @@ -9,6 +9,7 @@ #define REAL_TIME_HEIGHT_DETERMINISTIC_NPDA_H_ #include <map> +#include <set> #include <vector> #include <variant> #include <algorithm> @@ -42,7 +43,7 @@ class InitialStates; * Can store nondeterministic finite automaton without epsilon transitions. */ template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class RealTimeHeightDeterministicNPDA final : public AutomatonBase, public alib::Components < RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < BottomOfTheStackSymbol >, StateType, ext::tuple < States, InitialStates, FinalStates >, ext::tuple < > > { +class RealTimeHeightDeterministicNPDA final : public AutomatonBase, public alib::Components < RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, ext::set < InputSymbolType >, component::Set, InputAlphabet, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, BottomOfTheStackSymbol, ext::set < StateType >, component::Set, std::tuple < States, InitialStates, FinalStates > > { protected: ext::map < ext::pair < StateType, ext::variant < EpsilonType, InputSymbolType > >, ext::set < ext::pair < StateType, PushdownStoreSymbolType > > > callTransitions; ext::map < ext::tuple < StateType, ext::variant < EpsilonType, InputSymbolType >, PushdownStoreSymbolType >, ext::set < StateType > > returnTransitions; @@ -141,15 +142,15 @@ public: } const PushdownStoreSymbolType & getBottomOfTheStackSymbol ( ) const & { - return this->template accessElement < BottomOfTheStackSymbol > ( ).get ( ); + return this->template accessComponent < BottomOfTheStackSymbol > ( ).get ( ); } PushdownStoreSymbolType && getBottomOfTheStackSymbol ( ) && { - return std::move ( this->template accessElement < BottomOfTheStackSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < BottomOfTheStackSymbol > ( ).get ( ) ); } bool setBottomOfTheStackSymbol ( PushdownStoreSymbolType symbol ) { - return this->template accessElement < BottomOfTheStackSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < BottomOfTheStackSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < InputSymbolType > & getInputAlphabet ( ) const & { @@ -311,7 +312,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >::RealTimeHeightDeterministicNPDA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, ext::set < StateType > initialStates, PushdownStoreSymbolType bottomOfTheStackSymbol, ext::set < StateType > finalStates ) : alib::Components < RealTimeHeightDeterministicNPDA, InputSymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < BottomOfTheStackSymbol >, StateType, ext::tuple < States, InitialStates, FinalStates >, ext::tuple < > > ( ext::make_tuple ( std::move ( inputAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( pushdownStoreAlphabet ) ), ext::make_tuple ( std::move ( bottomOfTheStackSymbol ) ), ext::make_tuple ( std::move ( states ), std::move ( initialStates ), std::move ( finalStates ) ), ext::tuple < > { } ) { +RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >::RealTimeHeightDeterministicNPDA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, ext::set < StateType > initialStates, PushdownStoreSymbolType bottomOfTheStackSymbol, ext::set < StateType > finalStates ) : alib::Components < RealTimeHeightDeterministicNPDA, ext::set < InputSymbolType >, component::Set, InputAlphabet, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, BottomOfTheStackSymbol, ext::set < StateType >, component::Set, std::tuple < States, InitialStates, FinalStates > > ( std::move ( inputAlphabet ), std::move ( pushdownStoreAlphabet ), std::move ( bottomOfTheStackSymbol ), std::move ( states ), std::move ( initialStates ), std::move ( finalStates ) ) { } template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > @@ -759,7 +760,7 @@ alib::ObjectBase* RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType namespace alib { template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > { +class SetConstraint< automaton::RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > { public: static bool used ( const automaton::RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const InputSymbolType & symbol ) { for ( const std::pair<const ext::pair<StateType, ext::variant < EpsilonType, InputSymbolType >>, ext::set<ext::pair<StateType, PushdownStoreSymbolType> > >& callTransition : automaton.getCallTransitions()) @@ -786,7 +787,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { +class SetConstraint< automaton::RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { public: static bool used ( const automaton::RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const PushdownStoreSymbolType & symbol ) { if(automaton.getBottomOfTheStackSymbol() == symbol) @@ -824,7 +825,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { +class SetConstraint< automaton::RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { public: static bool used ( const automaton::RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const StateType & state ) { if ( automaton.getInitialStates ( ).count ( state ) ) @@ -872,7 +873,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { +class SetConstraint< automaton::RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { public: static bool used ( const automaton::RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > &, const StateType & ) { return false; @@ -887,7 +888,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::InitialStates > { +class SetConstraint< automaton::RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::InitialStates > { public: static bool used ( const automaton::RealTimeHeightDeterministicNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > &, const StateType & ) { return false; diff --git a/alib2data/src/automaton/PDA/SinglePopDPDA.h b/alib2data/src/automaton/PDA/SinglePopDPDA.h index 2e7165da107146663d1c1c9ecfc5279f6774cc32..6e517a61ee271c399d4a270be86cce11ac35ef94 100644 --- a/alib2data/src/automaton/PDA/SinglePopDPDA.h +++ b/alib2data/src/automaton/PDA/SinglePopDPDA.h @@ -47,7 +47,7 @@ class InitialState; * if $\delta(q, a, r) \neq \emptyset$, $\delta (q, \varepsilon, s) \neq \emptyset$, then $r \neq s$. */ template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class SinglePopDPDA final : public AutomatonBase, public alib::Components < SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < InitialSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > { +class SinglePopDPDA final : public AutomatonBase, public alib::Components < SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, ext::set < InputSymbolType >, component::Set, InputAlphabet, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, InitialSymbol, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > { protected: ext::map < ext::tuple < StateType, ext::variant < EpsilonType, InputSymbolType >, PushdownStoreSymbolType >, ext::pair < StateType, ext::vector < PushdownStoreSymbolType > > > transitions; @@ -60,15 +60,15 @@ public: virtual AutomatonBase * plunder ( ) &&; const StateType & getInitialState ( ) const & { - return this->template accessElement < InitialState > ( ).get ( ); + return this->template accessComponent < InitialState > ( ).get ( ); } StateType && getInitialState ( ) && { - return std::move ( this->template accessElement < InitialState > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialState > ( ).get ( ) ); } bool setInitialState ( StateType state ) { - return this->template accessElement < InitialState > ( ).set ( std::move ( state ) ); + return this->template accessComponent < InitialState > ( ).set ( std::move ( state ) ); } const ext::set < StateType > & getStates ( ) const & { @@ -136,15 +136,15 @@ public: } const PushdownStoreSymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } PushdownStoreSymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } bool setInitialSymbol ( PushdownStoreSymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < InputSymbolType > & getInputAlphabet ( ) const & { @@ -231,7 +231,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >::SinglePopDPDA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType initialSymbol, ext::set < StateType > finalStates ) : alib::Components < SinglePopDPDA, InputSymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < InitialSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > ( ext::make_tuple ( std::move ( inputAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( pushdownStoreAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ), ext::make_tuple ( std::move ( states ), std::move ( finalStates ) ), ext::make_tuple ( std::move ( initialState ) ) ) { +SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >::SinglePopDPDA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType initialSymbol, ext::set < StateType > finalStates ) : alib::Components < SinglePopDPDA, ext::set < InputSymbolType >, component::Set, InputAlphabet, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, InitialSymbol, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > ( std::move ( inputAlphabet ), std::move ( pushdownStoreAlphabet ), std::move ( initialSymbol ), std::move ( states ), std::move ( finalStates ), std::move ( initialState ) ) { } template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > @@ -461,7 +461,7 @@ alib::ObjectBase* SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSym namespace alib { template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > { +class SetConstraint< automaton::SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > { public: static bool used ( const automaton::SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const InputSymbolType & symbol ) { for ( const std::pair<const ext::tuple<StateType, ext::variant < EpsilonType, InputSymbolType >, PushdownStoreSymbolType>, ext::pair<StateType, ext::vector<PushdownStoreSymbolType> > >& transition : automaton.getTransitions()) @@ -480,7 +480,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { +class SetConstraint< automaton::SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { public: static bool used ( const automaton::SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const PushdownStoreSymbolType & symbol ) { for ( const std::pair<const ext::tuple<StateType, ext::variant < EpsilonType, InputSymbolType >, PushdownStoreSymbolType>, ext::pair<StateType, ext::vector<PushdownStoreSymbolType> > >& transition : automaton.getTransitions()) @@ -513,7 +513,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { +class SetConstraint< automaton::SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { public: static bool used ( const automaton::SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const StateType & state ) { if ( automaton.getInitialState ( ) == state ) @@ -538,7 +538,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { +class SetConstraint< automaton::SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { public: static bool used ( const automaton::SinglePopDPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > &, const StateType & ) { return false; diff --git a/alib2data/src/automaton/PDA/SinglePopNPDA.h b/alib2data/src/automaton/PDA/SinglePopNPDA.h index d7899299d9453dda2d3af3c5c5e4fd74800f3da2..20a8449e67fbea8bb837a300bc21c2fb4cc44026 100644 --- a/alib2data/src/automaton/PDA/SinglePopNPDA.h +++ b/alib2data/src/automaton/PDA/SinglePopNPDA.h @@ -42,7 +42,7 @@ class InitialState; * Push Down Automaton */ template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class SinglePopNPDA final : public AutomatonBase, public alib::Components < SinglePopNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < InitialSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > { +class SinglePopNPDA final : public AutomatonBase, public alib::Components < SinglePopNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, ext::set < InputSymbolType >, component::Set, InputAlphabet, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, InitialSymbol, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > { protected: ext::map < ext::tuple < StateType, ext::variant < EpsilonType, InputSymbolType >, PushdownStoreSymbolType >, ext::set < ext::pair < StateType, ext::vector < PushdownStoreSymbolType > > > > transitions; @@ -55,15 +55,15 @@ public: virtual AutomatonBase * plunder ( ) &&; const StateType & getInitialState ( ) const & { - return this->template accessElement < InitialState > ( ).get ( ); + return this->template accessComponent < InitialState > ( ).get ( ); } StateType && getInitialState ( ) && { - return std::move ( this->template accessElement < InitialState > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialState > ( ).get ( ) ); } bool setInitialState ( StateType state ) { - return this->template accessElement < InitialState > ( ).set ( std::move ( state ) ); + return this->template accessComponent < InitialState > ( ).set ( std::move ( state ) ); } const ext::set < StateType > & getStates ( ) const & { @@ -131,15 +131,15 @@ public: } const PushdownStoreSymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } PushdownStoreSymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } bool setInitialSymbol ( PushdownStoreSymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < InputSymbolType > & getInputAlphabet ( ) const & { @@ -238,7 +238,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -SinglePopNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >::SinglePopNPDA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType initialSymbol, ext::set < StateType > finalStates ) : alib::Components < SinglePopNPDA, InputSymbolType, ext::tuple < InputAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < InitialSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > ( ext::make_tuple ( std::move ( inputAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( pushdownStoreAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ), ext::make_tuple ( std::move ( states ), std::move ( finalStates ) ), ext::make_tuple ( std::move ( initialState ) ) ) { +SinglePopNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >::SinglePopNPDA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType initialSymbol, ext::set < StateType > finalStates ) : alib::Components < SinglePopNPDA, ext::set < InputSymbolType >, component::Set, InputAlphabet, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, InitialSymbol, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > ( std::move ( inputAlphabet ), std::move ( pushdownStoreAlphabet ), std::move ( initialSymbol ), std::move ( states ), std::move ( finalStates ), std::move ( initialState ) ) { } template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > @@ -473,7 +473,7 @@ alib::ObjectBase* SinglePopNPDA < InputSymbolType, EpsilonType, PushdownStoreSym namespace alib { template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::SinglePopNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > { +class SetConstraint< automaton::SinglePopNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > { public: static bool used ( const automaton::SinglePopNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const InputSymbolType & symbol ) { for ( const std::pair<const ext::tuple<StateType, ext::variant < EpsilonType, InputSymbolType >, PushdownStoreSymbolType>, ext::set<ext::pair<StateType, ext::vector<PushdownStoreSymbolType> > > >& transition : automaton.getTransitions()) @@ -492,7 +492,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::SinglePopNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { +class SetConstraint< automaton::SinglePopNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { public: static bool used ( const automaton::SinglePopNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const PushdownStoreSymbolType & symbol ) { if(automaton.getInitialSymbol() == symbol) @@ -530,7 +530,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::SinglePopNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { +class SetConstraint< automaton::SinglePopNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { public: static bool used ( const automaton::SinglePopNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > & automaton, const StateType & state ) { if ( automaton.getInitialState ( ) == state ) @@ -560,7 +560,7 @@ public: }; template < class InputSymbolType, class EpsilonType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::SinglePopNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { +class SetConstraint< automaton::SinglePopNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { public: static bool used ( const automaton::SinglePopNPDA < InputSymbolType, EpsilonType, PushdownStoreSymbolType, StateType > &, const StateType & ) { return false; diff --git a/alib2data/src/automaton/PDA/VisiblyPushdownDPDA.h b/alib2data/src/automaton/PDA/VisiblyPushdownDPDA.h index 562e0db0087d1742449ef4064d9c62d6c6f5bb90..935d197467947b958b31b24bd778dff46519275c 100644 --- a/alib2data/src/automaton/PDA/VisiblyPushdownDPDA.h +++ b/alib2data/src/automaton/PDA/VisiblyPushdownDPDA.h @@ -9,6 +9,7 @@ #define VISIBLY_PUSHDOWN_DPDA_H_ #include <map> +#include <set> #include <vector> #include <algorithm> #include <sstream> @@ -43,7 +44,7 @@ class InitialState; * Can store nondeterministic finite automaton without epsilon transitions. */ template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class VisiblyPushdownDPDA final : public AutomatonBase, public alib::Components < VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, ext::tuple < CallAlphabet, ReturnAlphabet, LocalAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < BottomOfTheStackSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > { +class VisiblyPushdownDPDA final : public AutomatonBase, public alib::Components < VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, ext::set < InputSymbolType >, component::Set, std::tuple < CallAlphabet, ReturnAlphabet, LocalAlphabet >, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, BottomOfTheStackSymbol, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > { protected: ext::map < ext::pair < StateType, InputSymbolType >, ext::pair < StateType, PushdownStoreSymbolType > > callTransitions; ext::map < ext::tuple < StateType, InputSymbolType, PushdownStoreSymbolType >, StateType > returnTransitions; @@ -58,15 +59,15 @@ public: virtual AutomatonBase * plunder ( ) &&; const StateType & getInitialState ( ) const & { - return this->template accessElement < InitialState > ( ).get ( ); + return this->template accessComponent < InitialState > ( ).get ( ); } StateType && getInitialState ( ) && { - return std::move ( this->template accessElement < InitialState > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialState > ( ).get ( ) ); } bool setInitialState ( StateType state ) { - return this->template accessElement < InitialState > ( ).set ( std::move ( state ) ); + return this->template accessComponent < InitialState > ( ).set ( std::move ( state ) ); } const ext::set < StateType > & getStates ( ) const & { @@ -134,15 +135,15 @@ public: } const PushdownStoreSymbolType & getBottomOfTheStackSymbol ( ) const & { - return this->template accessElement < BottomOfTheStackSymbol > ( ).get ( ); + return this->template accessComponent < BottomOfTheStackSymbol > ( ).get ( ); } PushdownStoreSymbolType && getBottomOfTheStackSymbol ( ) && { - return std::move ( this->template accessElement < BottomOfTheStackSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < BottomOfTheStackSymbol > ( ).get ( ) ); } bool setBottomOfTheStackSymbol ( PushdownStoreSymbolType symbol ) { - return this->template accessElement < BottomOfTheStackSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < BottomOfTheStackSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < InputSymbolType > & getCallInputAlphabet ( ) const & { @@ -311,7 +312,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >::VisiblyPushdownDPDA ( ext::set < StateType > states, ext::set < InputSymbolType > callAlphabet, ext::set < InputSymbolType > returnAlphabet, ext::set < InputSymbolType > localAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType bottomOfTheStackSymbol, ext::set < StateType > finalStates ) : alib::Components < VisiblyPushdownDPDA, InputSymbolType, ext::tuple < CallAlphabet, ReturnAlphabet, LocalAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < BottomOfTheStackSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > ( ext::make_tuple ( std::move ( callAlphabet ), std::move ( returnAlphabet ), std::move ( localAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( pushdownStoreAlphabet ) ), ext::make_tuple ( std::move ( bottomOfTheStackSymbol ) ), ext::make_tuple ( std::move ( states ), std::move ( finalStates ) ), ext::make_tuple ( std::move ( initialState ) ) ) { +VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >::VisiblyPushdownDPDA ( ext::set < StateType > states, ext::set < InputSymbolType > callAlphabet, ext::set < InputSymbolType > returnAlphabet, ext::set < InputSymbolType > localAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType bottomOfTheStackSymbol, ext::set < StateType > finalStates ) : alib::Components < VisiblyPushdownDPDA, ext::set < InputSymbolType >, component::Set, std::tuple < CallAlphabet, ReturnAlphabet, LocalAlphabet >, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, BottomOfTheStackSymbol, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > ( std::move ( callAlphabet ), std::move ( returnAlphabet ), std::move ( localAlphabet ), std::move ( pushdownStoreAlphabet ), std::move ( bottomOfTheStackSymbol ), std::move ( states ), std::move ( finalStates ), std::move ( initialState ) ) { } template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > @@ -668,7 +669,7 @@ alib::ObjectBase* VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType namespace alib { template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::CallAlphabet > { +class SetConstraint< automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::CallAlphabet > { public: static bool used ( const automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & automaton, const InputSymbolType & symbol ) { for ( const std::pair<const ext::pair<StateType, InputSymbolType>, ext::pair<StateType, PushdownStoreSymbolType> >& callTransition : automaton.getCallTransitions()) @@ -691,7 +692,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::ReturnAlphabet > { +class SetConstraint< automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::ReturnAlphabet > { public: static bool used ( const automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & automaton, const InputSymbolType & symbol ) { for ( const std::pair<const ext::tuple<StateType, InputSymbolType, PushdownStoreSymbolType>, StateType>& returnTransition : automaton.getReturnTransitions()) @@ -714,7 +715,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::LocalAlphabet > { +class SetConstraint< automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::LocalAlphabet > { public: static bool used ( const automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & automaton, const InputSymbolType & symbol ) { for ( const std::pair<const ext::pair<StateType, InputSymbolType>, StateType>& localTransition : automaton.getLocalTransitions()) @@ -737,7 +738,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { +class SetConstraint< automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { public: static bool used ( const automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & automaton, const PushdownStoreSymbolType & symbol ) { for ( const std::pair<const ext::pair<StateType, InputSymbolType>, ext::pair<StateType, PushdownStoreSymbolType> >& callTransition : automaton.getCallTransitions()) @@ -774,7 +775,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { +class SetConstraint< automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { public: static bool used ( const automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & automaton, const StateType & state ) { if ( automaton.getInitialState ( ) == state ) @@ -807,7 +808,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { +class SetConstraint< automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { public: static bool used ( const automaton::VisiblyPushdownDPDA < InputSymbolType, PushdownStoreSymbolType, StateType > &, const StateType & ) { return false; diff --git a/alib2data/src/automaton/PDA/VisiblyPushdownNPDA.h b/alib2data/src/automaton/PDA/VisiblyPushdownNPDA.h index 9fac87ce7c72cf904ddf7f3d91284c10543f7d18..b243aed49259a14d993d2b4685cfea476fe8163d 100644 --- a/alib2data/src/automaton/PDA/VisiblyPushdownNPDA.h +++ b/alib2data/src/automaton/PDA/VisiblyPushdownNPDA.h @@ -9,6 +9,7 @@ #define VISIBLY_PUSHDOWN_NPDA_H_ #include <map> +#include <set> #include <vector> #include <algorithm> #include <sstream> @@ -43,7 +44,7 @@ class InitialStates; * Can store nondeterministic finite automaton without epsilon transitions. */ template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class VisiblyPushdownNPDA final : public AutomatonBase, public alib::Components < VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, ext::tuple < CallAlphabet, ReturnAlphabet, LocalAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < BottomOfTheStackSymbol >, StateType, ext::tuple < States, InitialStates, FinalStates >, ext::tuple < > > { +class VisiblyPushdownNPDA final : public AutomatonBase, public alib::Components < VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, ext::set < InputSymbolType >, component::Set, std::tuple < CallAlphabet, ReturnAlphabet, LocalAlphabet >, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, BottomOfTheStackSymbol, ext::set < StateType >, component::Set, std::tuple < States, InitialStates, FinalStates > > { protected: ext::map < ext::pair < StateType, InputSymbolType >, ext::set < ext::pair < StateType, PushdownStoreSymbolType > > > callTransitions; ext::map < ext::tuple < StateType, InputSymbolType, PushdownStoreSymbolType >, ext::set < StateType > > returnTransitions; @@ -142,15 +143,15 @@ public: } const PushdownStoreSymbolType & getBottomOfTheStackSymbol ( ) const & { - return this->template accessElement < BottomOfTheStackSymbol > ( ).get ( ); + return this->template accessComponent < BottomOfTheStackSymbol > ( ).get ( ); } PushdownStoreSymbolType && getBottomOfTheStackSymbol ( ) && { - return std::move ( this->template accessElement < BottomOfTheStackSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < BottomOfTheStackSymbol > ( ).get ( ) ); } bool setBottomOfTheStackSymbol ( PushdownStoreSymbolType symbol ) { - return this->template accessElement < BottomOfTheStackSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < BottomOfTheStackSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < InputSymbolType > & getCallInputAlphabet ( ) const & { @@ -346,7 +347,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >::VisiblyPushdownNPDA ( ext::set < StateType > states, ext::set < InputSymbolType > callAlphabet, ext::set < InputSymbolType > returnAlphabet, ext::set < InputSymbolType > localAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, ext::set < StateType > initialStates, PushdownStoreSymbolType bottomOfTheStackSymbol, ext::set < StateType > finalStates ) : alib::Components < VisiblyPushdownNPDA, InputSymbolType, ext::tuple < CallAlphabet, ReturnAlphabet, LocalAlphabet >, ext::tuple < >, PushdownStoreSymbolType, ext::tuple < PushdownStoreAlphabet >, ext::tuple < BottomOfTheStackSymbol >, StateType, ext::tuple < States, InitialStates, FinalStates >, ext::tuple < > > ( ext::make_tuple ( std::move ( callAlphabet ), std::move ( returnAlphabet ), std::move ( localAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( pushdownStoreAlphabet ) ), ext::make_tuple ( std::move ( bottomOfTheStackSymbol ) ), ext::make_tuple ( std::move ( states ), std::move ( initialStates ), std::move ( finalStates ) ), ext::tuple < > ( ) ) { +VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >::VisiblyPushdownNPDA ( ext::set < StateType > states, ext::set < InputSymbolType > callAlphabet, ext::set < InputSymbolType > returnAlphabet, ext::set < InputSymbolType > localAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, ext::set < StateType > initialStates, PushdownStoreSymbolType bottomOfTheStackSymbol, ext::set < StateType > finalStates ) : alib::Components < VisiblyPushdownNPDA, ext::set < InputSymbolType >, component::Set, std::tuple < CallAlphabet, ReturnAlphabet, LocalAlphabet >, ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolType, component::Value, BottomOfTheStackSymbol, ext::set < StateType >, component::Set, std::tuple < States, InitialStates, FinalStates > > ( std::move ( callAlphabet ), std::move ( returnAlphabet ), std::move ( localAlphabet ), std::move ( pushdownStoreAlphabet ), std::move ( bottomOfTheStackSymbol ), std::move ( states ), std::move ( initialStates ), std::move ( finalStates ) ) { } template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > @@ -694,7 +695,7 @@ alib::ObjectBase* VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType namespace alib { template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::CallAlphabet > { +class SetConstraint< automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::CallAlphabet > { public: static bool used ( const automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & automaton, const InputSymbolType & symbol ) { for ( const std::pair<const ext::pair<StateType, InputSymbolType>, ext::set < ext::pair<StateType, PushdownStoreSymbolType> > >& callTransition : automaton.getCallTransitions()) @@ -717,7 +718,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::ReturnAlphabet > { +class SetConstraint< automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::ReturnAlphabet > { public: static bool used ( const automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & automaton, const InputSymbolType & symbol ) { for ( const std::pair<const ext::tuple<StateType, InputSymbolType, PushdownStoreSymbolType>, ext::set < StateType> >& returnTransition : automaton.getReturnTransitions()) @@ -740,7 +741,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::LocalAlphabet > { +class SetConstraint< automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::LocalAlphabet > { public: static bool used ( const automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & automaton, const InputSymbolType & symbol ) { for ( const std::pair<const ext::pair<StateType, InputSymbolType>, ext::set < StateType >>& localTransition : automaton.getLocalTransitions()) @@ -763,7 +764,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { +class SetConstraint< automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > { public: static bool used ( const automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & automaton, const PushdownStoreSymbolType & symbol ) { for ( const std::pair<const ext::pair<StateType, InputSymbolType>, ext::set<ext::pair<StateType, PushdownStoreSymbolType> > >& callTransition : automaton.getCallTransitions()) @@ -801,7 +802,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { +class SetConstraint< automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > { public: static bool used ( const automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & automaton, const StateType & state ) { if ( automaton.getInitialStates ( ).count ( state ) ) @@ -849,7 +850,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { +class SetConstraint< automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > { public: static bool used ( const automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType > &, const StateType & ) { return false; @@ -864,7 +865,7 @@ public: }; template < class InputSymbolType, class PushdownStoreSymbolType, class StateType > -class ComponentConstraint< automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::InitialStates > { +class SetConstraint< automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::InitialStates > { public: static bool used ( const automaton::VisiblyPushdownNPDA < InputSymbolType, PushdownStoreSymbolType, StateType > &, const StateType & ) { return false; diff --git a/alib2data/src/automaton/TA/DFTA.h b/alib2data/src/automaton/TA/DFTA.h index 47ba071ff00efb21837d75afb208c151d1102b38..b88d89b84bf7cf3a102a4a117536f2f96ffcebc7 100644 --- a/alib2data/src/automaton/TA/DFTA.h +++ b/alib2data/src/automaton/TA/DFTA.h @@ -9,6 +9,7 @@ #define DFTA_H_ #include <map> +#include <set> #include <vector> #include <ostream> #include <sstream> @@ -40,7 +41,7 @@ class FinalStates; * Can store nondeterministic finite automaton without epsilon transitions. */ template<class SymbolType, class RankType, class StateType > -class DFTA final : public AutomatonBase, public alib::Components < DFTA < SymbolType, RankType, StateType >, common::ranked_symbol < SymbolType, RankType >, ext::tuple < InputAlphabet >, ext::tuple < >, StateType, ext::tuple < States, FinalStates >, ext::tuple < > > { +class DFTA final : public AutomatonBase, public alib::Components < DFTA < SymbolType, RankType, StateType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, InputAlphabet, ext::set < StateType >, component::Set, std::tuple < States, FinalStates > > { ext::map < ext::pair < common::ranked_symbol < SymbolType, RankType >, ext::vector < StateType > >, StateType > transitions; public: @@ -179,7 +180,7 @@ public: namespace automaton { template<class SymbolType, class RankType, class StateType > -DFTA < SymbolType, RankType, StateType >::DFTA ( ext::set < StateType > states, ext::set < common::ranked_symbol < SymbolType, RankType > > inputAlphabet, ext::set < StateType > finalStates ) : alib::Components < DFTA, common::ranked_symbol < SymbolType, RankType >, ext::tuple < InputAlphabet >, ext::tuple < >, StateType, ext::tuple < States, FinalStates >, ext::tuple < > > ( ext::make_tuple ( std::move ( inputAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( states ), std::move ( finalStates ) ), ext::tuple < > ( ) ) { +DFTA < SymbolType, RankType, StateType >::DFTA ( ext::set < StateType > states, ext::set < common::ranked_symbol < SymbolType, RankType > > inputAlphabet, ext::set < StateType > finalStates ) : alib::Components < DFTA, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, InputAlphabet, ext::set < StateType >, component::Set, std::tuple < States, FinalStates > > ( std::move ( inputAlphabet ), std::move ( states ), std::move ( finalStates ) ) { } template<class SymbolType, class RankType, class StateType > @@ -332,7 +333,7 @@ alib::ObjectBase* DFTA < SymbolType, RankType, StateType >::inc() && { namespace alib { template<class SymbolType, class RankType, class StateType > -class ComponentConstraint< automaton::DFTA < SymbolType, RankType, StateType >, common::ranked_symbol < SymbolType, RankType >, automaton::InputAlphabet > { +class SetConstraint< automaton::DFTA < SymbolType, RankType, StateType >, common::ranked_symbol < SymbolType, RankType >, automaton::InputAlphabet > { public: static bool used ( const automaton::DFTA < SymbolType, RankType, StateType > & automaton, const common::ranked_symbol < SymbolType, RankType > & symbol ) { for ( const std::pair<const ext::pair<common::ranked_symbol < SymbolType, RankType >, ext::vector<StateType> >, StateType>& t : automaton.getTransitions()) @@ -351,7 +352,7 @@ public: }; template<class SymbolType, class RankType, class StateType > -class ComponentConstraint< automaton::DFTA < SymbolType, RankType, StateType >, StateType, automaton::States > { +class SetConstraint< automaton::DFTA < SymbolType, RankType, StateType >, StateType, automaton::States > { public: static bool used ( const automaton::DFTA < SymbolType, RankType, StateType > & automaton, const StateType & state ) { if ( automaton.getFinalStates ( ).count ( state ) ) @@ -373,7 +374,7 @@ public: }; template<class SymbolType, class RankType, class StateType > -class ComponentConstraint< automaton::DFTA < SymbolType, RankType, StateType >, StateType, automaton::FinalStates > { +class SetConstraint< automaton::DFTA < SymbolType, RankType, StateType >, StateType, automaton::FinalStates > { public: static bool used ( const automaton::DFTA < SymbolType, RankType, StateType > &, const StateType & ) { return false; diff --git a/alib2data/src/automaton/TA/NFTA.h b/alib2data/src/automaton/TA/NFTA.h index e27e3047c841146f4e9d5a2b5972190668f3f308..7a12522b68dc1eb42daaba1145798ce7d3eab27c 100644 --- a/alib2data/src/automaton/TA/NFTA.h +++ b/alib2data/src/automaton/TA/NFTA.h @@ -9,6 +9,7 @@ #define NFTA_H_ #include <map> +#include <set> #include <vector> #include <ostream> #include <sstream> @@ -38,7 +39,7 @@ class FinalStates; * Can store nondeterministic finite tree automaton without epsilon transitions. */ template < class SymbolType, class RankType, class StateType > -class NFTA final : public AutomatonBase, public alib::Components < NFTA < SymbolType, RankType, StateType >, common::ranked_symbol < SymbolType, RankType >, ext::tuple < InputAlphabet >, ext::tuple < >, StateType, ext::tuple < States, FinalStates >, ext::tuple < > > { +class NFTA final : public AutomatonBase, public alib::Components < NFTA < SymbolType, RankType, StateType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, InputAlphabet, ext::set < StateType >, component::Set, std::tuple < States, FinalStates > > { ext::map < ext::pair < common::ranked_symbol < SymbolType, RankType >, ext::vector < StateType > >, ext::set < StateType > > transitions; public: @@ -198,7 +199,7 @@ public: namespace automaton { template < class SymbolType, class RankType, class StateType > -NFTA < SymbolType, RankType, StateType >::NFTA ( ext::set < StateType > states, ext::set < common::ranked_symbol < SymbolType, RankType > > inputAlphabet, ext::set < StateType > finalStates ) : alib::Components < NFTA, common::ranked_symbol < SymbolType, RankType >, ext::tuple < InputAlphabet >, ext::tuple < >, StateType, ext::tuple < States, FinalStates >, ext::tuple < > > ( ext::make_tuple ( std::move ( inputAlphabet ) ), ext::tuple < > ( ), ext::make_tuple ( std::move ( states ), std::move ( finalStates ) ), ext::tuple < > ( ) ) { +NFTA < SymbolType, RankType, StateType >::NFTA ( ext::set < StateType > states, ext::set < common::ranked_symbol < SymbolType, RankType > > inputAlphabet, ext::set < StateType > finalStates ) : alib::Components < NFTA, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, InputAlphabet, ext::set < StateType >, component::Set, std::tuple < States, FinalStates > > ( std::move ( inputAlphabet ), std::move ( states ), std::move ( finalStates ) ) { } template < class SymbolType, class RankType, class StateType > @@ -383,7 +384,7 @@ alib::ObjectBase* NFTA < SymbolType, RankType, StateType >::inc() && { namespace alib { template < class SymbolType, class RankType, class StateType > -class ComponentConstraint< automaton::NFTA < SymbolType, RankType, StateType >, common::ranked_symbol < SymbolType, RankType >, automaton::InputAlphabet > { +class SetConstraint< automaton::NFTA < SymbolType, RankType, StateType >, common::ranked_symbol < SymbolType, RankType >, automaton::InputAlphabet > { public: static bool used ( const automaton::NFTA < SymbolType, RankType, StateType > & automaton, const common::ranked_symbol < SymbolType, RankType > & symbol ) { for ( const std::pair<const ext::pair<common::ranked_symbol < SymbolType, RankType >, ext::vector<StateType> >, ext::set<StateType>>& t : automaton.getTransitions()) @@ -402,7 +403,7 @@ public: }; template < class SymbolType, class RankType, class StateType > -class ComponentConstraint< automaton::NFTA < SymbolType, RankType, StateType >, StateType, automaton::States > { +class SetConstraint< automaton::NFTA < SymbolType, RankType, StateType >, StateType, automaton::States > { public: static bool used ( const automaton::NFTA < SymbolType, RankType, StateType > & automaton, const StateType & state ) { if ( automaton.getFinalStates ( ).count ( state ) ) @@ -424,7 +425,7 @@ public: }; template < class SymbolType, class RankType, class StateType > -class ComponentConstraint< automaton::NFTA < SymbolType, RankType, StateType >, StateType, automaton::FinalStates > { +class SetConstraint< automaton::NFTA < SymbolType, RankType, StateType >, StateType, automaton::FinalStates > { public: static bool used ( const automaton::NFTA < SymbolType, RankType, StateType > &, const StateType & ) { return false; diff --git a/alib2data/src/automaton/TM/OneTapeDTM.h b/alib2data/src/automaton/TM/OneTapeDTM.h index b3d1fba59d9a8bc7bd241d6c27fdcf7b76a8a165..41e70c659b9ff9cd912326530cf587d3c6ea422a 100644 --- a/alib2data/src/automaton/TM/OneTapeDTM.h +++ b/alib2data/src/automaton/TM/OneTapeDTM.h @@ -42,7 +42,7 @@ class InitialState; * One tape turing machine */ template<class SymbolType, class StateType > -class OneTapeDTM final : public AutomatonBase, public alib::Components < OneTapeDTM < SymbolType, StateType >, SymbolType, ext::tuple < TapeAlphabet, InputAlphabet >, ext::tuple < BlankSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > { +class OneTapeDTM final : public AutomatonBase, public alib::Components < OneTapeDTM < SymbolType, StateType >, ext::set < SymbolType >, component::Set, std::tuple < TapeAlphabet, InputAlphabet >, SymbolType, component::Value, BlankSymbol, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > { protected: ext::map < ext::pair < StateType, SymbolType >, ext::tuple < StateType, SymbolType, Shift > > transitions; @@ -56,15 +56,15 @@ public: virtual AutomatonBase * plunder ( ) &&; const StateType & getInitialState ( ) const & { - return this-> template accessElement < InitialState > ( ).get ( ); + return this-> template accessComponent < InitialState > ( ).get ( ); } StateType && getInitialState ( ) && { - return std::move ( this-> template accessElement < InitialState > ( ).get ( ) ); + return std::move ( this-> template accessComponent < InitialState > ( ).get ( ) ); } bool setInitialState ( StateType state ) { - return this-> template accessElement < InitialState > ( ).set ( std::move ( state ) ); + return this-> template accessComponent < InitialState > ( ).set ( std::move ( state ) ); } const ext::set < StateType > & getStates ( ) const & { @@ -156,15 +156,15 @@ public: } const SymbolType & getBlankSymbol ( ) const & { - return this-> template accessElement < BlankSymbol > ( ).get ( ); + return this-> template accessComponent < BlankSymbol > ( ).get ( ); } SymbolType && getBlankSymbol ( ) && { - return std::move ( this-> template accessElement < BlankSymbol > ( ).get ( ) ); + return std::move ( this-> template accessComponent < BlankSymbol > ( ).get ( ) ); } bool setBlankSymbol ( SymbolType state ) { - return this-> template accessElement < BlankSymbol > ( ).set ( std::move ( state ) ); + return this-> template accessComponent < BlankSymbol > ( ).set ( std::move ( state ) ); } /** @@ -219,7 +219,7 @@ public: }; template<class SymbolType, class StateType > -OneTapeDTM<SymbolType, StateType>::OneTapeDTM ( ext::set < StateType > states, ext::set < SymbolType > tapeAlphabet, SymbolType blankSymbol, ext::set< SymbolType > inputAlphabet, StateType initialState, ext::set < StateType > finalStates ) : alib::Components < OneTapeDTM, SymbolType, ext::tuple < TapeAlphabet, InputAlphabet >, ext::tuple < BlankSymbol >, StateType, ext::tuple < States, FinalStates >, ext::tuple < InitialState > > ( ext::make_tuple ( std::move ( tapeAlphabet), std::move ( inputAlphabet ) ), ext::make_tuple ( blankSymbol ), ext::make_tuple ( std::move ( states ), std::move ( finalStates ) ), ext::make_tuple ( std::move ( initialState ) ) ) { +OneTapeDTM<SymbolType, StateType>::OneTapeDTM ( ext::set < StateType > states, ext::set < SymbolType > tapeAlphabet, SymbolType blankSymbol, ext::set< SymbolType > inputAlphabet, StateType initialState, ext::set < StateType > finalStates ) : alib::Components < OneTapeDTM, ext::set < SymbolType >, component::Set, std::tuple < TapeAlphabet, InputAlphabet >, SymbolType, component::Value, BlankSymbol, ext::set < StateType>, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > ( std::move ( tapeAlphabet ), std::move ( inputAlphabet ), std::move ( blankSymbol ), std::move ( states ), std::move ( finalStates ), std::move ( initialState ) ) { } @@ -404,7 +404,7 @@ alib::ObjectBase* OneTapeDTM < SymbolType, StateType >::inc() && { namespace alib { template<class SymbolType, class StateType > -class ComponentConstraint< automaton::OneTapeDTM<SymbolType, StateType>, SymbolType, automaton::TapeAlphabet > { +class SetConstraint< automaton::OneTapeDTM<SymbolType, StateType>, SymbolType, automaton::TapeAlphabet > { public: static bool used ( const automaton::OneTapeDTM<SymbolType, StateType> & automaton, const SymbolType & symbol ) { if ( automaton.getBlankSymbol ( ) == symbol ) @@ -430,7 +430,7 @@ public: }; template<class SymbolType, class StateType > -class ComponentConstraint< automaton::OneTapeDTM<SymbolType, StateType>, SymbolType, automaton::InputAlphabet > { +class SetConstraint< automaton::OneTapeDTM<SymbolType, StateType>, SymbolType, automaton::InputAlphabet > { public: static bool used ( const automaton::OneTapeDTM<SymbolType, StateType> &, const SymbolType & ) { return false; @@ -460,7 +460,7 @@ public: }; template<class SymbolType, class StateType > -class ComponentConstraint< automaton::OneTapeDTM<SymbolType, StateType>, StateType, automaton::States > { +class SetConstraint< automaton::OneTapeDTM<SymbolType, StateType>, StateType, automaton::States > { public: static bool used ( const automaton::OneTapeDTM<SymbolType, StateType> & automaton, const StateType & state ) { if ( automaton.getInitialState ( ) == state ) @@ -485,7 +485,7 @@ public: }; template<class SymbolType, class StateType > -class ComponentConstraint< automaton::OneTapeDTM<SymbolType, StateType>, StateType, automaton::FinalStates > { +class SetConstraint< automaton::OneTapeDTM<SymbolType, StateType>, StateType, automaton::FinalStates > { public: static bool used ( const automaton::OneTapeDTM<SymbolType, StateType> &, const StateType & ) { return false; diff --git a/alib2data/src/grammar/ContextFree/CFG.h b/alib2data/src/grammar/ContextFree/CFG.h index acf146fd8aea64bd4154f14074b136581badcd64..0ccda519a7a57a54f7a3d123f1a0055cc0ccd831 100644 --- a/alib2data/src/grammar/ContextFree/CFG.h +++ b/alib2data/src/grammar/ContextFree/CFG.h @@ -9,6 +9,7 @@ #define CFG_H_ #include <map> +#include <set> #include <vector> #include <algorithm> #include <sstream> @@ -37,7 +38,7 @@ class NonterminalAlphabet; class InitialSymbol; template < class SymbolType > -class CFG final : public GrammarBase, public alib::Components < CFG < SymbolType >, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > { +class CFG final : public GrammarBase, public alib::Components < CFG < SymbolType >, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > { ext::map < SymbolType, ext::set < ext::vector < SymbolType > > > rules; public: @@ -68,15 +69,15 @@ public: bool removeRawRule ( const SymbolType & leftHandSide, const ext::vector < SymbolType > & rightHandSide ); const SymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } SymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } bool setInitialSymbol ( SymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < SymbolType > & getNonterminalAlphabet ( ) const & { @@ -151,7 +152,7 @@ CFG < SymbolType >::CFG ( SymbolType initialSymbol ) : CFG ( ext::set < SymbolTy } template < class SymbolType > -CFG < SymbolType >::CFG ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < CFG, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > ( ext::make_tuple ( std::move ( terminalAlphabet ), std::move ( nonterminalAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ) ) { +CFG < SymbolType >::CFG ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < CFG, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > ( std::move ( terminalAlphabet), std::move ( nonterminalAlphabet ), std::move ( initialSymbol ) ) { } template < class SymbolType > @@ -322,7 +323,7 @@ alib::ObjectBase* CFG < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint< grammar::CFG < SymbolType >, SymbolType, grammar::TerminalAlphabet > { +class SetConstraint< grammar::CFG < SymbolType >, SymbolType, grammar::TerminalAlphabet > { public: static bool used ( const grammar::CFG < SymbolType > & grammar, const SymbolType & symbol ) { for ( const std::pair < const SymbolType, ext::set < ext::vector < SymbolType > > > & rule : grammar.getRules ( ) ) @@ -344,7 +345,7 @@ public: }; template < class SymbolType > -class ComponentConstraint< grammar::CFG < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { +class SetConstraint< grammar::CFG < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { public: static bool used ( const grammar::CFG < SymbolType > & grammar, const SymbolType & symbol ) { for ( const std::pair < const SymbolType, ext::set < ext::vector < SymbolType > > > & rule : grammar.getRules ( ) ) { @@ -357,7 +358,7 @@ public: } - if ( grammar.template accessElement < grammar::InitialSymbol > ( ).get ( ) == symbol ) + if ( grammar.template accessComponent < grammar::InitialSymbol > ( ).get ( ) == symbol ) return true; return false; diff --git a/alib2data/src/grammar/ContextFree/CNF.h b/alib2data/src/grammar/ContextFree/CNF.h index cba62747e2ccf9cecb1faf50f57b2cfe96b56de0..429179df859e2edc102705055bd083a7266085df 100644 --- a/alib2data/src/grammar/ContextFree/CNF.h +++ b/alib2data/src/grammar/ContextFree/CNF.h @@ -9,6 +9,7 @@ #define CNF_H_ #include <map> +#include <set> #include <vector> #include <variant> #include <algorithm> @@ -38,7 +39,7 @@ class NonterminalAlphabet; class InitialSymbol; template < class SymbolType > -class CNF final : public GrammarBase, public alib::Components < CNF < SymbolType >, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > { +class CNF final : public GrammarBase, public alib::Components < CNF < SymbolType >, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > { ext::map < SymbolType, ext::set < ext::variant < SymbolType, ext::pair < SymbolType, SymbolType > > > > rules; bool generatesEpsilon; @@ -72,15 +73,15 @@ public: bool removeRawRule ( const SymbolType & leftHandSide, const ext::vector < SymbolType > & rightHandSide ); const SymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } SymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } bool setInitialSymbol ( SymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < SymbolType > & getNonterminalAlphabet ( ) const & { @@ -152,7 +153,7 @@ CNF < SymbolType >::CNF ( SymbolType initialSymbol ) : CNF ( ext::set < SymbolTy } template < class SymbolType > -CNF < SymbolType >::CNF ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < CNF, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > ( ext::make_tuple ( std::move ( terminalAlphabet ), std::move ( nonterminalAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ) ), generatesEpsilon ( false ) { +CNF < SymbolType >::CNF ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < CNF, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > ( std::move ( terminalAlphabet), std::move ( nonterminalAlphabet ), std::move ( initialSymbol ) ), generatesEpsilon ( false ) { } template < class SymbolType > @@ -416,7 +417,7 @@ alib::ObjectBase* CNF < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint< grammar::CNF < SymbolType >, SymbolType, grammar::TerminalAlphabet > { +class SetConstraint< grammar::CNF < SymbolType >, SymbolType, grammar::TerminalAlphabet > { public: static bool used ( const grammar::CNF < SymbolType > & grammar, const SymbolType & symbol ) { for ( const std::pair < const SymbolType, ext::set < ext::variant < SymbolType, ext::pair < SymbolType, SymbolType > > > > & rule : grammar.getRules ( ) ) @@ -438,7 +439,7 @@ public: }; template < class SymbolType > -class ComponentConstraint< grammar::CNF < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { +class SetConstraint< grammar::CNF < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { public: static bool used ( const grammar::CNF < SymbolType > & grammar, const SymbolType & symbol ) { for ( const std::pair < const SymbolType, ext::set < ext::variant < SymbolType, ext::pair < SymbolType, SymbolType > > > > & rule : grammar.getRules ( ) ) { @@ -451,7 +452,7 @@ public: } - if ( grammar.template accessElement < grammar::InitialSymbol > ( ).get ( ) == symbol ) + if ( grammar.template accessComponent < grammar::InitialSymbol > ( ).get ( ) == symbol ) return true; return false; diff --git a/alib2data/src/grammar/ContextFree/EpsilonFreeCFG.h b/alib2data/src/grammar/ContextFree/EpsilonFreeCFG.h index 0e02cd2c4e56b81fd98233837ea6532868ca603c..41c9046d919340330ec8ed34c9acd24cac386fd5 100644 --- a/alib2data/src/grammar/ContextFree/EpsilonFreeCFG.h +++ b/alib2data/src/grammar/ContextFree/EpsilonFreeCFG.h @@ -9,6 +9,7 @@ #define EPSILON_FREE_CFG_H_ #include <map> +#include <set> #include <vector> #include <algorithm> #include <sstream> @@ -37,7 +38,7 @@ class NonterminalAlphabet; class InitialSymbol; template < class SymbolType > -class EpsilonFreeCFG final : public GrammarBase, public alib::Components < EpsilonFreeCFG < SymbolType >, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > { +class EpsilonFreeCFG final : public GrammarBase, public alib::Components < EpsilonFreeCFG < SymbolType >, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > { ext::map < SymbolType, ext::set < ext::vector < SymbolType > > > rules; bool generatesEpsilon; @@ -67,15 +68,15 @@ public: bool removeRawRule ( const SymbolType & leftHandSide, const ext::vector < SymbolType > & rightHandSide ); const SymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } SymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } bool setInitialSymbol ( SymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < SymbolType > & getNonterminalAlphabet ( ) const & { @@ -147,7 +148,7 @@ EpsilonFreeCFG < SymbolType >::EpsilonFreeCFG ( SymbolType initialSymbol ) : Eps } template < class SymbolType > -EpsilonFreeCFG < SymbolType >::EpsilonFreeCFG ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < EpsilonFreeCFG, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > ( ext::make_tuple ( std::move ( terminalAlphabet ), std::move ( nonterminalAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ) ), generatesEpsilon ( false ) { +EpsilonFreeCFG < SymbolType >::EpsilonFreeCFG ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < EpsilonFreeCFG, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > ( std::move ( terminalAlphabet), std::move ( nonterminalAlphabet ), std::move ( initialSymbol ) ), generatesEpsilon ( false ) { } template < class SymbolType > @@ -351,7 +352,7 @@ alib::ObjectBase* EpsilonFreeCFG < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint< grammar::EpsilonFreeCFG < SymbolType >, SymbolType, grammar::TerminalAlphabet > { +class SetConstraint< grammar::EpsilonFreeCFG < SymbolType >, SymbolType, grammar::TerminalAlphabet > { public: static bool used ( const grammar::EpsilonFreeCFG < SymbolType > & grammar, const SymbolType & symbol ) { for ( const std::pair < const SymbolType, ext::set < ext::vector < SymbolType > > > & rule : grammar.getRules ( ) ) @@ -373,7 +374,7 @@ public: }; template < class SymbolType > -class ComponentConstraint< grammar::EpsilonFreeCFG < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { +class SetConstraint< grammar::EpsilonFreeCFG < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { public: static bool used ( const grammar::EpsilonFreeCFG < SymbolType > & grammar, const SymbolType & symbol ) { for ( const std::pair < const SymbolType, ext::set < ext::vector < SymbolType > > > & rule : grammar.getRules ( ) ) { @@ -386,7 +387,7 @@ public: } - if ( grammar.template accessElement < grammar::InitialSymbol > ( ).get ( ) == symbol ) + if ( grammar.template accessComponent < grammar::InitialSymbol > ( ).get ( ) == symbol ) return true; return false; diff --git a/alib2data/src/grammar/ContextFree/GNF.h b/alib2data/src/grammar/ContextFree/GNF.h index 6955a4b1477a026cee05671a0784fa453013a5ba..638d98cb5e5388494abcc872fc4c5d061d1b067b 100644 --- a/alib2data/src/grammar/ContextFree/GNF.h +++ b/alib2data/src/grammar/ContextFree/GNF.h @@ -9,6 +9,7 @@ #define GNF_H_ #include <map> +#include <set> #include <vector> #include <algorithm> #include <sstream> @@ -37,7 +38,7 @@ class NonterminalAlphabet; class InitialSymbol; template < class SymbolType > -class GNF final : public GrammarBase, public alib::Components < GNF < SymbolType >, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > { +class GNF final : public GrammarBase, public alib::Components < GNF < SymbolType >, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > { ext::map < SymbolType, ext::set < ext::pair < SymbolType, ext::vector < SymbolType > > > > rules; bool generatesEpsilon; @@ -67,15 +68,15 @@ public: bool removeRawRule ( const SymbolType & leftHandSide, const ext::vector < SymbolType > & rightHandSide ); const SymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } SymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } bool setInitialSymbol ( SymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < SymbolType > & getNonterminalAlphabet ( ) const & { @@ -148,7 +149,7 @@ GNF < SymbolType >::GNF ( SymbolType initialSymbol ) : GNF ( ext::set < SymbolTy } template < class SymbolType > -GNF < SymbolType >::GNF ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < GNF, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > ( ext::make_tuple ( std::move ( terminalAlphabet ), std::move ( nonterminalAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ) ), generatesEpsilon ( false ) { +GNF < SymbolType >::GNF ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < GNF, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > ( std::move ( terminalAlphabet), std::move ( nonterminalAlphabet ), std::move ( initialSymbol ) ), generatesEpsilon ( false ) { } template < class SymbolType > @@ -362,7 +363,7 @@ alib::ObjectBase* GNF < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint< grammar::GNF < SymbolType >, SymbolType, grammar::TerminalAlphabet > { +class SetConstraint< grammar::GNF < SymbolType >, SymbolType, grammar::TerminalAlphabet > { public: static bool used ( const grammar::GNF < SymbolType > & grammar, const SymbolType & symbol ) { for ( const std::pair < const SymbolType, ext::set < ext::pair < SymbolType, ext::vector < SymbolType > > > > & rule : grammar.getRules ( ) ) @@ -384,7 +385,7 @@ public: }; template < class SymbolType > -class ComponentConstraint< grammar::GNF < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { +class SetConstraint< grammar::GNF < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { public: static bool used ( const grammar::GNF < SymbolType > & grammar, const SymbolType & symbol ) { for ( const std::pair < const SymbolType, ext::set < ext::pair < SymbolType, ext::vector < SymbolType > > > > & rule : grammar.getRules ( ) ) { @@ -396,7 +397,7 @@ public: return true; } - if ( grammar.template accessElement < grammar::InitialSymbol > ( ).get ( ) == symbol ) + if ( grammar.template accessComponent < grammar::InitialSymbol > ( ).get ( ) == symbol ) return true; return false; diff --git a/alib2data/src/grammar/ContextFree/LG.h b/alib2data/src/grammar/ContextFree/LG.h index 18bdc6efdb813534ac07e84ee3669872a8e79daa..9ee3996e381963125ba7dda6143a297b2bfd3754 100644 --- a/alib2data/src/grammar/ContextFree/LG.h +++ b/alib2data/src/grammar/ContextFree/LG.h @@ -9,6 +9,7 @@ #define LG_H_ #include <map> +#include <set> #include <tuple> #include <vector> #include <variant> @@ -39,7 +40,7 @@ class NonterminalAlphabet; class InitialSymbol; template < class SymbolType > -class LG final : public GrammarBase, public alib::Components < LG < SymbolType >, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > { +class LG final : public GrammarBase, public alib::Components < LG < SymbolType >, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > { ext::map < SymbolType, ext::set < ext::variant < ext::vector < SymbolType >, ext::tuple < ext::vector < SymbolType >, SymbolType, ext::vector < SymbolType > > > > > rules; public: @@ -72,15 +73,15 @@ public: bool removeRawRule ( const SymbolType & leftHandSide, const ext::vector < SymbolType > & rightHandSide ); const SymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } SymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } bool setInitialSymbol ( SymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < SymbolType > & getNonterminalAlphabet ( ) const & { @@ -149,7 +150,7 @@ LG < SymbolType >::LG ( SymbolType initialSymbol ) : LG ( ext::set < SymbolType } template < class SymbolType > -LG < SymbolType >::LG ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < LG, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > ( ext::make_tuple ( std::move ( terminalAlphabet ), std::move ( nonterminalAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ) ) { +LG < SymbolType >::LG ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < LG, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > ( std::move ( terminalAlphabet), std::move ( nonterminalAlphabet ), std::move ( initialSymbol ) ) { } template < class SymbolType > @@ -404,7 +405,7 @@ alib::ObjectBase* LG < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint< grammar::LG < SymbolType >, SymbolType, grammar::TerminalAlphabet > { +class SetConstraint< grammar::LG < SymbolType >, SymbolType, grammar::TerminalAlphabet > { public: static bool used ( const grammar::LG < SymbolType > & grammar, const SymbolType & symbol ) { for ( const std::pair < const SymbolType, ext::set < ext::variant < ext::vector < SymbolType >, ext::tuple < ext::vector < SymbolType >, SymbolType, ext::vector < SymbolType > > > > > & rule : grammar.getRules ( ) ) { @@ -444,7 +445,7 @@ public: }; template < class SymbolType > -class ComponentConstraint< grammar::LG < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { +class SetConstraint< grammar::LG < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { public: static bool used ( const grammar::LG < SymbolType > & grammar, const SymbolType & symbol ) { for ( const std::pair < const SymbolType, ext::set < ext::variant < ext::vector < SymbolType >, ext::tuple < ext::vector < SymbolType >, SymbolType, ext::vector < SymbolType > > > > > & rule : grammar.getRules ( ) ) { @@ -461,7 +462,7 @@ public: } - if ( grammar.template accessElement < grammar::InitialSymbol > ( ).get ( ) == symbol ) + if ( grammar.template accessComponent < grammar::InitialSymbol > ( ).get ( ) == symbol ) return true; return false; diff --git a/alib2data/src/grammar/ContextSensitive/CSG.h b/alib2data/src/grammar/ContextSensitive/CSG.h index df1d1b0c64f2312168983edcc685f8e4feaea93e..0fb3e28c13045439604fc6a337104e2bb81a9881 100644 --- a/alib2data/src/grammar/ContextSensitive/CSG.h +++ b/alib2data/src/grammar/ContextSensitive/CSG.h @@ -9,6 +9,7 @@ #define CSG_H_ #include <map> +#include <set> #include <vector> #include <algorithm> #include <sstream> @@ -37,7 +38,7 @@ class NonterminalAlphabet; class InitialSymbol; template < class SymbolType > -class CSG final : public GrammarBase, public alib::Components < CSG < SymbolType >, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > { +class CSG final : public GrammarBase, public alib::Components < CSG < SymbolType >, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > { ext::map < ext::tuple < ext::vector < SymbolType >, SymbolType, ext::vector < SymbolType > >, ext::set < ext::vector < SymbolType > > > rules; bool generatesEpsilon; @@ -61,15 +62,15 @@ public: bool removeRule ( const ext::vector < SymbolType > & lContext, const SymbolType & leftHandSide, const ext::vector < SymbolType > & rContext, const ext::vector < SymbolType > & rightHandSide ); const SymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } SymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } bool setInitialSymbol ( SymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < SymbolType > & getNonterminalAlphabet ( ) const & { @@ -141,7 +142,7 @@ CSG < SymbolType >::CSG ( SymbolType initialSymbol ) : CSG ( ext::set < SymbolTy } template < class SymbolType > -CSG < SymbolType >::CSG ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < CSG, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > ( ext::make_tuple ( std::move ( terminalAlphabet ), std::move ( nonterminalAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ) ), generatesEpsilon ( false ) { +CSG < SymbolType >::CSG ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < CSG, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > ( std::move ( terminalAlphabet), std::move ( nonterminalAlphabet ), std::move ( initialSymbol ) ), generatesEpsilon ( false ) { } template < class SymbolType > @@ -331,7 +332,7 @@ alib::ObjectBase* CSG < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint< grammar::CSG < SymbolType >, SymbolType, grammar::TerminalAlphabet > { +class SetConstraint< grammar::CSG < SymbolType >, SymbolType, grammar::TerminalAlphabet > { public: static bool used ( const grammar::CSG < SymbolType > & grammar, const SymbolType & symbol ) { for ( const std::pair < const ext::tuple < ext::vector < SymbolType >, SymbolType, ext::vector < SymbolType > >, ext::set < ext::vector < SymbolType > > > & rule : grammar.getRules ( ) ) { @@ -363,7 +364,7 @@ public: }; template < class SymbolType > -class ComponentConstraint< grammar::CSG < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { +class SetConstraint< grammar::CSG < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { public: static bool used ( const grammar::CSG < SymbolType > & grammar, const SymbolType & symbol ) { for ( const std::pair < const ext::tuple < ext::vector < SymbolType >, SymbolType, ext::vector < SymbolType > >, ext::set < ext::vector < SymbolType > > > & rule : grammar.getRules ( ) ) { @@ -384,7 +385,7 @@ public: } - if ( grammar.template accessElement < grammar::InitialSymbol > ( ).get ( ) == symbol ) + if ( grammar.template accessComponent < grammar::InitialSymbol > ( ).get ( ) == symbol ) return true; return false; diff --git a/alib2data/src/grammar/ContextSensitive/NonContractingGrammar.h b/alib2data/src/grammar/ContextSensitive/NonContractingGrammar.h index d706e9e55f037c0f6ec11707e5477f580d5d248c..66925ddb48fb71f5c927017af28c663fa8d5532e 100644 --- a/alib2data/src/grammar/ContextSensitive/NonContractingGrammar.h +++ b/alib2data/src/grammar/ContextSensitive/NonContractingGrammar.h @@ -9,6 +9,7 @@ #define NON_CONTRACTING_GRAMMAR_H_ #include <map> +#include <set> #include <vector> #include <algorithm> #include <sstream> @@ -37,7 +38,7 @@ class NonterminalAlphabet; class InitialSymbol; template < class SymbolType > -class NonContractingGrammar final : public GrammarBase, public alib::Components < NonContractingGrammar < SymbolType >, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > { +class NonContractingGrammar final : public GrammarBase, public alib::Components < NonContractingGrammar < SymbolType >, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > { ext::map < ext::vector < SymbolType >, ext::set < ext::vector < SymbolType > > > rules; bool generatesEpsilon; @@ -61,15 +62,15 @@ public: bool removeRule ( const ext::vector < SymbolType > & leftHandSide, const ext::vector < SymbolType > & rightHandSide ); const SymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } SymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } bool setInitialSymbol ( SymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < SymbolType > & getNonterminalAlphabet ( ) const & { @@ -141,7 +142,7 @@ NonContractingGrammar < SymbolType >::NonContractingGrammar ( SymbolType initial } template < class SymbolType > -NonContractingGrammar < SymbolType >::NonContractingGrammar ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < NonContractingGrammar, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > ( ext::make_tuple ( std::move ( terminalAlphabet ), std::move ( nonterminalAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ) ), generatesEpsilon ( false ) { +NonContractingGrammar < SymbolType >::NonContractingGrammar ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < NonContractingGrammar, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > ( std::move ( terminalAlphabet), std::move ( nonterminalAlphabet ), std::move ( initialSymbol ) ), generatesEpsilon ( false ) { } template < class SymbolType > @@ -330,7 +331,7 @@ alib::ObjectBase* NonContractingGrammar < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint< grammar::NonContractingGrammar < SymbolType >, SymbolType, grammar::TerminalAlphabet > { +class SetConstraint< grammar::NonContractingGrammar < SymbolType >, SymbolType, grammar::TerminalAlphabet > { public: static bool used ( const grammar::NonContractingGrammar < SymbolType > & grammar, const SymbolType & symbol ) { for ( const std::pair < const ext::vector < SymbolType >, ext::set < ext::vector < SymbolType > > > & rule : grammar.getRules ( ) ) { @@ -357,7 +358,7 @@ public: }; template < class SymbolType > -class ComponentConstraint< grammar::NonContractingGrammar < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { +class SetConstraint< grammar::NonContractingGrammar < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { public: static bool used ( const grammar::NonContractingGrammar < SymbolType > & grammar, const SymbolType & symbol ) { for ( const std::pair < const ext::vector < SymbolType >, ext::set < ext::vector < SymbolType > > > & rule : grammar.getRules ( ) ) { @@ -370,7 +371,7 @@ public: } - if ( grammar.template accessElement < grammar::InitialSymbol > ( ).get ( ) == symbol ) + if ( grammar.template accessComponent < grammar::InitialSymbol > ( ).get ( ) == symbol ) return true; return false; diff --git a/alib2data/src/grammar/Regular/LeftLG.h b/alib2data/src/grammar/Regular/LeftLG.h index f7d272f5a0c09d04edf543714cf7998d0e747954..f2e4a2b6f7bf3bd5a25bc26dde5ed40a01c3ff6e 100644 --- a/alib2data/src/grammar/Regular/LeftLG.h +++ b/alib2data/src/grammar/Regular/LeftLG.h @@ -25,6 +25,7 @@ #define LEFT_LG_H_ #include <map> +#include <set> #include <vector> #include <variant> #include <algorithm> @@ -65,7 +66,7 @@ class InitialSymbol; * \tparam SymbolType used for the terminal alphabet, the nonterminal alphabet, and the initial symbol of the grammar. */ template < class SymbolType > -class LeftLG final : public GrammarBase, public alib::Components < LeftLG < SymbolType >, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > { +class LeftLG final : public GrammarBase, public alib::Components < LeftLG < SymbolType >, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > { /** * Rules as mapping from nonterminal symbol on the left hand side to set of either sequence of terminal symbols or doublets of sequence of terminal symbols and nonterminal symbol. */ @@ -218,7 +219,7 @@ public: * \returns the initial symbol of the grammar */ const SymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } /** @@ -227,7 +228,7 @@ public: * \returns the initial symbol of the grammar */ SymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } /** @@ -238,7 +239,7 @@ public: * \returns true if the initial symbol was indeed changed */ bool setInitialSymbol ( SymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } /** @@ -407,7 +408,7 @@ LeftLG < SymbolType >::LeftLG ( SymbolType initialSymbol ) : LeftLG ( ext::set < } template < class SymbolType > -LeftLG < SymbolType >::LeftLG ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < LeftLG, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > ( ext::make_tuple ( std::move ( terminalAlphabet ), std::move ( nonterminalAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ) ) { +LeftLG < SymbolType >::LeftLG ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < LeftLG, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > ( std::move ( terminalAlphabet), std::move ( nonterminalAlphabet ), std::move ( initialSymbol ) ) { } template < class SymbolType > @@ -650,7 +651,7 @@ namespace alib { * \tparam SymbolType used for the terminal alphabet of the grammar. */ template < class SymbolType > -class ComponentConstraint< grammar::LeftLG < SymbolType >, SymbolType, grammar::TerminalAlphabet > { +class SetConstraint< grammar::LeftLG < SymbolType >, SymbolType, grammar::TerminalAlphabet > { public: /** * Returns true if the terminal symbol is still used in some rule of the grammar. @@ -712,7 +713,7 @@ public: * \tparam SymbolType used for the nonterminal alphabet of the grammar. */ template < class SymbolType > -class ComponentConstraint< grammar::LeftLG < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { +class SetConstraint< grammar::LeftLG < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { public: /** * Returns true if the nonterminal symbol is still used in some rule of the grammar or if it is the initial symbol of the grammar. @@ -737,7 +738,7 @@ public: } - if ( grammar.template accessElement < grammar::InitialSymbol > ( ).get ( ) == symbol ) + if ( grammar.template accessComponent < grammar::InitialSymbol > ( ).get ( ) == symbol ) return true; return false; diff --git a/alib2data/src/grammar/Regular/LeftRG.h b/alib2data/src/grammar/Regular/LeftRG.h index 74aa117f76c704f31c4a0ddffff95d0c51bb54b8..9628892820c2ffa10cdc93ceb3deccd5aed7cc88 100644 --- a/alib2data/src/grammar/Regular/LeftRG.h +++ b/alib2data/src/grammar/Regular/LeftRG.h @@ -25,6 +25,7 @@ #define LEFT_RG_H_ #include <map> +#include <set> #include <vector> #include <variant> #include <algorithm> @@ -69,7 +70,7 @@ class InitialSymbol; * \tparam SymbolType used for the terminal alphabet, the nonterminal alphabet, and the initial symbol of the grammar. */ template < class SymbolType > -class LeftRG final : public GrammarBase, public alib::Components < LeftRG < SymbolType >, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > { +class LeftRG final : public GrammarBase, public alib::Components < LeftRG < SymbolType >, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > { /** * Rules as mapping from nonterminal symbol on the left hand side to set of either terminal symbols or doublets of terminal symbol and nonterminal symbol. */ @@ -227,7 +228,7 @@ public: * \returns the initial symbol of the grammar */ const SymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } /** @@ -236,7 +237,7 @@ public: * \returns the initial symbol of the grammar */ SymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } /** @@ -247,7 +248,7 @@ public: * \returns true if the initial symbol was indeed changed */ bool setInitialSymbol ( SymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } /** @@ -430,7 +431,7 @@ LeftRG < SymbolType >::LeftRG ( SymbolType initialSymbol ) : LeftRG ( ext::set < } template < class SymbolType > -LeftRG < SymbolType >::LeftRG ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < LeftRG, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > ( ext::make_tuple ( std::move ( terminalAlphabet ), std::move ( nonterminalAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ) ), generatesEpsilon ( false ) { +LeftRG < SymbolType >::LeftRG ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < LeftRG, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > ( std::move ( terminalAlphabet), std::move ( nonterminalAlphabet ), std::move ( initialSymbol ) ), generatesEpsilon ( false ) { } template < class SymbolType > @@ -698,7 +699,7 @@ namespace alib { * \tparam SymbolType used for the terminal alphabet of the grammar. */ template < class SymbolType > -class ComponentConstraint< grammar::LeftRG < SymbolType >, SymbolType, grammar::TerminalAlphabet > { +class SetConstraint< grammar::LeftRG < SymbolType >, SymbolType, grammar::TerminalAlphabet > { public: /** * Returns true if the terminal symbol is still used in some rule of the grammar. @@ -749,7 +750,7 @@ public: * \tparam SymbolType used for the nonterminal alphabet of the grammar. */ template < class SymbolType > -class ComponentConstraint< grammar::LeftRG < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { +class SetConstraint< grammar::LeftRG < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { public: /** * Returns true if the nonterminal symbol is still used in some rule of the grammar or if it is the initial symbol of the grammar. @@ -770,7 +771,7 @@ public: } - if ( grammar.template accessElement < grammar::InitialSymbol > ( ).get ( ) == symbol ) + if ( grammar.template accessComponent < grammar::InitialSymbol > ( ).get ( ) == symbol ) return true; return false; diff --git a/alib2data/src/grammar/Regular/RightLG.h b/alib2data/src/grammar/Regular/RightLG.h index 520c9ac80024608e63e487d4818da0cef1e25032..f5bab44dff5fb15ceab668b38de47e7ae7c6dc63 100644 --- a/alib2data/src/grammar/Regular/RightLG.h +++ b/alib2data/src/grammar/Regular/RightLG.h @@ -25,6 +25,7 @@ #define RIGHT_LG_H_ #include <map> +#include <set> #include <vector> #include <variant> #include <algorithm> @@ -65,7 +66,7 @@ class InitialSymbol; * \tparam SymbolType used for the terminal alphabet, the nonterminal alphabet, and the initial symbol of the grammar. */ template < class SymbolType > -class RightLG final : public GrammarBase, public alib::Components < RightLG < SymbolType >, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > { +class RightLG final : public GrammarBase, public alib::Components < RightLG < SymbolType >, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > { /** * Rules as mapping from nonterminal symbol on the left hand side to set of either sequence of terminal symbols or doublets of sequence of nonterminal symbol and terminal symbols. */ @@ -218,7 +219,7 @@ public: * \returns the initial symbol of the grammar */ const SymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } /** @@ -227,7 +228,7 @@ public: * \returns the initial symbol of the grammar */ SymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } /** @@ -238,7 +239,7 @@ public: * \returns true if the initial symbol was indeed changed */ bool setInitialSymbol ( SymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } /** @@ -407,7 +408,7 @@ RightLG < SymbolType >::RightLG ( SymbolType initialSymbol ) : RightLG ( ext::se } template < class SymbolType > -RightLG < SymbolType >::RightLG ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < RightLG, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > ( ext::make_tuple ( std::move ( terminalAlphabet ), std::move ( nonterminalAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ) ) { +RightLG < SymbolType >::RightLG ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < RightLG, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > ( std::move ( terminalAlphabet), std::move ( nonterminalAlphabet ), std::move ( initialSymbol ) ) { } template < class SymbolType > @@ -648,7 +649,7 @@ namespace alib { * \tparam SymbolType used for the terminal alphabet of the grammar. */ template < class SymbolType > -class ComponentConstraint< grammar::RightLG < SymbolType >, SymbolType, grammar::TerminalAlphabet > { +class SetConstraint< grammar::RightLG < SymbolType >, SymbolType, grammar::TerminalAlphabet > { public: /** * Returns true if the terminal symbol is still used in some rule of the grammar. @@ -710,7 +711,7 @@ public: * \tparam SymbolType used for the nonterminal alphabet of the grammar. */ template < class SymbolType > -class ComponentConstraint< grammar::RightLG < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { +class SetConstraint< grammar::RightLG < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { public: /** * Returns true if the nonterminal symbol is still used in some rule of the grammar or if it is the initial symbol of the grammar. @@ -735,7 +736,7 @@ public: } - if ( grammar.template accessElement < grammar::InitialSymbol > ( ).get ( ) == symbol ) + if ( grammar.template accessComponent < grammar::InitialSymbol > ( ).get ( ) == symbol ) return true; return false; diff --git a/alib2data/src/grammar/Regular/RightRG.h b/alib2data/src/grammar/Regular/RightRG.h index abf23d6159e500b7325b98b90e4a017bf80468e8..87ccc337f5d908393206198c60a40b0ab4421b16 100644 --- a/alib2data/src/grammar/Regular/RightRG.h +++ b/alib2data/src/grammar/Regular/RightRG.h @@ -25,6 +25,7 @@ #define RIGHT_RG_H_ #include <map> +#include <set> #include <vector> #include <variant> #include <algorithm> @@ -69,7 +70,7 @@ class InitialSymbol; * \tparam SymbolType used for the terminal alphabet, the nonterminal alphabet, and the initial symbol of the grammar. */ template < class SymbolType > -class RightRG final : public GrammarBase, public alib::Components < RightRG < SymbolType >, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > { +class RightRG final : public GrammarBase, public alib::Components < RightRG < SymbolType >, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > { /** * Rules function as mapping from nonterminal symbol on the left hand side to set of either terminal symbols or doublets of nonterminal symbol and terminal symbol. */ @@ -227,7 +228,7 @@ public: * \returns the initial symbol of the grammar */ const SymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } /** @@ -236,7 +237,7 @@ public: * \returns the initial symbol of the grammar */ SymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } /** @@ -247,7 +248,7 @@ public: * \returns true if the initial symbol was indeed changed */ bool setInitialSymbol ( SymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } /** @@ -430,7 +431,7 @@ RightRG < SymbolType >::RightRG ( SymbolType initialSymbol ) : RightRG ( ext::se } template < class SymbolType > -RightRG < SymbolType >::RightRG ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < RightRG, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > ( ext::make_tuple ( std::move ( terminalAlphabet ), std::move ( nonterminalAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ) ), generatesEpsilon ( false ) { +RightRG < SymbolType >::RightRG ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < RightRG, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > ( std::move ( terminalAlphabet), std::move ( nonterminalAlphabet ), std::move ( initialSymbol ) ), generatesEpsilon ( false ) { } template < class SymbolType > @@ -695,7 +696,7 @@ namespace alib { * \tparam SymbolType used for the terminal alphabet of the grammar. */ template < class SymbolType > -class ComponentConstraint< grammar::RightRG < SymbolType >, SymbolType, grammar::TerminalAlphabet > { +class SetConstraint< grammar::RightRG < SymbolType >, SymbolType, grammar::TerminalAlphabet > { public: /** * Returns true if the terminal symbol is still used in some rule of the grammar. @@ -746,7 +747,7 @@ public: * \tparam SymbolType used for the nonterminal alphabet of the grammar. */ template < class SymbolType > -class ComponentConstraint< grammar::RightRG < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { +class SetConstraint< grammar::RightRG < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { public: /** * Returns true if the nonterminal symbol is still used in some rule of the grammar or if it is the initial symbol of the grammar. @@ -767,7 +768,7 @@ public: } - if ( grammar.template accessElement < grammar::InitialSymbol > ( ).get ( ) == symbol ) + if ( grammar.template accessComponent < grammar::InitialSymbol > ( ).get ( ) == symbol ) return true; return false; diff --git a/alib2data/src/grammar/Unrestricted/ContextPreservingUnrestrictedGrammar.h b/alib2data/src/grammar/Unrestricted/ContextPreservingUnrestrictedGrammar.h index 0dbd8028959d266b1d82d83a76cabc3755fc4661..3336141f787db64ea28ff24f16448aedef07e3df 100644 --- a/alib2data/src/grammar/Unrestricted/ContextPreservingUnrestrictedGrammar.h +++ b/alib2data/src/grammar/Unrestricted/ContextPreservingUnrestrictedGrammar.h @@ -9,6 +9,7 @@ #define CONTEXT_PRESERVING_UNRESTRICTED_GRAMMAR_H_ #include <map> +#include <set> #include <vector> #include <algorithm> #include <sstream> @@ -37,7 +38,7 @@ class NonterminalAlphabet; class InitialSymbol; template < class SymbolType > -class ContextPreservingUnrestrictedGrammar final : public GrammarBase, public alib::Components < ContextPreservingUnrestrictedGrammar < SymbolType >, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > { +class ContextPreservingUnrestrictedGrammar final : public GrammarBase, public alib::Components < ContextPreservingUnrestrictedGrammar < SymbolType >, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > { ext::map < ext::tuple < ext::vector < SymbolType >, SymbolType, ext::vector < SymbolType > >, ext::set < ext::vector < SymbolType > > > rules; public: @@ -60,15 +61,15 @@ public: bool removeRule ( const ext::vector < SymbolType > & lContext, const SymbolType & leftHandSide, const ext::vector < SymbolType > & rContext, const ext::vector < SymbolType > & rightHandSide ); const SymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } SymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } bool setInitialSymbol ( SymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < SymbolType > & getNonterminalAlphabet ( ) const & { @@ -137,7 +138,7 @@ ContextPreservingUnrestrictedGrammar < SymbolType >::ContextPreservingUnrestrict } template < class SymbolType > -ContextPreservingUnrestrictedGrammar < SymbolType >::ContextPreservingUnrestrictedGrammar ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < ContextPreservingUnrestrictedGrammar, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > ( ext::make_tuple ( std::move ( terminalAlphabet ), std::move ( nonterminalAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ) ) { +ContextPreservingUnrestrictedGrammar < SymbolType >::ContextPreservingUnrestrictedGrammar ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < ContextPreservingUnrestrictedGrammar, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > ( std::move ( terminalAlphabet), std::move ( nonterminalAlphabet ), std::move ( initialSymbol ) ) { } template < class SymbolType > @@ -303,7 +304,7 @@ alib::ObjectBase* ContextPreservingUnrestrictedGrammar < SymbolType >::inc() && namespace alib { template < class SymbolType > -class ComponentConstraint< grammar::ContextPreservingUnrestrictedGrammar < SymbolType >, SymbolType, grammar::TerminalAlphabet > { +class SetConstraint< grammar::ContextPreservingUnrestrictedGrammar < SymbolType >, SymbolType, grammar::TerminalAlphabet > { public: static bool used ( const grammar::ContextPreservingUnrestrictedGrammar < SymbolType > & grammar, const SymbolType & symbol ) { for ( const std::pair < const ext::tuple < ext::vector < SymbolType >, SymbolType, ext::vector < SymbolType > >, ext::set < ext::vector < SymbolType > > > & rule : grammar.getRules ( ) ) { @@ -335,7 +336,7 @@ public: }; template < class SymbolType > -class ComponentConstraint< grammar::ContextPreservingUnrestrictedGrammar < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { +class SetConstraint< grammar::ContextPreservingUnrestrictedGrammar < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { public: static bool used ( const grammar::ContextPreservingUnrestrictedGrammar < SymbolType > & grammar, const SymbolType & symbol ) { for ( const std::pair < const ext::tuple < ext::vector < SymbolType >, SymbolType, ext::vector < SymbolType > >, ext::set < ext::vector < SymbolType > > > & rule : grammar.getRules ( ) ) { @@ -356,7 +357,7 @@ public: } - if ( grammar.template accessElement < grammar::InitialSymbol > ( ).get ( ) == symbol ) + if ( grammar.template accessComponent < grammar::InitialSymbol > ( ).get ( ) == symbol ) return true; return false; diff --git a/alib2data/src/grammar/Unrestricted/UnrestrictedGrammar.h b/alib2data/src/grammar/Unrestricted/UnrestrictedGrammar.h index 215185ccb21677f8f0179556618fc9e412307230..6f4a88b8ca1cb01ecadf9e92f18d73aed1f0de9d 100644 --- a/alib2data/src/grammar/Unrestricted/UnrestrictedGrammar.h +++ b/alib2data/src/grammar/Unrestricted/UnrestrictedGrammar.h @@ -9,6 +9,7 @@ #define UNRESTRICTED_GRAMMAR_H_ #include <map> +#include <set> #include <vector> #include <algorithm> #include <sstream> @@ -37,7 +38,7 @@ class NonterminalAlphabet; class InitialSymbol; template < class SymbolType > -class UnrestrictedGrammar final : public GrammarBase, public alib::Components < UnrestrictedGrammar < SymbolType >, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > { +class UnrestrictedGrammar final : public GrammarBase, public alib::Components < UnrestrictedGrammar < SymbolType >, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > { ext::map < ext::vector < SymbolType >, ext::set < ext::vector < SymbolType > > > rules; public: @@ -60,15 +61,15 @@ public: bool removeRule ( const ext::vector < SymbolType > & leftHandSide, const ext::vector < SymbolType > & rightHandSide ); const SymbolType & getInitialSymbol ( ) const & { - return this->template accessElement < InitialSymbol > ( ).get ( ); + return this->template accessComponent < InitialSymbol > ( ).get ( ); } SymbolType && getInitialSymbol ( ) && { - return std::move ( this->template accessElement < InitialSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) ); } bool setInitialSymbol ( SymbolType symbol ) { - return this->template accessElement < InitialSymbol > ( ).set ( std::move ( symbol ) ); + return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) ); } const ext::set < SymbolType > & getNonterminalAlphabet ( ) const & { @@ -137,7 +138,7 @@ UnrestrictedGrammar < SymbolType >::UnrestrictedGrammar ( SymbolType initialSymb } template < class SymbolType > -UnrestrictedGrammar < SymbolType >::UnrestrictedGrammar ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < UnrestrictedGrammar, SymbolType, ext::tuple < TerminalAlphabet, NonterminalAlphabet >, ext::tuple < InitialSymbol > > ( ext::make_tuple ( std::move ( terminalAlphabet ), std::move ( nonterminalAlphabet ) ), ext::make_tuple ( std::move ( initialSymbol ) ) ) { +UnrestrictedGrammar < SymbolType >::UnrestrictedGrammar ( ext::set < SymbolType > nonterminalAlphabet, ext::set < SymbolType > terminalAlphabet, SymbolType initialSymbol ) : alib::Components < UnrestrictedGrammar, ext::set < SymbolType >, component::Set, std::tuple < TerminalAlphabet, NonterminalAlphabet >, SymbolType, component::Value, InitialSymbol > ( std::move ( terminalAlphabet), std::move ( nonterminalAlphabet ), std::move ( initialSymbol ) ) { } template < class SymbolType > @@ -295,7 +296,7 @@ alib::ObjectBase* UnrestrictedGrammar < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint< grammar::UnrestrictedGrammar < SymbolType >, SymbolType, grammar::TerminalAlphabet > { +class SetConstraint< grammar::UnrestrictedGrammar < SymbolType >, SymbolType, grammar::TerminalAlphabet > { public: static bool used ( const grammar::UnrestrictedGrammar < SymbolType > & grammar, const SymbolType & symbol ) { for ( const std::pair < const ext::vector < SymbolType >, ext::set < ext::vector < SymbolType > > > & rule : grammar.getRules ( ) ) { @@ -322,7 +323,7 @@ public: }; template < class SymbolType > -class ComponentConstraint< grammar::UnrestrictedGrammar < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { +class SetConstraint< grammar::UnrestrictedGrammar < SymbolType >, SymbolType, grammar::NonterminalAlphabet > { public: static bool used ( const grammar::UnrestrictedGrammar < SymbolType > & grammar, const SymbolType & symbol ) { for ( const std::pair < const ext::vector < SymbolType >, ext::set < ext::vector < SymbolType > > > & rule : grammar.getRules ( ) ) { @@ -335,7 +336,7 @@ public: } - if ( grammar.template accessElement < grammar::InitialSymbol > ( ).get ( ) == symbol ) + if ( grammar.template accessComponent < grammar::InitialSymbol > ( ).get ( ) == symbol ) return true; return false; diff --git a/alib2data/src/indexes/arbology/CompressedBitParallelTreeIndex.h b/alib2data/src/indexes/arbology/CompressedBitParallelTreeIndex.h index 1e11fe4159e1167fe306c102e1b3b6ea10f6c9d3..71316e74b3a13107a6cc000fb11315d800c9720a 100644 --- a/alib2data/src/indexes/arbology/CompressedBitParallelTreeIndex.h +++ b/alib2data/src/indexes/arbology/CompressedBitParallelTreeIndex.h @@ -8,6 +8,8 @@ #ifndef ARBOLOGY_COMPRESSED_BIT_PARALLEL_INDEX_H_ #define ARBOLOGY_COMPRESSED_BIT_PARALLEL_INDEX_H_ +#include <set> +#include <map> #include <string> #include <sstream> @@ -49,7 +51,7 @@ class GeneralAlphabet; * as a tree of RegExpElement. */ template < class SymbolType = DefaultSymbolType, class RankType = DefaultRankType > -class CompressedBitParallelTreeIndex final : public alib::ObjectBase, public alib::Components < CompressedBitParallelTreeIndex < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet >, ext::tuple < > > { +class CompressedBitParallelTreeIndex final : public alib::ObjectBase, public alib::Components < CompressedBitParallelTreeIndex < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet > { protected: ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > m_vectors; ext::vector < int > m_jumpTable; @@ -136,7 +138,7 @@ namespace indexes { namespace arbology { template < class SymbolType, class RankType > -CompressedBitParallelTreeIndex < SymbolType, RankType >::CompressedBitParallelTreeIndex ( ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > vectors, ext::vector < int > jumpTable ) : alib::Components < CompressedBitParallelTreeIndex, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ), m_vectors ( std::move ( vectors ) ), m_jumpTable ( std::move ( jumpTable ) ) { +CompressedBitParallelTreeIndex < SymbolType, RankType >::CompressedBitParallelTreeIndex ( ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > vectors, ext::vector < int > jumpTable ) : alib::Components < CompressedBitParallelTreeIndex, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet > ( std::move ( alphabet ) ), m_vectors ( std::move ( vectors ) ), m_jumpTable ( std::move ( jumpTable ) ) { } template < class SymbolType, class RankType > @@ -226,7 +228,7 @@ alib::ObjectBase * CompressedBitParallelTreeIndex < SymbolType, RankType >::inc namespace alib { template < class SymbolType, class RankType > -class ComponentConstraint < indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, indexes::arbology::GeneralAlphabet > { +class SetConstraint < indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, indexes::arbology::GeneralAlphabet > { public: static bool used ( const indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < SymbolType, RankType > > & index, const common::ranked_symbol < SymbolType, RankType > & symbol ) { const ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > & content = index.getData ( ); diff --git a/alib2data/src/indexes/arbology/NonlinearCompressedBitParallelTreeIndex.h b/alib2data/src/indexes/arbology/NonlinearCompressedBitParallelTreeIndex.h index e6302ed3af63547a60bede5ca8fa34f9c4b31efa..bb98a88ba7e6982545890d4e280cdb32574597fa 100644 --- a/alib2data/src/indexes/arbology/NonlinearCompressedBitParallelTreeIndex.h +++ b/alib2data/src/indexes/arbology/NonlinearCompressedBitParallelTreeIndex.h @@ -8,6 +8,8 @@ #ifndef ARBOLOGY_NONLINEAR_COMPRESSED_BIT_PARALLEL_INDEX_H_ #define ARBOLOGY_NONLINEAR_COMPRESSED_BIT_PARALLEL_INDEX_H_ +#include <set> +#include <map> #include <string> #include <sstream> @@ -47,7 +49,7 @@ class GeneralAlphabet; * as a tree of RegExpElement. */ template < class SymbolType = DefaultSymbolType, class RankType = DefaultRankType > -class NonlinearCompressedBitParallelTreeIndex final : public alib::ObjectBase, public alib::Components < NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet >, ext::tuple < > > { +class NonlinearCompressedBitParallelTreeIndex final : public alib::ObjectBase, public alib::Components < NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet > { protected: ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > m_vectors; ext::vector < int > m_jumpTable; @@ -139,7 +141,7 @@ namespace indexes { namespace arbology { template < class SymbolType, class RankType > -NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >::NonlinearCompressedBitParallelTreeIndex ( ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > vectors, ext::vector < int > jumpTable, ext::vector < unsigned > repeats ) : alib::Components < NonlinearCompressedBitParallelTreeIndex, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ), m_vectors ( std::move ( vectors ) ), m_jumpTable ( std::move ( jumpTable ) ), m_repeats ( std::move ( repeats ) ) { +NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >::NonlinearCompressedBitParallelTreeIndex ( ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > vectors, ext::vector < int > jumpTable, ext::vector < unsigned > repeats ) : alib::Components < NonlinearCompressedBitParallelTreeIndex, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet > ( std::move ( alphabet ) ), m_vectors ( std::move ( vectors ) ), m_jumpTable ( std::move ( jumpTable ) ), m_repeats ( std::move ( repeats ) ) { } template < class SymbolType, class RankType > @@ -239,7 +241,7 @@ alib::ObjectBase * NonlinearCompressedBitParallelTreeIndex < SymbolType, RankTyp namespace alib { template < class SymbolType, class RankType > -class ComponentConstraint < indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, indexes::arbology::GeneralAlphabet > { +class SetConstraint < indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, indexes::arbology::GeneralAlphabet > { public: static bool used ( const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType > & index, const common::ranked_symbol < SymbolType, RankType > & symbol ) { const ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > & content = index.getData ( ); diff --git a/alib2data/src/indexes/stringology/BNDMMatcher.h b/alib2data/src/indexes/stringology/BNDMMatcher.h index cb8644caed13d3c12a11f3db8175d703c0c7f1cc..d50dc4eb37a715280ed51f0538e91bdf35d596ee 100644 --- a/alib2data/src/indexes/stringology/BNDMMatcher.h +++ b/alib2data/src/indexes/stringology/BNDMMatcher.h @@ -8,6 +8,7 @@ #ifndef BNDM_MATCHER_H_ #define BNDM_MATCHER_H_ +#include <set> #include <string> #include <iostream> #include <sstream> @@ -49,7 +50,7 @@ class GeneralAlphabet; * as a tree of RegExpElement. */ template < class SymbolType = DefaultSymbolType, size_t BitmaskBitCount = 64 > -class BNDMMatcher final : public alib::ObjectBase, public alib::Components < BNDMMatcher < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > { +class BNDMMatcher final : public alib::ObjectBase, public alib::Components < BNDMMatcher < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet > { protected: ext::map < SymbolType, ext::bitset < BitmaskBitCount > > m_vectors; ext::vector < SymbolType > m_string; @@ -131,7 +132,7 @@ namespace indexes { namespace stringology { template < class SymbolType, size_t BitmaskBitCount > -BNDMMatcher < SymbolType, BitmaskBitCount >::BNDMMatcher ( ext::set < SymbolType > alphabet, ext::map < SymbolType, ext::bitset < BitmaskBitCount > > vectors, ext::vector < SymbolType > string ) : alib::Components < BNDMMatcher, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ), m_vectors ( std::move ( vectors ) ), m_string ( std::move ( string ) ) { +BNDMMatcher < SymbolType, BitmaskBitCount >::BNDMMatcher ( ext::set < SymbolType > alphabet, ext::map < SymbolType, ext::bitset < BitmaskBitCount > > vectors, ext::vector < SymbolType > string ) : alib::Components < BNDMMatcher, ext::set < SymbolType >, component::Set, GeneralAlphabet > ( std::move ( alphabet ) ), m_vectors ( std::move ( vectors ) ), m_string ( std::move ( string ) ) { } template < class SymbolType, size_t BitmaskBitCount > @@ -203,7 +204,7 @@ alib::ObjectBase* BNDMMatcher < SymbolType, BitmaskBitCount >::inc() && { namespace alib { template < class SymbolType, size_t BitmaskBitCount > -class ComponentConstraint < indexes::stringology::BNDMMatcher < SymbolType, BitmaskBitCount >, SymbolType, indexes::stringology::GeneralAlphabet > { +class SetConstraint < indexes::stringology::BNDMMatcher < SymbolType, BitmaskBitCount >, SymbolType, indexes::stringology::GeneralAlphabet > { public: static bool used ( const indexes::stringology::BNDMMatcher < SymbolType, BitmaskBitCount > & index, const SymbolType & symbol ) { const ext::map < SymbolType, ext::bitset < BitmaskBitCount > > & content = index.getData ( ); diff --git a/alib2data/src/indexes/stringology/BitParallelIndex.h b/alib2data/src/indexes/stringology/BitParallelIndex.h index 6d663d72b769d8c4faec9b1b5979a60f5b92d065..29a003ecfc9f969cbde285a4ac65a5bff4a48c1a 100644 --- a/alib2data/src/indexes/stringology/BitParallelIndex.h +++ b/alib2data/src/indexes/stringology/BitParallelIndex.h @@ -8,6 +8,7 @@ #ifndef BIT_PARALLEL_INDEX_H_ #define BIT_PARALLEL_INDEX_H_ +#include <set> #include <string> #include <iostream> #include <sstream> @@ -47,7 +48,7 @@ class GeneralAlphabet; * as a tree of RegExpElement. */ template < class SymbolType = DefaultSymbolType > -class BitParallelIndex final : public alib::ObjectBase, public alib::Components < BitParallelIndex < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > { +class BitParallelIndex final : public alib::ObjectBase, public alib::Components < BitParallelIndex < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet > { protected: ext::map < SymbolType, ext::vector < bool > > m_vectors; @@ -126,7 +127,7 @@ namespace indexes { namespace stringology { template < class SymbolType > -BitParallelIndex < SymbolType >::BitParallelIndex ( ext::set < SymbolType > alphabet, ext::map < SymbolType, ext::vector < bool > > vectors ) : alib::Components < BitParallelIndex, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ), m_vectors ( std::move ( vectors ) ) { +BitParallelIndex < SymbolType >::BitParallelIndex ( ext::set < SymbolType > alphabet, ext::map < SymbolType, ext::vector < bool > > vectors ) : alib::Components < BitParallelIndex, ext::set < SymbolType >, component::Set, GeneralAlphabet > ( std::move ( alphabet ) ), m_vectors ( std::move ( vectors ) ) { } template < class SymbolType > @@ -205,7 +206,7 @@ alib::ObjectBase* BitParallelIndex < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint < indexes::stringology::BitParallelIndex < SymbolType >, SymbolType, indexes::stringology::GeneralAlphabet > { +class SetConstraint < indexes::stringology::BitParallelIndex < SymbolType >, SymbolType, indexes::stringology::GeneralAlphabet > { public: static bool used ( const indexes::stringology::BitParallelIndex < SymbolType > & index, const SymbolType & symbol ) { const ext::map < SymbolType, ext::vector < bool > > & content = index.getData ( ); diff --git a/alib2data/src/indexes/stringology/CompressedBitParallelIndex.h b/alib2data/src/indexes/stringology/CompressedBitParallelIndex.h index b85f3563fcf6619c362db8d8c3cbb4434292a45e..5657c41f36c710c8980137a521735565e69d52a0 100644 --- a/alib2data/src/indexes/stringology/CompressedBitParallelIndex.h +++ b/alib2data/src/indexes/stringology/CompressedBitParallelIndex.h @@ -8,6 +8,7 @@ #ifndef COMPRESSED_BIT_PARALLEL_INDEX_H_ #define COMPRESSED_BIT_PARALLEL_INDEX_H_ +#include <set> #include <string> #include <iostream> #include <sstream> @@ -47,7 +48,7 @@ class GeneralAlphabet; * as a tree of RegExpElement. */ template < class SymbolType = DefaultSymbolType > -class CompressedBitParallelIndex final : public alib::ObjectBase, public alib::Components < CompressedBitParallelIndex < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > { +class CompressedBitParallelIndex final : public alib::ObjectBase, public alib::Components < CompressedBitParallelIndex < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet > { protected: ext::map < SymbolType, common::SparseBoolVector > m_vectors; @@ -126,7 +127,7 @@ namespace indexes { namespace stringology { template < class SymbolType > -CompressedBitParallelIndex < SymbolType >::CompressedBitParallelIndex ( ext::set < SymbolType > alphabet, ext::map < SymbolType, common::SparseBoolVector > vectors ) : alib::Components < CompressedBitParallelIndex, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ), m_vectors ( std::move ( vectors ) ) { +CompressedBitParallelIndex < SymbolType >::CompressedBitParallelIndex ( ext::set < SymbolType > alphabet, ext::map < SymbolType, common::SparseBoolVector > vectors ) : alib::Components < CompressedBitParallelIndex, ext::set < SymbolType >, component::Set, GeneralAlphabet > ( std::move ( alphabet ) ), m_vectors ( std::move ( vectors ) ) { } template < class SymbolType > @@ -205,7 +206,7 @@ alib::ObjectBase* CompressedBitParallelIndex < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint < indexes::stringology::CompressedBitParallelIndex < SymbolType >, SymbolType, indexes::stringology::GeneralAlphabet > { +class SetConstraint < indexes::stringology::CompressedBitParallelIndex < SymbolType >, SymbolType, indexes::stringology::GeneralAlphabet > { public: static bool used ( const indexes::stringology::CompressedBitParallelIndex < SymbolType > & index, const SymbolType & symbol ) { const ext::map < SymbolType, common::SparseBoolVector > & content = index.getData ( ); diff --git a/alib2data/src/indexes/stringology/PositionHeap.h b/alib2data/src/indexes/stringology/PositionHeap.h index 303de9de0af6239bbafb7e86d3ffcd9bea34d8db..a1a943c363bd7c098e288e80729491c90a9d810c 100644 --- a/alib2data/src/indexes/stringology/PositionHeap.h +++ b/alib2data/src/indexes/stringology/PositionHeap.h @@ -52,7 +52,7 @@ class GeneralAlphabet; * as a tree of RegExpElement. */ template < class SymbolType = DefaultSymbolType > -class PositionHeap final : public alib::ObjectBase, public alib::Components < PositionHeap < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > { +class PositionHeap final : public alib::ObjectBase, public alib::Components < PositionHeap < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet > { protected: ext::trie < SymbolType, unsigned > m_trie; ext::vector < SymbolType > m_string; @@ -137,7 +137,7 @@ namespace indexes { namespace stringology { template < class SymbolType > -PositionHeap < SymbolType >::PositionHeap ( ext::set < SymbolType > edgeAlphabet, ext::trie < SymbolType, unsigned > trie, ext::vector < SymbolType > string ) : alib::Components < PositionHeap, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( edgeAlphabet ) ), ext::tuple < > ( ) ), m_trie ( std::move ( trie ) ), m_string ( std::move ( string ) ) { +PositionHeap < SymbolType >::PositionHeap ( ext::set < SymbolType > edgeAlphabet, ext::trie < SymbolType, unsigned > trie, ext::vector < SymbolType > string ) : alib::Components < PositionHeap, ext::set < SymbolType >, component::Set, GeneralAlphabet > ( std::move ( edgeAlphabet ) ), m_trie ( std::move ( trie ) ), m_string ( std::move ( string ) ) { checkTrie ( this->m_trie ); // TODO check validity of the string like in LinearString } @@ -225,7 +225,7 @@ alib::ObjectBase* PositionHeap < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint < indexes::stringology::PositionHeap < SymbolType >, SymbolType, indexes::stringology::GeneralAlphabet > { +class SetConstraint < indexes::stringology::PositionHeap < SymbolType >, SymbolType, indexes::stringology::GeneralAlphabet > { static bool used ( const ext::trie < SymbolType, unsigned > & trie, const SymbolType & symbol ) { for ( const std::pair < const SymbolType, ext::trie < SymbolType, unsigned > > & child : trie.getChildren ( ) ) { diff --git a/alib2data/src/indexes/stringology/SuffixArray.h b/alib2data/src/indexes/stringology/SuffixArray.h index 7bf6c9685216e7d5d94f7eb29c051a7389df7bd2..6ae09bf40217f22ef5d388c911a2a6b323e6548d 100644 --- a/alib2data/src/indexes/stringology/SuffixArray.h +++ b/alib2data/src/indexes/stringology/SuffixArray.h @@ -48,7 +48,7 @@ class GeneralAlphabet; * as a tree of RegExpElement. */ template < class SymbolType = DefaultSymbolType > -class SuffixArray final : public alib::ObjectBase, public alib::Components < SuffixArray < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > { +class SuffixArray final : public alib::ObjectBase, public alib::Components < SuffixArray < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet > { protected: ext::vector < unsigned > m_data; ext::vector < SymbolType > m_string; @@ -130,7 +130,7 @@ namespace indexes { namespace stringology { template < class SymbolType > -SuffixArray < SymbolType >::SuffixArray ( ext::set < SymbolType > alphabet, ext::vector < unsigned > data, ext::vector < SymbolType > string ) : alib::Components < SuffixArray, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ), m_data ( std::move ( data ) ), m_string ( std::move ( string ) ) { +SuffixArray < SymbolType >::SuffixArray ( ext::set < SymbolType > alphabet, ext::vector < unsigned > data, ext::vector < SymbolType > string ) : alib::Components < SuffixArray, ext::set < SymbolType >, component::Set, GeneralAlphabet > ( std::move ( alphabet ) ), m_data ( std::move ( data ) ), m_string ( std::move ( string ) ) { // TODO check validity of the string like in LinearString } @@ -203,7 +203,7 @@ alib::ObjectBase* SuffixArray < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint < indexes::stringology::SuffixArray < SymbolType >, SymbolType, indexes::stringology::GeneralAlphabet > { +class SetConstraint < indexes::stringology::SuffixArray < SymbolType >, SymbolType, indexes::stringology::GeneralAlphabet > { public: static bool used ( const indexes::stringology::SuffixArray < SymbolType > & index, const SymbolType & symbol ) { const ext::vector < SymbolType > & content = index.getString ( ); diff --git a/alib2data/src/indexes/stringology/SuffixTrie.h b/alib2data/src/indexes/stringology/SuffixTrie.h index 63cba13519857224e7b4508a3088864cb2369689..89437ae352bb87085757e9634348f4f3f7104852 100644 --- a/alib2data/src/indexes/stringology/SuffixTrie.h +++ b/alib2data/src/indexes/stringology/SuffixTrie.h @@ -54,7 +54,7 @@ class GeneralAlphabet; * as a tree of RegExpElement. */ template < class SymbolType = DefaultSymbolType > -class SuffixTrie final : public alib::ObjectBase, public alib::Components < SuffixTrie < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > { +class SuffixTrie final : public alib::ObjectBase, public alib::Components < SuffixTrie < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet > { protected: ext::trie < SymbolType, ext::variant < void, unsigned > > m_trie; @@ -139,7 +139,7 @@ SuffixTrie < SymbolType >::SuffixTrie ( ext::set < SymbolType > edgeAlphabet ) : } template < class SymbolType > -SuffixTrie < SymbolType >::SuffixTrie ( ext::set < SymbolType > edgeAlphabet, ext::trie < SymbolType, ext::variant < void, unsigned > > trie ) : alib::Components < SuffixTrie, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( edgeAlphabet ) ), ext::tuple < > ( ) ), m_trie ( std::move ( trie ) ) { +SuffixTrie < SymbolType >::SuffixTrie ( ext::set < SymbolType > edgeAlphabet, ext::trie < SymbolType, ext::variant < void, unsigned > > trie ) : alib::Components < SuffixTrie, ext::set < SymbolType >, component::Set, GeneralAlphabet > ( std::move ( edgeAlphabet ) ), m_trie ( std::move ( trie ) ) { checkTrie ( this->m_trie ); } @@ -216,7 +216,7 @@ alib::ObjectBase* SuffixTrie < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint < indexes::stringology::SuffixTrie < SymbolType >, SymbolType, indexes::stringology::GeneralAlphabet > { +class SetConstraint < indexes::stringology::SuffixTrie < SymbolType >, SymbolType, indexes::stringology::GeneralAlphabet > { static bool used ( const ext::trie < SymbolType, ext::variant < void, unsigned > > & trie, const SymbolType & symbol ) { for ( const std::pair < const SymbolType, ext::trie < SymbolType, ext::variant < void, unsigned > > > & child : trie.getChildren ( ) ) { diff --git a/alib2data/src/regexp/formal/FormalRegExp.h b/alib2data/src/regexp/formal/FormalRegExp.h index 7f22cbe62bf68839a7a6a8bc76fea5a23a9ac6c9..9372f90d4a360c992041b9fa64aa7b9819c82a08 100644 --- a/alib2data/src/regexp/formal/FormalRegExp.h +++ b/alib2data/src/regexp/formal/FormalRegExp.h @@ -37,7 +37,7 @@ class GeneralAlphabet; * as a tree of RegExpElement. */ template < class SymbolType > -class FormalRegExp final : public RegExpBase, public alib::Components < FormalRegExp < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > { +class FormalRegExp final : public RegExpBase, public alib::Components < FormalRegExp < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet > { protected: FormalRegExpStructure < SymbolType > m_regExp; @@ -121,7 +121,7 @@ public: namespace regexp { template < class SymbolType > -FormalRegExp < SymbolType >::FormalRegExp ( ext::set < SymbolType > alphabet, FormalRegExpStructure < SymbolType > regExp ) : alib::Components < FormalRegExp < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ), m_regExp ( std::move ( regExp ) ) { +FormalRegExp < SymbolType >::FormalRegExp ( ext::set < SymbolType > alphabet, FormalRegExpStructure < SymbolType > regExp ) : alib::Components < FormalRegExp, ext::set < SymbolType >, component::Set, GeneralAlphabet > ( std::move ( alphabet ) ), m_regExp ( std::move ( regExp ) ) { if ( !this->m_regExp.getStructure ( ).checkAlphabet ( getAlphabet ( ) ) ) throw exception::CommonException ( "Input symbols not in the alphabet." ); } @@ -220,7 +220,7 @@ alib::ObjectBase* FormalRegExp < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint< regexp::FormalRegExp < SymbolType >, SymbolType, regexp::GeneralAlphabet > { +class SetConstraint< regexp::FormalRegExp < SymbolType >, SymbolType, regexp::GeneralAlphabet > { public: static bool used ( const regexp::FormalRegExp < SymbolType > & regexp, const SymbolType & symbol ) { return regexp.getRegExp ( ).getStructure ( ).testSymbol ( symbol ); diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExp.h b/alib2data/src/regexp/unbounded/UnboundedRegExp.h index a04a7ea6809cae8db6585d22f4d843263525aa55..186010018804c20ef295bc8f8d9b5d14a2f29594 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExp.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExp.h @@ -37,7 +37,7 @@ class GeneralAlphabet; * as a tree of RegExpElement. */ template < class SymbolType > -class UnboundedRegExp final : public RegExpBase, public alib::Components < UnboundedRegExp < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > { +class UnboundedRegExp final : public RegExpBase, public alib::Components < UnboundedRegExp < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet > { protected: UnboundedRegExpStructure < SymbolType > m_regExp; @@ -121,7 +121,7 @@ public: namespace regexp { template < class SymbolType > -UnboundedRegExp < SymbolType >::UnboundedRegExp ( ext::set < SymbolType > alphabet, UnboundedRegExpStructure < SymbolType > regExp ) : alib::Components < UnboundedRegExp, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ), m_regExp ( std::move ( regExp ) ) { +UnboundedRegExp < SymbolType >::UnboundedRegExp ( ext::set < SymbolType > alphabet, UnboundedRegExpStructure < SymbolType > regExp ) : alib::Components < UnboundedRegExp, ext::set < SymbolType >, component::Set, GeneralAlphabet > ( std::move ( alphabet ) ), m_regExp ( std::move ( regExp ) ) { if ( !this->m_regExp.getStructure ( ).checkAlphabet ( getAlphabet ( ) ) ) throw exception::CommonException ( "Input symbols not in the alphabet." ); } @@ -220,7 +220,7 @@ alib::ObjectBase* UnboundedRegExp < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint< regexp::UnboundedRegExp < SymbolType >, SymbolType, regexp::GeneralAlphabet > { +class SetConstraint< regexp::UnboundedRegExp < SymbolType >, SymbolType, regexp::GeneralAlphabet > { public: static bool used ( const regexp::UnboundedRegExp < SymbolType > & regexp, const SymbolType & symbol ) { return regexp.getRegExp ( ).getStructure ( ).testSymbol ( symbol ); diff --git a/alib2data/src/rte/formal/FormalRTE.h b/alib2data/src/rte/formal/FormalRTE.h index 539842508e594919c65a8bd6523f14037c0098cc..c6baa4e57467469ca72e1a5915a379233f14a18e 100644 --- a/alib2data/src/rte/formal/FormalRTE.h +++ b/alib2data/src/rte/formal/FormalRTE.h @@ -38,7 +38,7 @@ class ConstantAlphabet; * as a tree of RTEElement elements. */ template < class SymbolType, class RankType > -class FormalRTE final : public RTEBase, public alib::Components < FormalRTE < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet, ConstantAlphabet >, ext::tuple < > > { +class FormalRTE final : public RTEBase, public alib::Components < FormalRTE < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, ConstantAlphabet > > { protected: FormalRTEStructure < SymbolType, RankType > m_rte; @@ -156,7 +156,7 @@ public: }; template < class SymbolType, class RankType > -FormalRTE < SymbolType, RankType >::FormalRTE ( ext::set < common::ranked_symbol < SymbolType, RankType > > alphabetF, ext::set < common::ranked_symbol < SymbolType, RankType > > alphabetK, FormalRTEStructure < SymbolType, RankType > rte ) : alib::Components < FormalRTE, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet, ConstantAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabetF ), std::move ( alphabetK ) ), ext::tuple < > ( ) ), m_rte ( std::move ( rte ) ) { +FormalRTE < SymbolType, RankType >::FormalRTE ( ext::set < common::ranked_symbol < SymbolType, RankType > > alphabetF, ext::set < common::ranked_symbol < SymbolType, RankType > > alphabetK, FormalRTEStructure < SymbolType, RankType > rte ) : alib::Components < FormalRTE, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, ConstantAlphabet > > ( std::move ( alphabetF ), std::move ( alphabetK ) ), m_rte ( std::move ( rte ) ) { if ( !this->m_rte.getStructure ( ).checkAlphabet ( getAlphabet ( ), getSubstitutionAlphabet ( ) ) ) throw exception::CommonException ( "Input symbols not in the alphabet." ); } @@ -253,7 +253,7 @@ alib::ObjectBase* FormalRTE < SymbolType, RankType >::inc() && { namespace alib { template < class SymbolType, class RankType > -class ComponentConstraint< rte::FormalRTE < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, rte::GeneralAlphabet > { +class SetConstraint< rte::FormalRTE < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, rte::GeneralAlphabet > { public: static bool used ( const rte::FormalRTE < SymbolType, RankType > & rte, const common::ranked_symbol < SymbolType, RankType > & symbol ) { return rte.getRTE ( ).getStructure ( ).testSymbol ( symbol ); @@ -270,7 +270,7 @@ public: }; template < class SymbolType, class RankType > -class ComponentConstraint< rte::FormalRTE < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, rte::ConstantAlphabet > { +class SetConstraint< rte::FormalRTE < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, rte::ConstantAlphabet > { public: static bool used ( const rte::FormalRTE < SymbolType, RankType > & rte, const common::ranked_symbol < SymbolType, RankType > & symbol ) { return rte.getRTE ( ).getStructure ( ).testSymbol ( symbol ); diff --git a/alib2data/src/string/CyclicString.h b/alib2data/src/string/CyclicString.h index de18b89bcfd960c59766542526025ca83822000b..78b2677d0654894f411442cb2d8aaaefba76a61d 100644 --- a/alib2data/src/string/CyclicString.h +++ b/alib2data/src/string/CyclicString.h @@ -35,7 +35,7 @@ class GeneralAlphabet; * as a tree of CyclicStringElement. */ template < class SymbolType > -class CyclicString final : public StringBase, public alib::Components < CyclicString < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > { +class CyclicString final : public StringBase, public alib::Components < CyclicString < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet > { ext::vector < SymbolType > m_Data; public: @@ -109,7 +109,7 @@ public: namespace string { template < class SymbolType > -CyclicString < SymbolType >::CyclicString(ext::set<SymbolType> alphabet, ext::vector<SymbolType> str) : alib::Components < CyclicString < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ) { +CyclicString < SymbolType >::CyclicString(ext::set<SymbolType> alphabet, ext::vector<SymbolType> str) : alib::Components < CyclicString, ext::set < SymbolType >, component::Set, GeneralAlphabet > ( std::move ( alphabet ) ) { setContent(std::move(str)); } @@ -225,7 +225,7 @@ alib::ObjectBase* CyclicString < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint< string::CyclicString < SymbolType >, SymbolType, string::GeneralAlphabet > { +class SetConstraint< string::CyclicString < SymbolType >, SymbolType, string::GeneralAlphabet > { public: static bool used ( const string::CyclicString < SymbolType > & str, const SymbolType & symbol ) { const ext::vector<SymbolType>& content = str.getContent ( ); diff --git a/alib2data/src/string/Epsilon.h b/alib2data/src/string/Epsilon.h index ef781b4dc1bb3b81756aa6e890c68387c1560181..05d080a99b57135bf0c77572e2c769ac3af5358c 100644 --- a/alib2data/src/string/Epsilon.h +++ b/alib2data/src/string/Epsilon.h @@ -32,7 +32,7 @@ class GeneralAlphabet; * as a tree of EpsilonElement. */ template < class SymbolType > -class Epsilon final : public StringBase, public alib::Components < Epsilon < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > { +class Epsilon final : public StringBase, public alib::Components < Epsilon < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet > { static const ext::vector < SymbolType > content; public: @@ -95,7 +95,7 @@ public: }; template < class SymbolType > -Epsilon < SymbolType >::Epsilon(ext::set<SymbolType> alphabet) : alib::Components < Epsilon < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ) { +Epsilon < SymbolType >::Epsilon ( ext::set < SymbolType > alphabet ) : alib::Components < Epsilon, ext::set < SymbolType >, component::Set, GeneralAlphabet > ( std::move ( alphabet ) ) { } template < class SymbolType > @@ -169,7 +169,7 @@ alib::ObjectBase* Epsilon < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint< string::Epsilon < SymbolType >, SymbolType, string::GeneralAlphabet > { +class SetConstraint< string::Epsilon < SymbolType >, SymbolType, string::GeneralAlphabet > { public: static bool used ( const string::Epsilon < SymbolType > &, const SymbolType & ) { return false; diff --git a/alib2data/src/string/LinearString.h b/alib2data/src/string/LinearString.h index 15f3da186767e6eaf3200476b41312d07628b9d2..6c37e603d787c2aedb4b419b601627cfba708679 100644 --- a/alib2data/src/string/LinearString.h +++ b/alib2data/src/string/LinearString.h @@ -37,7 +37,7 @@ class GeneralAlphabet; * as a tree of LinearStringElement. */ template < class SymbolType > -class LinearString final : public StringBase, public alib::Components < LinearString < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > { +class LinearString final : public StringBase, public alib::Components < LinearString < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet > { ext::vector < SymbolType > m_Data; public: @@ -147,7 +147,7 @@ public: namespace string { template < class SymbolType > -LinearString < SymbolType >::LinearString(ext::set<SymbolType> alphabet, ext::vector<SymbolType> str) : alib::Components < LinearString < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ) { +LinearString < SymbolType >::LinearString(ext::set<SymbolType> alphabet, ext::vector<SymbolType> str) : alib::Components < LinearString, ext::set < SymbolType >, component::Set, GeneralAlphabet > ( std::move ( alphabet ) ) { setContent(std::move(str)); } @@ -315,7 +315,7 @@ alib::ObjectBase* LinearString < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint< string::LinearString < SymbolType >, SymbolType, string::GeneralAlphabet > { +class SetConstraint< string::LinearString < SymbolType >, SymbolType, string::GeneralAlphabet > { public: static bool used ( const string::LinearString < SymbolType > & str, const SymbolType & symbol ) { const ext::vector<SymbolType>& content = str.getContent ( ); diff --git a/alib2data/src/tree/ranked/PostfixRankedTree.h b/alib2data/src/tree/ranked/PostfixRankedTree.h index 0dcd7d1d44a0472c279b4fefc96174d7a95cca41..a5d1ae67d49ed2fbed3de25fe33c58384b9fea06 100644 --- a/alib2data/src/tree/ranked/PostfixRankedTree.h +++ b/alib2data/src/tree/ranked/PostfixRankedTree.h @@ -39,7 +39,7 @@ class GeneralAlphabet; * as a tree of LinearStringElement. */ template < class SymbolType, class RankType > -class PostfixRankedTree final : public RankedTreeBase, public alib::Components < PostfixRankedTree < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet >, ext::tuple < > > { +class PostfixRankedTree final : public RankedTreeBase, public alib::Components < PostfixRankedTree < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet > { ext::vector < common::ranked_symbol < SymbolType, RankType > > m_Data; static ext::vector < common::ranked_symbol < SymbolType, RankType > > toPostfixRanked ( const ext::tree < common::ranked_symbol < SymbolType, RankType > > & tree ); @@ -114,7 +114,7 @@ public: namespace tree { template < class SymbolType, class RankType > -PostfixRankedTree < SymbolType, RankType >::PostfixRankedTree ( ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::vector < common::ranked_symbol < SymbolType, RankType > > data ) : alib::Components < PostfixRankedTree, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ) { +PostfixRankedTree < SymbolType, RankType >::PostfixRankedTree ( ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::vector < common::ranked_symbol < SymbolType, RankType > > data ) : alib::Components < PostfixRankedTree, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet > ( std::move ( alphabet ) ) { setContent ( std::move ( data ) ); } @@ -247,7 +247,7 @@ alib::ObjectBase * PostfixRankedTree < SymbolType, RankType >::inc ( ) && { namespace alib { template < class SymbolType, class RankType > -class ComponentConstraint < ::tree::PostfixRankedTree < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { +class SetConstraint < ::tree::PostfixRankedTree < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { public: static bool used ( const ::tree::PostfixRankedTree < SymbolType, RankType > & tree, const common::ranked_symbol < SymbolType, RankType > & symbol ) { const ext::vector < common::ranked_symbol < SymbolType, RankType > > & content = tree.getContent ( ); diff --git a/alib2data/src/tree/ranked/PrefixRankedBarNonlinearPattern.h b/alib2data/src/tree/ranked/PrefixRankedBarNonlinearPattern.h index feba9608ce8407dd6ce26432ede9aa1ebf0fe6c2..95825ddc30df50c3e4d2aa034b09affc0edaf276 100644 --- a/alib2data/src/tree/ranked/PrefixRankedBarNonlinearPattern.h +++ b/alib2data/src/tree/ranked/PrefixRankedBarNonlinearPattern.h @@ -48,7 +48,7 @@ class NonlinearAlphabet; * as a tree of LinearStringElement. */ template < class SymbolType, class RankType > -class PrefixRankedBarNonlinearPattern final : public RankedTreeBase, public alib::Components < PrefixRankedBarNonlinearPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet, NonlinearAlphabet, BarSymbols >, ext::tuple < SubtreeWildcard, VariablesBarSymbol > > { +class PrefixRankedBarNonlinearPattern final : public RankedTreeBase, public alib::Components < PrefixRankedBarNonlinearPattern < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, NonlinearAlphabet, BarSymbols >, common::ranked_symbol < SymbolType, RankType >, component::Value, std::tuple < SubtreeWildcard, VariablesBarSymbol > > { ext::vector < common::ranked_symbol < SymbolType, RankType > > m_Data; static ext::vector < common::ranked_symbol < SymbolType, RankType > > toPrefixRankedBar ( const ext::tree < common::ranked_symbol < SymbolType, RankType > > & node, const common::ranked_symbol < SymbolType, RankType > & subtreeWildcard, const ext::set < common::ranked_symbol < SymbolType, RankType > > & nonlinearVariables, const SymbolType & barBase, const common::ranked_symbol < SymbolType, RankType > & variablesBar ); @@ -90,11 +90,11 @@ public: } const common::ranked_symbol < SymbolType, RankType > & getSubtreeWildcard ( ) const & { - return this->template accessElement < SubtreeWildcard > ( ).get ( ); + return this->template accessComponent < SubtreeWildcard > ( ).get ( ); } common::ranked_symbol < SymbolType, RankType > && getSubtreeWildcard ( ) && { - return std::move ( this->template accessElement < SubtreeWildcard > ( ).get ( ) ); + return std::move ( this->template accessComponent < SubtreeWildcard > ( ).get ( ) ); } const ext::set < common::ranked_symbol < SymbolType, RankType > > & getNonlinearVariables ( ) const & { @@ -106,11 +106,11 @@ public: } const common::ranked_symbol < SymbolType, RankType > & getVariablesBar ( ) const & { - return this->template accessElement < VariablesBarSymbol > ( ).get ( ); + return this->template accessComponent < VariablesBarSymbol > ( ).get ( ); } common::ranked_symbol < SymbolType, RankType > && getVariablesBar ( ) && { - return std::move ( this->template accessElement < VariablesBarSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < VariablesBarSymbol > ( ).get ( ) ); } /** @@ -167,7 +167,7 @@ public: namespace tree { template < class SymbolType, class RankType > -PrefixRankedBarNonlinearPattern < SymbolType, RankType >::PrefixRankedBarNonlinearPattern ( ext::set < common::ranked_symbol < SymbolType, RankType > > bars, common::ranked_symbol < SymbolType, RankType > variablesBar, common::ranked_symbol < SymbolType, RankType > subtreeWildcard, ext::set < common::ranked_symbol < SymbolType, RankType > > nonlinearVariables, ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::vector < common::ranked_symbol < SymbolType, RankType > > data ) : alib::Components < PrefixRankedBarNonlinearPattern, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet, NonlinearAlphabet, BarSymbols >, ext::tuple < SubtreeWildcard, VariablesBarSymbol > > ( ext::make_tuple ( std::move ( alphabet ), std::move ( nonlinearVariables ), std::move ( bars ) ), ext::make_tuple ( std::move ( subtreeWildcard ), std::move ( variablesBar ) ) ) { +PrefixRankedBarNonlinearPattern < SymbolType, RankType >::PrefixRankedBarNonlinearPattern ( ext::set < common::ranked_symbol < SymbolType, RankType > > bars, common::ranked_symbol < SymbolType, RankType > variablesBar, common::ranked_symbol < SymbolType, RankType > subtreeWildcard, ext::set < common::ranked_symbol < SymbolType, RankType > > nonlinearVariables, ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::vector < common::ranked_symbol < SymbolType, RankType > > data ) : alib::Components < PrefixRankedBarNonlinearPattern, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, NonlinearAlphabet, BarSymbols >, common::ranked_symbol < SymbolType, RankType >, component::Value, std::tuple < SubtreeWildcard, VariablesBarSymbol > > ( std::move ( alphabet ), std::move ( nonlinearVariables ), std::move ( bars ), std::move ( subtreeWildcard ), std::move ( variablesBar ) ) { setContent ( std::move ( data ) ); } @@ -364,12 +364,12 @@ alib::ObjectBase* PrefixRankedBarNonlinearPattern < SymbolType, RankType >::inc( namespace alib { template < class SymbolType, class RankType > -class ComponentConstraint< ::tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { +class SetConstraint< ::tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { public: static bool used ( const ::tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType > & pattern, const common::ranked_symbol < SymbolType, RankType > & symbol ) { const ext::vector < common::ranked_symbol < SymbolType, RankType > > & content = pattern.getContent ( ); - return std::find ( content.begin ( ), content.end ( ), symbol ) != content.end ( ) || pattern.template accessElement < ::tree::VariablesBarSymbol > ( ).get ( ) == symbol || pattern.template accessComponent < ::tree::BarSymbols > ( ).get ( ).count ( symbol ) || pattern.template accessElement < ::tree::SubtreeWildcard > ( ).get ( ) == symbol; + return std::find ( content.begin ( ), content.end ( ), symbol ) != content.end ( ) || pattern.template accessComponent < ::tree::VariablesBarSymbol > ( ).get ( ) == symbol || pattern.template accessComponent < ::tree::BarSymbols > ( ).get ( ).count ( symbol ) || pattern.template accessComponent < ::tree::SubtreeWildcard > ( ).get ( ) == symbol; } static bool available ( const ::tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType > &, const common::ranked_symbol < SymbolType, RankType > & ) { @@ -381,12 +381,12 @@ public: }; template < class SymbolType, class RankType > -class ComponentConstraint< ::tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::BarSymbols > { +class SetConstraint< ::tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::BarSymbols > { public: static bool used ( const ::tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType > & pattern, const common::ranked_symbol < SymbolType, RankType > & symbol ) { const ext::vector < common::ranked_symbol < SymbolType, RankType > > & content = pattern.getContent ( ); - return std::find ( content.begin ( ), content.end ( ), symbol ) != content.end ( ) || pattern.template accessElement < ::tree::VariablesBarSymbol > ( ).get ( ) == symbol; + return std::find ( content.begin ( ), content.end ( ), symbol ) != content.end ( ) || pattern.template accessComponent < ::tree::VariablesBarSymbol > ( ).get ( ) == symbol; } static bool available ( const ::tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType > & pattern, const common::ranked_symbol < SymbolType, RankType > & symbol ) { @@ -398,7 +398,7 @@ public: }; template < class SymbolType, class RankType > -class ComponentConstraint< ::tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::NonlinearAlphabet > { +class SetConstraint< ::tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::NonlinearAlphabet > { public: static bool used ( const ::tree::PrefixRankedBarNonlinearPattern < SymbolType, RankType > &, const common::ranked_symbol < SymbolType, RankType > & ) { return false; @@ -412,7 +412,7 @@ public: if ( ( unsigned ) symbol.getRank ( ) != 0 ) throw ::tree::TreeException ( "SubtreeWildcard symbol has nonzero arity" ); - if ( pattern.template accessElement < ::tree::SubtreeWildcard > ( ).get ( ) == symbol ) + if ( pattern.template accessComponent < ::tree::SubtreeWildcard > ( ).get ( ) == symbol ) throw ::tree::TreeException ( "Symbol " + ext::to_string ( symbol ) + "cannot be set as nonlinear variable since it is already subtree wildcard" ); } }; diff --git a/alib2data/src/tree/ranked/PrefixRankedBarPattern.h b/alib2data/src/tree/ranked/PrefixRankedBarPattern.h index a6f581b656b201d3b9a26e80a83dedfc464c1f55..8a19925cee64626337949dc3ee541424a272b15f 100644 --- a/alib2data/src/tree/ranked/PrefixRankedBarPattern.h +++ b/alib2data/src/tree/ranked/PrefixRankedBarPattern.h @@ -47,7 +47,7 @@ class VariablesBarSymbol; * as a tree of LinearStringElement. */ template < class SymbolType, class RankType > -class PrefixRankedBarPattern final : public RankedTreeBase, public alib::Components < PrefixRankedBarPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet, BarSymbols >, ext::tuple < SubtreeWildcard, VariablesBarSymbol > > { +class PrefixRankedBarPattern final : public RankedTreeBase, public alib::Components < PrefixRankedBarPattern < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, BarSymbols >, common::ranked_symbol < SymbolType, RankType >, component::Value, std::tuple < SubtreeWildcard, VariablesBarSymbol > > { ext::vector < common::ranked_symbol < SymbolType, RankType > > m_Data; static ext::vector < common::ranked_symbol < SymbolType, RankType > > toPrefixRankedBar ( const ext::tree < common::ranked_symbol < SymbolType, RankType > > & node, const common::ranked_symbol < SymbolType, RankType > & subtreeWildcard, const SymbolType & barBase, const common::ranked_symbol < SymbolType, RankType > & variablesBar ); @@ -83,19 +83,19 @@ public: } const common::ranked_symbol < SymbolType, RankType > & getSubtreeWildcard ( ) const & { - return this->template accessElement < SubtreeWildcard > ( ).get ( ); + return this->template accessComponent < SubtreeWildcard > ( ).get ( ); } common::ranked_symbol < SymbolType, RankType > && getSubtreeWildcard ( ) && { - return std::move ( this->template accessElement < SubtreeWildcard > ( ).get ( ) ); + return std::move ( this->template accessComponent < SubtreeWildcard > ( ).get ( ) ); } const common::ranked_symbol < SymbolType, RankType > & getVariablesBar ( ) const & { - return this->template accessElement < VariablesBarSymbol > ( ).get ( ); + return this->template accessComponent < VariablesBarSymbol > ( ).get ( ); } common::ranked_symbol < SymbolType, RankType > && getVariablesBar ( ) && { - return std::move ( this->template accessElement < VariablesBarSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < VariablesBarSymbol > ( ).get ( ) ); } /** @@ -149,7 +149,7 @@ public: namespace tree { template < class SymbolType, class RankType > -PrefixRankedBarPattern < SymbolType, RankType >::PrefixRankedBarPattern ( ext::set < common::ranked_symbol < SymbolType, RankType > > bars, common::ranked_symbol < SymbolType, RankType > variablesBar, common::ranked_symbol < SymbolType, RankType > subtreeWildcard, ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::vector < common::ranked_symbol < SymbolType, RankType > > data ) : alib::Components < PrefixRankedBarPattern, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet, BarSymbols >, ext::tuple < SubtreeWildcard, VariablesBarSymbol > > ( ext::make_tuple ( std::move ( alphabet ), std::move ( bars ) ), ext::make_tuple ( std::move ( subtreeWildcard ), std::move ( variablesBar ) ) ) { +PrefixRankedBarPattern < SymbolType, RankType >::PrefixRankedBarPattern ( ext::set < common::ranked_symbol < SymbolType, RankType > > bars, common::ranked_symbol < SymbolType, RankType > variablesBar, common::ranked_symbol < SymbolType, RankType > subtreeWildcard, ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::vector < common::ranked_symbol < SymbolType, RankType > > data ) : alib::Components < PrefixRankedBarPattern, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, BarSymbols >, common::ranked_symbol < SymbolType, RankType >, component::Value, std::tuple < SubtreeWildcard, VariablesBarSymbol > > ( std::move ( alphabet ), std::move ( bars ), std::move ( subtreeWildcard ), std::move ( variablesBar ) ) { setContent ( std::move ( data ) ); } @@ -316,12 +316,12 @@ alib::ObjectBase* PrefixRankedBarPattern < SymbolType, RankType >::inc() && { namespace alib { template < class SymbolType, class RankType > -class ComponentConstraint< ::tree::PrefixRankedBarPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { +class SetConstraint< ::tree::PrefixRankedBarPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { public: static bool used ( const ::tree::PrefixRankedBarPattern < SymbolType, RankType > & pattern, const common::ranked_symbol < SymbolType, RankType > & symbol ) { const ext::vector < common::ranked_symbol < SymbolType, RankType > > & content = pattern.getContent ( ); - return std::find ( content.begin ( ), content.end ( ), symbol ) != content.end ( ) || pattern.template accessElement < ::tree::VariablesBarSymbol > ( ).get ( ) == symbol || pattern.template accessComponent < ::tree::BarSymbols > ( ).get ( ).count ( symbol ) || pattern.template accessElement < ::tree::SubtreeWildcard > ( ).get ( ) == symbol; + return std::find ( content.begin ( ), content.end ( ), symbol ) != content.end ( ) || pattern.template accessComponent < ::tree::VariablesBarSymbol > ( ).get ( ) == symbol || pattern.template accessComponent < ::tree::BarSymbols > ( ).get ( ).count ( symbol ) || pattern.template accessComponent < ::tree::SubtreeWildcard > ( ).get ( ) == symbol; } static bool available ( const ::tree::PrefixRankedBarPattern < SymbolType, RankType > &, const common::ranked_symbol < SymbolType, RankType > & ) { @@ -333,12 +333,12 @@ public: }; template < class SymbolType, class RankType > -class ComponentConstraint< ::tree::PrefixRankedBarPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::BarSymbols > { +class SetConstraint< ::tree::PrefixRankedBarPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::BarSymbols > { public: static bool used ( const ::tree::PrefixRankedBarPattern < SymbolType, RankType > & pattern, const common::ranked_symbol < SymbolType, RankType > & symbol ) { const ext::vector < common::ranked_symbol < SymbolType, RankType > > & content = pattern.getContent ( ); - return std::find ( content.begin ( ), content.end ( ), symbol ) != content.end ( ) || pattern.template accessElement < ::tree::VariablesBarSymbol > ( ).get ( ) == symbol; + return std::find ( content.begin ( ), content.end ( ), symbol ) != content.end ( ) || pattern.template accessComponent < ::tree::VariablesBarSymbol > ( ).get ( ) == symbol; } static bool available ( const ::tree::PrefixRankedBarPattern < SymbolType, RankType > & pattern, const common::ranked_symbol < SymbolType, RankType > & symbol ) { diff --git a/alib2data/src/tree/ranked/PrefixRankedBarTree.h b/alib2data/src/tree/ranked/PrefixRankedBarTree.h index 74d8c74692e84b38242c1aed274222602f8a5631..267b8e09ef91e5d58fbbece4feac28a121a14b4f 100644 --- a/alib2data/src/tree/ranked/PrefixRankedBarTree.h +++ b/alib2data/src/tree/ranked/PrefixRankedBarTree.h @@ -43,7 +43,7 @@ class BarSymbols; * as a tree of LinearStringElement. */ template < class SymbolType, class RankType > -class PrefixRankedBarTree final : public RankedTreeBase, public alib::Components < PrefixRankedBarTree < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet, BarSymbols >, ext::tuple < > > { +class PrefixRankedBarTree final : public RankedTreeBase, public alib::Components < PrefixRankedBarTree < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, BarSymbols > > { ext::vector < common::ranked_symbol < SymbolType, RankType > > m_Data; static ext::vector < common::ranked_symbol < SymbolType, RankType > > toPrefixRankedBar ( const ext::tree < common::ranked_symbol < SymbolType, RankType > > & node, const SymbolType & barBase ); @@ -127,7 +127,7 @@ public: namespace tree { template < class SymbolType, class RankType > -PrefixRankedBarTree < SymbolType, RankType >::PrefixRankedBarTree ( ext::set < common::ranked_symbol < SymbolType, RankType > > bars, ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::vector < common::ranked_symbol < SymbolType, RankType > > data ) : alib::Components < PrefixRankedBarTree, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet, BarSymbols >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ), std::move ( bars ) ), ext::tuple < > ( ) ) { +PrefixRankedBarTree < SymbolType, RankType >::PrefixRankedBarTree ( ext::set < common::ranked_symbol < SymbolType, RankType > > bars, ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::vector < common::ranked_symbol < SymbolType, RankType > > data ) : alib::Components < PrefixRankedBarTree, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, BarSymbols > > ( std::move ( alphabet ), std::move ( bars ) ) { setContent ( std::move ( data ) ); } @@ -278,7 +278,7 @@ alib::ObjectBase* PrefixRankedBarTree < SymbolType, RankType >::inc() && { namespace alib { template < class SymbolType, class RankType > -class ComponentConstraint< ::tree::PrefixRankedBarTree < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { +class SetConstraint< ::tree::PrefixRankedBarTree < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { public: static bool used ( const ::tree::PrefixRankedBarTree < SymbolType, RankType > & tree, const common::ranked_symbol < SymbolType, RankType > & symbol ) { const ext::vector < common::ranked_symbol < SymbolType, RankType > > & content = tree.getContent ( ); @@ -295,7 +295,7 @@ public: }; template < class SymbolType, class RankType > -class ComponentConstraint< ::tree::PrefixRankedBarTree < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::BarSymbols > { +class SetConstraint< ::tree::PrefixRankedBarTree < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::BarSymbols > { public: static bool used ( const ::tree::PrefixRankedBarTree < SymbolType, RankType > & tree, const common::ranked_symbol < SymbolType, RankType > & symbol ) { const ext::vector < common::ranked_symbol < SymbolType, RankType > > & content = tree.getContent ( ); diff --git a/alib2data/src/tree/ranked/PrefixRankedNonlinearPattern.h b/alib2data/src/tree/ranked/PrefixRankedNonlinearPattern.h index 7fb89eb4a0e9148efea0cfacf4ee19192d61b899..cfe54782637e8ff992f65ffb5ca97186581f3416 100644 --- a/alib2data/src/tree/ranked/PrefixRankedNonlinearPattern.h +++ b/alib2data/src/tree/ranked/PrefixRankedNonlinearPattern.h @@ -43,7 +43,7 @@ class NonlinearAlphabet; * as a tree of LinearStringElement. */ template < class SymbolType, class RankType > -class PrefixRankedNonlinearPattern final : public RankedTreeBase, public alib::Components < PrefixRankedNonlinearPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet, NonlinearAlphabet >, ext::tuple < SubtreeWildcard > > { +class PrefixRankedNonlinearPattern final : public RankedTreeBase, public alib::Components < PrefixRankedNonlinearPattern < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, NonlinearAlphabet >, common::ranked_symbol < SymbolType, RankType >, component::Value, SubtreeWildcard > { ext::vector < common::ranked_symbol < SymbolType, RankType > > m_Data; static ext::vector < common::ranked_symbol < SymbolType, RankType > > toPrefixRanked ( const ext::tree < common::ranked_symbol < SymbolType, RankType > > & tree ); @@ -74,11 +74,11 @@ public: } const common::ranked_symbol < SymbolType, RankType > & getSubtreeWildcard ( ) const & { - return this->template accessElement < SubtreeWildcard > ( ).get ( ); + return this->template accessComponent < SubtreeWildcard > ( ).get ( ); } common::ranked_symbol < SymbolType, RankType > && getSubtreeWildcard ( ) && { - return std::move ( this->template accessElement < SubtreeWildcard > ( ).get ( ) ); + return std::move ( this->template accessComponent < SubtreeWildcard > ( ).get ( ) ); } const ext::set < common::ranked_symbol < SymbolType, RankType > > & getNonlinearVariables ( ) const & { @@ -143,7 +143,7 @@ public: namespace tree { template < class SymbolType, class RankType > -PrefixRankedNonlinearPattern < SymbolType, RankType >::PrefixRankedNonlinearPattern ( common::ranked_symbol < SymbolType, RankType > subtreeWildcard, ext::set < common::ranked_symbol < SymbolType, RankType > > nonlinearVariables, ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::vector < common::ranked_symbol < SymbolType, RankType > > data ) : alib::Components < PrefixRankedNonlinearPattern, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet, NonlinearAlphabet >, ext::tuple < SubtreeWildcard > > ( ext::make_tuple ( std::move ( alphabet ), std::move ( nonlinearVariables ) ), ext::make_tuple ( subtreeWildcard ) ) { +PrefixRankedNonlinearPattern < SymbolType, RankType >::PrefixRankedNonlinearPattern ( common::ranked_symbol < SymbolType, RankType > subtreeWildcard, ext::set < common::ranked_symbol < SymbolType, RankType > > nonlinearVariables, ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::vector < common::ranked_symbol < SymbolType, RankType > > data ) : alib::Components < PrefixRankedNonlinearPattern, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, NonlinearAlphabet >, common::ranked_symbol < SymbolType, RankType >, component::Value, SubtreeWildcard > ( std::move ( alphabet ), std::move ( nonlinearVariables ), std::move ( subtreeWildcard ) ) { setContent ( std::move ( data ) ); } @@ -300,12 +300,12 @@ alib::ObjectBase* PrefixRankedNonlinearPattern < SymbolType, RankType >::inc() & namespace alib { template < class SymbolType, class RankType > -class ComponentConstraint< ::tree::PrefixRankedNonlinearPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { +class SetConstraint< ::tree::PrefixRankedNonlinearPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { public: static bool used ( const ::tree::PrefixRankedNonlinearPattern < SymbolType, RankType > & pattern, const common::ranked_symbol < SymbolType, RankType > & symbol ) { const ext::vector < common::ranked_symbol < SymbolType, RankType > > & m_content = pattern.getContent ( ); - return std::find ( m_content.begin ( ), m_content.end ( ), symbol ) != m_content.end ( ) || pattern.template accessElement < ::tree::SubtreeWildcard > ( ).get ( ) == symbol; + return std::find ( m_content.begin ( ), m_content.end ( ), symbol ) != m_content.end ( ) || pattern.template accessComponent < ::tree::SubtreeWildcard > ( ).get ( ) == symbol; } static bool available ( const ::tree::PrefixRankedNonlinearPattern < SymbolType, RankType > &, const common::ranked_symbol < SymbolType, RankType > & ) { @@ -317,7 +317,7 @@ public: }; template < class SymbolType, class RankType > -class ComponentConstraint< ::tree::PrefixRankedNonlinearPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::NonlinearAlphabet > { +class SetConstraint< ::tree::PrefixRankedNonlinearPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::NonlinearAlphabet > { public: static bool used ( const ::tree::PrefixRankedNonlinearPattern < SymbolType, RankType > &, const common::ranked_symbol < SymbolType, RankType > & ) { return false; @@ -331,7 +331,7 @@ public: if ( ( unsigned ) symbol.getRank ( ) != 0 ) throw ::tree::TreeException ( "SubtreeWildcard symbol has nonzero arity" ); - if ( pattern.template accessElement < ::tree::SubtreeWildcard > ( ).get ( ) == symbol ) + if ( pattern.template accessComponent < ::tree::SubtreeWildcard > ( ).get ( ) == symbol ) throw ::tree::TreeException ( "Symbol " + ext::to_string ( symbol ) + "cannot be set as nonlinear variable since it is already subtree wildcard" ); } }; diff --git a/alib2data/src/tree/ranked/PrefixRankedPattern.h b/alib2data/src/tree/ranked/PrefixRankedPattern.h index b6299a1f608ea88810576573cbd4368b4c0f0be7..b498e8bd38893de5e2cf93ca8bacc974f610c918 100644 --- a/alib2data/src/tree/ranked/PrefixRankedPattern.h +++ b/alib2data/src/tree/ranked/PrefixRankedPattern.h @@ -42,7 +42,7 @@ class SubtreeWildcard; * as a tree of LinearStringElement. */ template < class SymbolType, class RankType > -class PrefixRankedPattern final : public RankedTreeBase, public alib::Components < PrefixRankedPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet >, ext::tuple < SubtreeWildcard > > { +class PrefixRankedPattern final : public RankedTreeBase, public alib::Components < PrefixRankedPattern < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet, common::ranked_symbol < SymbolType, RankType >, component::Value, SubtreeWildcard > { ext::vector < common::ranked_symbol < SymbolType, RankType > > m_Data; static ext::vector < common::ranked_symbol < SymbolType, RankType > > toPrefixRanked ( const ext::tree < common::ranked_symbol < SymbolType, RankType > > & tree ); @@ -69,11 +69,11 @@ public: } const common::ranked_symbol < SymbolType, RankType > & getSubtreeWildcard ( ) const & { - return this->template accessElement < SubtreeWildcard > ( ).get ( ); + return this->template accessComponent < SubtreeWildcard > ( ).get ( ); } common::ranked_symbol < SymbolType, RankType > && getSubtreeWildcard ( ) && { - return std::move ( this->template accessElement < SubtreeWildcard > ( ).get ( ) ); + return std::move ( this->template accessComponent < SubtreeWildcard > ( ).get ( ) ); } /** @@ -127,7 +127,7 @@ public: namespace tree { template < class SymbolType, class RankType > -PrefixRankedPattern < SymbolType, RankType >::PrefixRankedPattern ( common::ranked_symbol < SymbolType, RankType > subtreeWildcard, ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::vector < common::ranked_symbol < SymbolType, RankType > > data ) : alib::Components < PrefixRankedPattern, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet >, ext::tuple < SubtreeWildcard > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::make_tuple ( subtreeWildcard ) ) { +PrefixRankedPattern < SymbolType, RankType >::PrefixRankedPattern ( common::ranked_symbol < SymbolType, RankType > subtreeWildcard, ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::vector < common::ranked_symbol < SymbolType, RankType > > data ) : alib::Components < PrefixRankedPattern, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet, common::ranked_symbol < SymbolType, RankType >, component::Value, SubtreeWildcard > ( std::move ( alphabet ), std::move ( subtreeWildcard ) ) { setContent ( std::move ( data ) ); } @@ -266,12 +266,12 @@ alib::ObjectBase* PrefixRankedPattern < SymbolType, RankType >::inc() && { namespace alib { template < class SymbolType, class RankType > -class ComponentConstraint< ::tree::PrefixRankedPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { +class SetConstraint< ::tree::PrefixRankedPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { public: static bool used ( const ::tree::PrefixRankedPattern < SymbolType, RankType > & pattern, const common::ranked_symbol < SymbolType, RankType > & symbol ) { const ext::vector < common::ranked_symbol < SymbolType, RankType > > & content = pattern.getContent ( ); - return std::find ( content.begin ( ), content.end ( ), symbol ) != content.end ( ) || pattern.template accessElement < ::tree::SubtreeWildcard > ( ).get ( ) == symbol; + return std::find ( content.begin ( ), content.end ( ), symbol ) != content.end ( ) || pattern.template accessComponent < ::tree::SubtreeWildcard > ( ).get ( ) == symbol; } static bool available ( const ::tree::PrefixRankedPattern < SymbolType, RankType > &, const common::ranked_symbol < SymbolType, RankType > & ) { diff --git a/alib2data/src/tree/ranked/PrefixRankedTree.h b/alib2data/src/tree/ranked/PrefixRankedTree.h index 8f128b6c9b6d4e29f3510b2706487d9e63052d23..405bf3297344446a4b3a24f6abe60b396febffe9 100644 --- a/alib2data/src/tree/ranked/PrefixRankedTree.h +++ b/alib2data/src/tree/ranked/PrefixRankedTree.h @@ -39,7 +39,7 @@ class GeneralAlphabet; * as a tree of LinearStringElement. */ template < class SymbolType, class RankType > -class PrefixRankedTree final : public RankedTreeBase, public alib::Components < PrefixRankedTree < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet >, ext::tuple < > > { +class PrefixRankedTree final : public RankedTreeBase, public alib::Components < PrefixRankedTree < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet > { ext::vector < common::ranked_symbol < SymbolType, RankType > > m_Data; static ext::vector < common::ranked_symbol < SymbolType, RankType > > toPrefixRanked ( const ext::tree < common::ranked_symbol < SymbolType, RankType > > & tree ); @@ -114,7 +114,7 @@ public: namespace tree { template < class SymbolType, class RankType > -PrefixRankedTree < SymbolType, RankType >::PrefixRankedTree ( ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::vector < common::ranked_symbol < SymbolType, RankType > > data ) : alib::Components < PrefixRankedTree, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ) { +PrefixRankedTree < SymbolType, RankType >::PrefixRankedTree ( ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::vector < common::ranked_symbol < SymbolType, RankType > > data ) : alib::Components < PrefixRankedTree, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet > ( std::move ( alphabet ) ) { setContent ( std::move ( data ) ); } @@ -247,7 +247,7 @@ alib::ObjectBase* PrefixRankedTree < SymbolType, RankType >::inc() && { namespace alib { template < class SymbolType, class RankType > -class ComponentConstraint< ::tree::PrefixRankedTree < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { +class SetConstraint< ::tree::PrefixRankedTree < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { public: static bool used ( const ::tree::PrefixRankedTree < SymbolType, RankType > & tree, const common::ranked_symbol < SymbolType, RankType > & symbol ) { const ext::vector < common::ranked_symbol < SymbolType, RankType > > & content = tree.getContent ( ); diff --git a/alib2data/src/tree/ranked/RankedNonlinearPattern.h b/alib2data/src/tree/ranked/RankedNonlinearPattern.h index e1b0d5f0e75ab0bfb696647981c6604cc86e4e3b..76730b4b0fb92ba705fb2a19c594d4a56d4ecdf3 100644 --- a/alib2data/src/tree/ranked/RankedNonlinearPattern.h +++ b/alib2data/src/tree/ranked/RankedNonlinearPattern.h @@ -42,7 +42,7 @@ class NonlinearAlphabet; * as a pattern of RegExpElement. */ template < class SymbolType, class RankType > -class RankedNonlinearPattern final : public RankedTreeBase, public alib::Components < RankedNonlinearPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet, NonlinearAlphabet >, ext::tuple < SubtreeWildcard > > { +class RankedNonlinearPattern final : public RankedTreeBase, public alib::Components < RankedNonlinearPattern < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, NonlinearAlphabet >, common::ranked_symbol < SymbolType, RankType >, component::Value, SubtreeWildcard > { ext::tree < common::ranked_symbol < SymbolType, RankType > > m_content; void checkAlphabet ( const ext::tree < common::ranked_symbol < SymbolType, RankType > > & pattern ) const; @@ -78,11 +78,11 @@ public: } const common::ranked_symbol < SymbolType, RankType > & getSubtreeWildcard ( ) const & { - return this->template accessElement < SubtreeWildcard > ( ).get ( ); + return this->template accessComponent < SubtreeWildcard > ( ).get ( ); } common::ranked_symbol < SymbolType, RankType > && getSubtreeWildcard ( ) && { - return std::move ( this->template accessElement < SubtreeWildcard > ( ).get ( ) ); + return std::move ( this->template accessComponent < SubtreeWildcard > ( ).get ( ) ); } const ext::set < common::ranked_symbol < SymbolType, RankType > > & getNonlinearVariables ( ) const & { @@ -147,7 +147,7 @@ public: namespace tree { template < class SymbolType, class RankType > -RankedNonlinearPattern < SymbolType, RankType >::RankedNonlinearPattern ( common::ranked_symbol < SymbolType, RankType > subtreeWildcard, ext::set < common::ranked_symbol < SymbolType, RankType > > nonlinearVariables, ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::tree < common::ranked_symbol < SymbolType, RankType > > pattern ) : alib::Components < RankedNonlinearPattern, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet, NonlinearAlphabet >, ext::tuple < SubtreeWildcard > > ( ext::make_tuple ( std::move ( alphabet ), std::move ( nonlinearVariables ) ), ext::make_tuple ( std::move ( subtreeWildcard ) ) ), m_content ( std::move ( pattern ) ) { +RankedNonlinearPattern < SymbolType, RankType >::RankedNonlinearPattern ( common::ranked_symbol < SymbolType, RankType > subtreeWildcard, ext::set < common::ranked_symbol < SymbolType, RankType > > nonlinearVariables, ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::tree < common::ranked_symbol < SymbolType, RankType > > pattern ) : alib::Components < RankedNonlinearPattern, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, NonlinearAlphabet >, common::ranked_symbol < SymbolType, RankType >, component::Value, SubtreeWildcard > ( std::move ( alphabet ), std::move ( nonlinearVariables ), std::move ( subtreeWildcard ) ), m_content ( std::move ( pattern ) ) { checkAlphabet ( m_content ); checkArities ( m_content ); } @@ -271,11 +271,11 @@ alib::ObjectBase* RankedNonlinearPattern < SymbolType, RankType >::inc() && { namespace alib { template < class SymbolType, class RankType > -class ComponentConstraint< ::tree::RankedNonlinearPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { +class SetConstraint< ::tree::RankedNonlinearPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { public: static bool used ( const ::tree::RankedNonlinearPattern < SymbolType, RankType > & pattern, const common::ranked_symbol < SymbolType, RankType > & symbol ) { const ext::tree < common::ranked_symbol < SymbolType, RankType > > & m_content = pattern.getContent ( ); - return std::find(m_content.prefix_begin(), m_content.prefix_end(), symbol) != m_content.prefix_end() || pattern.template accessElement < ::tree::SubtreeWildcard > ( ).get ( ) == symbol || pattern.template accessComponent < ::tree::NonlinearAlphabet > ( ).get ( ).count ( symbol ); + return std::find(m_content.prefix_begin(), m_content.prefix_end(), symbol) != m_content.prefix_end() || pattern.template accessComponent < ::tree::SubtreeWildcard > ( ).get ( ) == symbol || pattern.template accessComponent < ::tree::NonlinearAlphabet > ( ).get ( ).count ( symbol ); } static bool available ( const ::tree::RankedNonlinearPattern < SymbolType, RankType > &, const common::ranked_symbol < SymbolType, RankType > & ) { @@ -287,7 +287,7 @@ public: }; template < class SymbolType, class RankType > -class ComponentConstraint< ::tree::RankedNonlinearPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::NonlinearAlphabet > { +class SetConstraint< ::tree::RankedNonlinearPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::NonlinearAlphabet > { public: static bool used ( const ::tree::RankedNonlinearPattern < SymbolType, RankType > &, const common::ranked_symbol < SymbolType, RankType > & ) { return false; @@ -301,7 +301,7 @@ public: if( ( unsigned ) symbol.getRank() != 0 ) throw ::tree::TreeException ( "SubtreeWildcard symbol has nonzero arity" ); - if ( pattern.template accessElement < ::tree::SubtreeWildcard > ( ).get ( ) == symbol ) + if ( pattern.template accessComponent < ::tree::SubtreeWildcard > ( ).get ( ) == symbol ) throw ::tree::TreeException ( "Symbol " + ext::to_string ( symbol ) + "cannot be set as nonlinear variable since it is already subtree wildcard" ); } }; diff --git a/alib2data/src/tree/ranked/RankedPattern.h b/alib2data/src/tree/ranked/RankedPattern.h index 977a10b056440459bfd1cff4ca97640785431994..05a41330325b0075068c126a43c76caca47fc5c6 100644 --- a/alib2data/src/tree/ranked/RankedPattern.h +++ b/alib2data/src/tree/ranked/RankedPattern.h @@ -41,7 +41,7 @@ class SubtreeWildcard; * as a pattern of RegExpElement. */ template < class SymbolType, class RankType > -class RankedPattern final : public RankedTreeBase, public alib::Components < RankedPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet >, ext::tuple < SubtreeWildcard > > { +class RankedPattern final : public RankedTreeBase, public alib::Components < RankedPattern < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet, common::ranked_symbol < SymbolType, RankType >, component::Value, SubtreeWildcard > { ext::tree < common::ranked_symbol < SymbolType, RankType > > m_content; void checkAlphabet ( const ext::tree < common::ranked_symbol < SymbolType, RankType > > & pattern ) const; @@ -76,11 +76,11 @@ public: } const common::ranked_symbol < SymbolType, RankType > & getSubtreeWildcard ( ) const & { - return this->template accessElement < SubtreeWildcard > ( ).get ( ); + return this->template accessComponent < SubtreeWildcard > ( ).get ( ); } common::ranked_symbol < SymbolType, RankType > && getSubtreeWildcard ( ) && { - return std::move ( this->template accessElement < SubtreeWildcard > ( ).get ( ) ); + return std::move ( this->template accessComponent < SubtreeWildcard > ( ).get ( ) ); } /** @@ -137,7 +137,7 @@ public: namespace tree { template < class SymbolType, class RankType > -RankedPattern < SymbolType, RankType >::RankedPattern ( common::ranked_symbol < SymbolType, RankType > subtreeWildcard, ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::tree < common::ranked_symbol < SymbolType, RankType > > pattern ) : alib::Components < RankedPattern, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet >, ext::tuple < SubtreeWildcard > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::make_tuple ( std::move ( subtreeWildcard ) ) ), m_content ( std::move ( pattern ) ) { +RankedPattern < SymbolType, RankType >::RankedPattern ( common::ranked_symbol < SymbolType, RankType > subtreeWildcard, ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::tree < common::ranked_symbol < SymbolType, RankType > > pattern ) : alib::Components < RankedPattern, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet, common::ranked_symbol < SymbolType, RankType >, component::Value, SubtreeWildcard > ( std::move ( alphabet ), std::move ( subtreeWildcard ) ), m_content ( std::move ( pattern ) ) { checkAlphabet ( m_content ); checkArities ( m_content ); } @@ -255,11 +255,11 @@ alib::ObjectBase* RankedPattern < SymbolType, RankType >::inc() && { namespace alib { template < class SymbolType, class RankType > -class ComponentConstraint< ::tree::RankedPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { +class SetConstraint< ::tree::RankedPattern < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { public: static bool used ( const ::tree::RankedPattern < SymbolType, RankType > & pattern, const common::ranked_symbol < SymbolType, RankType > & symbol ) { const ext::tree < common::ranked_symbol < SymbolType, RankType > > & m_content = pattern.getContent ( ); - return std::find(m_content.prefix_begin(), m_content.prefix_end(), symbol) != m_content.prefix_end() || pattern.template accessElement < ::tree::SubtreeWildcard > ( ).get ( ) == symbol; + return std::find(m_content.prefix_begin(), m_content.prefix_end(), symbol) != m_content.prefix_end() || pattern.template accessComponent < ::tree::SubtreeWildcard > ( ).get ( ) == symbol; } static bool available ( const ::tree::RankedPattern < SymbolType, RankType > &, const common::ranked_symbol < SymbolType, RankType > & ) { diff --git a/alib2data/src/tree/ranked/RankedTree.h b/alib2data/src/tree/ranked/RankedTree.h index 4eb1677ac526f64f86383ba1cf1ca356a453152a..d51ab74874d355a38d91afc1a6ba9b1487d5fc76 100644 --- a/alib2data/src/tree/ranked/RankedTree.h +++ b/alib2data/src/tree/ranked/RankedTree.h @@ -41,7 +41,7 @@ class GeneralAlphabet; * as a tree of RegExpElement. */ template < class SymbolType, class RankType > -class RankedTree final : public RankedTreeBase, public alib::Components < RankedTree < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet >, ext::tuple < > > { +class RankedTree final : public RankedTreeBase, public alib::Components < RankedTree < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet > { ext::tree < common::ranked_symbol < SymbolType, RankType > > m_content; void checkAlphabet ( const ext::tree < common::ranked_symbol < SymbolType, RankType > > & pattern ) const; @@ -131,7 +131,7 @@ public: namespace tree { template < class SymbolType, class RankType > -RankedTree < SymbolType, RankType >::RankedTree ( ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::tree < common::ranked_symbol < SymbolType, RankType > > tree ) : alib::Components < RankedTree, common::ranked_symbol < SymbolType, RankType >, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ), m_content ( std::move ( tree ) ) { +RankedTree < SymbolType, RankType >::RankedTree ( ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::tree < common::ranked_symbol < SymbolType, RankType > > tree ) : alib::Components < RankedTree, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet > ( std::move ( alphabet ) ), m_content ( std::move ( tree ) ) { checkAlphabet ( m_content ); checkArities ( m_content ); } @@ -251,7 +251,7 @@ alib::ObjectBase* RankedTree < SymbolType, RankType >::inc() && { namespace alib { template < class SymbolType, class RankType > -class ComponentConstraint< ::tree::RankedTree < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { +class SetConstraint< ::tree::RankedTree < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, ::tree::GeneralAlphabet > { public: static bool used ( const ::tree::RankedTree < SymbolType, RankType > & tree, const common::ranked_symbol < SymbolType, RankType > & symbol ) { const ext::tree < common::ranked_symbol < SymbolType, RankType > > & m_content = tree.getContent ( ); diff --git a/alib2data/src/tree/unranked/PrefixBarTree.h b/alib2data/src/tree/unranked/PrefixBarTree.h index a88b670c9fa5a78f73a0df5d083baff074720f95..8fabd6ff291b00e47c102907cf1ee4ffa95edf3f 100644 --- a/alib2data/src/tree/unranked/PrefixBarTree.h +++ b/alib2data/src/tree/unranked/PrefixBarTree.h @@ -39,7 +39,7 @@ class BarSymbol; * Represents a tree in prefix bar notation. */ template < class SymbolType > -class PrefixBarTree final : public UnrankedTreeBase, public alib::Components < PrefixBarTree < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < BarSymbol > > { +class PrefixBarTree final : public UnrankedTreeBase, public alib::Components < PrefixBarTree < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet, SymbolType, component::Value, BarSymbol > { ext::vector < SymbolType > m_Data; static ext::vector < SymbolType > toPrefixBar ( const ext::tree < SymbolType > & tree, const SymbolType & bar ); @@ -66,11 +66,11 @@ public: } const SymbolType & getBar ( ) const & { - return this->template accessElement < BarSymbol > ( ).get ( ); + return this->template accessComponent < BarSymbol > ( ).get ( ); } SymbolType && getBar ( ) && { - return std::move ( this->template accessElement < BarSymbol > ( ).get ( ) ); + return std::move ( this->template accessComponent < BarSymbol > ( ).get ( ) ); } /** @@ -123,7 +123,7 @@ public: namespace tree { template < class SymbolType > -PrefixBarTree < SymbolType >::PrefixBarTree ( SymbolType bar, ext::set < SymbolType > alphabet, ext::vector < SymbolType > data ) : alib::Components < PrefixBarTree, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < BarSymbol > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::make_tuple ( std::move ( bar ) ) ) { +PrefixBarTree < SymbolType >::PrefixBarTree ( SymbolType bar, ext::set < SymbolType > alphabet, ext::vector < SymbolType > data ) : alib::Components < PrefixBarTree, ext::set < SymbolType >, component::Set, GeneralAlphabet, SymbolType, component::Value, BarSymbol > ( std::move ( alphabet ), std::move ( bar ) ) { setContent ( std::move ( data ) ); } @@ -267,7 +267,7 @@ alib::ObjectBase* PrefixBarTree < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint< ::tree::PrefixBarTree < SymbolType >, SymbolType, ::tree::GeneralAlphabet > { +class SetConstraint< ::tree::PrefixBarTree < SymbolType >, SymbolType, ::tree::GeneralAlphabet > { public: static bool used ( const ::tree::PrefixBarTree < SymbolType > & tree, const SymbolType & symbol ) { const ext::vector < SymbolType > & content = tree.getContent ( ); diff --git a/alib2data/src/tree/unranked/UnrankedNonlinearPattern.h b/alib2data/src/tree/unranked/UnrankedNonlinearPattern.h index af16c4bc603ac22564dc9585152623ab0351a93f..fda1bdc99bb134c44dcb8da33143689a7810d007 100644 --- a/alib2data/src/tree/unranked/UnrankedNonlinearPattern.h +++ b/alib2data/src/tree/unranked/UnrankedNonlinearPattern.h @@ -40,7 +40,7 @@ class NonlinearAlphabet; * as a pattern of RegExpElement. */ template < class SymbolType > -class UnrankedNonlinearPattern final : public UnrankedTreeBase, public alib::Components < UnrankedNonlinearPattern < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet, NonlinearAlphabet >, ext::tuple < SubtreeWildcard > > { +class UnrankedNonlinearPattern final : public UnrankedTreeBase, public alib::Components < UnrankedNonlinearPattern < SymbolType >, ext::set < SymbolType >, component::Set, std::tuple < GeneralAlphabet, NonlinearAlphabet >, SymbolType, component::Value, SubtreeWildcard > { ext::tree < SymbolType > m_content; void checkAlphabet ( const ext::tree < SymbolType > & pattern ) const; @@ -75,11 +75,11 @@ public: } const SymbolType & getSubtreeWildcard ( ) const & { - return this->template accessElement < SubtreeWildcard > ( ).get ( ); + return this->template accessComponent < SubtreeWildcard > ( ).get ( ); } SymbolType && getSubtreeWildcard ( ) && { - return std::move ( this->template accessElement < SubtreeWildcard > ( ).get ( ) ); + return std::move ( this->template accessComponent < SubtreeWildcard > ( ).get ( ) ); } const ext::set < SymbolType > & getNonlinearVariables ( ) const & { @@ -150,7 +150,7 @@ public: namespace tree { template < class SymbolType > -UnrankedNonlinearPattern < SymbolType >::UnrankedNonlinearPattern ( SymbolType subtreeWildcard, ext::set < SymbolType > nonlinearVariables, ext::set < SymbolType > alphabet, ext::tree < SymbolType > pattern ) : alib::Components < UnrankedNonlinearPattern, SymbolType, ext::tuple < GeneralAlphabet, NonlinearAlphabet >, ext::tuple < SubtreeWildcard > > ( ext::make_tuple ( std::move ( alphabet ), std::move ( nonlinearVariables ) ), ext::make_tuple ( std::move ( subtreeWildcard ) ) ), m_content ( std::move ( pattern ) ) { +UnrankedNonlinearPattern < SymbolType >::UnrankedNonlinearPattern ( SymbolType subtreeWildcard, ext::set < SymbolType > nonlinearVariables, ext::set < SymbolType > alphabet, ext::tree < SymbolType > pattern ) : alib::Components < UnrankedNonlinearPattern, ext::set < SymbolType >, component::Set, std::tuple < GeneralAlphabet, NonlinearAlphabet >, SymbolType, component::Value, SubtreeWildcard > ( std::move ( alphabet ), std::move ( nonlinearVariables ), std::move ( subtreeWildcard ) ), m_content ( std::move ( pattern ) ) { checkAlphabet ( m_content ); } @@ -264,11 +264,11 @@ alib::ObjectBase* UnrankedNonlinearPattern < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint< ::tree::UnrankedNonlinearPattern < SymbolType >, SymbolType, ::tree::GeneralAlphabet > { +class SetConstraint< ::tree::UnrankedNonlinearPattern < SymbolType >, SymbolType, ::tree::GeneralAlphabet > { public: static bool used ( const ::tree::UnrankedNonlinearPattern < SymbolType > & pattern, const SymbolType & symbol ) { const ext::tree<SymbolType>& m_content = pattern.getContent ( ); - return std::find(m_content.prefix_begin(), m_content.prefix_end(), symbol) != m_content.prefix_end() || pattern.template accessElement < ::tree::SubtreeWildcard > ( ).get ( ) == symbol || pattern.template accessComponent < ::tree::NonlinearAlphabet > ( ).get ( ).count ( symbol ); + return std::find(m_content.prefix_begin(), m_content.prefix_end(), symbol) != m_content.prefix_end() || pattern.template accessComponent < ::tree::SubtreeWildcard > ( ).get ( ) == symbol || pattern.template accessComponent < ::tree::NonlinearAlphabet > ( ).get ( ).count ( symbol ); } static bool available ( const ::tree::UnrankedNonlinearPattern < SymbolType > &, const SymbolType & ) { @@ -280,7 +280,7 @@ public: }; template < class SymbolType > -class ComponentConstraint< ::tree::UnrankedNonlinearPattern < SymbolType >, SymbolType, ::tree::NonlinearAlphabet > { +class SetConstraint< ::tree::UnrankedNonlinearPattern < SymbolType >, SymbolType, ::tree::NonlinearAlphabet > { public: static bool used ( const ::tree::UnrankedNonlinearPattern < SymbolType > &, const SymbolType & ) { return false; @@ -291,7 +291,7 @@ public: } static void valid ( const ::tree::UnrankedNonlinearPattern < SymbolType > & pattern, const SymbolType & symbol) { - if ( pattern.template accessElement < ::tree::SubtreeWildcard > ( ).get ( ) == symbol ) + if ( pattern.template accessComponent < ::tree::SubtreeWildcard > ( ).get ( ) == symbol ) throw ::tree::TreeException ( "Symbol " + ext::to_string ( symbol ) + "cannot be set as nonlinear variable since it is already subtree wildcard" ); } }; diff --git a/alib2data/src/tree/unranked/UnrankedPattern.h b/alib2data/src/tree/unranked/UnrankedPattern.h index 2a382a85e7387bf571a239dda486d146f9942d5f..0b09a1ca63aedf64d289d5c036aee972ec327fca 100644 --- a/alib2data/src/tree/unranked/UnrankedPattern.h +++ b/alib2data/src/tree/unranked/UnrankedPattern.h @@ -39,7 +39,7 @@ class SubtreeWildcard; * as a pattern of RegExpElement. */ template < class SymbolType > -class UnrankedPattern final : public UnrankedTreeBase, public alib::Components < UnrankedPattern < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < SubtreeWildcard > > { +class UnrankedPattern final : public UnrankedTreeBase, public alib::Components < UnrankedPattern < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet, SymbolType, component::Value, SubtreeWildcard > { ext::tree < SymbolType > m_content; void checkAlphabet ( const ext::tree < SymbolType > & pattern ) const; @@ -73,11 +73,11 @@ public: } const SymbolType & getSubtreeWildcard ( ) const & { - return this->template accessElement < SubtreeWildcard > ( ).get ( ); + return this->template accessComponent < SubtreeWildcard > ( ).get ( ); } SymbolType && getSubtreeWildcard ( ) && { - return std::move ( this->template accessElement < SubtreeWildcard > ( ).get ( ) ); + return std::move ( this->template accessComponent < SubtreeWildcard > ( ).get ( ) ); } /** @@ -134,7 +134,7 @@ public: namespace tree { template < class SymbolType > -UnrankedPattern < SymbolType >::UnrankedPattern ( SymbolType subtreeWildcard, ext::set < SymbolType > alphabet, ext::tree < SymbolType > pattern ) : alib::Components < UnrankedPattern, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < SubtreeWildcard > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::make_tuple ( std::move ( subtreeWildcard ) ) ), m_content ( std::move ( pattern ) ) { +UnrankedPattern < SymbolType >::UnrankedPattern ( SymbolType subtreeWildcard, ext::set < SymbolType > alphabet, ext::tree < SymbolType > pattern ) : alib::Components < UnrankedPattern, ext::set < SymbolType >, component::Set, GeneralAlphabet, SymbolType, component::Value, SubtreeWildcard > ( std::move ( alphabet ), std::move ( subtreeWildcard ) ), m_content ( std::move ( pattern ) ) { checkAlphabet ( m_content ); } @@ -242,11 +242,11 @@ alib::ObjectBase* UnrankedPattern < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint< ::tree::UnrankedPattern < SymbolType >, SymbolType, ::tree::GeneralAlphabet > { +class SetConstraint< ::tree::UnrankedPattern < SymbolType >, SymbolType, ::tree::GeneralAlphabet > { public: static bool used ( const ::tree::UnrankedPattern < SymbolType > & pattern, const SymbolType & symbol ) { const ext::tree<SymbolType>& m_content = pattern.getContent ( ); - return std::find(m_content.prefix_begin(), m_content.prefix_end(), symbol) != m_content.prefix_end() || pattern.template accessElement < ::tree::SubtreeWildcard > ( ).get ( ) == symbol; + return std::find(m_content.prefix_begin(), m_content.prefix_end(), symbol) != m_content.prefix_end() || pattern.template accessComponent < ::tree::SubtreeWildcard > ( ).get ( ) == symbol; } static bool available ( const ::tree::UnrankedPattern < SymbolType > &, const SymbolType & ) { diff --git a/alib2data/src/tree/unranked/UnrankedTree.h b/alib2data/src/tree/unranked/UnrankedTree.h index 73729fd0c5b30456129644907389e1ef84b9a23d..c24fb26620461af1c3d4da1efe96903b71efd9a8 100644 --- a/alib2data/src/tree/unranked/UnrankedTree.h +++ b/alib2data/src/tree/unranked/UnrankedTree.h @@ -38,7 +38,7 @@ class GeneralAlphabet; * as a tree of RegExpElement. */ template < class SymbolType > -class UnrankedTree final : public UnrankedTreeBase, public alib::Components < UnrankedTree < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > { +class UnrankedTree final : public UnrankedTreeBase, public alib::Components < UnrankedTree < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet > { ext::tree < SymbolType > m_content; void checkAlphabet ( const ext::tree < SymbolType > & pattern ) const; @@ -125,7 +125,7 @@ public: namespace tree { template < class SymbolType > -UnrankedTree < SymbolType >::UnrankedTree ( ext::set < SymbolType > alphabet, ext::tree < SymbolType > tree ) : alib::Components < UnrankedTree, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ), m_content ( std::move ( tree ) ) { +UnrankedTree < SymbolType >::UnrankedTree ( ext::set < SymbolType > alphabet, ext::tree < SymbolType > tree ) : alib::Components < UnrankedTree, ext::set < SymbolType >, component::Set, GeneralAlphabet > ( std::move ( alphabet ) ), m_content ( std::move ( tree ) ) { checkAlphabet ( m_content ); } @@ -231,7 +231,7 @@ alib::ObjectBase* UnrankedTree < SymbolType >::inc() && { namespace alib { template < class SymbolType > -class ComponentConstraint< ::tree::UnrankedTree < SymbolType >, SymbolType, ::tree::GeneralAlphabet > { +class SetConstraint< ::tree::UnrankedTree < SymbolType >, SymbolType, ::tree::GeneralAlphabet > { public: static bool used ( const ::tree::UnrankedTree < SymbolType > & tree, const SymbolType & symbol ) { const ext::tree<SymbolType>& m_content = tree.getContent ( ); diff --git a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.cpp b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.cpp index 1d448adcac7c489830ed5b2a7a5af982d25fbd2a..da244d7a0637ca4f76f9d8f7c957afe453240c09 100644 --- a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.cpp +++ b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.cpp @@ -9,6 +9,7 @@ #include "SuffixTrieTerminatingSymbol.h" #include <exception/CommonException.h> #include <sstream> +#include <tuple> namespace indexes { diff --git a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.cpp b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.cpp index 7cdba83be8c0b6e88480ef4112023aca23f7f84a..7c89ebe73ff41e82a14a961a56f5184d96805874 100644 --- a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.cpp +++ b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.cpp @@ -26,18 +26,18 @@ namespace indexes { SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( ext::set < DefaultSymbolType > alphabet, DefaultSymbolType terminatingSymbol ) : SuffixTrieTerminatingSymbol ( std::move ( alphabet ), std::move ( terminatingSymbol ), SuffixTrieNodeTerminatingSymbol ( { } ) ) { } -SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( ext::set < DefaultSymbolType > alphabet, DefaultSymbolType terminatingSymbol, SuffixTrieNodeTerminatingSymbol tree ) : alib::Components < SuffixTrieTerminatingSymbol, DefaultSymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < TerminatingSymbol > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::make_tuple ( std::move ( terminatingSymbol ) ) ), m_tree ( NULL ) { +SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( ext::set < DefaultSymbolType > alphabet, DefaultSymbolType terminatingSymbol, SuffixTrieNodeTerminatingSymbol tree ) : alib::Components < SuffixTrieTerminatingSymbol, ext::set < DefaultSymbolType >, component::Set, GeneralAlphabet, DefaultSymbolType, component::Value, TerminatingSymbol > ( std::move ( alphabet ), std::move ( terminatingSymbol ) ), m_tree ( NULL ) { setTree ( std::move ( tree ) ); } SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( DefaultSymbolType terminatingSymbol, SuffixTrieNodeTerminatingSymbol tree ) : SuffixTrieTerminatingSymbol ( tree.computeMinimalAlphabet ( ) + ext::set < DefaultSymbolType > { terminatingSymbol }, terminatingSymbol, tree ) { } -SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( const SuffixTrieTerminatingSymbol & other ) : alib::Components < SuffixTrieTerminatingSymbol, DefaultSymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < TerminatingSymbol > > ( ext::make_tuple ( other.getAlphabet ( ) ), ext::make_tuple ( other.getTerminatingSymbol ( ) ) ), m_tree ( other.m_tree->clone ( ) ) { +SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( const SuffixTrieTerminatingSymbol & other ) : alib::Components < SuffixTrieTerminatingSymbol, ext::set < DefaultSymbolType >, component::Set, GeneralAlphabet, DefaultSymbolType, component::Value, TerminatingSymbol > ( other.getAlphabet ( ), other.getTerminatingSymbol ( ) ), m_tree ( other.m_tree->clone ( ) ) { this->m_tree->attachTree ( this ); } -SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( SuffixTrieTerminatingSymbol && other ) noexcept : alib::Components < SuffixTrieTerminatingSymbol, DefaultSymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < TerminatingSymbol > > ( ext::make_tuple ( std::move ( other.accessComponent < GeneralAlphabet > ( ).get ( ) ) ), ext::make_tuple ( std::move ( other.accessElement < TerminatingSymbol > ( ).get ( ) ) ) ), m_tree ( other.m_tree ) { +SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( SuffixTrieTerminatingSymbol && other ) noexcept : alib::Components < SuffixTrieTerminatingSymbol, ext::set < DefaultSymbolType >, component::Set, GeneralAlphabet, DefaultSymbolType, component::Value, TerminatingSymbol > ( std::move ( other.accessComponent < GeneralAlphabet > ( ).get ( ) ), std::move ( other.accessComponent < TerminatingSymbol > ( ).get ( ) ) ), m_tree ( other.m_tree ) { this->m_tree->attachTree ( this ); other.m_tree = NULL; } @@ -62,7 +62,7 @@ SuffixTrieTerminatingSymbol & SuffixTrieTerminatingSymbol::operator =( const Suf SuffixTrieTerminatingSymbol & SuffixTrieTerminatingSymbol::operator =( SuffixTrieTerminatingSymbol && other ) noexcept { std::swap ( this->m_tree, other.m_tree ); std::swap ( accessComponent < GeneralAlphabet > ( ).get ( ), other.accessComponent < GeneralAlphabet > ( ).get ( ) ); - std::swap ( accessElement < TerminatingSymbol > ( ).get ( ), other.accessElement < TerminatingSymbol > ( ).get ( ) ); + std::swap ( accessComponent < TerminatingSymbol > ( ).get ( ), other.accessComponent < TerminatingSymbol > ( ).get ( ) ); return * this; } diff --git a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.h b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.h index 78ea11eed75c1a3684313baac984d1ec3b7df21a..566d2410bb4c2b4c56b6aea9043f4b8362239103 100644 --- a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.h +++ b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.h @@ -25,7 +25,7 @@ class TerminatingSymbol; * Represents regular expression parsed from the XML. Regular expression is stored * as a tree of RegExpElement. */ -class SuffixTrieTerminatingSymbol final : public alib::ObjectBase, public alib::Components < SuffixTrieTerminatingSymbol, DefaultSymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < TerminatingSymbol > > { +class SuffixTrieTerminatingSymbol final : public alib::ObjectBase, public alib::Components < SuffixTrieTerminatingSymbol, ext::set < DefaultSymbolType >, component::Set, GeneralAlphabet, DefaultSymbolType, component::Value, TerminatingSymbol > { protected: SuffixTrieNodeTerminatingSymbol * m_tree; @@ -75,7 +75,7 @@ public: } const DefaultSymbolType & getTerminatingSymbol ( ) const { - return accessElement < TerminatingSymbol > ( ).get ( ); + return accessComponent < TerminatingSymbol > ( ).get ( ); } /** @@ -107,7 +107,7 @@ public: namespace alib { template < > -class ComponentConstraint< indexes::SuffixTrieTerminatingSymbol, DefaultSymbolType, indexes::GeneralAlphabet > { +class SetConstraint< indexes::SuffixTrieTerminatingSymbol, DefaultSymbolType, indexes::GeneralAlphabet > { public: static bool used ( const indexes::SuffixTrieTerminatingSymbol & index, const DefaultSymbolType & symbol ) { return index.getTerminatingSymbol ( ) == symbol || index.getRoot ( ).testSymbol ( symbol ); diff --git a/alib2data_experimental/src/string/LinearStringTerminatingSymbol.cpp b/alib2data_experimental/src/string/LinearStringTerminatingSymbol.cpp index 88c94c62bbbe8dc6af16632bf5ece8792f1bfa72..c91319dea2adb75565f0e24cbabeaa78f0c5af85 100644 --- a/alib2data_experimental/src/string/LinearStringTerminatingSymbol.cpp +++ b/alib2data_experimental/src/string/LinearStringTerminatingSymbol.cpp @@ -25,7 +25,7 @@ namespace string { -LinearStringTerminatingSymbol::LinearStringTerminatingSymbol ( ext::set < DefaultSymbolType > alphabet, DefaultSymbolType terminatingSymbol, ext::vector < DefaultSymbolType > data ) : alib::Components < LinearStringTerminatingSymbol, DefaultSymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < TerminatingSymbol > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::make_tuple ( std::move ( terminatingSymbol ) ) ) { +LinearStringTerminatingSymbol::LinearStringTerminatingSymbol ( ext::set < DefaultSymbolType > alphabet, DefaultSymbolType terminatingSymbol, ext::vector < DefaultSymbolType > data ) : alib::Components < LinearStringTerminatingSymbol, ext::set < DefaultSymbolType >, component::Set, GeneralAlphabet, DefaultSymbolType, component::Value, TerminatingSymbol > ( std::move ( alphabet ), std::move ( terminatingSymbol ) ) { setContent ( std::move ( data ) ); } diff --git a/alib2data_experimental/src/string/LinearStringTerminatingSymbol.h b/alib2data_experimental/src/string/LinearStringTerminatingSymbol.h index 853c6254b217d0538b73ac6c8fb147002636f83b..353fc281e079b4ac2adfb8581af14903e4716343 100644 --- a/alib2data_experimental/src/string/LinearStringTerminatingSymbol.h +++ b/alib2data_experimental/src/string/LinearStringTerminatingSymbol.h @@ -27,7 +27,7 @@ class TerminatingSymbol; * Represents regular expression parsed from the XML. Regular expression is stored * as a tree of LinearStringElement. */ -class LinearStringTerminatingSymbol final : public StringBase, public alib::Components < LinearStringTerminatingSymbol, DefaultSymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < TerminatingSymbol > > { +class LinearStringTerminatingSymbol final : public StringBase, public alib::Components < LinearStringTerminatingSymbol, ext::set < DefaultSymbolType >, component::Set, GeneralAlphabet, DefaultSymbolType, component::Value, TerminatingSymbol > { ext::vector < DefaultSymbolType > m_Data; public: @@ -48,7 +48,7 @@ public: } const DefaultSymbolType & getTerminatingSymbol ( ) const { - return accessElement < TerminatingSymbol > ( ).get ( ); + return accessComponent < TerminatingSymbol > ( ).get ( ); } /** @@ -100,7 +100,7 @@ public: namespace alib { template < > -class ComponentConstraint< ::string::LinearStringTerminatingSymbol, DefaultSymbolType, ::string::GeneralAlphabet > { +class SetConstraint< ::string::LinearStringTerminatingSymbol, DefaultSymbolType, ::string::GeneralAlphabet > { public: static bool used ( const ::string::LinearStringTerminatingSymbol & str, const DefaultSymbolType & symbol ) { const ext::vector<DefaultSymbolType>& content = str.getContent ( );