GetObjectsByType.
This commit is contained in:
parent
dcb78cc640
commit
55e65f4ad6
|
@ -185,6 +185,20 @@ XObject* ObjectTable::LookupObject(X_HANDLE handle, bool already_locked) {
|
|||
return object;
|
||||
}
|
||||
|
||||
void ObjectTable::GetObjectsByType(XObject::Type type,
|
||||
std::vector<object_ref<XObject>>& results) {
|
||||
std::lock_guard<xe::mutex> lock(table_mutex_);
|
||||
for (uint32_t slot = 0; slot < table_capacity_; ++slot) {
|
||||
auto& entry = table_[slot];
|
||||
if (entry.object) {
|
||||
if (entry.object->type() == type) {
|
||||
entry.object->Retain();
|
||||
results.push_back(object_ref<XObject>(entry.object));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
X_HANDLE ObjectTable::TranslateHandle(X_HANDLE handle) {
|
||||
if (handle == 0xFFFFFFFF) {
|
||||
// CurrentProcess
|
||||
|
|
|
@ -38,9 +38,18 @@ class ObjectTable {
|
|||
X_STATUS AddNameMapping(const std::string& name, X_HANDLE handle);
|
||||
void RemoveNameMapping(const std::string& name);
|
||||
X_STATUS GetObjectByName(const std::string& name, X_HANDLE* out_handle);
|
||||
template <typename T>
|
||||
std::vector<object_ref<T>> GetObjectsByType(XObject::Type type) {
|
||||
std::vector<object_ref<T>> results;
|
||||
GetObjectsByType(
|
||||
type, *reinterpret_cast<std::vector<object_ref<XObject>>*>(&results));
|
||||
return results;
|
||||
}
|
||||
|
||||
private:
|
||||
XObject* LookupObject(X_HANDLE handle, bool already_locked);
|
||||
void GetObjectsByType(XObject::Type type,
|
||||
std::vector<object_ref<XObject>>& results);
|
||||
|
||||
X_HANDLE TranslateHandle(X_HANDLE handle);
|
||||
X_STATUS FindFreeSlot(uint32_t* out_slot);
|
||||
|
|
Loading…
Reference in New Issue