BPMN-OS
BPMN for optimization and simulation
Loading...
Searching...
No Matches
CollectionRegistry.h
Go to the documentation of this file.
1#ifndef BPMNOS_Model_CollectionRegistry_H
2#define BPMNOS_Model_CollectionRegistry_H
3
4#include <string>
5#include <vector>
6#include <mutex>
7#include <shared_mutex>
8#include "Number.h"
9#include "vector_map.h"
10
11namespace BPMNOS {
12
13 /**
14 * @brief Utility class for representing collections by numeric values.
15 *
16 * The CollectionRegistry class provides efficient access to the collection by index
17 * and retrieval of the index by the values representing the collection.
18 */
20 /// Constructor adds empty collection at index 0.
22
23 /// Operator providing access to a registered collections by index.
24 const std::vector<double>& operator[](size_t i) const;
25 /// Operator to register a collection by its values and return its index.
26 size_t operator()(const std::vector<double>& collection);
27 size_t size() const;
28 void clear();
29 private:
30 std::vector< std::vector<double> > registeredCollections;
31 vector_map<std::vector<double>, size_t> index;
32 mutable std::shared_mutex registryMutex;
33 public:
34 // Prevent use of copy constructor and assignment operator as mutex is not copyable
37 };
38
39
40} // namespace BPMNOS
41
42#endif // BPMNOS_Model_CollectionRegistry_H
43
44// `CollectionRegistry` is a global variable
BPMNOS::CollectionRegistry collectionRegistry
Wrapper class around std::unordered_map for maps with vector keys.
Definition vector_map.h:31
Utility class for representing collections by numeric values.
const std::vector< double > & operator[](size_t i) const
Operator providing access to a registered collections by index.
size_t operator()(const std::vector< double > &collection)
Operator to register a collection by its values and return its index.
CollectionRegistry()
Constructor adds empty collection at index 0.
CollectionRegistry & operator=(const CollectionRegistry &)=delete
CollectionRegistry(const CollectionRegistry &)=delete