Exemple #1
0
void FillCommendCfg(void)
{
    const VideoOptionMap& videoOptionMap = gHardwareInfoSystem.getVideoOptionMap();

    VideoOptionMap::const_iterator it = videoOptionMap.begin();

    //while (it != videoOptionMap.end())
    //{
    //    char debugString[256];
    //    sprintf(debugString, "%s : %d : %d\n", it->first.c_str(), it->second.mMinValue, it->second.mMaxValue);
    //    ::OutputDebugString(debugString);
    //    ++it;
    //}

	//备用内存
	static CStringA  s_staValueBackup[g_cfgCommendSize];

    for(int i=0; i<g_cfgCommendSize; i++)
    {
        std::string variableName(g_cfgCommend[i].szName);

        VideoOptionMap::const_iterator it = videoOptionMap.find(variableName);

        if (it != videoOptionMap.end())
        {
			s_staValueBackup[i].Format("%d", it->second.mMinValue);
            // 设置推荐值
			g_cfgCommend[i].szValue = (LPCSTR)(s_staValueBackup[i]);
        }
    }
}
std::wstring Writer::operator ()(const Term &term, const Dictionary &dictionary, SymbolType *symbolType) const
{
    if (symbolType) {
        *symbolType = term.type();
    }

    std::wstring result = dictionary(term.symbol());

    if (result.empty()) {
        switch (term.type()) {
        case NONE_SYMBOL:
            return symbolic.noneSymbol;

            break;

        case VARIABLE:
            return variableName(term.symbol().id);

            break;
        case CONSTANT:
            return constantName(term.symbol().id);

            break;
        case OPERATION:
            result = operationName(term.symbol().id);

            break;

        default:
            throw(1);

            break;
        }
    }

    if (term.type()!=OPERATION) {
        return result;
    }

    result += symbolic.leftTermBracket;

    if (term.arity()) {
        result += operator ()(term.args()[0], dictionary);

        for (size_t i = 1; i < term.arity(); ++i) {
            result += symbolic.operationSeparatorSymbol;
            result += operator ()(term.args()[i], dictionary);
        }
    }

    result += symbolic.rightTermBracket;

    return result;
}
dScriptCompiler::dUserVariable dScriptCompiler::NewVariableToCurrentBlock (const dString& modifiers, const dUserVariable& type, const dString& name)
{
	dUserVariable variableName(NewVariableStatement (name, modifiers));

	dDAGParameterNode* const variableNameNode = (dDAGParameterNode*)variableName.m_node;
	dAssert (variableNameNode->IsType(dDAGParameterNode::GetRttiType()));

	dDAGTypeNode* const typeNode = (dDAGTypeNode*)type.m_node;
	dAssert (typeNode->GetTypeId() == dDAGTypeNode::GetRttiType());
	variableNameNode->SetType(typeNode);

	dAssert (m_scopeStack.GetCount());
	dDAGScopeBlockNode* const block = GetCurrentScope();
	block->AddStatement(variableNameNode);

	dUserVariable returnNode (NewExpressionNodeVariable (name, modifiers));
	dAssert (returnNode.m_node->GetTypeId() == dDAGExpressionNodeVariable::GetRttiType());
	dDAGExpressionNodeVariable* const node = (dDAGExpressionNodeVariable*) returnNode.m_node;
	node->SetType((dDAGTypeNode*) typeNode->Clone (m_allNodes));
	return returnNode;
}
Exemple #4
0
void CodeGenPB::go() {

    // first analyse the objects if they are embedded objects
    // for all objects that could accept such an object
    for(int i=0; i < m_objects.size(); i++) {
        // for all objects
        XSDObject *obj1 = m_objects.at(i);

        // find if there is another object that refers to the obj
        for(int h=0; h < m_objects.size(); h++) {

            XSDObject *obj2 = m_objects.at(h);

            // refers means obj2 has an attribute of type obj1
            for(int j=0; j < obj2->attributes().size(); j++) {
                XSDAttribute *attr = obj2->attributes().at(j);
                QString objType = attr->type();

                if (objType == obj1->name()) {
                    obj1->setEmbedded();    // obj1 is embedded in obj2
                }
            }
        }
    }

    // open the proto filea
    QString baseName;
    if (m_prefix != "") {
        baseName = m_outDir + "/" + m_prefix + ".proto";
    } else {
        baseName = m_outDir + "/interface.proto"; // must have prefix
    }
    QFile protoFile(baseName);
    if (!protoFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
        std::cerr << QString("cannot create file: %1").arg(baseName).toLatin1().data() << std::endl;
        std::exit(-1);
    }
    QTextStream protoFileOut(&protoFile);

    // GPL header
    protoFileOut << writeHeader( baseName );

    for(int i=0; i < m_objects.size(); i++) {
        // get a class
        XSDObject *obj = m_objects.at(i);

        // get some vars we frequently use
        QString name = obj->name();
        QString upperName = name.toUpper();
        QVector<XSDAttribute*>attributes = obj->attributes();
        QMap<QString, QString>fixedValues = obj->fixedValues();

        // report
        std::cout << QString("creating class: %1").arg(className(name)).toLatin1().data() << std::endl;

        //-----------------------------------------------------------------------------------------------
        // generate the header
        //-----------------------------------------------------------------------------------------------

        // define the class
        protoFileOut << "\nmessage " << className(name) << " { \n";
        if (obj->hasBaseClass()) {
            protoFileOut << "\nextend " << className(obj->baseClass()) << " { \n";
        }

        // the tag counter
        int tag = 1;

        // variables  section
        for(int j=0; j < attributes.size(); j++) {
            XSDAttribute *attr = attributes.at(j);
            QString type = localType(attr->type()); // convert to cpp types
            // definition
            if (attr->isScalar()) { // there more then one
                protoFileOut << "    repeated " << type << " " << variableName(attr->name()) << " = " << tag++ << ";\n";
            } else if (!attr->required() || obj->isMerged()) {
                protoFileOut << "    optional " << type << " " << variableName(attr->name()) <<  " = " << tag++ << ";\n";
            } else {
                protoFileOut << "    required " << type << " " << variableName(attr->name()) << " = " << tag++ << ";\n";
            }
        }

        // and fixed values
        for(int j=0; j < fixedValues.size(); j++) {
            QString attrName = fixedValues.keys().at(j);
            protoFileOut << "    required string " << variableName(attrName) << " = " << tag++ << ";\n";
        }
        protoFileOut << "}\n";
        if (obj->hasBaseClass()) {
            protoFileOut << "}\n";
        }
    }

    // close and flush
    protoFileOut.flush();
    protoFile.close();
}
int main() {
    bool test1 = variableName("var_1__Int");
    bool test2 = variableName("2w2");
    std::cout << test1 << std::endl;
    std::cout << test2 << std::endl;
}
int main(int argc, char *argv[])
{	

	Foam::timeSelector::addOptions();
	#   include "addRegionOption.H"
	Foam::argList::addBoolOption
	(
	"noWrite",
	"suppress writing results"
	);
	#include "addDictOption.H"

	#include "setRootCase.H"
	#include "createTime.H"
	Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args);
	#include "createNamedMesh.H"

	#include "createFields.H" 	 

	
        // Post-processing dictionary
        #include "postProcessingDict.H"
		
	// Create conditional averaging class
	conditionalAve condAve(postProcessingDict,conditionalAveragingDict,
						mesh,nVariable,nAveragingVariable,nTotalCase,conditionalAveraging);

	// Create multiple variable conditional averaging class
	multipleVarsConditionalAve multipleVarsCondAve(postProcessingDict,multConditionalAveragingDict,
						mesh,multNVariable,multNAveragingVariable,multNTotalCase,multConditionalAveraging);
	
		
	//-Time loop
	forAll(timeDirs, timeI)
	{
  
		runTime.setTime(timeDirs[timeI], timeI);

		Foam::Info << " " << endl;
		Foam::Info << "Time = " << runTime.timeName() << Foam::endl;
		
		if(fluidCoarsening)
		{
		  forAll(filterWidth,fWidth)
		  {
		    //- Create name for filter width			  
		    char charName[100];
		    sprintf(charName, "%dX%dX%d",filterWidth[fWidth],filterWidth[fWidth],filterWidth[fWidth]);
		    word filterWidthName(charName);
			  
		    // Read Eulerian variables
		    #include "readEulerianVar.H"
				    	
		    //- Conditionally averaging		    
		    if(conditionalAveraging)
		    {
			//- Loop over variables
			forAll(variableList,jj)
			{
			   word variableName(variableList[jj]);
			   word varName(filterWidthName);
			   condAve.calc(variableName,varName,averagingVariableList,jj+variableList.size()*fWidth);
			}

	  	    }	
	  	    //- Multi-variable averaging
		    if(multConditionalAveraging) 
		    {
			forAll(multVariableList,jj)
			{
			   word variableName(multVariableList[jj]);
			   word varName(filterWidthName);
			   multipleVarsCondAve.calc(variableName,varName,multAveragingVariableList,jj+multVariableList.size()*fWidth);
			}
		    }