.. _program_listing_file_simulations_simulation.h: Program Listing for File simulation.h ===================================== |exhale_lsh| :ref:`Return to documentation for file ` (``simulations/simulation.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #include #include #include #include #include #include #include "lupnt/agents/agent.h" #include "lupnt/agents/constellation.h" #include "lupnt/core/definitions.h" #include "lupnt/core/event.h" #include "lupnt/interfaces/cesium.h" #include "lupnt/measurements/channel.h" #include "lupnt/simulations/world.h" namespace lupnt { class Simulation : public Object { private: Config config_; Real time_ = 0.0; std::string name_; std::priority_queue queue_; Real duration_ = 0.0; bool running_ = false; bool setup_complete_ = false; std::unordered_map>> subscribers_; std::unordered_map> agents_; std::unordered_map> channels_; std::unordered_map> constellations_; Ptr world_; // shared read-only environment (built from the `world:` config block) Ptr cesium_viewer_; public: Simulation() = default; Simulation(Config& config); virtual void Setup(); virtual void Precompute(); void Schedule(Real time, const std::function& func, Real freq = Event::SINGLE_EVENT, Event::Priority priority = Event::Priority::LOW); void Schedule(const Event& e); void SetDuration(Real time) { duration_ = time; } virtual void Run(); Real GetDuration() { return duration_; } Real GetTime() { return time_; } void Subscribe(const std::string& topic, std::function callback); void Publish(double time, const std::string& topic, const std::any& message); Channel* GetChannel(const std::string& name); Agent* GetAgent(const std::string& name); World* GetWorld() const { return world_.get(); } void SetWorld(Ptr world) { world_ = std::move(world); if (world_) world_->SetSimulation(this); } CesiumViewer* GetCesiumViewer() { return cesium_viewer_.get(); } }; }; // namespace lupnt