summaryrefslogtreecommitdiff
path: root/src/core/object.h
blob: e78b1b322f645c65f1f5a7682acb90557967db8c (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
45
46
#ifndef __REFCOUNTED_H__
#define __REFCOUNTED_H__

#include <list>

namespace Coal
{

class Object
{
    public:
        enum Type
        {
            T_Device,
            T_CommandQueue,
            T_Event,
            T_Context,
            T_Kernel,
            T_MemObject,
            T_Program,
            T_Sampler
        };

        Object(Type type, Object *parent = 0);
        virtual ~Object();

        void reference();
        bool dereference();
        unsigned int references() const;
        void setReleaseParent(bool release);

        Object *parent() const;
        Type type() const;
        bool isA(Type type) const;

    private:
        unsigned int p_references;
        Object *p_parent;
        Type p_type;
        std::list<Object *>::iterator p_it;
        bool p_release_parent;
};

}

#endif