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 <unordered_map>
7#include <mutex>
8#include "Number.h"
9
10namespace BPMNOS {
11
12 struct Collection {
13 Collection(const std::string& collection);
14 std::string collection;
16 };
17
18 /**
19 * @brief Utility class for representing collections by numeric values.
20 *
21 * The CollectionRegistry class provides efficient access to the collection by index
22 * and retrieval of the index by the string representing the collection.
23 */
25 /// Constructor adds empty collection at index 0.
27
28 /// Operator providing access to a registered collections by index.
29 const Collection& operator[](size_t i) const;
30 /// Operator to register a collection by its string representation and return its index.
31 size_t operator()(const std::string& collection);
32 void clear();
33 private:
34 std::vector<Collection> registeredCollections;
35 std::unordered_map<std::string, size_t> index;
36 std::mutex registryMutex;
37 public:
38 // Prevent use of copy constructor and assignment operator as mutex is not copyable
41 };
42
43
44} // namespace BPMNOS
45
46#endif // BPMNOS_Model_CollectionRegistry_H
47
48// `CollectionRegistry` is a global variable
BPMNOS::CollectionRegistry collectionRegistry
Utility class for representing collections by numeric values.
CollectionRegistry()
Constructor adds empty collection at index 0.
const Collection & operator[](size_t i) const
Operator providing access to a registered collections by index.
CollectionRegistry & operator=(const CollectionRegistry &)=delete
CollectionRegistry(const CollectionRegistry &)=delete
size_t operator()(const std::string &collection)
Operator to register a collection by its string representation and return its index.
Collection(const std::string &collection)