Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
observed_ptr.cpp
Go to the documentation of this file.
1// Copyright 2019 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "core/fxcrt/observed_ptr.h"
6
7#include "third_party/base/check.h"
8#include "third_party/base/containers/contains.h"
9
10namespace fxcrt {
11
12Observable::Observable() = default;
13
17
19 DCHECK(!pdfium::Contains(m_Observers, pObserver));
20 m_Observers.insert(pObserver);
21}
22
24 DCHECK(pdfium::Contains(m_Observers, pObserver));
25 m_Observers.erase(pObserver);
26}
27
29 for (auto* pObserver : m_Observers)
30 pObserver->OnObservableDestroyed();
31 m_Observers.clear();
32}
33
34} // namespace fxcrt
void AddObserver(ObserverIface *pObserver)
void RemoveObserver(ObserverIface *pObserver)