]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.cpp
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / tools / lldb-mi / MICmdMgrSetCmdDeleteCallback.cpp
1 //===-- MICmdMgrSetCmdDeleteCallback.cpp ------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // In-house headers:
10 #include "MICmdMgrSetCmdDeleteCallback.h"
11
12 namespace CMICmdMgrSetCmdDeleteCallback {
13
14 //++
15 // Details: CSetClients constructor.
16 // Type:    Method.
17 // Args:    None.
18 // Return:  None.
19 // Throws:  None.
20 //--
21 CSetClients::CSetClients() : m_bClientUnregistered(false) {}
22
23 //++
24 // Details: CSetClients destructor.
25 // Type:    Method.
26 // Args:    None.
27 // Return:  None.
28 // Throws:  None.
29 //--
30 CSetClients::~CSetClients() {}
31
32 //++
33 // Details: Register an object to be called when a command object is deleted.
34 // Type:    Method.
35 // Args:    vObject - (R) A new interested client.
36 // Return:  MIstatus::success - Functional succeeded.
37 //          MIstatus::failure - Functional failed.
38 // Throws:  None.
39 //--
40 bool CSetClients::Register(ICallback &vObject) {
41   insert(&vObject);
42
43   return MIstatus::success;
44 }
45
46 //++
47 // Details: Unregister an object from being called when a command object is
48 // deleted.
49 // Type:    Method.
50 // Args:    vObject - (R) The was interested client.
51 // Return:  MIstatus::success - Functional succeeded.
52 //          MIstatus::failure - Functional failed.
53 // Throws:  None.
54 //--
55 bool CSetClients::Unregister(ICallback &vObject) {
56   m_bClientUnregistered = true;
57   erase(&vObject);
58
59   return MIstatus::success;
60 }
61
62 //++
63 // Details: Iterate all interested clients and tell them a command is being
64 // deleted.
65 // Type:    Method.
66 // Args:    vCmd    - (RW) The command to be deleted.
67 // Return:  MIstatus::success - Functional succeeded.
68 //          MIstatus::failure - Functional failed.
69 // Throws:  None.
70 //--
71 void CSetClients::Delete(SMICmdData &vCmd) {
72   m_bClientUnregistered = false; // Reset
73   iterator it = begin();
74   while (it != end()) {
75     ICallback *pObj = *it;
76     pObj->Delete(vCmd);
77
78     if (m_bClientUnregistered) {
79       m_bClientUnregistered = false; // Reset
80       it = begin();
81     } else
82       // Next
83       ++it;
84   }
85 }
86
87 } // namespace CMICmdMgrSetCmdDeleteCallback