|
| StorageUniquer () |
|
| ~StorageUniquer () |
|
template<typename Storage , typename Arg , typename... Args> |
Storage * | get (std::function< void(Storage *)> initFn, unsigned kind, Arg &&arg, Args &&... args) |
|
template<typename Storage > |
Storage * | get (std::function< void(Storage *)> initFn, unsigned kind) |
|
template<typename Storage , typename Arg , typename... Args> |
void | erase (unsigned kind, Arg &&arg, Args &&... args) |
|
A utility class to get, or create instances of storage classes. These storage classes must respect the following constraints:
For non-parametric storage classes, i.e. those that are solely uniqued by their kind, nothing else is needed. Instances of these classes can be created by calling get
without trailing arguments.
Otherwise, the parametric storage classes may be created with get
, and must respect the following:
- Define a type alias, KeyTy, to a type that uniquely identifies the instance of the storage class within its kind.
- The key type must be constructible from the values passed into the getComplex call after the kind.
- If the KeyTy does not have an llvm::DenseMapInfo specialization, the storage class must define a hashing method: 'static unsigned hashKey(const KeyTy &)'
- Provide a method, 'bool operator==(const KeyTy &) const', to compare the storage instance against an instance of the key type.
- Provide a static construction method: 'DerivedStorage *construct(StorageAllocator &, const KeyTy &key)' that builds a unique instance of the derived storage. The arguments to this function are an allocator to store any uniqued data and the key type for this storage.
- Provide a cleanup method: 'void cleanup()' that is called when erasing a storage instance. This should cleanup any fields of the storage as necessary and not attempt to free the memory of the storage itself.