#ifndef __KERNEL_KOBJECT_H
#define __KERNEL_KOBJECT_H

#include <sys/types.h>
#include <cpp/Uncopyable.h>
#include <List.h>

namespace OS {
namespace Kernel {

class KObject : private Uncopyable {
  public:
	enum KObjectType {
		UNKNOWN,
		THREAD,
		MODULE,
	};

	static const int kInvalidObjectId = -1;

	KObject(enum KObjectType type, const char *name);
	virtual ~KObject();

	void MakeGlobal(); // add to a public hash table
	status_t RemoveFromGlobal(); // remove from the public hash table

	kobj_id Id() const { return mId; }
	enum KObjectType Type() const { return mObjectType; }
	const char *Name() const { return mObjectName; }

	/* static methods */
	static KObject *Lookup(kobj_id, KObjectType = UNKNOWN); // type unknown will return any object

  private:
	kobj_id mId;
	ListNode<KObject> mObjectIdHashNode;
	enum KObjectType mObjectType;
	char mObjectName[32];
};

}} // namespace OS::Kernel

#endif

