+typedef Action::ActionList ActionList;
+
+typedef boost::intrusive::member_hook<
+ Action, boost::intrusive::list_member_hook<>, &Action::action_lmm_hook> ActionLmmOptions;
+typedef boost::intrusive::list<Action, ActionLmmOptions> ActionLmmList;
+typedef ActionLmmList* ActionLmmListPtr;
+
+/*********
+ * Model *
+ *********/
+
+/** @ingroup SURF_interface
+ * @brief SURF model interface class
+ * @details A model is an object which handle the interactions between its Resources and its Actions
+ */
+XBT_PUBLIC_CLASS Model {
+public:
+ Model();
+ virtual ~Model();
+
+ /** @brief Get the set of [actions](@ref Action) in *ready* state */
+ virtual ActionList* getReadyActionSet() {return readyActionSet_;}
+
+ /** @brief Get the set of [actions](@ref Action) in *running* state */
+ virtual ActionList* getRunningActionSet() {return runningActionSet_;}
+
+ /** @brief Get the set of [actions](@ref Action) in *failed* state */
+ virtual ActionList* getFailedActionSet() {return failedActionSet_;}
+
+ /** @brief Get the set of [actions](@ref Action) in *done* state */
+ virtual ActionList* getDoneActionSet() {return doneActionSet_;}
+
+ /** @brief Get the set of modified [actions](@ref Action) */
+ virtual ActionLmmListPtr getModifiedSet() {return modifiedSet_;}
+
+ /** @brief Get the maxmin system of the current Model */
+ lmm_system_t getMaxminSystem() {return maxminSystem_;}
+
+ /**
+ * @brief Get the update mechanism of the current Model
+ * @see e_UM_t
+ */
+ e_UM_t getUpdateMechanism() {return updateMechanism_;}
+
+ /** @brief Get Action heap */
+ xbt_heap_t getActionHeap() {return actionHeap_;}
+
+ /**
+ * @brief Share the resources between the actions
+ *
+ * @param now The current time of the simulation
+ * @return The delta of time till the next action will finish
+ */
+ virtual double next_occuring_event(double now);
+ virtual double next_occuring_event_lazy(double now);
+ virtual double next_occuring_event_full(double now);
+ double shareResourcesMaxMin(ActionList* running_actions,
+ lmm_system_t sys, void (*solve) (lmm_system_t));
+
+ /**
+ * @brief Update action to the current time
+ *
+ * @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);
+
+ /** @brief Returns whether this model have an idempotent shareResource()
+ *
+ * The only model that is not is NS3: computing the next timestamp moves the model up to that point,
+ * so we need to call it only when the next timestamp of other sources is computed.
+ */
+ virtual bool next_occuring_event_isIdempotent()=0;
+
+protected:
+ ActionLmmListPtr modifiedSet_;
+ lmm_system_t maxminSystem_ = nullptr;
+ e_UM_t updateMechanism_ = UM_UNDEFINED;
+ int selectiveUpdate_;
+ xbt_heap_t actionHeap_;
+
+private:
+ ActionList* readyActionSet_; /**< Actions in state SURF_ACTION_READY */
+ ActionList* runningActionSet_; /**< Actions in state SURF_ACTION_RUNNING */
+ ActionList* failedActionSet_; /**< Actions in state SURF_ACTION_FAILED */
+ ActionList* doneActionSet_; /**< Actions in state SURF_ACTION_DONE */
+};
+
+}
+}
+
+/************
+ * Resource *
+ ************/
+
+/** @ingroup SURF_interface
+ * @brief Resource which have a metric handled by a maxmin system
+ */
+typedef struct {
+ double peak; /**< The peak of the metric, ie its max value */
+ double scale; /**< Current availability of the metric according to the traces, in [0,1] */
+ tmgr_trace_iterator_t event; /**< The associated trace event associated to the metric */
+} s_surf_metric_t;
+
+namespace simgrid {
+namespace surf {
+
+/** @ingroup SURF_interface
+ * @brief SURF resource interface class
+ * @details This is the ancestor class of every resources in SimGrid, such as links, CPU or storage
+ */
+XBT_PUBLIC_CLASS Resource {
+public:
+ /**
+ * @brief Constructor of non-LMM Resources
+ *
+ * @param model Model associated to this Resource
+ * @param name The name of the Resource
+ */
+ Resource(Model *model, const char *name);
+
+ /**
+ * @brief Constructor of LMM Resources
+ *
+ * @param model Model associated to this Resource
+ * @param name The name of the Resource
+ * @param constraint The lmm constraint associated to this Resource if it is part of a LMM component
+ */
+ Resource(Model *model, const char *name, lmm_constraint_t constraint);
+
+ virtual ~Resource();
+
+ /** @brief Get the Model of the current Resource */
+ Model *getModel() const;
+
+ /** @brief Get the name of the current Resource */
+ const char *getName() const;
+
+ bool operator==(const Resource &other) const;
+
+ /**
+ * @brief Apply an event of external load event to that resource
+ *
+ * @param event What happened
+ * @param value [TODO]
+ */
+ virtual void apply_event(tmgr_trace_iterator_t event, double value)=0;
+
+ /** @brief Check if the current Resource is used (if it currently serves an action) */
+ virtual bool isUsed()=0;
+
+ /** @brief Check if the current Resource is active */
+ virtual bool isOn() const;
+ /** @brief Check if the current Resource is shut down */
+ virtual bool isOff() const;
+ /** @brief Turn on the current Resource */
+ virtual void turnOn();
+ /** @brief Turn off the current Resource */
+ virtual void turnOff();
+
+private:
+ const char *name_;
+ Model *model_;
+ bool isOn_ = true;
+
+public: /* LMM */
+ /** @brief Get the lmm constraint associated to this Resource if it is part of a LMM component (or null if none) */
+ lmm_constraint_t getConstraint() const;
+protected:
+ lmm_constraint_t constraint_ = nullptr;
+};
+
+}
+}
+
+namespace std {
+ template <>
+ struct hash<simgrid::surf::Resource>
+ {
+ std::size_t operator()(const simgrid::surf::Resource& r) const
+ {
+ return (std::size_t) xbt_str_hash(r.getName());
+ }
+ };
+}
+