Cogs.Core
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes | List of all members
Cogs::Core::Context Class Reference

A Context instance contains all the services, systems and runtime components needed to use Cogs. More...

#include <Context.h>

Inheritance diagram for Cogs::Core::Context:
Cogs::Core::ContextBase

Classes

struct  Callbacks
 Context callbacks. More...
 
struct  Debug
 Debugging context. More...
 

Public Member Functions

 Context (const char **variables, int count)
 Constructs a new context instance, initializing all services, an engine instance, and extension systems.
 
 ~Context () override
 Destructs a context instance.
 
bool createDevice ()
 
void initialize ()
 Initialize all services and component systems.
 
void clear ()
 Does clearing of context.
 
void initializeDynamicComponents ()
 Initialize and register dynamic component types.
 
void registerDynamicComponentType (const StringView &typeName)
 Register a dynamic component type with the given typeName.
 
void registerExtensionSystem (const uint16_t id, class ComponentSystemBase *system)
 Register an extension component system using the given id.
 
class ComponentSystemBasegetExtensionSystem (const uint16_t id)
 Retrieve the system with the given id.
 
void update ()
 
void preRender ()
 
ViewContextcreateView (WindowData *windowData)
 
void deleteView (ViewContext *view)
 
void setDefaultView (ViewContext *view)
 
ViewContextgetDefaultView () const
 
std::span< ViewContext * > getViews ()
 

Static Public Member Functions

static void initializeStatic ()
 Perform static initialization of the Context.
 
static void cleanupStatic ()
 Perform static cleanup of the Context.
 

Public Attributes

std::unique_ptr< struct MemoryContextmemory
 Memory and allocation info.
 
std::unique_ptr< class Servicesservices
 Services.
 
std::unique_ptr< class Featuresfeatures
 Features service instance.
 
std::unique_ptr< class Variablesvariables
 Variables service instance.
 
std::unique_ptr< class ResourceUsageLoggerresourceUsageLogger
 Resource usage logger service instance.
 
std::unique_ptr< class TaskManagertaskManager
 TaskManager service instance.
 
std::unique_ptr< class Randomrandom
 Random Number service instance.
 
std::unique_ptr< class ScriptingManagerscriptingManager
 ScriptingManager service instance.
 
std::unique_ptr< class CullingManagercullingManager
 CullingManager instance.
 
std::unique_ptr< class Timetime
 Time service instance.
 
std::unique_ptr< class QualityServicequalityService
 Quality service instance.
 
std::unique_ptr< class DeferredNameResolutiondeferredResolution
 Deferred name resolution service instance.
 
std::unique_ptr< FileSystemWatcherwatcher
 File system watcher.
 
std::unique_ptr< class ResourceStoreresourceStore
 ResourceStore service instance.
 
std::unique_ptr< class RayPickingrayPicking
 RayPicking service instance.
 
std::unique_ptr< class Boundsbounds
 Bounds service instance.
 
std::unique_ptr< class ExtensionSystemsextensionSystems
 Mapping of active extension systems.
 
std::unique_ptr< class Engineengine
 Engine instance.
 
std::unique_ptr< class Scenescene
 Scene structure.
 
class IRendererrenderer
 Renderer.
 
class EntityStorestore
 Entity store.
 
struct Cogs::Core::Context::Debug debug
 
struct Cogs::Core::Context::Callbacks callbacks
 
- Public Attributes inherited from Cogs::Core::ContextBase
class TransformSystemtransformSystem = nullptr
 
class SceneSystemsceneSystem = nullptr
 
class MeshSystemmeshSystem = nullptr
 
class RenderSystemrenderSystem = nullptr
 
class SubMeshRenderSystemsubMeshRenderSystem = nullptr
 
class InstancedMeshRenderSysteminstancedMeshRenderSystem = nullptr
 

Private Attributes

ViewContextdefaultView = nullptr
 
std::vector< ViewContext * > views
 

Detailed Description

A Context instance contains all the services, systems and runtime components needed to use Cogs.

In addition to the engine and core systems, the context contains services, extensions, and additional component systems not part of the core.

The context acts as a kind of service locator for modules in Cogs.Core, allowing them to access services and systems. All references contained herein should be forward declared, ensuring that consumers of dependencies must locally include what's needed to access them.

