Max OS 0.3
Loading...
Searching...
No Matches
MaxOS::processes::resources::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 BaseResourceRegistry * get_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 101 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 141 of file resource.cpp.

141 {
142 s_current = this;
143
144}

◆ ~GlobalResourceRegistry()

GlobalResourceRegistry::~GlobalResourceRegistry ( )

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

Definition at line 149 of file resource.cpp.

149 {
150 if(s_current == this)
151 s_current = nullptr;
152
153}

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 176 of file resource.cpp.

176 {
177
178 // Does it already exist?
179 if(s_current->m_registries.find(type) != s_current->m_registries.end())
180 return;
181
182 s_current->m_registries.insert(type, registry);
183}

Referenced by MaxOS::processes::resources::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 161 of file resource.cpp.

161 {
162
163 auto registry = s_current->m_registries.find(type);
164 if(registry == s_current->m_registries.end())
165 return nullptr;
166
167 return registry->second;
168}

Referenced by MaxOS::processes::resources::BridgeHandler::BridgeHandler(), MaxOS::processes::resources::ResourceManager::close_resource(), MaxOS::processes::resources::ResourceManager::open_resource(), and MaxOS::system::SyscallManager::syscall_resource_create().

◆ 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 190 of file resource.cpp.

190 {
191
192 // Does it already exist?
193 if(s_current->m_registries.find(registry->type()) == s_current->m_registries.end())
194 return;
195
196 s_current->m_registries.erase(registry->type());
197
198}
resource_type_t type()
Gets the type of resources this registry handles.
Definition resource.cpp:41

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

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


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