1 //===-- MICmdInvoker.h ------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 // File: MICmdInvoker.h
13 // Overview: CMICmdInvoker interface.
15 // Environment: Compilers: Visual C++ 12.
16 // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
17 // Libraries: See MIReadmetxt.
24 // Third party headers
28 #include "MICmnBase.h"
29 #include "MICmdData.h"
30 #include "MICmdMgrSetCmdDeleteCallback.h"
31 #include "MIUtilSingletonBase.h"
35 class CMICmnStreamStdout;
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
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.
52 // Authors: Illya Rudkin 19/02/2014.
57 , public CMICmdMgrSetCmdDeleteCallback::ICallback
58 , public MI::ISingleton< CMICmdInvoker >
60 friend class MI::ISingleton< CMICmdInvoker >;
65 // Description: Invoker's interface for commands to implement.
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;
81 /* dtor */ virtual ~ICmd( void ) {};
86 bool Initialize( void );
87 bool Shutdown( void );
88 bool CmdExecute( CMICmdBase & vCmd );
89 bool CmdExecuteFinished( CMICmdBase & vCmd );
93 typedef std::map< MIuint, CMICmdBase * > MapCmdIdToCmd_t;
94 typedef std::pair< MIuint, CMICmdBase * > MapPairCmdIdToCmd_t;
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;
110 /* dtor */ virtual ~CMICmdInvoker( void );
111 // From CMICmdMgrSetCmdDeleteCallback::ICallback
112 virtual void Delete( SMICmdData & vCmd );
116 MapCmdIdToCmd_t m_mapCmdIdToCmd;
117 CMICmnStreamStdout & m_rStreamOut;