Definition at line 82 of file Context.h.

Constructor & Destructor Documentation

◆ Context() [1/2]

Cogs::Core::Context::Context ( const char **  variables,
int  count 
)

Constructs a new context instance, initializing all services, an engine instance, and extension systems.

The order of initialization is as follows:

  • Create and initialize all services (such as Variables etc.)
  • Create the Engine instance
  • Create scene services
  • Create and initialize component systems not part of the core. Component system lifetimes are not managed by the context.

Definition at line 106 of file Context.cpp.

References Context(), memory, resourceStore, store, and variables.

Referenced by Context().

◆ Context() [2/2]

Cogs::Core::Context::Context ( )

Definition at line 103 of file Context.cpp.

◆ ~Context()

Cogs::Core::Context::~Context ( )
override

Destructs a context instance.

All services and components are destructed in the order of initialization.

Definition at line 149 of file Context.cpp.

References Cogs::Factory::releaseDevice().

Member Function Documentation

◆ cleanupStatic()

void Cogs::Core::Context::cleanupStatic ( )
static

Perform static cleanup of the Context.

Calling cleanupStatic() twice has no effect but may produce warnings.

Definition at line 214 of file Context.cpp.

◆ clear()

void Cogs::Core::Context::clear ( )

Does clearing of context.

Called by Bridge clearContext

Definition at line 355 of file Context.cpp.

Referenced by Cogs::Core::Engine::~Engine().

◆ createDevice()

bool Cogs::Core::Context::createDevice ( )

Definition at line 229 of file Context.cpp.

◆ createView()

Cogs::Core::ViewContext * Cogs::Core::Context::createView ( WindowData windowData)

Definition at line 449 of file Context.cpp.

◆ deleteView()

void Cogs::Core::Context::deleteView ( ViewContext view)

Definition at line 456 of file Context.cpp.

◆ getDefaultView()

ViewContext * Cogs::Core::Context::getDefaultView ( ) const
inline

Definition at line 167 of file Context.h.

◆ getExtensionSystem()

Cogs::Core::ComponentSystemBase * Cogs::Core::Context::getExtensionSystem ( const uint16_t  id)

Retrieve the system with the given id.

Parameters
idType id of the system to retrieve.
Returns
Pointer to the component system with the given key.

Definition at line 415 of file Context.cpp.

Referenced by Cogs::Core::ExtensionRegistry::getExtensionSystem().

◆ getViews()

std::span< ViewContext * > Cogs::Core::Context::getViews ( )
inline

Definition at line 168 of file Context.h.

◆ initialize()

void Cogs::Core::Context::initialize ( )

◆ initializeDynamicComponents()

void Cogs::Core::Context::initializeDynamicComponents ( )

Initialize and register dynamic component types.

All component types derived from DynamicComponent should be registered here.

Definition at line 362 of file Context.cpp.

◆ initializeStatic()

void Cogs::Core::Context::initializeStatic ( )
static

Perform static initialization of the Context.

All type information will be initialized by calling this method. Calling initializeStatic() twice has no effect but may produce warnings.

Definition at line 189 of file Context.cpp.

References Cogs::Core::ExtensionRegistry::initializeStatic().

◆ preRender()

void Cogs::Core::Context::preRender ( )

Definition at line 433 of file Context.cpp.

◆ registerDynamicComponentType()

void Cogs::Core::Context::registerDynamicComponentType ( const StringView typeName)

◆ registerExtensionSystem()

void Cogs::Core::Context::registerExtensionSystem ( const uint16_t  id,
class ComponentSystemBase system 
)

Register an extension component system using the given id.

Parameters
idId used to retrieve the extension system.
systemPointer to the system to register. Ownership of the system is assumed to reside elsewhere.

Definition at line 404 of file Context.cpp.

References Cogs::Core::ComponentSystemBase::initialize().

Referenced by Cogs::Core::ExtensionRegistry::registerExtensionSystem().

◆ setDefaultView()

void Cogs::Core::Context::setDefaultView ( ViewContext view)
inline

Definition at line 166 of file Context.h.

◆ update()

void Cogs::Core::Context::update ( )

