1 //===-- MICmdFactory.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: MICmdFactory.h
13 // Overview: CMICmdFactory 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 "MIUtilSingletonBase.h"
35 //++ ============================================================================
36 // Details: MI Command Factory. Holds a list of registered MI commands that
37 // MI application understands to interpret. Creates commands objects.
38 // The Command Factory is carried out in the main thread.
41 // Authors: Illya Rudkin 19/02/2014.
46 , public MI::ISingleton< CMICmdFactory >
48 friend class MI::ISingleton< CMICmdFactory >;
52 typedef CMICmdBase * (*CmdCreatorFnPtr)( void );
57 // Description: Command's factory's interface for commands to implement.
62 virtual const CMIUtilString & GetMiCmd( void ) const = 0;
63 virtual CmdCreatorFnPtr GetCmdCreatorFn( void ) const = 0;
64 //virtual CMICmdBase * CreateSelf( void ) = 0; // Not possible as require a static creator function in the command class, here for awareness
66 /* dtor */ virtual ~ICmd( void ) {};
71 bool Initialize( void );
72 bool Shutdown( void );
73 bool CmdRegister( const CMIUtilString & vMiCmd, CmdCreatorFnPtr vCmdCreateFn );
74 bool CmdCreate( const CMIUtilString & vMiCmd, const SMICmdData & vCmdData, CMICmdBase *& vpNewCmd );
75 bool CmdExist( const CMIUtilString & vMiCmd ) const;
79 /* ctor */ CMICmdFactory( void );
80 /* ctor */ CMICmdFactory( const CMICmdFactory & );
81 void operator=( const CMICmdFactory & );
83 bool HaveAlready( const CMIUtilString & vMiCmd ) const;
84 bool IsValid( const CMIUtilString & vMiCmd ) const;
89 /* dtor */ virtual ~CMICmdFactory( void );
93 typedef std::map< CMIUtilString, CmdCreatorFnPtr > MapMiCmdToCmdCreatorFn_t;
94 typedef std::pair< CMIUtilString, CmdCreatorFnPtr > MapPairMiCmdToCmdCreatorFn_t;
98 MapMiCmdToCmdCreatorFn_t m_mapMiCmdToCmdCreatorFn;