From: Martin Quinson Date: Sat, 10 Mar 2018 13:44:34 +0000 (+0100) Subject: change simgrid::surf::Resource into simgrid::kernel::model::Resource X-Git-Tag: v3.19~101 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/07eb08dd092e89871ab3ed9fcf41ad0219598e3b?hp=6b32b23aea39e895a5aca1fbd6613337ca1ae47c change simgrid::surf::Resource into simgrid::kernel::model::Resource --- diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index 156c99355a..67ba4588bc 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -47,6 +47,9 @@ class Constraint; class ConstraintLight; class System; } +namespace model { +class Resource; +} namespace routing { class NetPoint; class NetZoneImpl; @@ -59,7 +62,6 @@ namespace simix { } namespace surf { - class Resource; class Cpu; class LinkImpl; class HostImpl; @@ -81,7 +83,7 @@ typedef simgrid::s4u::NetZone s4u_NetZone; typedef simgrid::s4u::VirtualMachine s4u_VM; typedef boost::intrusive_ptr smx_activity_t; typedef simgrid::kernel::routing::NetPoint routing_NetPoint; -typedef simgrid::surf::Resource surf_Resource; +typedef simgrid::kernel::model::Resource surf_Resource; typedef simgrid::trace_mgr::trace tmgr_Trace; typedef simgrid::kernel::context::Context* smx_context_t; diff --git a/src/surf/StorageImpl.hpp b/src/surf/StorageImpl.hpp index e0b4112dd1..20ccd5571f 100644 --- a/src/surf/StorageImpl.hpp +++ b/src/surf/StorageImpl.hpp @@ -80,7 +80,7 @@ public: * @brief SURF storage interface class * @details A Storage represent a storage unit (e.g.: hard drive, usb key) */ -class StorageImpl : public Resource, public PropertyHolder { +class StorageImpl : public kernel::model::Resource, public PropertyHolder { public: /** @brief Storage constructor */ StorageImpl(Model* model, std::string name, lmm_system_t maxminSystem, double bread, double bwrite, diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index 5a02c5b3b5..e5a92661ea 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -225,7 +225,8 @@ std::list CpuAction::cpus() { for (int i = 0; i < llen; i++) { /* Beware of composite actions: ptasks put links and cpus together */ // extra pb: we cannot dynamic_cast from void*... - Resource* resource = static_cast(getVariable()->get_constraint(i)->get_id()); + kernel::model::Resource* resource = + static_cast(getVariable()->get_constraint(i)->get_id()); Cpu* cpu = dynamic_cast(resource); if (cpu != nullptr) retlist.push_back(cpu); diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index 757bb99133..9a8bdde71b 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -45,7 +45,8 @@ public: * @brief SURF cpu resource interface class * @details A Cpu represent a cpu associated to a host */ -XBT_PUBLIC_CLASS Cpu : public simgrid::surf::Resource { +XBT_PUBLIC_CLASS Cpu : public simgrid::kernel::model::Resource +{ public: /** * @brief Cpu constructor diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 59da83b254..86202a2562 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -202,7 +202,8 @@ namespace simgrid { for (int i = 0; i < llen; i++) { /* Beware of composite actions: ptasks put links and cpus together */ // extra pb: we cannot dynamic_cast from void*... - Resource* resource = static_cast(getVariable()->get_constraint(i)->get_id()); + kernel::model::Resource* resource = + static_cast(getVariable()->get_constraint(i)->get_id()); LinkImpl* link = dynamic_cast(resource); if (link != nullptr) retlist.push_back(link); diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index dab1d629c1..082dc35f07 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -113,7 +113,7 @@ public: * @brief SURF network link interface class * @details A Link represents the link between two [hosts](\ref simgrid::surf::HostImpl) */ -class LinkImpl : public simgrid::surf::Resource, public simgrid::surf::PropertyHolder { +class LinkImpl : public simgrid::kernel::model::Resource, public simgrid::surf::PropertyHolder { protected: LinkImpl(simgrid::surf::NetworkModel* model, const std::string& name, kernel::lmm::Constraint* constraint); ~LinkImpl() override; diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 069dc37556..94ad29d9d8 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -124,7 +124,7 @@ void HostL07Model::updateActionsState(double /*now*/, double delta) while (cnst != nullptr) { i++; void* constraint_id = cnst->get_id(); - if (static_cast(constraint_id)->isOff()) { + if (static_cast(constraint_id)->isOff()) { XBT_DEBUG("Action (%p) Failed!!", &action); action.finish(Action::State::failed); break; diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 59954a7d84..aeba3b6b5e 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -21,7 +21,7 @@ void surf_presolve() double next_event_date = -1.0; tmgr_trace_event_t event = nullptr; double value = -1.0; - simgrid::surf::Resource *resource = nullptr; + simgrid::kernel::model::Resource* resource = nullptr; XBT_DEBUG ("Consume all trace events occurring before the starting time."); while ((next_event_date = future_evt_set->next_date()) != -1.0) { @@ -44,7 +44,7 @@ double surf_solve(double max_date) double time_delta = -1.0; /* duration */ double model_next_action_end = -1.0; double value = -1.0; - simgrid::surf::Resource *resource = nullptr; + simgrid::kernel::model::Resource* resource = nullptr; tmgr_trace_event_t event = nullptr; if (max_date > 0.0) { diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 684d22a961..d887e1f4ae 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -516,9 +516,10 @@ void Model::updateActionsStateFull(double /*now*/, double /*delta*/) ************/ namespace simgrid { -namespace surf { +namespace kernel { +namespace model { -Resource::Resource(Model* model, const std::string& name, kernel::lmm::Constraint* constraint) +Resource::Resource(surf::Model* model, const std::string& name, lmm::Constraint* constraint) : name_(name), model_(model), constraint_(constraint) {} @@ -546,7 +547,7 @@ double Resource::getLoad() return constraint_->get_usage(); } -Model* Resource::model() const +surf::Model* Resource::model() const { return model_; } @@ -571,6 +572,7 @@ kernel::lmm::Constraint* Resource::constraint() const } } +} // namespace kernel } /********** diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index 6722a2d000..9c0859b2e0 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -383,7 +383,8 @@ struct s_surf_metric_t { }; namespace simgrid { -namespace surf { +namespace kernel { +namespace model { /** @ingroup SURF_interface * @brief SURF resource interface class @@ -398,12 +399,12 @@ public: * @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 std::string& name, kernel::lmm::Constraint* constraint); + Resource(surf::Model * model, const std::string& name, lmm::Constraint* constraint); virtual ~Resource(); /** @brief Get the Model of the current Resource */ - Model* model() const; + surf::Model* model() const; /** @brief Get the name of the current Resource */ const std::string& getName() const; @@ -437,7 +438,7 @@ public: private: std::string name_; - Model *model_; + surf::Model* model_; bool isOn_ = true; public: /* LMM */ @@ -447,14 +448,17 @@ public: /* LMM */ protected: const kernel::lmm::Constraint* constraint_ = nullptr; }; - +} // namespace model } } namespace std { -template <> class hash { +template <> class hash { public: - std::size_t operator()(const simgrid::surf::Resource& r) const { return (std::size_t)xbt_str_hash(r.getCname()); } + std::size_t operator()(const simgrid::kernel::model::Resource& r) const + { + return (std::size_t)xbt_str_hash(r.getCname()); + } }; } diff --git a/src/surf/trace_mgr.cpp b/src/surf/trace_mgr.cpp index d5e70c1f27..c5b9e2f349 100644 --- a/src/surf/trace_mgr.cpp +++ b/src/surf/trace_mgr.cpp @@ -121,7 +121,7 @@ tmgr_trace_t tmgr_trace_new_from_file(std::string filename) } /** @brief Registers a new trace into the future event set, and get an iterator over the integrated trace */ -tmgr_trace_event_t simgrid::trace_mgr::future_evt_set::add_trace(tmgr_trace_t trace, surf::Resource* resource) +tmgr_trace_event_t simgrid::trace_mgr::future_evt_set::add_trace(tmgr_trace_t trace, kernel::model::Resource* resource) { tmgr_trace_event_t trace_iterator = nullptr; @@ -146,7 +146,7 @@ double simgrid::trace_mgr::future_evt_set::next_date() const /** @brief Retrieves the next occurring event, or nullptr if none happens before #date */ tmgr_trace_event_t simgrid::trace_mgr::future_evt_set::pop_leq(double date, double* value, - simgrid::surf::Resource** resource) + kernel::model::Resource** resource) { double event_date = next_date(); if (event_date > date) diff --git a/src/surf/trace_mgr.hpp b/src/surf/trace_mgr.hpp index 955ff2a041..a3a8aa0db4 100644 --- a/src/surf/trace_mgr.hpp +++ b/src/surf/trace_mgr.hpp @@ -87,8 +87,8 @@ public: future_evt_set(); virtual ~future_evt_set(); double next_date() const; - tmgr_trace_event_t pop_leq(double date, double* value, simgrid::surf::Resource** resource); - tmgr_trace_event_t add_trace(tmgr_trace_t trace, simgrid::surf::Resource * resource); + tmgr_trace_event_t pop_leq(double date, double* value, simgrid::kernel::model::Resource** resource); + tmgr_trace_event_t add_trace(tmgr_trace_t trace, simgrid::kernel::model::Resource * resource); private: typedef std::pair Qelt; diff --git a/src/surf/trace_mgr_test.cpp b/src/surf/trace_mgr_test.cpp index 4bdb1d7574..a63420b93e 100644 --- a/src/surf/trace_mgr_test.cpp +++ b/src/surf/trace_mgr_test.cpp @@ -23,9 +23,9 @@ namespace tmgr = simgrid::trace_mgr; XBT_LOG_NEW_DEFAULT_CATEGORY(unit, "Unit tests of the Trace Manager"); double thedate; -class MockedResource : public simgrid::surf::Resource { +class MockedResource : public simgrid::kernel::model::Resource { public: - explicit MockedResource() : simgrid::surf::Resource(nullptr, "fake", nullptr) {} + explicit MockedResource() : simgrid::kernel::model::Resource(nullptr, "fake", nullptr) {} void apply_event(tmgr_trace_event_t event, double value) { XBT_VERB("t=%.1f: Change value to %lg (idx: %u)", thedate, value, event->idx); @@ -49,7 +49,7 @@ static void trace2vector(const char* str, std::vector* whereto while (fes.next_date() <= 20.0 && fes.next_date() >= 0) { thedate = fes.next_date(); double value; - simgrid::surf::Resource* res; + simgrid::kernel::model::Resource* res; tmgr_trace_event_t it = fes.pop_leq(thedate, &value, &res); if (it == nullptr) continue;