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
StringWriterRegistry.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <ext/memory>
9#include <ext/typeinfo>
10
11#include <alib/string>
12#include <alib/set>
13#include <alib/map>
14
16
17namespace abstraction {
18
20public:
21 class Entry {
22 public:
23 virtual std::shared_ptr < abstraction::OperationAbstraction > getAbstraction ( ) const = 0;
24
25 virtual ~Entry ( ) = default;
26
27 };
28
29private:
30 template < class Param >
31 class EntryImpl : public Entry {
32 public:
33 EntryImpl ( ) = default;
34
35 std::shared_ptr < abstraction::OperationAbstraction > getAbstraction ( ) const override;
36 };
37
39
40public:
41 static void unregisterStringWriter ( const std::string & param );
42
43 template < class ParamType >
44 static void unregisterStringWriter ( ) {
45 std::string param = ext::to_string < ParamType > ( );
46 unregisterStringWriter ( param );
47 }
48
49 static void registerStringWriter ( std::string param, std::unique_ptr < Entry > entry );
50
51 template < class ParamType >
52 static void registerStringWriter ( std::string param ) {
53 registerStringWriter ( std::move ( param ), std::unique_ptr < Entry > ( new EntryImpl < ParamType > ( ) ) );
54 }
55
56 template < class ParamType >
57 static void registerStringWriter ( ) {
58 std::string param = ext::to_string < ParamType > ( );
59 registerStringWriter < ParamType > ( std::move ( param ) );
60 }
61
62 static std::shared_ptr < abstraction::OperationAbstraction > getAbstraction ( const std::string & param );
63};
64
65} /* namespace abstraction */
66
68
69namespace abstraction {
70
71template < class Param >
72std::shared_ptr < abstraction::OperationAbstraction > StringWriterRegistry::EntryImpl < Param >::getAbstraction ( ) const {
73 return std::make_shared < abstraction::StringWriterAbstraction < const Param & > > ( );
74}
75
76
77} /* namespace abstraction */
78
Definition: StringWriterRegistry.hpp:21
virtual std::shared_ptr< abstraction::OperationAbstraction > getAbstraction() const =0
Definition: StringWriterRegistry.hpp:19
static void registerStringWriter(std::string param)
Definition: StringWriterRegistry.hpp:52
static void unregisterStringWriter()
Definition: StringWriterRegistry.hpp:44
static std::shared_ptr< abstraction::OperationAbstraction > getAbstraction(const std::string &param)
Definition: StringWriterRegistry.cpp:27
static void registerStringWriter()
Definition: StringWriterRegistry.hpp:57
Class extending the map class from the standard library. Original reason is to allow printing of the ...
Definition: map.hpp:48
Definition: AlgorithmAbstraction.hpp:11