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 // In-house headers: 11 #include "MICmdMgrSetCmdDeleteCallback.h" 12 13 namespace CMICmdMgrSetCmdDeleteCallback { 14 15 //++ 16 //------------------------------------------------------------------------------------ 17 // Details: CSetClients constructor. 18 // Type: Method. 19 // Args: None. 20 // Return: None. 21 // Throws: None. 22 //-- CSetClients()23CSetClients::CSetClients() : m_bClientUnregistered(false) {} 24 25 //++ 26 //------------------------------------------------------------------------------------ 27 // Details: CSetClients destructor. 28 // Type: Method. 29 // Args: None. 30 // Return: None. 31 // Throws: None. 32 //-- ~CSetClients()33CSetClients::~CSetClients() {} 34 35 //++ 36 //------------------------------------------------------------------------------------ 37 // Details: Register an object to be called when a command object is deleted. 38 // Type: Method. 39 // Args: vObject - (R) A new interested client. 40 // Return: MIstatus::success - Functional succeeded. 41 // MIstatus::failure - Functional failed. 42 // Throws: None. 43 //-- Register(ICallback & vObject)44bool CSetClients::Register(ICallback &vObject) { 45 insert(&vObject); 46 47 return MIstatus::success; 48 } 49 50 //++ 51 //------------------------------------------------------------------------------------ 52 // Details: Unregister an object from being called when a command object is 53 // deleted. 54 // Type: Method. 55 // Args: vObject - (R) The was interested client. 56 // Return: MIstatus::success - Functional succeeded. 57 // MIstatus::failure - Functional failed. 58 // Throws: None. 59 //-- Unregister(ICallback & vObject)60bool CSetClients::Unregister(ICallback &vObject) { 61 m_bClientUnregistered = true; 62 erase(&vObject); 63 64 return MIstatus::success; 65 } 66 67 //++ 68 //------------------------------------------------------------------------------------ 69 // Details: Iterate all interested clients and tell them a command is being 70 // deleted. 71 // Type: Method. 72 // Args: vCmd - (RW) The command to be deleted. 73 // Return: MIstatus::success - Functional succeeded. 74 // MIstatus::failure - Functional failed. 75 // Throws: None. 76 //-- Delete(SMICmdData & vCmd)77void CSetClients::Delete(SMICmdData &vCmd) { 78 m_bClientUnregistered = false; // Reset 79 iterator it = begin(); 80 while (it != end()) { 81 ICallback *pObj = *it; 82 pObj->Delete(vCmd); 83 84 if (m_bClientUnregistered) { 85 m_bClientUnregistered = false; // Reset 86 it = begin(); 87 } else 88 // Next 89 ++it; 90 } 91 } 92 93 } // namespace CMICmdMgrSetCmdDeleteCallback 94