1 //===-- MICmdMgrSetCmdDeleteCallback.h --------------------------*- 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 #pragma once
12 
13 // Third party headers:
14 #include <set>
15 
16 // In-house headers:
17 #include "MICmnBase.h"
18 
19 // Declarations:
20 struct SMICmdData;
21 
22 namespace CMICmdMgrSetCmdDeleteCallback {
23 
24 //++
25 //============================================================================
26 // Details: MI Command Manager interface for client call back.
27 //          Objects that want to be notified of a command being deleted
28 //          inherit this interface and register interest in command object
29 //          deletion. An object deleting a command must not do it itself but
30 //          call
31 //          the Command Manager CmdDelete() function to delete a command object.
32 //--
33 class ICallback {
34 public:
35   virtual void Delete(SMICmdData &vCmd) = 0;
36 
~ICallback()37   /* dtor */ virtual ~ICallback() {}
38 };
39 
40 //++
41 //============================================================================
42 // Details: MI Command Manager container for clients registered interest in
43 // command
44 //          objects being deleted. Objects register an interest so when a
45 //          command
46 //          is to be deleted that object wanting the delete calls the Command
47 //          Manager to delete the command object. In so do all other registered
48 //          objects get called to about the deletion including the object
49 //          wanting
50 //          to do the delete in the first place.
51 //--
52 class CSetClients : public std::set<class ICallback *>, public CMICmnBase {
53   // Methods:
54 public:
55   /* ctor */ CSetClients();
56 
57   bool Register(class ICallback &vObject);
58   bool Unregister(class ICallback &vObject);
59   void Delete(SMICmdData &vCmdData);
60 
61   // Overridden:
62 public:
63   // From CMICmnBase
64   /* dtor */ ~CSetClients() override;
65 
66   // Attributes:
67 private:
68   bool m_bClientUnregistered; // True = yes while deleting a client
69                               // unregistered, false = no client unregistered
70                               // during deletion
71 };
72 
73 } // namespace CMICmdMgrSetCmdDeleteCallback
74