Definition at line 420 of file Context.cpp.

Member Data Documentation

◆ bounds

std::unique_ptr<class Bounds> Cogs::Core::Context::bounds

◆ cullingManager

std::unique_ptr<class CullingManager> Cogs::Core::Context::cullingManager

◆ defaultView

ViewContext* Cogs::Core::Context::defaultView = nullptr
private

Definition at line 319 of file Context.h.

◆ deferredResolution

std::unique_ptr<class DeferredNameResolution> Cogs::Core::Context::deferredResolution

Deferred name resolution service instance.

Definition at line 204 of file Context.h.

Referenced by Cogs::Core::applyFieldValues(), and Cogs::Core::InstancedModelSystem::update().

◆ engine

std::unique_ptr<class Engine> Cogs::Core::Context::engine

◆ extensionSystems

std::unique_ptr<class ExtensionSystems> Cogs::Core::Context::extensionSystems

Mapping of active extension systems.

Definition at line 219 of file Context.h.

◆ features

std::unique_ptr<class Features> Cogs::Core::Context::features

Features service instance.

Definition at line 177 of file Context.h.

◆ memory

std::unique_ptr<struct MemoryContext> Cogs::Core::Context::memory

◆ qualityService

std::unique_ptr<class QualityService> Cogs::Core::Context::qualityService

Quality service instance.

Definition at line 201 of file Context.h.

Referenced by Cogs::Core::OGC3DTilesSystem::pruneTileCache(), Cogs::Core::Engine::update(), and Cogs::Core::AssetSystem::update().

◆ random

std::unique_ptr<class Random> Cogs::Core::Context::random

Random Number service instance.

Definition at line 189 of file Context.h.

◆ rayPicking

std::unique_ptr<class RayPicking> Cogs::Core::Context::rayPicking

◆ renderer

class IRenderer* Cogs::Core::Context::renderer

◆ resourceStore

std::unique_ptr<class ResourceStore> Cogs::Core::Context::resourceStore

◆ resourceUsageLogger

std::unique_ptr<class ResourceUsageLogger> Cogs::Core::Context::resourceUsageLogger

Resource usage logger service instance.

Definition at line 183 of file Context.h.

Referenced by Cogs::Core::Engine::update(), and Cogs::Core::Engine::~Engine().

◆ scene

std::unique_ptr<class Scene> Cogs::Core::Context::scene

Scene structure.

Definition at line 225 of file Context.h.

Referenced by Cogs::Core::AssetSystem::update().

◆ scriptingManager

std::unique_ptr<class ScriptingManager> Cogs::Core::Context::scriptingManager

ScriptingManager service instance.

Definition at line 192 of file Context.h.

Referenced by Cogs::Core::ScriptSystem::update().

◆ services

std::unique_ptr<class Services> Cogs::Core::Context::services

◆ store

class EntityStore* Cogs::Core::Context::store

Entity store.

Definition at line 231 of file Context.h.

