Make a KernelObject base class for all Capabilities.
This commit is contained in:
parent
d358c1d672
commit
4e278a4664
9 changed files with 50 additions and 21 deletions
|
|
@ -6,6 +6,9 @@ class RefPtr;
|
|||
template <typename T>
|
||||
RefPtr<T> AdoptPtr(T* ptr);
|
||||
|
||||
template <typename T, typename U>
|
||||
RefPtr<T> StaticCastRefPtr(const RefPtr<U>& ref);
|
||||
|
||||
template <typename T>
|
||||
class RefPtr {
|
||||
public:
|
||||
|
|
@ -38,6 +41,11 @@ class RefPtr {
|
|||
return *this;
|
||||
}
|
||||
|
||||
enum DontAdoptTag {
|
||||
DontAdopt,
|
||||
};
|
||||
RefPtr(T* ptr, DontAdoptTag) : ptr_(ptr) { ptr->Acquire(); }
|
||||
|
||||
T* get() const { return ptr_; };
|
||||
T& operator*() const { return *ptr_; }
|
||||
T* operator->() const { return ptr_; }
|
||||
|
|
@ -74,3 +82,8 @@ template <typename T>
|
|||
RefPtr<T> AdoptPtr(T* ptr) {
|
||||
return RefPtr(ptr);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
RefPtr<T> StaticCastRefPtr(const RefPtr<U>& ref) {
|
||||
return RefPtr(static_cast<T*>(ref.get()), RefPtr<T>::DontAdopt);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue