summaryrefslogtreecommitdiff
path: root/src/KingSystem/Resource/resCache.h
blob: 8326ab309ed05f3aabbf9266a79193904ff32afe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once

#include <hostio/seadHostIONode.h>
#include "KingSystem/Resource/resHandle.h"
#include "KingSystem/Resource/resUnit.h"
#include "KingSystem/Utils/Container/StrTreeMap.h"
#include "KingSystem/Utils/Types.h"

namespace ksys::res {

class ControlTaskData;

class Cache : public sead::hostio::Node {
public:
    Cache();
    virtual ~Cache() = default;

    void init();
    ResourceUnit* findUnit(const ResourceUnitMapNode::KeyType& key) const;
    Handle::Status loadResource(const ControlTaskData& data);

    void eraseUnit(ResourceUnit* unit);
    void eraseUnits();

private:
    void removeUnitAndClearCache_(ResourceUnit* unit);

    // This seems to be unused.
    [[maybe_unused]] u8 _8 = 2;
    util::StrTreeMap<ResourceUnitMapNode> mMap;
};
KSYS_CHECK_SIZE_NX150(Cache, 0x18);

}  // namespace ksys::res