Referenced by Cogs::Core::OGC3DTilesSystem::addModelToScene(), Cogs::Core::CreateEntityCommand::apply(), Cogs::Core::ExportCommand::apply(), Cogs::Core::ExportGltfCommand::apply(), Cogs::Core::SetFieldCommand< T >::apply(), Cogs::Core::PackMeshCommand::apply(), Cogs::Core::applyFieldValues(), Context(), Cogs::Core::OGC3DTilesSystem::destroyComponent(), Cogs::Core::EditorState::eraseInvalidSelected(), Cogs::Core::EditorState::getSelected(), Cogs::Core::Editor::hideUnselected(), Cogs::Core::AxisCube::AxisCubeExtension::initialize(), Cogs::Core::CasingExtension::initialize(), Cogs::Core::CurtainView::CurtainViewExtension::initialize(), Cogs::Core::DrillingExtension::initialize(), Cogs::Core::EchoSounder::EchoSounderExtension::initialize(), Cogs::Core::HeightMap::HeightMapExtension::initialize(), Cogs::Core::Image360Extension::initialize(), Cogs::Core::MultiphaseFlowExtension::initialize(), Cogs::Core::OGC3DTilesExtension::initialize(), Cogs::Core::PotreeExtension::initialize(), Cogs::Core::ProceduralSkyExtension::initialize(), Cogs::Core::SeaCurrentsExtension::initialize(), Cogs::Core::TerrainExtension::initialize(), Cogs::Core::VectorField::VectorFieldExtension::initialize(), Cogs::VideoExtension::VideoExtension::initialize(), Cogs::Core::Volumetric::VolumetricExtension::initialize(), Cogs::Core::WellLogExtension::initialize(), Cogs::Core::Editor::invertVisibility(), Cogs::Core::Editor::isUserRootEntity(), Cogs::Core::EchoSounder::UniformGridSystem::preUpdate(), Cogs::Core::OGC3DTilesSystem::pruneTileCache(), Cogs::Core::Engine::registerSystem(), Cogs::Core::Editor::selectFurthestAway(), Cogs::Core::Scene::setup(), Cogs::Core::Editor::showAll(), Cogs::Core::Editor::showHide(), Cogs::Core::VariableExtrusionSystem::update(), Cogs::Core::GhostSystem::update(), Cogs::Core::RigidBodySystem::update(), Cogs::Core::TriggerSystem::update(), Cogs::Core::EchoSounder::SwathBottomSystem::update(), Cogs::Core::EchoSounder::SwathIsoSystem::update(), Cogs::Core::OGC3DTilesSystem::update(), Cogs::Core::OceanSystem::update(), Cogs::Core::BasicOceanSystem::update(), Cogs::Core::AssetSystem::update(), Cogs::Core::InstancedModelSystem::update(), Cogs::Core::AdaptivePlanarGridSystem::update(), Cogs::Core::EditorState::updateSelectedInfo(), and Cogs::Core::writeEntity().

◆ taskManager

std::unique_ptr<class TaskManager> Cogs::Core::Context::taskManager

TaskManager service instance.

Definition at line 186 of file Context.h.

Referenced by Cogs::Core::BasicOceanSystem::cleanup(), Cogs::Core::ScreenSizeSystem::cleanup(), Cogs::Core::InstancedMeshRenderSystem::cleanup(), Cogs::Core::RenderSystem::cleanup(), Cogs::Core::SubMeshRenderSystem::cleanup(), Cogs::Core::EchoSounder::UniformGridSystem::createComponent(), Cogs::Core::CaptureSystem::destroyComponent(), Cogs::Core::EchoSounder::UniformGridSystem::initialize(), Cogs::Core::BasicOceanSystem::initialize(), Cogs::Core::ScreenSizeSystem::initialize(), Cogs::Core::InstancedMeshRenderSystem::initialize(), Cogs::Core::RenderSystem::initialize(), Cogs::Core::SubMeshRenderSystem::initialize(), Cogs::Core::MeshManager::MeshManager(), Cogs::Core::ModelManager::ModelManager(), Cogs::Core::MeshRenderPicker::pickImpl(), Cogs::Core::BasicOceanSystem::postUpdate(), Cogs::Core::EchoSounder::UniformGridSystem::preUpdate(), Cogs::Core::TransformSystem::update(), Cogs::Core::AnimationSystem::update(), Cogs::Core::VariableExtrusionSystem::update(), Cogs::Core::EchoSounder::OctProviderSystem::update(), Cogs::Core::EchoSounder::PingIsoSystem::update(), Cogs::Core::Volumetric::DensityFieldSystem::update(), Cogs::Core::Volumetric::OctDummyProviderSystem::update(), Cogs::Core::BasicOceanSystem::update(), Cogs::Core::CaptureSystem::update(), Cogs::Core::InstancedMeshRenderSystem::update(), Cogs::Core::RenderSystem::update(), Cogs::Core::SubMeshRenderSystem::update(), and Cogs::Core::Engine::~Engine().

◆ time

std::unique_ptr<class Time> Cogs::Core::Context::time

◆ variables

std::unique_ptr<class Variables> Cogs::Core::Context::variables

◆ views

std::vector<ViewContext*> Cogs::Core::Context::views
private

Definition at line 320 of file Context.h.

◆ watcher

std::unique_ptr<FileSystemWatcher> Cogs::Core::Context::watcher

File system watcher.

Definition at line 207 of file Context.h.


The documentation for this class was generated from the following files: