8 : earliestInstantiationTime(earliestInstantiationTime)
9 , latestInstantiationTime(latestInstantiationTime)
13 for (
auto& [attribute, value] : globalValueMap ) {
14 globals[attribute->index] = value;
19 instances[(size_t)instanceId] = {process, (size_t)instanceId, instantiationTime, {}};
23 instances[(size_t)instanceId].values[attribute] = value;
27 disclosure[(size_t)instanceId][node] = disclosureTime;
39 std::vector< const Scenario::InstanceData* > result;
40 for (
auto& [
id, instance] :
instances ) {
41 if ( instance.instantiationTime <= currentTime ) {
42 result.push_back(&instance);
50 std::vector< const Scenario::InstanceData* > result;
51 for (
auto& [
id, instance] :
instances ) {
52 result.push_back(&instance);
58 std::vector< std::tuple<const BPMN::Process*, BPMNOS::Values, BPMNOS::Values> > result;
59 for (
auto& [
id, instance] :
instances ) {
63 BPMNOS::number effectiveInstantiationTime = instance.instantiationTime;
64 if (
disclosure.contains(instance.id) &&
disclosure.at(instance.id).contains(instance.process) ) {
65 effectiveInstantiationTime = std::max(effectiveInstantiationTime,
disclosure.at(instance.id).at(instance.process));
67 if ( effectiveInstantiationTime == currentTime ) {
70 if ( effectiveInstantiationTime > instance.instantiationTime ) {
73 result.push_back({instance.process, std::move(status),
getKnownInitialData(&instance, currentTime)});
82 result.push_back(
getKnownValue(instance, attribute.get(), currentTime) );
90 result.push_back(
getKnownValue(instance, attribute.get(), currentTime) );
99 std::vector<double> variableValues;
100 for (
auto input : attribute->
expression->variables ) {
101 if ( !input->isImmutable ) {
105 if ( !value.has_value() ) {
108 variableValues.push_back( (
double)value.value() );
111 std::vector<std::vector<double>> collectionValues;
112 for (
auto input : attribute->
expression->collections ) {
113 if ( !input->isImmutable ) {
116 collectionValues.push_back( {} );
117 auto collection =
getKnownValue(instance, input, currentTime);
118 if ( !collection.has_value() ) {
122 collectionValues.back().push_back( value );
126 return number(attribute->
expression->compiled.evaluate(variableValues, collectionValues));
130 if ( instance->
values.contains(attribute) ) {
131 return instance->
values.at(attribute);
142 auto& instance =
instances.at((
size_t)instanceId);
145 if ( currentTime <
disclosure.at(instance.id).at(node) ) {
151 result.push_back(
getKnownValue(&instance, attribute.get(), currentTime) );
157 auto& instance =
instances.at((
size_t)instanceId);
160 if ( currentTime <
disclosure.at(instance.id).at(node) ) {
166 result.push_back(
getKnownValue(&instance, attribute.get(), currentTime) );
177 auto& instance =
instances.at(instanceId);
180 auto it = pendings.begin();
181 while (it != pendings.end()) {
182 if (currentTime >= it->disclosureTime) {
184 instance.values[it->attribute] = it->value;
186 it = pendings.erase(it);
CollectionRegistry collectionRegistry
std::unique_ptr< const Expression > expression
std::optional< BPMNOS::number > getKnownValue(const Scenario::InstanceData *instance, const BPMNOS::Model::Attribute *attribute, const BPMNOS::number currentTime) const override
Method returning a known value of an attribute.
std::unordered_map< size_t, std::vector< PendingDisclosure > > pendingDisclosures
Instance ID -> pending disclosures.
BPMNOS::number getEarliestInstantiationTime() const override
Method returning the time of the earliest instantiation.
std::optional< BPMNOS::Values > getKnownValues(const BPMNOS::number instanceId, const BPMN::Node *node, const BPMNOS::number currentTime) const override
Method returning all known values of new attributes.
BPMNOS::number latestInstantiationTime
void addInstance(const BPMN::Process *process, const BPMNOS::number instanceId, BPMNOS::number instantiationTime)
void revealData(BPMNOS::number currentTime) const
void setValue(const BPMNOS::number instanceId, const Attribute *attribute, std::optional< BPMNOS::number > value)
void setDisclosure(const BPMNOS::number instanceId, const BPMN::Node *node, BPMNOS::number disclosureTime)
std::unordered_map< size_t, std::unordered_map< const BPMN::Node *, BPMNOS::number > > disclosure
Instance ID -> Node -> time when node's data is disclosed.
Values getKnownInitialStatus(const InstanceData *, const BPMNOS::number time) const override
Method returning the initial status attributes for process instantiation.
std::set< std::pair< size_t, const Attribute * > > disclosedAttributes
Track which attributes have been disclosed.
std::vector< const InstanceData * > getKnownInstances(const BPMNOS::number currentTime) const override
Method returning a vector of all instances that have been created or are known for sure until the giv...
std::vector< std::tuple< const BPMN::Process *, BPMNOS::Values, BPMNOS::Values > > getCurrentInstantiations(const BPMNOS::number currentTime) const override
Method returning a vector of all instances that are known to be instantiated at the given time.
bool isCompleted(const BPMNOS::number currentTime) const override
Method returning true if the currentTime exceeds the completion time.
std::optional< BPMNOS::Values > getKnownData(const BPMNOS::number instanceId, const BPMN::Node *node, const BPMNOS::number currentTime) const override
Method returning all known values of new attributes.
void addPendingDisclosure(const BPMNOS::number instanceId, PendingDisclosure &&pending)
std::vector< const InstanceData * > getCreatedInstances(const BPMNOS::number currentTime) const override
Method returning a vector of all instances that have been created until the given time.
DynamicScenario(const Model *model, BPMNOS::number earliestInstantiationTime, BPMNOS::number latestInstantiationTime, const std::unordered_map< const Attribute *, BPMNOS::number > &globalValueMap)
Values getKnownInitialData(const InstanceData *, const BPMNOS::number time) const override
Method returning the initial data attributes for process instantiation.
std::unordered_map< size_t, InstanceData > instances
BPMNOS::number earliestInstantiationTime
Class holding extension elements representing execution data for nodes.
std::vector< std::unique_ptr< Attribute > > attributes
Vector containing new status attributes declared for the node.
std::vector< std::unique_ptr< Attribute > > data
Vector containing data attributes declared for data objects within the node's scope.
Represents a BPMN model with all its processes.
std::vector< std::unique_ptr< Attribute > > attributes
Vector containing new global attributes declared for the model.
const Model * model
Pointer to the BPMN model.
std::unique_ptr< ExtensionElements > extensionElements
Base class for all nodes in a BPMN model.
BPMNOS_NUMBER_TYPE number
static constexpr size_t Timestamp
Structure representing a pending disclosure.
std::unordered_map< const Attribute *, std::optional< BPMNOS::number > > values
Attribute values.
const BPMN::Process * process