1 /* Copyright (c) 2004-2018. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMGRID_KERNEL_RESOURCE_MODEL_HPP
7 #define SIMGRID_KERNEL_RESOURCE_MODEL_HPP
9 #include "src/kernel/resource/Action.hpp"
15 /** @ingroup SURF_interface
16 * @brief SURF model interface class
17 * @details A model is an object which handle the interactions between its Resources and its Actions
19 XBT_PUBLIC_CLASS Model
25 /** @brief Get the set of [actions](@ref Action) in *ready* state */
26 virtual ActionList* getReadyActionSet() const { return readyActionSet_; }
28 /** @brief Get the set of [actions](@ref Action) in *running* state */
29 virtual ActionList* getRunningActionSet() const { return runningActionSet_; }
31 /** @brief Get the set of [actions](@ref Action) in *failed* state */
32 virtual ActionList* getFailedActionSet() const { return failedActionSet_; }
34 /** @brief Get the set of [actions](@ref Action) in *done* state */
35 virtual ActionList* getDoneActionSet() const { return doneActionSet_; }
37 /** @brief Get the set of modified [actions](@ref Action) */
38 virtual ActionLmmListPtr getModifiedSet() const { return modifiedSet_; }
40 /** @brief Get the maxmin system of the current Model */
41 lmm_system_t getMaxminSystem() const { return maxminSystem_; }
44 * @brief Get the update mechanism of the current Model
47 e_UM_t getUpdateMechanism() const { return updateMechanism_; }
48 void setUpdateMechanism(e_UM_t mechanism) { updateMechanism_ = mechanism; }
50 /** @brief Get Action heap */
51 heap_type& getActionHeap() { return actionHeap_; }
53 double actionHeapTopDate() const { return actionHeap_.top().first; }
54 Action* actionHeapPop();
55 bool actionHeapIsEmpty() const { return actionHeap_.empty(); }
58 * @brief Share the resources between the actions
60 * @param now The current time of the simulation
61 * @return The delta of time till the next action will finish
63 virtual double nextOccuringEvent(double now);
64 virtual double nextOccuringEventLazy(double now);
65 virtual double nextOccuringEventFull(double now);
68 * @brief Update action to the current time
70 * @param now The current time of the simulation
71 * @param delta The delta of time since the last update
73 virtual void updateActionsState(double now, double delta);
74 virtual void updateActionsStateLazy(double now, double delta);
75 virtual void updateActionsStateFull(double now, double delta);
77 /** @brief Returns whether this model have an idempotent shareResource()
79 * The only model that is not is NS3: computing the next timestamp moves the model up to that point,
80 * so we need to call it only when the next timestamp of other sources is computed.
82 virtual bool nextOccuringEventIsIdempotent() { return true; }
85 ActionLmmListPtr modifiedSet_;
86 lmm_system_t maxminSystem_ = nullptr;
87 bool selectiveUpdate_;
90 e_UM_t updateMechanism_ = UM_UNDEFINED;
91 ActionList* readyActionSet_; /**< Actions in state SURF_ACTION_READY */
92 ActionList* runningActionSet_; /**< Actions in state SURF_ACTION_RUNNING */
93 ActionList* failedActionSet_; /**< Actions in state SURF_ACTION_FAILED */
94 ActionList* doneActionSet_; /**< Actions in state SURF_ACTION_DONE */
95 heap_type actionHeap_;
99 } // namespace simgrid
100 } // namespace simgrid