//---------------------------------------------------------
bool CCMD_Module::Create(CSG_Module_Library *pLibrary, CSG_Module *pModule)
{
	Destroy();

	if( (m_pLibrary = pLibrary) != NULL && (m_pModule = pModule) != NULL )
	{
		_Set_Parameters(m_pModule->Get_Parameters(), false);

		for(int i=0; i<m_pModule->Get_Parameters_Count(); i++)
		{
			_Set_Parameters(m_pModule->Get_Parameters(i), true);
		}

		return( true );
	}

	return( false );
}
示例#2
0
//---------------------------------------------------------
bool CCMD_Module::Create(CSG_Module *pModule)
{
    Destroy();

    m_CMD.SetSwitchChars(SG_T("-"));

    if( (m_pModule = pModule) != NULL )
    {
        _Set_Parameters(m_pModule->Get_Parameters(), false);

        for(int i=0; i<m_pModule->Get_Parameters_Count(); i++)
        {
            _Set_Parameters(m_pModule->Get_Parameters(i), true);
        }

        return( true );
    }

    return( false );
}
示例#3
0
//---------------------------------------------------------
bool CCMD_Module::_Set_Parameters(CSG_Parameters *pParameters, bool bOptional)
{
    if( !pParameters )
    {
        return( false );
    }

    //-----------------------------------------------------
    for(int i=0; i<pParameters->Get_Count(); i++)
    {
        CSG_Parameter	*pParameter	= pParameters->Get_Parameter(i);

        wxString	Description	= pParameter->Get_Description(
                                      PARAMETER_DESCRIPTION_NAME|PARAMETER_DESCRIPTION_TYPE|PARAMETER_DESCRIPTION_PROPERTIES, SG_T("\n\t")
                                  ).c_str();

        Description.Replace(wxT("\xb2"), wxT("2"));	// unicode problem: quick'n'dirty bug fix, to be replaced

        if( pParameter->is_Input() || pParameter->is_Output() )
        {
            m_CMD.AddOption(_Get_ID(pParameter), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_NEEDS_SEPARATOR
                            | (pParameter->is_Optional() || pParameter->is_Output() || bOptional
                               ? wxCMD_LINE_PARAM_OPTIONAL : wxCMD_LINE_OPTION_MANDATORY
                              ));
        }

        else if( pParameter->is_Option() && !pParameter->is_Information() )
        {
            switch( pParameter->Get_Type() )
            {
            default:
                break;

            case PARAMETER_TYPE_Parameters:
                _Set_Parameters(pParameter->asParameters(), true);
                break;

            case PARAMETER_TYPE_Bool:
                m_CMD.AddSwitch(_Get_ID(pParameter), wxEmptyString, Description, wxCMD_LINE_PARAM_OPTIONAL);
                break;

            case PARAMETER_TYPE_Int:
                m_CMD.AddOption(_Get_ID(pParameter), wxEmptyString, Description, wxCMD_LINE_VAL_NUMBER, wxCMD_LINE_PARAM_OPTIONAL);
                break;

            case PARAMETER_TYPE_Choice:
            case PARAMETER_TYPE_Table_Field:
            case PARAMETER_TYPE_Table_Fields:
                m_CMD.AddOption(_Get_ID(pParameter), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
                break;

            case PARAMETER_TYPE_Double:
            case PARAMETER_TYPE_Degree:
                m_CMD.AddOption(_Get_ID(pParameter), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
                break;

            case PARAMETER_TYPE_Range:
                m_CMD.AddOption(_Get_ID(pParameter, wxT("MIN")), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
                m_CMD.AddOption(_Get_ID(pParameter, wxT("MAX")), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
                break;

            case PARAMETER_TYPE_String:
            case PARAMETER_TYPE_Text:
            case PARAMETER_TYPE_FilePath:
                m_CMD.AddOption(_Get_ID(pParameter), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
                break;

            case PARAMETER_TYPE_FixedTable:
                m_CMD.AddOption(_Get_ID(pParameter), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
                break;

            case PARAMETER_TYPE_Grid_System:
                if( pParameter->Get_Children_Count() == 0 )
                {
                    m_CMD.AddOption(_Get_ID(pParameter, wxT("NX")), wxEmptyString, Description, wxCMD_LINE_VAL_NUMBER, wxCMD_LINE_PARAM_OPTIONAL);
                    m_CMD.AddOption(_Get_ID(pParameter, wxT("NY")), wxEmptyString, Description, wxCMD_LINE_VAL_NUMBER, wxCMD_LINE_PARAM_OPTIONAL);
                    m_CMD.AddOption(_Get_ID(pParameter, wxT( "X")), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
                    m_CMD.AddOption(_Get_ID(pParameter, wxT( "Y")), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
                    m_CMD.AddOption(_Get_ID(pParameter, wxT( "D")), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
                }
                break;
            }
        }
    }

    return( true );
}