michael@0: // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: // This file defines the type used to provide details for NotificationService michael@0: // notifications. michael@0: michael@0: #ifndef CHROME_COMMON_NOTIFICATION_DETAILS_H__ michael@0: #define CHROME_COMMON_NOTIFICATION_DETAILS_H__ michael@0: michael@0: #include "base/basictypes.h" michael@0: michael@0: // Do not declare a NotificationDetails directly--use either michael@0: // "Details(detailsclasspointer)" or michael@0: // NotificationService::NoDetails(). michael@0: class NotificationDetails { michael@0: public: michael@0: NotificationDetails() : ptr_(NULL) {} michael@0: NotificationDetails(const NotificationDetails& other) : ptr_(other.ptr_) {} michael@0: ~NotificationDetails() {} michael@0: michael@0: // NotificationDetails can be used as the index for a map; this method michael@0: // returns the pointer to the current details as an identifier, for use as a michael@0: // map index. michael@0: uintptr_t map_key() const { return reinterpret_cast(ptr_); } michael@0: michael@0: bool operator!=(const NotificationDetails& other) const { michael@0: return ptr_ != other.ptr_; michael@0: } michael@0: michael@0: bool operator==(const NotificationDetails& other) const { michael@0: return ptr_ == other.ptr_; michael@0: } michael@0: michael@0: protected: michael@0: NotificationDetails(void* ptr) : ptr_(ptr) {} michael@0: michael@0: void* ptr_; michael@0: }; michael@0: michael@0: template michael@0: class Details : public NotificationDetails { michael@0: public: michael@0: Details(T* ptr) : NotificationDetails(ptr) {} michael@0: Details(const NotificationDetails& other) michael@0: : NotificationDetails(other) {} michael@0: michael@0: T* operator->() const { return ptr(); } michael@0: T* ptr() const { return static_cast(ptr_); } michael@0: }; michael@0: michael@0: #endif // CHROME_COMMON_NOTIFICATION_DETAILS_H__