1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2013 Inktank Storage, Inc.
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #ifndef CEPH_TRACKEDINTPTR_H
16 #define CEPH_TRACKEDINTPTR_H
24 TrackedIntPtr() : ptr(NULL), id(0) {}
25 TrackedIntPtr(T *ptr) : ptr(ptr), id(ptr ? get_with_id(ptr) : 0) {}
32 void swap(TrackedIntPtr &other) {
34 uint64_t oid = other.id;
40 TrackedIntPtr(const TrackedIntPtr &rhs) :
41 ptr(rhs.ptr), id(ptr ? get_with_id(ptr) : 0) {}
43 TrackedIntPtr& operator=(const TrackedIntPtr &rhs) {
44 TrackedIntPtr o(rhs.ptr);
48 T &operator*() const {
51 T *operator->() const {
54 T *get() const { return ptr; }
56 operator bool() const {
59 bool operator<(const TrackedIntPtr &lhs) const {
62 bool operator==(const TrackedIntPtr &lhs) const {
63 return ptr == lhs.ptr;