carl  24.04
Computer ARithmetic Library
SortValueManager.h
Go to the documentation of this file.
1 /**
2  * @file SortValueManager.h
3  * @author Florian Corzilius <corzilius@cs.rwth-aachen.de>
4  * @since 2014-10-24
5  * @version 2014-10-24
6  */
7 
8 #pragma once
9 
10 #include <cassert>
11 #include <iostream>
12 #include <map>
13 #include <set>
14 #include <utility>
15 #include <vector>
16 
19 #include "SortValue.h"
20 
21 namespace carl {
22 
23 /**
24  * Implements a manager for sort values, containing the actual contents of these sort and allocating their ids.
25  */
26 class SortValueManager : public Singleton<SortValueManager> {
28 
29 private:
30  // Members.
31 
32  /// Stores for each sort the latest instantiated sort value.
34 
35  /**
36  * Constructs a sort value manager.
37  */
38  SortValueManager() = default;
39 
40 public:
41  /**
42  * Creates a new value for the given sort.
43  * @param sort The sort to create a new value for.
44  * @return The resulting sort value.
45  */
46  SortValue newSortValue(const Sort& sort) {
47  auto res = mSortValueIDMap.emplace(sort, 1);
48  if (!res.second) {
49  ++res.first->second;
50  }
51  return SortValue(sort, res.first->second);
52  }
53  /**
54  * Returns the default value for the given sort.
55  * @param sort The sort to return the default value for.
56  * @return The resulting sort value.
57  */
58  SortValue defaultSortValue(const Sort& sort) const {
59  return SortValue(sort, 0);
60  }
61 };
62 
63 /**
64  * Creates a new value for the given sort.
65  * @param sort The sort to create a new value for.
66  * @return The resulting sort value.
67  */
68 inline SortValue newSortValue(const Sort& sort) {
70 }
71 /**
72  * Returns the default value for the given sort.
73  * @param sort The sort to return the default value for.
74  * @return The resulting sort value.
75  */
76 inline SortValue defaultSortValue(const Sort& sort) {
78 }
79 
80 } // namespace carl
carl is the main namespace for the library.
SortValue newSortValue(const Sort &sort)
Creates a new value for the given sort.
SortValue defaultSortValue(const Sort &sort)
Returns the default value for the given sort.
std::unordered_map< T1, T2, std::hash< T1 > > FastMap
Base class that implements a singleton.
Definition: Singleton.h:24
static SortValueManager & getInstance()
Returns the single instance of this class by reference.
Definition: Singleton.h:45
Implements a sort (for defining types of variables and functions).
Definition: Sort.h:20
Implements a sort value, being a value of the uninterpreted domain specified by this sort.
Definition: SortValue.h:22
Implements a manager for sort values, containing the actual contents of these sort and allocating the...
SortValueManager()=default
Constructs a sort value manager.
SortValue defaultSortValue(const Sort &sort) const
Returns the default value for the given sort.
carl::FastMap< Sort, std::size_t > mSortValueIDMap
Stores for each sort the latest instantiated sort value.
SortValue newSortValue(const Sort &sort)
Creates a new value for the given sort.