8#include "CogsVersion.h"
10#include "Foundation/Platform/Module.h"
100 virtual const void *
getPublicAPI()
const {
return reinterpret_cast<const void*
>(-1); }
123 static bool hasExtension(
const StringView & key,
bool silent =
false);
132 static void* getExtensionSymbol(
const char* extension,
const char* name);
138 static void initializeStatic();
144 static void initialize(
Context * context);
149 static void cleanup(
Context * context);
154 static void remove(
Context * context);
177 static const void * loadExtensionModule(
const std::string & path,
void ** modulehandle =
nullptr, ExtensionModuleLoadResult * result =
nullptr);
187 template<
typename API>
189 void* moduleHandle =
nullptr;
190 const void* api = loadExtensionModule(path, &moduleHandle);
192 if (moduleHandle && api && (api !=
reinterpret_cast<void*
>(-1))) {
207 template<
typename ComponentSystemType>
210 auto system = context->
engine->registerSystem<ComponentSystemType>(systemPriority,
nullptr, capacity);
226 template<
typename ComponentSystemType>
229 return static_cast<ComponentSystemType *
>(context->
getExtensionSystem(ComponentSystemType::getTypeId()));
236 static std::vector<Extension *> & getExtensions();
238 static std::deque<Extension *> & getDelayedExtensions();
240 static std::vector<Context *> contexts;
241 static bool initialized;
A Context instance contains all the services, systems and runtime components needed to use Cogs.
class ComponentSystemBase * getExtensionSystem(const uint16_t id)
Retrieve the system with the given id.
void registerExtensionSystem(const uint16_t id, class ComponentSystemBase *system)
Register an extension component system using the given id.
std::unique_ptr< class Engine > engine
Engine instance.
Extension registry used to host and manage extension instances.
static ComponentSystemType * getExtensionSystem(Context *context)
Retrieve the extension component system of the given template type.
static ModuleAPI< API > loadExtensionModule(const std::string &path)
Loads the extension module with the given name.
static ComponentSystemType * registerExtensionSystem(Context *context, SystemPriority::ESystemPriority systemPriority, uint32_t capacity)
Registers an instance of the given component system type in the extension system registry.
ExtensionModuleLoadResult
Defines possible results of an extension module load.
Helper class for shared libraries that implement the getPublicAPI function and provide a structure of...
Provides a weakly referenced view over the contents of a string.
@ Success
Resource activated successfully.
@ Failure
Resource activation failed.
Contains all Cogs related functionality.
Defines an extension to Cogs.Core and provides methods to override in order to initialize extension c...
virtual void cleanup(Context *)
Cleanup context bound extension content.
virtual bool initialize(Context *)
Initialize extension for the given context.
virtual const void * getPublicAPI() const
Retrieve a pointer to a struct containing all publicly available function pointers.
virtual bool initializeStatic()
Initialize extension statically.
virtual void * getSymbolPointer(const char *) const
Get pointer to symbol defined by extension.
virtual const char * getExtensionKey() const =0
Get the extensions unique key, used to check for extension presence and retrieve extension specific d...
ESystemPriority
Defines priority values for systems.