X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0f5828869a4c6d79018e8eca27a10d0fe51979e5..8372ae97612f27b84e8d75aeeed9de0ba6d2ba6a:/include/simgrid/kernel/resource/Model.hpp diff --git a/include/simgrid/kernel/resource/Model.hpp b/include/simgrid/kernel/resource/Model.hpp index 5de68af026..83076bebf1 100644 --- a/include/simgrid/kernel/resource/Model.hpp +++ b/include/simgrid/kernel/resource/Model.hpp @@ -8,19 +8,6 @@ #include -extern "C" { - -/** @brief Possible update mechanisms */ -enum e_UM_t { - UM_FULL, /**< Full update mechanism: the remaining time of every action is recomputed at each step */ - UM_LAZY, /**< Lazy update mechanism: only the modified actions get recomputed. - It may be slower than full if your system is tightly coupled to the point where every action - gets recomputed anyway. In that case, you'd better not try to be cleaver with lazy and go for - a simple full update. */ - UM_UNDEFINED /**< Mechanism not defined */ -}; -} - namespace simgrid { namespace kernel { namespace resource { @@ -31,33 +18,42 @@ namespace resource { */ class XBT_PUBLIC Model { public: - Model(); + /** @brief Possible update mechanisms */ + enum class UpdateAlgo { + Full, /**< Full update mechanism: the remaining time of every action is recomputed at each step */ + Lazy /**< Lazy update mechanism: only the modified actions get recomputed. + It may be slower than full if your system is tightly coupled to the point where every action + gets recomputed anyway. In that case, you'd better not try to be cleaver with lazy and go for + a simple full update. */ + }; + + explicit Model(Model::UpdateAlgo algo); + virtual ~Model(); /** @brief Get the set of [actions](@ref Action) in *ready* state */ - ActionList* getReadyActionSet() const { return ready_action_set_; } + Action::StateSet* get_ready_action_set() const { return ready_action_set_; } /** @brief Get the set of [actions](@ref Action) in *running* state */ - ActionList* getRunningActionSet() const { return running_action_set_; } + Action::StateSet* get_running_action_set() const { return running_action_set_; } /** @brief Get the set of [actions](@ref Action) in *failed* state */ - ActionList* getFailedActionSet() const { return failed_action_set_; } + Action::StateSet* get_failed_action_set() const { return failed_action_set_; } /** @brief Get the set of [actions](@ref Action) in *done* state */ - ActionList* getDoneActionSet() const { return done_action_set_; } + Action::StateSet* get_done_action_set() const { return done_action_set_; } /** @brief Get the set of modified [actions](@ref Action) */ - ActionLmmListPtr getModifiedSet() const; + Action::ModifiedSet* get_modified_set() const; /** @brief Get the maxmin system of the current Model */ - lmm::System* getMaxminSystem() const { return maxmin_system_; } + lmm::System* get_maxmin_system() const { return maxmin_system_; } - /** - * @brief Get the update mechanism of the current Model - * @see e_UM_t - */ - e_UM_t getUpdateMechanism() const { return update_mechanism_; } - void setUpdateMechanism(e_UM_t mechanism) { update_mechanism_ = mechanism; } + /** @brief Set the maxmin system of the current Model */ + void set_maxmin_system(lmm::System* system) { maxmin_system_ = system; } + + /** @brief Get the update mechanism of the current Model */ + UpdateAlgo getUpdateMechanism() const { return update_algorithm_; } /** @brief Get Action heap */ heap_type& getActionHeap() { return action_heap_; } @@ -72,9 +68,9 @@ public: * @param now The current time of the simulation * @return The delta of time till the next action will finish */ - virtual double nextOccuringEvent(double now); - virtual double nextOccuringEventLazy(double now); - virtual double nextOccuringEventFull(double now); + virtual double next_occuring_event(double now); + virtual double next_occuring_event_lazy(double now); + virtual double next_occuring_event_full(double now); /** * @brief Update action to the current time @@ -82,9 +78,9 @@ public: * @param now The current time of the simulation * @param delta The delta of time since the last update */ - virtual void updateActionsState(double now, double delta); - virtual void updateActionsStateLazy(double now, double delta); - virtual void updateActionsStateFull(double now, double delta); + virtual void update_actions_state(double now, double delta); + virtual void update_actions_state_lazy(double now, double delta); + virtual void update_actions_state_full(double now, double delta); /** @brief Returns whether this model have an idempotent shareResource() * @@ -93,15 +89,13 @@ public: */ virtual bool nextOccuringEventIsIdempotent() { return true; } -protected: - lmm::System* maxmin_system_ = nullptr; - private: - e_UM_t update_mechanism_ = UM_UNDEFINED; - ActionList* ready_action_set_ = new ActionList(); /**< Actions in state SURF_ACTION_READY */ - ActionList* running_action_set_ = new ActionList(); /**< Actions in state SURF_ACTION_RUNNING */ - ActionList* failed_action_set_ = new ActionList(); /**< Actions in state SURF_ACTION_FAILED */ - ActionList* done_action_set_ = new ActionList(); /**< Actions in state SURF_ACTION_DONE */ + lmm::System* maxmin_system_ = nullptr; + const UpdateAlgo update_algorithm_; + Action::StateSet* ready_action_set_ = new Action::StateSet(); /**< Actions in state SURF_ACTION_READY */ + Action::StateSet* running_action_set_ = new Action::StateSet(); /**< Actions in state SURF_ACTION_RUNNING */ + Action::StateSet* failed_action_set_ = new Action::StateSet(); /**< Actions in state SURF_ACTION_FAILED */ + Action::StateSet* done_action_set_ = new Action::StateSet(); /**< Actions in state SURF_ACTION_DONE */ heap_type action_heap_; };