mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 17:04:55 +00:00
Prelim CSimplePool RE work (needs verification)
This commit is contained in:
@@ -9,36 +9,61 @@ CSimplePool::CSimplePool(IFactory& factory)
|
||||
: x30_factory(factory), x34_paramXfer(new TObjOwnerParam<IObjectStore*>(this))
|
||||
{}
|
||||
|
||||
CToken CSimplePool::GetObj(const SObjectTag&, const CVParamTransfer&)
|
||||
CToken CSimplePool::GetObj(const SObjectTag& tag, const CVParamTransfer& paramXfer)
|
||||
{
|
||||
auto iter = std::find_if(x4_resources.begin(), x4_resources.end(), [&tag](std::pair<SObjectTag, CObjectReference*> pair)->bool{
|
||||
return pair.first == tag;
|
||||
});
|
||||
|
||||
if (iter != x4_resources.end())
|
||||
return CToken(iter.second);
|
||||
// TODO: There is some logic missing here, need to figure out what it's doing
|
||||
CObjectReference* ret = new CObjectReference(*this, x30_factory.Build(tag, paramXfer), paramXfer);
|
||||
|
||||
return CToken(ret);
|
||||
}
|
||||
|
||||
CToken CSimplePool::GetObj(const SObjectTag&)
|
||||
CToken CSimplePool::GetObj(const SObjectTag& tag)
|
||||
{
|
||||
return GetObj(tag, x34_paramXfer);
|
||||
}
|
||||
|
||||
CToken CSimplePool::GetObj(char const*)
|
||||
CToken CSimplePool::GetObj(char const* resourceName)
|
||||
{
|
||||
return GetObj(resourceName, x34_paramXfer);
|
||||
}
|
||||
|
||||
CToken CSimplePool::GetObj(char const*, const CVParamTransfer&)
|
||||
CToken CSimplePool::GetObj(char const* resourceName, const CVParamTransfer& paramXfer)
|
||||
{
|
||||
const SObjectTag* tag = x30_factory.GetResourceIdByName(resourceName);
|
||||
return GetObj(*tag, paramXfer);
|
||||
}
|
||||
|
||||
void CSimplePool::HasObject(const SObjectTag&) const
|
||||
bool CSimplePool::HasObject(const SObjectTag& tag) const
|
||||
{
|
||||
auto iter = std::find_if(x4_resources.begin(), x4_resources.end(), [&tag](std::pair<SObjectTag, CObjectReference*> pair)->bool{
|
||||
return pair.first == tag;
|
||||
});
|
||||
|
||||
return iter != x4_resources.end();
|
||||
}
|
||||
|
||||
void CSimplePool::ObjectIsLive(const SObjectTag&) const
|
||||
bool CSimplePool::ObjectIsLive(const SObjectTag&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void CSimplePool::Flush()
|
||||
{
|
||||
}
|
||||
|
||||
void CSimplePool::ObjectUnreferenced(const SObjectTag&)
|
||||
void CSimplePool::ObjectUnreferenced(const SObjectTag& tag)
|
||||
{
|
||||
auto iter = std::find_if(x4_resources.begin(), x4_resources.end(), [&tag](std::pair<SObjectTag, CObjectReference*> pair)->bool{
|
||||
return pair.first == tag;
|
||||
});
|
||||
if (iter != x4_resources.end())
|
||||
x4_resources.erase(iter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ class CObjectReference;
|
||||
|
||||
class CSimplePool : public IObjectStore
|
||||
{
|
||||
std::unordered_map<SObjectTag, CObjectReference*> x4_resources;
|
||||
std::list<std::pair<SObjectTag, CObjectReference*>> x4_resources;
|
||||
//std::unordered_map<SObjectTag, CObjectReference*> x4_resources;
|
||||
IFactory& x30_factory;
|
||||
CVParamTransfer x34_paramXfer;
|
||||
public:
|
||||
@@ -22,8 +23,8 @@ public:
|
||||
CToken GetObj(const SObjectTag&);
|
||||
CToken GetObj(char const*);
|
||||
CToken GetObj(char const*, const CVParamTransfer&);
|
||||
void HasObject(const SObjectTag&) const;
|
||||
void ObjectIsLive(const SObjectTag&) const;
|
||||
bool HasObject(const SObjectTag&) const;
|
||||
bool ObjectIsLive(const SObjectTag&) const;
|
||||
IFactory& GetFactory() const {return x30_factory;}
|
||||
void Flush();
|
||||
void ObjectUnreferenced(const SObjectTag&);
|
||||
|
||||
@@ -15,8 +15,8 @@ public:
|
||||
virtual CToken GetObj(const SObjectTag&)=0;
|
||||
virtual CToken GetObj(char const*)=0;
|
||||
virtual CToken GetObj(char const*, const CVParamTransfer&)=0;
|
||||
virtual void HasObject(const SObjectTag&) const=0;
|
||||
virtual void ObjectIsLive(const SObjectTag&) const=0;
|
||||
virtual bool HasObject(const SObjectTag&) const=0;
|
||||
virtual bool ObjectIsLive(const SObjectTag&) const=0;
|
||||
virtual IFactory& GetFactory() const=0;
|
||||
virtual void Flush()=0;
|
||||
virtual void ObjectUnreferenced(const SObjectTag&)=0;
|
||||
|
||||
Reference in New Issue
Block a user