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
InitialStateLabel.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
26#include <compare>
27
28#include <object/Object.h>
29
30namespace label {
31
37public:
42 explicit InitialStateLabel ( );
43
51 std::strong_ordering operator <=> ( const InitialStateLabel & ) const {
52 return std::strong_ordering::equal;
53 }
54
62 bool operator == ( const InitialStateLabel & ) const {
63 return true;
64 }
65
75
79 template < typename Base >
80 static inline Base instance ( );
81};
82
83template < typename Base >
85 if constexpr ( std::is_integral_v < Base > ) {
86 return 0;
87 } else if constexpr ( std::is_same_v < Base, std::string > ) {
88 return std::string ( "initial" );
89 } else if constexpr ( std::is_same_v < Base, InitialStateLabel > ) {
90 return InitialStateLabel ( );
91 } else if constexpr ( std::is_same_v < Base, object::Object > ) {
92 return object::Object ( InitialStateLabel ( ) );
93 } else {
94 static_assert ( std::is_same_v < Base, Base >, "Unsupported type of instance" );
95 }
96}
97
98} /* namespace label */
99
Definition: ostream.h:14
Represents label of the final state of an automaton.
Definition: InitialStateLabel.h:36
friend ext::ostream & operator<<(ext::ostream &out, const InitialStateLabel &instance)
Definition: InitialStateLabel.cpp:16
InitialStateLabel()
Creates a new instance of the label.
std::strong_ordering operator<=>(const InitialStateLabel &) const
Definition: InitialStateLabel.h:51
static Base instance()
Factory for the label construction of the label based on given type.
Definition: InitialStateLabel.h:84
bool operator==(const InitialStateLabel &) const
Definition: InitialStateLabel.h:62
Definition: Object.h:16
Definition: FailStateLabel.cpp:12