| // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| #ifndef BASE_MAC_SCOPED_IOOBJECT_H_ |
| #define BASE_MAC_SCOPED_IOOBJECT_H_ |
| #include <IOKit/IOKitLib.h> |
| #include "base/basictypes.h" |
| #include "base/compiler_specific.h" |
| // Just like ScopedCFTypeRef but for io_object_t and subclasses. |
| typedef IOT element_type; |
| explicit ScopedIOObject(IOT object = IO_OBJECT_NULL) |
| IOObjectRelease(object_); |
| void reset(IOT object = IO_OBJECT_NULL) { |
| IOObjectRelease(object_); |
| bool operator==(IOT that) const { |
| bool operator!=(IOT that) const { |
| void swap(ScopedIOObject& that) { |
| IOT release() WARN_UNUSED_RESULT { |
| object_ = IO_OBJECT_NULL; |
| DISALLOW_COPY_AND_ASSIGN(ScopedIOObject); |
| #endif // BASE_MAC_SCOPED_IOOBJECT_H_ |