[zion] Dynamically check Capability type.
Instead of passing an enum with the capability when creating it, relying on polymorphism and a template struct tag to determine the object type at runtime. This is cleaner and avoids errors where we pass the wrong capability type with the cap and do a bad cast at runtime.
This commit is contained in:
parent
b4902a79ef
commit
a47bac9966
13 changed files with 113 additions and 106 deletions
|
|
@ -2,4 +2,22 @@
|
|||
|
||||
#include "lib/ref_counted.h"
|
||||
|
||||
class KernelObject : public RefCounted<KernelObject> {};
|
||||
class KernelObject : public RefCounted<KernelObject> {
|
||||
public:
|
||||
enum ObjectType {
|
||||
INVALID = 0x0,
|
||||
PROCESS = 0x1,
|
||||
THREAD = 0x2,
|
||||
ADDRESS_SPACE = 0x3,
|
||||
MEMORY_OBJECT = 0x4,
|
||||
CHANNEL = 0x5,
|
||||
PORT = 0x6,
|
||||
};
|
||||
|
||||
virtual uint64_t TypeTag() = 0;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct KernelObjectTag {
|
||||
static const int type = KernelObject::INVALID;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue