summaryrefslogtreecommitdiff
path: root/lib/hkStubs/Havok/Common/Serialize/Resource/hkResource.h
blob: df647006d63a0f025cafabeba8579bd730eee978 (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
35
36
37
38
39
40
41
42
43
44
#pragma once

#include <Havok/Common/Base/hkBase.h>

class hkTypeInfoRegistry;

class hkResource : public hkReferencedObject {
public:
    HK_DECLARE_CLASS_ALLOCATOR(hkResource)

    struct Export {
        HK_DECLARE_CLASS_ALLOCATOR(Export)

        const char* name;
        void* data;
    };

    struct Import {
        HK_DECLARE_CLASS_ALLOCATOR(Import)

        const char* name;
        void** location;
    };

    virtual const char* getName() const = 0;

    ~hkResource() override = default;

    virtual void callDestructors() {}

    virtual void getImportsExports(hkArray<Import>& impOut, hkArray<Export>& expOut) const = 0;

    virtual void* getContentsPointer(const char* typeName,
                                     const hkTypeInfoRegistry* typeRegistry) const = 0;

    template <typename T>
    inline T* getContentsWithRegistry(const hkTypeInfoRegistry* typeRegistry) const;

    template <typename T>
    inline T* getContents() const;

    /// Return the top level object type name.
    virtual const char* getContentsTypeName() const = 0;
};