Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Concepts
GapSymbol.h
Go to the documentation of this file.
1
6/*
7 * This file is part of Algorithms library toolkit.
8 * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
9
10 * Algorithms library toolkit is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14
15 * Algorithms library toolkit is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19
20 * You should have received a copy of the GNU General Public License
21 * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#pragma once
25
27#include <object/Object.h>
28
29namespace alphabet {
30
35class GapSymbol {
36public:
41 explicit GapSymbol ( );
42
50 std::strong_ordering operator <=> ( const GapSymbol & ) const {
51 return std::strong_ordering::equal;
52 }
53
61 bool operator == ( const GapSymbol & ) const {
62 return true;
63 }
64
73 friend ext::ostream & operator << ( ext::ostream & out, const GapSymbol & instance );
74
78 template < typename Base >
79 static inline Base instance ( );
80};
81
82template < typename Base >
83inline Base GapSymbol::instance ( ) {
84 if constexpr ( std::is_integral_v < Base > ) {
85 return '*';
86 } else if constexpr ( std::is_same_v < Base, std::string > ) {
87 return std::string ( 1, GapSymbol::instance < char > ( ) );
88 } else if constexpr ( std::is_same_v < Base, GapSymbol > ) {
89 return GapSymbol ( );
90 } else if constexpr ( std::is_same_v < Base, object::Object > ) {
91 return object::Object ( GapSymbol ( ) );
92 } else if constexpr ( std::is_same_v < Base, common::ranked_symbol < > > ) {
93 return common::ranked_symbol < > ( GapSymbol::instance < DefaultSymbolType > ( ), 0u );
94 } else {
95 static_assert ( std::is_same_v < Base, Base >, "Unsupported type of instance" );
96 }
97}
98
99} /* namespace alphabet */
Represents a wildcard used as representation of anything here in a string or a tree.
Definition: GapSymbol.h:35
std::strong_ordering operator<=>(const GapSymbol &) const
Definition: GapSymbol.h:50
bool operator==(const GapSymbol &) const
Definition: GapSymbol.h:61
GapSymbol()
Creates a new instance of the symbol.
friend ext::ostream & operator<<(ext::ostream &out, const GapSymbol &instance)
Definition: GapSymbol.cpp:16
static Base instance()
Factory for the symbol construction of the symbol based on given type.
Definition: GapSymbol.h:83
Definition: ranked_symbol.hpp:20
Definition: ostream.h:14
Definition: Object.h:16
Definition: BarSymbol.cpp:12