BPMN-OS
BPMN for optimization and simulation
Loading...
Searching...
No Matches
DynamicDataProvider.h
Go to the documentation of this file.
1#ifndef BPMNOS_Model_DynamicDataProvider_H
2#define BPMNOS_Model_DynamicDataProvider_H
3
4#include <bpmn++.h>
5#include "DataProvider.h"
8#include <memory>
9#include <vector>
10
11namespace BPMNOS::Model {
12
13/**
14 * @brief Structure representing a deferred initialization.
15 *
16 * Stores a pre-computed value to be revealed at disclosure time.
17 * The value is computed at parse time using only global attributes.
18 */
20 const Attribute* attribute; ///< The attribute to initialize
21 BPMNOS::number disclosureTime; ///< Effective disclosure time (max of own, parent)
22 BPMNOS::number value; ///< Pre-computed value to reveal at disclosure time
23};
24
25/**
26 * @brief Class representing a data provider for dynamic BPMN instance data.
27 *
28 * The DynamicDataProvider class is responsible for providing and managing instance data
29 * for BPMN processes.
30 * */
32public:
33 /**
34 * @brief Constructor for DynamicDataProvider.
35 *
36 * @param modelFile The file path to the BPMN model file.
37 * @param instanceFileOrString The file path to the instance data file or a string containing the data.
38 */
39 DynamicDataProvider(const std::string& modelFile, const std::string& instanceFileOrString);
40 /**
41 * @brief Constructor for DynamicDataProvider.
42 *
43 * @param modelFile The file path to the BPMN model file.
44 * @param folders The folders containing lookup tables.
45 * @param instanceFileOrString The file path to the instance data file or a string containing the data.
46 */
47 DynamicDataProvider(const std::string& modelFile, const std::vector<std::string>& folders, const std::string& instanceFileOrString);
48 ~DynamicDataProvider() override = default;
49 std::unique_ptr<Scenario> createScenario(unsigned int scenarioId = 0) override;
50protected:
52 void readInstances();
53
58 std::unordered_map< const Attribute*, BPMNOS::number > data;
59 };
60 std::unordered_map< long unsigned int, DynamicInstanceData > instances;
61 std::unordered_map< const Attribute*, BPMNOS::number > globalValueMap;
62 std::unordered_map< size_t, std::vector<DeferredInitialization> > deferredInitializations; ///< Instance ID -> deferred inits
63 std::unordered_map< size_t, std::unordered_map<const BPMN::Node*, BPMNOS::number> > disclosure; ///< Instance ID -> Node -> time when node's data is disclosed
66
67 void ensureDefaultValue(DynamicInstanceData& instance, const std::string attributeId, std::optional<BPMNOS::number> value = std::nullopt);
68 std::pair<std::string, std::string> parseInitialization(const std::string& initialization) const;
69 BPMNOS::number evaluateExpression(const std::string& expression) const;
70 BPMNOS::number getEffectiveDisclosure(size_t instanceId, const BPMN::Node* node, BPMNOS::number ownDisclosure);
71};
72
73} // namespace BPMNOS::Model
74
75#endif // BPMNOS_Model_DynamicDataProvider_H
Abstract base class representing a data provider for BPMN instance data.
Class representing a data provider for dynamic BPMN instance data.
std::unordered_map< const Attribute *, BPMNOS::number > globalValueMap
DynamicDataProvider(const std::string &modelFile, const std::string &instanceFileOrString)
Constructor for DynamicDataProvider.
std::unique_ptr< Scenario > createScenario(unsigned int scenarioId=0) override
void ensureDefaultValue(DynamicInstanceData &instance, const std::string attributeId, std::optional< BPMNOS::number > value=std::nullopt)
std::unordered_map< size_t, std::vector< DeferredInitialization > > deferredInitializations
Instance ID -> deferred inits.
std::unordered_map< long unsigned int, DynamicInstanceData > instances
BPMNOS::number getEffectiveDisclosure(size_t instanceId, const BPMN::Node *node, BPMNOS::number ownDisclosure)
~DynamicDataProvider() override=default
std::unordered_map< size_t, std::unordered_map< const BPMN::Node *, BPMNOS::number > > disclosure
Instance ID -> Node -> time when node's data is disclosed.
BPMNOS::number evaluateExpression(const std::string &expression) const
std::pair< std::string, std::string > parseInitialization(const std::string &initialization) const
Base class for all nodes in a BPMN model.
Definition bpmn++.h:16444
BPMNOS_NUMBER_TYPE number
Definition Number.h:50
Structure representing a deferred initialization.
BPMNOS::number value
Pre-computed value to reveal at disclosure time.
BPMNOS::number disclosureTime
Effective disclosure time (max of own, parent)
const Attribute * attribute
The attribute to initialize.
std::unordered_map< const Attribute *, BPMNOS::number > data