Esempio n. 1
0
//++ ------------------------------------------------------------------------------------
// Details:	Create a command given the specified MI command name. The command data object
//			contains the options for the command.
// Type:	Method.
// Args:	vMiCmd		- (R) Command's name, the MI command.
//			vCmdData	- (RW) Command's metadata status/information/result object.		
//			vpNewCmd	- (W) New command instance.
// Return:	MIstatus::success - Functionality succeeded.
//			MIstatus::failure - Functionality failed.
// Throws:	None.
//--
bool CMICmdFactory::CmdCreate( const CMIUtilString & vMiCmd, const SMICmdData & vCmdData, CMICmdBase *& vpNewCmd )
{
	bool bOk = MIstatus::success;

	vpNewCmd = nullptr;

	if( !IsValid( vMiCmd ) )
	{
		SetErrorDescription( CMIUtilString::Format( MIRSRC( IDS_CMDFACTORY_ERR_INVALID_CMD_NAME ), vMiCmd.c_str() ) );
		return MIstatus::failure;
	}
	if( !HaveAlready( vMiCmd ) )
	{
		SetErrorDescription( CMIUtilString::Format( MIRSRC( IDS_CMDFACTORY_ERR_CMD_NOT_REGISTERED ), vMiCmd.c_str() ) );
		return MIstatus::failure;
	}

	const MapMiCmdToCmdCreatorFn_t::const_iterator it = m_mapMiCmdToCmdCreatorFn.find( vMiCmd );
	const CMIUtilString & rMiCmd( (*it).first ); MIunused( rMiCmd );
	CmdCreatorFnPtr pFn = (*it).second;
	CMICmdBase * pCmd = (*pFn)();

	SMICmdData cmdData( vCmdData );
	cmdData.id = pCmd->GetGUID();
	bOk = pCmd->SetCmdData( cmdData );
	if( bOk )
		vpNewCmd = pCmd;

	return bOk;
}
Esempio n. 2
0
//++ ------------------------------------------------------------------------------------
// Details: Register a command's creator function with the command identifier the MI
//          command name i.e. 'file-exec-and-symbols'.
// Type:    Method.
// Args:    vMiCmd          - (R) Command's name, the MI command.
//          vCmdCreateFn    - (R) Command's creator function pointer.
// Return:  MIstatus::success - Functionality succeeded.
//          MIstatus::failure - Functionality failed.
// Throws:  None.
//--
bool
CMICmdFactory::CmdRegister(const CMIUtilString &vMiCmd, CmdCreatorFnPtr vCmdCreateFn)
{
    if (!IsValid(vMiCmd))
    {
        SetErrorDescription(CMIUtilString::Format(MIRSRC(IDS_CMDFACTORY_ERR_INVALID_CMD_NAME), vMiCmd.c_str()));
        return MIstatus::failure;
    }
    if (vCmdCreateFn == nullptr)
    {
        SetErrorDescription(CMIUtilString::Format(MIRSRC(IDS_CMDFACTORY_ERR_INVALID_CMD_CR8FN), vMiCmd.c_str()));
        return MIstatus::failure;
    }

    if (HaveAlready(vMiCmd))
    {
        SetErrorDescription(CMIUtilString::Format(MIRSRC(IDS_CMDFACTORY_ERR_CMD_ALREADY_REGED), vMiCmd.c_str()));
        return MIstatus::failure;
    }

    MapPairMiCmdToCmdCreatorFn_t pr(vMiCmd, vCmdCreateFn);
    m_mapMiCmdToCmdCreatorFn.insert(pr);

    return MIstatus::success;
}
Esempio n. 3
0
//++ ------------------------------------------------------------------------------------
// Details:	Check a command is already registered.
// Type:	Method.
// Args:	vMiCmd	- (R) Command's name, the MI command.
// Return:	True - registered.
//			False - not found.
// Throws:	None.
//--
bool CMICmdFactory::CmdExist( const CMIUtilString & vMiCmd ) const
{
	return HaveAlready( vMiCmd );
}