]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.cpp
Merge ^/head r274961 through r276472.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / tools / lldb-mi / MICmdMgrSetCmdDeleteCallback.cpp
1 //===-- MICmdMgrSetCmdDeleteCallback.cpp ------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 //++
11 // File:                MICmdMgrSetCmdDeleteCallback.cpp
12 //
13 // Overview:    CSetClients implementation.
14 //
15 // Environment: Compilers:      Visual C++ 12.
16 //                                                      gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
17 //                              Libraries:      See MIReadmetxt. 
18 //
19 // Copyright:   None.
20 //--
21
22 // In-house headers:
23 #include "MICmdMgrSetCmdDeleteCallback.h"
24
25 namespace CMICmdMgrSetCmdDeleteCallback
26 {
27
28 //++ ------------------------------------------------------------------------------------
29 // Details:     CSetClients constructor.
30 // Type:        Method.
31 // Args:        None.
32 // Return:      None.
33 // Throws:      None.
34 //--
35 CSetClients::CSetClients( void )
36 :       m_bClientUnregistered( false )
37 {
38 }
39
40 //++ ------------------------------------------------------------------------------------
41 // Details:     CSetClients destructor.
42 // Type:        Method.
43 // Args:        None.
44 // Return:      None.
45 // Throws:      None.
46 //--
47 CSetClients::~CSetClients( void )
48 {
49 }
50
51 //++ ------------------------------------------------------------------------------------
52 // Details:     Register an object to be called when a command object is deleted.
53 // Type:        Method.
54 // Args:        vObject - (R) A new interested client.
55 // Return:      MIstatus::success - Functional succeeded.
56 //                      MIstatus::failure - Functional failed.
57 // Throws:      None.
58 //--
59 bool CSetClients::Register( ICallback & vObject )
60 {
61         insert( &vObject );
62
63         return MIstatus::success;
64 }
65
66 //++ ------------------------------------------------------------------------------------
67 // Details:     Unregister an object from being called when a command object is deleted.
68 // Type:        Method.
69 // Args:        vObject - (R) The was interested client.
70 // Return:      MIstatus::success - Functional succeeded.
71 //                      MIstatus::failure - Functional failed.
72 // Throws:      None.
73 //--
74 bool CSetClients::Unregister( ICallback & vObject )
75 {
76         m_bClientUnregistered = true;
77         erase( &vObject );
78
79         return MIstatus::success;
80 }
81
82 //++ ------------------------------------------------------------------------------------
83 // Details:     Iterate all interested clients and tell them a command is being deleted.
84 // Type:        Method.
85 // Args:        vCmd    - (RW) The command to be deleted.
86 // Return:      MIstatus::success - Functional succeeded.
87 //                      MIstatus::failure - Functional failed.
88 // Throws:      None.
89 //--
90 void CSetClients::Delete( SMICmdData & vCmd )
91 {
92         m_bClientUnregistered = false;  // Reset
93         iterator it = begin();
94         while( it != end() )
95         {
96                 ICallback * pObj = *it;
97                 pObj->Delete( vCmd );
98
99                 if( m_bClientUnregistered )
100                 {
101                         m_bClientUnregistered = false;  // Reset
102                         it = begin();
103                 }
104                 else
105                         // Next
106                         ++it;
107         }
108 }
109
110 } // namespace CMICmdMgrSetCmdDeleteCallback