]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/tools/lldb-mi/MICmdInvoker.h
Update LLDB snapshot to upstream r216948 (git 50f7fe44)
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / tools / lldb-mi / MICmdInvoker.h
1 //===-- MICmdInvoker.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 // File:                MICmdInvoker.h
12 //
13 // Overview:    CMICmdInvoker interface.
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 #pragma once
23
24 // Third party headers
25 #include <map>
26
27 // In-house headers:
28 #include "MICmnBase.h"
29 #include "MICmdData.h"
30 #include "MICmdMgrSetCmdDeleteCallback.h"
31 #include "MIUtilSingletonBase.h"
32
33 // Declarations:
34 class CMICmdBase;
35 class CMICmnStreamStdout;
36
37 //++ ============================================================================
38 // Details:     MI Command Invoker. The Invoker works on the command pattern design.
39 //                      There two main jobs; action command Execute() function, followed by
40 //                      the command's Acknowledge() function. When a command has finished its
41 //                      execute function it returns to the invoker. The invoker then calls the
42 //                      command's Acknowledge() function to do more work, form and give
43 //                      back a MI result. In the meantime the Command Monitor is monitoring
44 //                      the each command doing their Execute() function work so they do not 
45 //                      exceed a time limit which if it exceeds informs the command(s) to
46 //                      stop work.
47 //                      The work by the Invoker is carried out in the main thread.
48 //                      The Invoker takes ownersip of any commands created which means it
49 //                      is the only object to delete them when a command is finished working.
50 //                      A singleton class.
51 // Gotchas:     None.
52 // Authors:     Illya Rudkin 19/02/2014.
53 // Changes:     None.
54 //--
55 class CMICmdInvoker
56 :       public CMICmnBase
57 ,       public CMICmdMgrSetCmdDeleteCallback::ICallback
58 ,       public MI::ISingleton< CMICmdInvoker >
59 {
60         friend class MI::ISingleton< CMICmdInvoker >;
61
62 // Class:
63 public:
64         //++
65         // Description: Invoker's interface for commands to implement.
66         //--
67         class ICmd
68         {
69         public:
70                 virtual bool                                    Acknowledge( void ) = 0;
71                 virtual bool                                    Execute( void ) = 0;
72                 virtual bool                                    ParseArgs( void ) = 0;
73                 virtual bool                                    SetCmdData( const SMICmdData & vCmdData ) = 0;
74                 virtual const SMICmdData &              GetCmdData( void ) const = 0;
75                 virtual const CMIUtilString &   GetErrorDescription( void ) const = 0;
76                 virtual void                                    CmdFinishedTellInvoker( void ) const = 0;
77                 virtual const CMIUtilString &   GetMIResultRecord( void ) const = 0;
78                 virtual const CMIUtilString &   GetMIResultRecordExtra( void ) const = 0;
79                 virtual bool                                    HasMIResultRecordExtra( void ) const = 0;
80
81                 /* dtor */ virtual ~ICmd( void ) {};
82         };
83         
84 // Methods:
85 public:
86         bool    Initialize( void );
87         bool    Shutdown( void );
88         bool    CmdExecute( CMICmdBase & vCmd );
89         bool    CmdExecuteFinished( CMICmdBase & vCmd );
90
91 // Typedefs:
92 private:
93         typedef std::map< MIuint, CMICmdBase * >        MapCmdIdToCmd_t;
94         typedef std::pair< MIuint, CMICmdBase * >       MapPairCmdIdToCmd_t;
95
96 // Methods:
97 private:
98         /* ctor */      CMICmdInvoker( void );
99         /* ctor */      CMICmdInvoker( const CMICmdInvoker & );
100         void            operator=( const CMICmdInvoker & );
101         void            CmdDeleteAll( void );
102         bool            CmdDelete( const MIuint vCmdId, const bool vbYesDeleteCmd = false );
103         bool            CmdAdd( const CMICmdBase & vCmd );
104         bool            CmdStdout( const SMICmdData & vCmdData ) const;
105         void            CmdCauseAppExit( const CMICmdBase & vCmd ) const;
106         
107 // Overridden:
108 private:
109         // From CMICmnBase
110         /* dtor */ virtual ~CMICmdInvoker( void );
111         // From CMICmdMgrSetCmdDeleteCallback::ICallback 
112         virtual void Delete( SMICmdData & vCmd );
113
114 // Attributes:
115 private:
116         MapCmdIdToCmd_t                 m_mapCmdIdToCmd;
117         CMICmnStreamStdout &    m_rStreamOut;
118 };