diff --git a/alib2data/src/label/FailStateLabel.h b/alib2data/src/label/FailStateLabel.h index 2cef0752ba49f11e5611153ad14aeea740a6451d..9d263adea2f73efc7c9c6d67d4e442e3520458e0 100644 --- a/alib2data/src/label/FailStateLabel.h +++ b/alib2data/src/label/FailStateLabel.h @@ -1,6 +1,22 @@ /* * FailStateLabel.h * + * This file is part of Algorithms library toolkit. + * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz) + + * Algorithms library toolkit is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * Algorithms library toolkit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>. + * * Created on: Mar 26, 2013 * Author: Jan Travnicek */ @@ -15,37 +31,70 @@ namespace label { /** - * Represents symbol in an alphabet. + * \brief + * Represents label of the fail state of an automaton. */ class FailStateLabel final : public LabelBase { public: /** - * Creates new symbol with given name. - * @param symbol name of the symbol + * \brief + * Creates a new instance of the label. */ explicit FailStateLabel ( ); + /** + * @copydoc label::LabelBase::clone ( ) const & + */ virtual LabelBase * clone ( ) const &; + /** + * @copydoc label::LabelBase::clone ( ) && + */ virtual LabelBase * clone ( ) &&; + /** + * @copydoc base::CommonBase < ObjectBase >::compare ( const ObjectBase & ) const + */ virtual int compare ( const ObjectBase & other ) const { if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) ); } + /** + * The actual compare method + * + * \param other the other instance + * + * \returns the actual relation between two by type same labels + */ virtual int compare ( const FailStateLabel & other ) const; + /** + * @copydoc base::CommonBase < ObjectBase >::operator >> ( std::ostream & ) const + */ virtual void operator >>( std::ostream & ) const; + /** + * @copydoc base::CommonBase < ObjectBase >::operator std::string ( ) const + */ virtual explicit operator std::string ( ) const; + /** + * \brief Factory for the label construction of the label based on given type. + */ template < typename Base > static inline typename std::enable_if < std::is_integral < Base >::value, Base >::type instance ( ); + + /** + * \brief Factory for the label construction of the label based on given type. + */ template < typename Base > static inline typename std::enable_if < ! std::is_integral < Base >::value, Base >::type instance ( ); + /** + * @copydoc object::ObjectBase::inc ( ) && + */ virtual LabelBase * inc ( ) &&; }; diff --git a/alib2data/src/label/FinalStateLabel.h b/alib2data/src/label/FinalStateLabel.h index 73cdc0185282843d758d7dbaaf9c077dd0ff8109..ebe594ceab0d61b23fc1bb2e99ec67c763616d98 100644 --- a/alib2data/src/label/FinalStateLabel.h +++ b/alib2data/src/label/FinalStateLabel.h @@ -1,6 +1,22 @@ /* * FinalStateLabel.h * + * This file is part of Algorithms library toolkit. + * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz) + + * Algorithms library toolkit is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * Algorithms library toolkit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>. + * * Created on: Mar 26, 2013 * Author: Jan Travnicek */ @@ -15,37 +31,70 @@ namespace label { /** - * Represents symbol in an alphabet. + * \brief + * Represents label of the final state of an automaton. */ class FinalStateLabel final : public LabelBase { public: /** - * Creates new symbol with given name. - * @param symbol name of the symbol + * \brief + * Creates a new instance of the label. */ explicit FinalStateLabel ( ); + /** + * @copydoc label::LabelBase::clone ( ) const & + */ virtual LabelBase * clone ( ) const &; + /** + * @copydoc label::LabelBase::clone ( ) && + */ virtual LabelBase * clone ( ) &&; + /** + * @copydoc base::CommonBase < ObjectBase >::compare ( const ObjectBase & ) const + */ virtual int compare ( const ObjectBase & other ) const { if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) ); } + /** + * The actual compare method + * + * \param other the other instance + * + * \returns the actual relation between two by type same labels + */ virtual int compare ( const FinalStateLabel & other ) const; + /** + * @copydoc base::CommonBase < ObjectBase >::operator >> ( std::ostream & ) const + */ virtual void operator >>( std::ostream & ) const; + /** + * @copydoc base::CommonBase < ObjectBase >::operator std::string ( ) const + */ virtual explicit operator std::string ( ) const; + /** + * \brief Factory for the label construction of the label based on given type. + */ template < typename Base > static inline typename std::enable_if < std::is_integral < Base >::value, Base >::type instance ( ); + + /** + * \brief Factory for the label construction of the label based on given type. + */ template < typename Base > static inline typename std::enable_if < ! std::is_integral < Base >::value, Base >::type instance ( ); + /** + * @copydoc object::ObjectBase::inc ( ) && + */ virtual LabelBase * inc ( ) &&; }; diff --git a/alib2data/src/label/HexavigesimalLabel.h b/alib2data/src/label/HexavigesimalLabel.h index e581e7fd4fdf1f4126d6efcbe24f1d8cfe801968..ed6e2356253e3925123b55b42fac55f2a7a7aebf 100644 --- a/alib2data/src/label/HexavigesimalLabel.h +++ b/alib2data/src/label/HexavigesimalLabel.h @@ -1,6 +1,22 @@ /* * HexavigesimalLabel.h * + * This file is part of Algorithms library toolkit. + * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz) + + * Algorithms library toolkit is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * Algorithms library toolkit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>. + * * Created on: Mar 26, 2013 * Author: Jan Travnicek */ @@ -15,42 +31,77 @@ namespace label { /** - * Represents symbol in an alphabet. + * \brief + * \deprecated + * Represents generated label coded in base 26 but internally represented as int. */ class HexavigesimalLabel final : public LabelBase { -protected: int m_hexavigesimal; public: /** - * Creates new symbol with given name. - * @param symbol name of the symbol + * \brief + * Creates a new instance of the label with specific hexavigesimal raw value + * + * \param raw value of the hexavigesimal */ explicit HexavigesimalLabel ( int hexavigesimal ); + /** + * @copydoc label::LabelBase::clone ( ) const & + */ virtual LabelBase * clone ( ) const &; + /** + * @copydoc label::LabelBase::clone ( ) && + */ virtual LabelBase * clone ( ) &&; /** - * @return name of the symbol + * Getter of the hexavigesimal raw value. + * + * \return the raw representation of the hexavigesimal number */ int getData ( ) const; + /** + * Getter of the hexavigesimal raw value. + * + * \return the raw representation of the hexavigesimal number + */ void setData ( int data ); + /** + * @copydoc base::CommonBase < ObjectBase >::compare ( const ObjectBase & ) const + */ virtual int compare ( const ObjectBase & other ) const { if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) ); } + /** + * The actual compare method + * + * \param other the other instance + * + * \returns the actual relation between two by type same labels + */ virtual int compare ( const HexavigesimalLabel & other ) const; + /** + * @copydoc base::CommonBase < ObjectBase >::operator >> ( std::ostream & ) const + */ virtual void operator >>( std::ostream & ) const; + /** + * @copydoc base::CommonBase < ObjectBase >::operator std::string ( ) const + */ virtual explicit operator std::string ( ) const; + /** + * @copydoc object::ObjectBase::inc ( ) && + */ virtual LabelBase * inc ( ) &&; }; diff --git a/alib2data/src/label/InitialStateLabel.h b/alib2data/src/label/InitialStateLabel.h index c1978b93c9b568cbd59ccde933c554f4028c7b6b..c66a80100eb50aaaaf9d8907e0a57ae4a08f74df 100644 --- a/alib2data/src/label/InitialStateLabel.h +++ b/alib2data/src/label/InitialStateLabel.h @@ -1,6 +1,22 @@ /* * InitialStateLabel.h * + * This file is part of Algorithms library toolkit. + * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz) + + * Algorithms library toolkit is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * Algorithms library toolkit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>. + * * Created on: Mar 26, 2013 * Author: Jan Travnicek */ @@ -15,37 +31,70 @@ namespace label { /** - * Represents symbol in an alphabet. + * \brief + * Represents label of the final state of an automaton. */ class InitialStateLabel final : public LabelBase { public: /** - * Creates new symbol with given name. - * @param symbol name of the symbol + * \brief + * Creates a new instance of the label. */ explicit InitialStateLabel ( ); + /** + * @copydoc label::LabelBase::clone ( ) const & + */ virtual LabelBase * clone ( ) const &; + /** + * @copydoc label::LabelBase::clone ( ) && + */ virtual LabelBase * clone ( ) &&; + /** + * @copydoc base::CommonBase < ObjectBase >::compare ( const ObjectBase & ) const + */ virtual int compare ( const ObjectBase & other ) const { if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) ); } + /** + * The actual compare method + * + * \param other the other instance + * + * \returns the actual relation between two by type same labels + */ virtual int compare ( const InitialStateLabel & other ) const; + /** + * @copydoc base::CommonBase < ObjectBase >::operator >> ( std::ostream & ) const + */ virtual void operator >>( std::ostream & ) const; + /** + * @copydoc base::CommonBase < ObjectBase >::operator std::string ( ) const + */ virtual explicit operator std::string ( ) const; + /** + * \brief Factory for the label construction of the label based on given type. + */ template < typename Base > static inline typename std::enable_if < std::is_integral < Base >::value, Base >::type instance ( ); + + /** + * \brief Factory for the label construction of the label based on given type. + */ template < typename Base > static inline typename std::enable_if < ! std::is_integral < Base >::value, Base >::type instance ( ); + /** + * @copydoc object::ObjectBase::inc ( ) && + */ virtual LabelBase * inc ( ) &&; }; diff --git a/alib2data/src/label/ObjectLabel.h b/alib2data/src/label/ObjectLabel.h index aba4eeee152c602d907585f66102087ab32e2725..bc163e835c7891402fe0af83e6492439e8251cb1 100644 --- a/alib2data/src/label/ObjectLabel.h +++ b/alib2data/src/label/ObjectLabel.h @@ -1,6 +1,22 @@ /* * ObjectLabel.h * + * This file is part of Algorithms library toolkit. + * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz) + + * Algorithms library toolkit is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * Algorithms library toolkit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>. + * * Created on: Mar 26, 2013 * Author: Jan Travnicek */ @@ -14,40 +30,72 @@ namespace label { /** - * Represents symbol in an alphabet. + * \brief + * \depricated + * Represents a label serving as wrapper of an object (automaton, grammar, etc.) */ class ObjectLabel final : public LabelBase { -protected: + /** + * \brief + * The object value of the label. + */ object::Object m_label; public: /** - * Creates new symbol with given name. - * @param symbol name of the symbol + * \brief + * Creates a new instance of the label with preexistent object. */ explicit ObjectLabel ( object::Object label ); + /** + * @copydoc alphabet::SymbolBase::clone ( ) const & + */ virtual LabelBase * clone ( ) const &; + /** + * @copydoc alphabet::SymbolBase::clone ( ) && + */ virtual LabelBase * clone ( ) &&; /** - * @return name of the symbol + * Getter of the label's object value. + * + * \return the object value of the label */ const object::Object & getData ( ) const; + /** + * @copydoc base::CommonBase < ObjectBase >::compare ( const ObjectBase & ) const + */ virtual int compare ( const ObjectBase & other ) const { if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) ); } + /** + * The actual compare method + * + * \param other the other instance + * + * \returns the actual relation between two by type same labels + */ virtual int compare ( const ObjectLabel & other ) const; + /** + * @copydoc base::CommonBase < ObjectBase >::operator >> ( std::ostream & ) const + */ virtual void operator >>( std::ostream & ) const; + /** + * @copydoc base::CommonBase < ObjectBase >::operator std::string ( ) const + */ virtual explicit operator std::string ( ) const; + /** + * @copydoc object::ObjectBase::inc ( ) && + */ virtual LabelBase * inc ( ) &&; }; diff --git a/alib2data/src/label/PrimitiveLabel.h b/alib2data/src/label/PrimitiveLabel.h index e3452a529956adb8d201fecc18d23ef8ee326241..547742ab978abbde8939a7e4b02f6c48a92e07cb 100644 --- a/alib2data/src/label/PrimitiveLabel.h +++ b/alib2data/src/label/PrimitiveLabel.h @@ -1,6 +1,22 @@ /* * PrimitiveLabel.h * + * This file is part of Algorithms library toolkit. + * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz) + + * Algorithms library toolkit is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * Algorithms library toolkit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>. + * * Created on: Mar 26, 2013 * Author: Jan Travnicek */ @@ -14,42 +30,79 @@ namespace label { /** - * Represents symbol in an alphabet. + * \brief + * \depricated + * Represents a label serving as wrapper of a primitive datatype (int, unsigned, char, etc.) */ class PrimitiveLabel final : public LabelBase { -protected: + /** + * \brief + * The primitive value of the label. + */ primitive::Primitive m_primitive; public: /** - * Creates new symbol with given name. - * @param symbol name of the symbol + * \brief + * Creates a new instance of the label with preexistent primitive. */ explicit PrimitiveLabel ( primitive::Primitive primitive ); + /** + * @copydoc alphabet::SymbolBase::clone ( ) const & + */ virtual LabelBase * clone ( ) const &; + /** + * @copydoc alphabet::SymbolBase::clone ( ) && + */ virtual LabelBase * clone ( ) &&; /** - * @return name of the symbol + * Getter of the label's primitive value. + * + * \return the primitive value of the label */ const primitive::Primitive & getData ( ) const; + /** + * Getter of the label's primitive value. + * + * \return the primitive value of the label + */ primitive::Primitive & getData ( ); + /** + * @copydoc base::CommonBase < ObjectBase >::compare ( const ObjectBase & ) const + */ virtual int compare ( const ObjectBase & other ) const { if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) ); } + /** + * The actual compare method + * + * \param other the other instance + * + * \returns the actual relation between two by type same labels + */ virtual int compare ( const PrimitiveLabel & other ) const; + /** + * @copydoc base::CommonBase < ObjectBase >::operator >> ( std::ostream & ) const + */ virtual void operator >>( std::ostream & ) const; + /** + * @copydoc base::CommonBase < ObjectBase >::operator std::string ( ) const + */ virtual explicit operator std::string ( ) const; + /** + * @copydoc object::ObjectBase::inc ( ) && + */ virtual LabelBase * inc ( ) &&; }; diff --git a/alib2data/src/label/UniqueLabel.cpp b/alib2data/src/label/UniqueLabel.cpp index 500e4a8315f9d988cce6db90cd3fcbb0ccf38a29..3f32c7e35cef6a01d51dcd34a1ec565b98b4702b 100644 --- a/alib2data/src/label/UniqueLabel.cpp +++ b/alib2data/src/label/UniqueLabel.cpp @@ -24,18 +24,22 @@ LabelBase* UniqueLabel::clone() && { return new UniqueLabel(std::move(*this)); } -const Label& UniqueLabel::getLabel() const { +const Label & UniqueLabel::getLabel ( ) const & { return m_label; } -const primitive::Integer& UniqueLabel::getId() const { - return m_id; +Label && UniqueLabel::getLabel ( ) && { + return std::move ( m_label ); } -primitive::Integer& UniqueLabel::getId() { +const primitive::Integer & UniqueLabel::getId ( ) const & { return m_id; } +primitive::Integer && UniqueLabel::getId ( ) && { + return std::move ( m_id ); +} + int UniqueLabel::compare(const UniqueLabel& other) const { int res = m_label.getData().compare(other.m_label.getData()); if(res == 0) res = m_id.compare(other.m_id); diff --git a/alib2data/src/label/UniqueLabel.h b/alib2data/src/label/UniqueLabel.h index 94ea914cf38b335b1b6de996d2747739f29234bb..11a9dc1eba4551fdcff61f4a6e236f84cfbea49e 100644 --- a/alib2data/src/label/UniqueLabel.h +++ b/alib2data/src/label/UniqueLabel.h @@ -1,6 +1,22 @@ /* * UniqueLabel.h * + * This file is part of Algorithms library toolkit. + * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz) + + * Algorithms library toolkit is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * Algorithms library toolkit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>. + * * Created on: Mar 26, 2013 * Author: Jan Travnicek */ @@ -14,45 +30,103 @@ namespace label { /** - * Represents symbol in an alphabet. + * \brief + * Represents label based on other label with additional differentiation counter. + * + * The UniqueLabel is used in situations when some label is given and one would like to create new based on it but different. For example q vs. q' vs q'', etc. + * + * Primarly the class is used from inc method. */ class UniqueLabel final : public LabelBase { -protected: + /** + * The underlying label. + */ Label m_label; + + /** + * The differentiating number. + */ primitive::Integer m_id; public: /** - * Creates new symbol with given name. - * @param symbol name of the symbol + * \brief + * Creates new label with given name and set differentiating number. + * + * \param label the underlying label + * \param id the differentiating number */ explicit UniqueLabel ( Label label, primitive::Integer id ); + /** + * @copydoc alphabet::SymbolBase::clone ( ) const & + */ virtual LabelBase * clone ( ) const &; + /** + * @copydoc alphabet::SymbolBase::clone ( ) && + */ virtual LabelBase * clone ( ) &&; /** - * @return name of the symbol + * Getter of the underlying label. + * + * \return the underlying label + */ + const Label & getLabel ( ) const &; + + /** + * Getter of the underlying label. + * + * \return the underlying label */ - const Label & getLabel ( ) const; + Label && getLabel ( ) &&; - const primitive::Integer & getId ( ) const; + /** + * Getter of the differentiating number. + * + * \return the differentiating number + */ + const primitive::Integer & getId ( ) const &; - primitive::Integer & getId ( ); + /** + * Getter of the differentiating number. + * + * \return the differentiating number + */ + primitive::Integer && getId ( ) &&; + /** + * @copydoc base::CommonBase < ObjectBase >::compare ( const ObjectBase & ) const + */ virtual int compare ( const ObjectBase & other ) const { if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) ); } + /** + * The actual compare method + * + * \param other the other instance + * + * \returns the actual relation between two by type same labels + */ virtual int compare ( const UniqueLabel & other ) const; + /** + * @copydoc base::CommonBase < ObjectBase >::operator >> ( std::ostream & ) const + */ virtual void operator >>( std::ostream & ) const; + /** + * @copydoc base::CommonBase < ObjectBase >::operator std::string ( ) const + */ virtual explicit operator std::string ( ) const; + /** + * @copydoc object::ObjectBase::inc ( ) && + */ virtual LabelBase * inc ( ) &&; };