Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
RawWriterRegistry.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
28private:
29 template < class Param >
30 class EntryImpl : public Entry {
31 public:
32 EntryImpl ( ) = default;
33
34 std::shared_ptr < abstraction::OperationAbstraction > getAbstraction ( ) const override;
35 };
36
38
39public:
40 static void unregisterRawWriter ( const std::string & param );
41
42 template < class ParamType >
43 static void unregisterRawWriter ( ) {
44 std::string param = ext::to_string < ParamType > ( );
45 unregisterRawWriter ( param );
46 }
47
48 static void registerRawWriter ( std::string param, std::unique_ptr < Entry > entry );
49
50 template < class ParamType >
51 static void registerRawWriter ( std::string param ) {
52 registerRawWriter ( std::move ( param ), std::unique_ptr < Entry > ( new EntryImpl < ParamType > ( ) ) );
53 }
54
55 template < class ParamType >
56 static void registerRawWriter ( ) {
57 std::string param = ext::to_string < ParamType > ( );
58 registerRawWriter < ParamType > ( std::move ( param ) );
59 }
60
61 static std::shared_ptr < abstraction::OperationAbstraction > getAbstraction ( const std::string & param );
62};
63
64} /* namespace abstraction */
65
67
68namespace abstraction {
69
70template < class Param >
71std::shared_ptr < abstraction::OperationAbstraction > RawWriterRegistry::EntryImpl < Param >::getAbstraction ( ) const {
72 return std::make_shared < abstraction::RawWriterAbstraction < const Param & > > ( );
73}
74
75
76} /* namespace abstraction */
77
Definition: RawWriterRegistry.hpp:21
virtual std::shared_ptr< abstraction::OperationAbstraction > getAbstraction() const =0
Definition: RawWriterRegistry.hpp:19
static void registerRawWriter(std::string param)
Definition: RawWriterRegistry.hpp:51
static void registerRawWriter()
Definition: RawWriterRegistry.hpp:56
static void unregisterRawWriter()
Definition: RawWriterRegistry.hpp:43
static std::shared_ptr< abstraction::OperationAbstraction > getAbstraction(const std::string &param)
Definition: RawWriterRegistry.cpp:27
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