Max OS 0.3
Loading...
Searching...
No Matches
MaxOS::processes::GlobalResourceRegistry Class Reference

Manages all the resource registries for each resource type. More...

#include <resource.h>

Public Member Functions

 GlobalResourceRegistry ()
 Constructs a new GlobalResourceRegistry and sets it as the current global registry.
 
 ~GlobalResourceRegistry ()
 Destructor for GlobalResourceRegistry, unsets it as the current global registry if it is.
 

Static Public Member Functions

static BaseResourceRegistryget_registry (resource_type_t type)
 Gets a registry of a type.
 
static void add_registry (resource_type_t type, BaseResourceRegistry *registry)
 Adds a registry to the global list if there is not already one for that type.
 
static void remove_registry (BaseResourceRegistry *registry)
 Adds a registry to the global list if there is not already one for that type.
 

Detailed Description

Manages all the resource registries for each resource type.

Definition at line 121 of file resource.h.

Constructor & Destructor Documentation

◆ GlobalResourceRegistry()

GlobalResourceRegistry::GlobalResourceRegistry ( )

Constructs a new GlobalResourceRegistry and sets it as the current global registry.

Definition at line 197 of file resource.cpp.

197 {
198 s_current = this;
199
200}

◆ ~GlobalResourceRegistry()

GlobalResourceRegistry::~GlobalResourceRegistry ( )

Destructor for GlobalResourceRegistry, unsets it as the current global registry if it is.

Definition at line 205 of file resource.cpp.

205 {
206 if(s_current == this)
207 s_current = nullptr;
208
209}

Member Function Documentation

◆ add_registry()

void GlobalResourceRegistry::add_registry ( resource_type_t  type,
BaseResourceRegistry registry 
)
static

Adds a registry to the global list if there is not already one for that type.

Parameters
typeThe type of registry being added
registryThe registry to add

Definition at line 232 of file resource.cpp.

232 {
233
234 // Does it already exist?
235 if(s_current->m_registries.find(type) != s_current->m_registries.end())
236 return;
237
238 s_current->m_registries.insert(type, registry);
239}

Referenced by MaxOS::processes::BaseResourceRegistry::BaseResourceRegistry().

◆ get_registry()

BaseResourceRegistry * GlobalResourceRegistry::get_registry ( resource_type_t  type)
static

Gets a registry of a type.

Parameters
typeThe type of registry to get
Returns
The registry or nullptr if not found

Definition at line 217 of file resource.cpp.

217 {
218
219 auto registry = s_current->m_registries.find(type);
220 if(registry == s_current->m_registries.end())
221 return nullptr;
222
223 return registry->second;
224}

Referenced by MaxOS::processes::ResourceManager::close_resource(), MaxOS::processes::ResourceManager::open_resource(), MaxOS::system::SyscallManager::syscall_resource_create(), MaxOS::filesystem::FileResource::write(), and MaxOS::filesystem::DirectoryResource::write().

◆ remove_registry()

void GlobalResourceRegistry::remove_registry ( BaseResourceRegistry registry)
static

Adds a registry to the global list if there is not already one for that type.

Parameters
registryThe registry to add

Definition at line 246 of file resource.cpp.

246 {
247
248 // Does it already exist?
249 if(s_current->m_registries.find(registry->type()) == s_current->m_registries.end())
250 return;
251
252 s_current->m_registries.erase(registry->type());
253
254}
resource_type_t type()
Gets the type of resources this registry handles.
Definition resource.cpp:117

References MaxOS::processes::BaseResourceRegistry::type().

Referenced by MaxOS::processes::BaseResourceRegistry::~BaseResourceRegistry().


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