Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
ValuePrinterRegistry.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <ext/memory>
9#include <ext/string>
10#include <ext/map>
11#include <ext/typeinfo>
12
14#include "BaseRegistryEntry.hpp"
15
16namespace abstraction {
17
19public:
20 class Entry : public BaseRegistryEntry {
21 };
22
23private:
24 template < class Param >
25 class EntryImpl : public Entry {
26 public:
27 EntryImpl ( ) = default;
28
29 std::shared_ptr < abstraction::OperationAbstraction > getAbstraction ( ) const override;
30 };
31
33
34public:
35 static void unregisterValuePrinter ( const std::string & param );
36
37 template < class ParamType >
38 static void unregisterValuePrinter ( ) {
39 std::string param = ext::to_string < ParamType > ( );
40 unregisterValuePrinter ( param );
41 }
42
43 static void registerValuePrinter ( std::string param, std::unique_ptr < Entry > entry );
44
45 template < class ParamType >
46 static void registerValuePrinter ( std::string param ) {
47 registerValuePrinter ( std::move ( param ), std::unique_ptr < Entry > ( new EntryImpl < ParamType > ( ) ) );
48 }
49
50 template < class ParamType >
51 static void registerValuePrinter ( ) {
52 std::string param = ext::to_string < ParamType > ( );
53 registerValuePrinter < ParamType > ( std::move ( param ) );
54 }
55
56 static std::shared_ptr < abstraction::OperationAbstraction > getAbstraction ( const std::string & param );
57};
58
59} /* namespace abstraction */
60
62
63namespace abstraction {
64
65template < class Param >
66std::shared_ptr < abstraction::OperationAbstraction > ValuePrinterRegistry::EntryImpl < Param >::getAbstraction ( ) const {
67 return std::make_shared < abstraction::ValuePrinterAbstraction < const Param & > > ( );
68}
69
70template < >
71std::shared_ptr < abstraction::OperationAbstraction > ValuePrinterRegistry::EntryImpl < void >::getAbstraction ( ) const;
72
73} /* namespace abstraction */
74
Definition: BaseRegistryEntry.hpp:12
Definition: ValuePrinterRegistry.hpp:20
Definition: ValuePrinterRegistry.hpp:18
static std::shared_ptr< abstraction::OperationAbstraction > getAbstraction(const std::string &param)
Definition: ValuePrinterRegistry.cpp:15
static void registerValuePrinter(std::string param)
Definition: ValuePrinterRegistry.hpp:46
static void registerValuePrinter()
Definition: ValuePrinterRegistry.hpp:51
static void unregisterValuePrinter()
Definition: ValuePrinterRegistry.hpp:38
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