예제 #1
0
void Translator::reloadConfiguration()
{
    KConfigGroup grp = config();

    m_primary = grp.readEntry(CONFIG_PRIMARY);
    m_secondary = grp.readEntry(CONFIG_SECONDARY);
    m_yandexKey = grp.readEntry(CONFIG_YANDEX_KEY);
    m_glosbeWord = stringToBool(grp.readEntry(CONFIG_GLOSBE_WORD));
    m_glosbePhrase = stringToBool(grp.readEntry(CONFIG_GLOSBE_PHRASE));
    m_glosbeExamples = stringToBool(grp.readEntry(CONFIG_GLOSBE_EXAMPLES));
    m_yandexWord = stringToBool(grp.readEntry(CONFIG_YANDEX_WORD));
    m_yandexPhrase = stringToBool(grp.readEntry(CONFIG_YANDEX_PHRASE));
}
예제 #2
0
void setBool(const char* value, uint8_t* target) {
    bool result;
    if(stringToBool(&result, value)){
        *target = result; // convert bool to uint8_t
        eepromManager.storeTempConstantsAndSettings();
    }
}
예제 #3
0
void CSVreader::readVector( const string &filename, const string &csvdelimiter, vector<bool> &sarr, int numY )
{
	numY++;
	ifstream fin(filename.c_str());

	string s;
	vector<string> selements;
	//vector<double> delements;

	int x = 0;
	while ( !fin.eof() ) 
	{
		getline(fin, s);

		if ( !s.empty() ) 
		{
			splitString(s, selements, csvdelimiter);

			sarr.push_back(stringToBool(selements[1]));
			selements.clear();
			//delements.clear();
		}

		x++;
		if (x>=numY) break;
	}

	fin.close();
}
예제 #4
0
void ArgList::setArgValue(const std::string & sName, const std::string & sValue)
{
    ArgBasePtr pArg = getArg(sName);
    Arg<string>* pStringArg = dynamic_cast<Arg<string>* >(&*pArg);
    Arg<UTF8String>* pUTF8StringArg = dynamic_cast<Arg<UTF8String>* >(&*pArg);
    Arg<int>* pIntArg = dynamic_cast<Arg<int>* >(&*pArg);
    Arg<float>* pFloatArg = dynamic_cast<Arg<float>* >(&*pArg);
    Arg<bool>* pBoolArg = dynamic_cast<Arg<bool>* >(&*pArg);
    Arg<glm::vec2>* pVec2Arg = dynamic_cast<Arg<glm::vec2>* >(&*pArg);
    Arg<glm::vec3>* pVec3Arg = dynamic_cast<Arg<glm::vec3>* >(&*pArg);
    Arg<glm::ivec3>* pIVec3Arg = dynamic_cast<Arg<glm::ivec3>* >(&*pArg);
    Arg<vector<float> >* pFVectorArg = dynamic_cast<Arg<vector<float> >* >(&*pArg);
    Arg<vector<int> >* pIVectorArg = dynamic_cast<Arg<vector<int> >* >(&*pArg);
    Arg<vector<glm::vec2> >* pVec2VectorArg = 
            dynamic_cast<Arg<vector<glm::vec2> >* >(&*pArg);
    Arg<vector<glm::ivec3> >* pIVec3VectorArg = 
            dynamic_cast<Arg<vector<glm::ivec3> >* >(&*pArg);
    Arg<CollVec2Vector>* pCollVec2VectorArg =
            dynamic_cast<Arg<CollVec2Vector>* >(&*pArg);
    if (pStringArg) {
        pStringArg->setValue(sValue);
    } else if (pUTF8StringArg) {
        pUTF8StringArg->setValue(sValue);
    } else if (pIntArg) {
        pIntArg->setValue(stringToInt(sValue));
    } else if (pFloatArg) {
        pFloatArg->setValue(stringToFloat(sValue));
    } else if (pBoolArg) {
        pBoolArg->setValue(stringToBool(sValue));
    } else if (pVec2Arg) {
        pVec2Arg->setValue(stringToVec2(sValue));
    } else if (pVec3Arg) {
        pVec3Arg->setValue(stringToVec3(sValue));
    } else if (pIVec3Arg) {
        pIVec3Arg->setValue(stringToIVec3(sValue));
    } else if (pFVectorArg) {
        vector<float> v;
        fromString(sValue, v);
        pFVectorArg->setValue(v);
    } else if (pIVectorArg) {
        vector<int> v;
        fromString(sValue, v);
        pIVectorArg->setValue(v);
    } else if (pVec2VectorArg) {
        vector<glm::vec2> v;
        fromString(sValue, v);
        pVec2VectorArg->setValue(v);
    } else if (pIVec3VectorArg) {
        vector<glm::ivec3> v;
        fromString(sValue, v);
        pIVec3VectorArg->setValue(v);
    } else if (pCollVec2VectorArg) {
        CollVec2Vector v;
        fromString(sValue, v);
        pCollVec2VectorArg->setValue(v);
    } else {
        AVG_ASSERT(false);
    }   
}
예제 #5
0
// QC:G
GraphicalEffects Factory::loadEffects(TiXmlElement *xmlData) {
	GraphicalEffects effects;

	const char* aVal;
	bool b;
	int i;
	coord c;
	Rect r;
	Point p;

	if((aVal=xmlData->Attribute("effects"))) {
		effects.setEffects(aVal);
	}

	if(stringToPoint(xmlData->Attribute("scale"), p))
		effects.setScale(p);
		
	if(stringToPoint(xmlData->Attribute("sectionPointStart"), p))
		effects.setSectionPointStart(p);
	
	if(stringToPoint(xmlData->Attribute("sectionWidthHeight"), p))
		effects.setSectionWidthHeight(p);
	
	if(stringToRect(xmlData->Attribute("section"), r))
		effects.setSection(r);

	if(stringToCoord(xmlData->Attribute("rotation"), &c))
		effects.setRotation(c);

	if(stringToInt(xmlData->Attribute("opacity"), &i))
		effects.setOpacity(i);

	if(stringToInt(xmlData->Attribute("redFilter"), &i))
		effects.setIntegerEffect("RFIL", i);

	if(stringToInt(xmlData->Attribute("greenFilter"), &i))
		effects.setIntegerEffect("GFIL", i);

	if(stringToInt(xmlData->Attribute("blueFilter"), &i))
		effects.setIntegerEffect("BFIL", i);

	effects.setBlendMode(xmlData->Attribute("blend"));

	if(stringToBool(xmlData->Attribute("renderCache"), &b))
		effects.setRenderCache(b);
	
	if((aVal=xmlData->Attribute("preProcess"))) {
		effects.setPreProcess(aVal, NULL);
	}

	if((aVal=xmlData->Attribute("postProcess"))) {
		effects.setPostProcess(aVal, NULL);
	}

	return effects;
}
예제 #6
0
/*!
  Sets rememberDimensions value in configuration to \a newValue.

  \sa rememberDimensions
  */
void CcfConfig::setRememberDimensions(bool newValue)
{
    QString current = mConfiguration->value("remember dimensions on exit");
    bool currentBool = stringToBool(current);

    if (currentBool != newValue) {
        mConfiguration->replace("remember dimensions on exit", boolToString(newValue));
        emit rememberDimensionsChanged();
    }
}
예제 #7
0
void CheckQualityConfig::ParseConfiguration(const cv::FileNode& node)
{
    ConfigBase::ParseConfiguration(node);
    
    std::string isManual;
    node[config::kManualKeyPath] >> isManual;
    (*m_parameterStorage)[config::kManualKeyPath] = new ConfigurationElement<bool>(stringToBool(isManual));
    
    std::string* parameter = new std::string();
    node[config::kCheckQualityNewLandmarkDataFileNameKeyPath] >> *parameter;
    (*m_parameterStorage)[config::kCheckQualityNewLandmarkDataFileNameKeyPath] = new ConfigurationElement<std::string>(parameter);
}
예제 #8
0
void TestbedConfigManager::parseConfigFile() {
	Common::SeekableReadStream *rs = getConfigReadStream();

	if (!rs) {
		Testsuite::logPrintf("Info! No config file found, using default configuration.\n");
		initDefaultConfiguration();
		return;
	}
	_configFileInterface.loadFromStream(*rs);
	Common::INIFile::SectionList sections = _configFileInterface.getSections();
	Testsuite *currTS = 0;

	for (Common::INIFile::SectionList::const_iterator i = sections.begin(); i != sections.end(); i++) {
		if (i->name.equalsIgnoreCase("Global")) {
			// Global params may be directly queried, ignore them
		} else {
			// A testsuite, process it.
			currTS = getTestsuiteByName(i->name);
			Common::INIFile::SectionKeyList kList = i->getKeys();
			if (!currTS) {
				Testsuite::logPrintf("Warning! Error in config: Testsuite %s not found\n", i->name.c_str());
				continue;
			}

			for (Common::INIFile::SectionKeyList::const_iterator j = kList.begin(); j != kList.end(); j++) {
				if (j->key.equalsIgnoreCase("this")) {
					currTS->enable(stringToBool(j->value));
				} else {
					if (!currTS->enableTest(j->key, stringToBool(j->value))) {
						Testsuite::logPrintf("Warning! Error in config: Test %s not found\n", j->key.c_str());
					}
				}
			}
		}
	}
	delete rs;
}
예제 #9
0
std::vector<bool> StringTools::stringVectorToBoolVector(std::vector<std::string> inputStringVector)
{
	std::vector<bool> result;
	std::string tmpString;

	for(std::vector<std::string>::iterator currentStringVectorEntry = inputStringVector.begin(); currentStringVectorEntry < inputStringVector.end(); ++currentStringVectorEntry)
	{
		trimString( *currentStringVectorEntry );
		tmpString.clear();
		tmpString = *currentStringVectorEntry;
		trimString(tmpString);

		result.push_back( stringToBool(tmpString) );
	}

	return result;
}
예제 #10
0
    static STDataItem stringToItem(const STString &str)
    {
        STString itemTag = getFirstTagName(str);
        if (itemTag.empty() ) {
            return STDataItem("");
        }

        STString interTagStr = getTagStr(str, itemTag, false);
        if (interTagStr.empty() ) {
            return STDataItem("");
        }

        STDataItem item(itemTag);
        if (isValueStr(interTagStr)) {
            STString valueTag = getFirstTagName(interTagStr);
            STString valueStr = getTagStr(interTagStr, valueTag);
            if ("bool" == valueTag) {
                item = stringToBool(valueStr);
            }
            else if ("int" == valueTag) {
                item = stringToInt(valueStr);
            }
            else if ("string" == valueTag) {
                item = valueStr;
            }
        }
        else {
            STString childStr = interTagStr;
            int childPos = -1;
            STString childTag = getFirstTagName(childStr, childPos);
            while (!childTag.empty()) {
                STString realChildStr = getTagStr(childStr, childTag, true);
                STDataItem child = stringToItem(getTagStr(childStr, childTag, true));
                if ( child.isValid() ) {
                    item.addChild(child);
                }

                childStr = childStr.substr(childPos+realChildStr.size()
                                           , childStr.size()-childPos-realChildStr.size());
                childTag = getFirstTagName(childStr, childPos);
            }
        }

        return item;
    }
예제 #11
0
void TestbedConfigManager::selectTestsuites() {

	parseConfigFile();

	if (_configFileInterface.hasKey("isSessionInteractive", "Global")) {
		Common::String in;
		_configFileInterface.getKey("isSessionInteractive", "Global", in);
		ConfParams.setSessionAsInteractive(stringToBool(in));
	}

	if (!ConfParams.isSessionInteractive()) {
		// Non interactive sessions don't need to go beyond
		return;
	}

	// XXX: disabling these as of now for fastly testing other tests
	// Testsuite::isSessionInteractive = false;
	Common::String prompt("Welcome to the ScummVM testbed!\n"
						"It is a framework to test the various ScummVM subsystems namely GFX, Sound, FS, events etc.\n"
						"If you see this, it means interactive tests would run on this system :)\n");

	if (!ConfParams.isGameDataFound()) {
		prompt += "\nSeems like Game data files are not configured properly.\n"
		"Create Game data files using script ./create-testbed-data.sh in dists/engine-data\n"
		"Next, Configure the game path in launcher / command-line.\n"
		"Currently a few testsuites namely FS/AudioCD/MIDI would be disabled\n";
	}

	Testsuite::logPrintf("Info! : Interactive tests are also being executed.\n");

	if (Testsuite::handleInteractiveInput(prompt, "Proceed?", "Customize", kOptionRight)) {
		if (Engine::shouldQuit()) {
			return;
		}
		// Select testsuites using checkboxes
		TestbedOptionsDialog tbd(_testsuiteList, this);
		tbd.runModal();
	}

	// Clear it to remove entries before next rerun
	_configFileInterface.clear();
}
예제 #12
0
void addToContext(	QNFA *cxt, QDomElement c, int fid,
					QFormatScheme *f, QHash<QString, int>& pids,
					const QStringList& pref,
					const QStringList& suff,
					bool cs)
{
	QString tag = c.tagName();
	
	if ( !c.hasChildNodes() && tag != "embed" )
		return;
	
	cs = stringToBool(c.attribute("caseSensitive"), cs);
	
	if ( (tag == "start") || (tag == "stop") || (tag == "escape") )
	{
		return;
	} else if ( tag == "word" ) {
		//qDebug("adding word : %s", qPrintable(c.firstChild().toText().data()));
		const QString value = c.firstChild().toText().data();
		
		if ( pref.isEmpty() && suff.isEmpty() )
		{
			addWord(cxt, value, fid, cs);
		} else if ( pref.count() ) {
			foreach ( const QString& p, pref )
			{
				if ( suff.isEmpty() )
				{
					addWord(cxt, p + value, fid, cs);
				} else {
					foreach ( const QString& s, suff )
					{
						addWord(cxt, p + value + s, fid, cs);
					}
				}
			}
		} else {
예제 #13
0
void getBusData(ifstream& input,vector<Bus>& vecBus)
{//读取所有节点信息
	if(!input)
		return;
	string str;
	
	while(1)
	{
		str.clear();
		getline(input,str);
		if(str=="<Bus::nx type=全数>")
		{
			int i=0;
			str.clear();
			getline(input,str);
			vector<string> vecBusHeader=split(str);
			
			int busNameColumn(0);//识别表头
			int busVoltColumn(0);
			int busVColumn(0);
			int busAngColumn(0);
			int busOffColumn(0);
			int busV_maxColumn(0);
			int busV_minColumn(0);
			for(size_t t=0;t<vecBusHeader.size();++t)
			{
				if(vecBusHeader[t]=="node")
				{
					busNameColumn=t;
				}
				else if(vecBusHeader[t]=="volt")
				{
					busVoltColumn=t;
				}
				else if(vecBusHeader[t]=="V")
				{
					busVColumn=t;
				}
				else if(vecBusHeader[t]=="Ang")
				{
					busAngColumn=t;
				}
				else if(vecBusHeader[t]=="off")
				{
					busOffColumn=t;
				}
				else if(vecBusHeader[t]=="v_max")
				{
					busV_maxColumn=t;
				}
				else if(vecBusHeader[t]=="v_min")
				{
					busV_minColumn=t;
				}
				else
					continue;
			}
			const int busNameColumnConst=busNameColumn;
			const int busVoltColumnConst=busVoltColumn;
			const int busVColumnConst=busVColumn;
			const int busAngColumnConst=busAngColumn;
			const int busOffColumnConst=busOffColumn;
			const int busV_maxColumnConst=busV_maxColumn;
			const int busV_minColumnConst=busV_minColumn;
			//记录所需要行列的位置

			str.clear();//其中一行数据是不需要的,先清除一行数据
			getline(input,str);
			str.clear();
			getline(input,str);
			
			while(str!="</Bus::nx>")
			{
				vector<string> vec=split(str);
				//所有数据都已经存放在vec中,接下来是选出有用数据,对数所进行转换
				int volt=stringToInt(vec[busVoltColumnConst]);
				double v=stringToDouble(vec[busVColumnConst]);
				double ang=stringToDouble(vec[busAngColumnConst]);
				bool off=stringToBool(vec[busOffColumnConst]);
				double V_max=stringToDouble(vec[busV_maxColumnConst]);
				double V_min=stringToDouble(vec[busV_minColumnConst]);
				Bus bus=createBus(i,vec[busNameColumnConst],volt,v,ang,off,V_max,V_min);
				size_t t=0;
				for(;t<vecBus.size();++t)
				{
					if(vecBus[t]==bus)
					{
						str.clear();
						getline(input,str);
						break;
					}
				}
				if(t<vecBus.size())continue;
				vecBus.push_back(bus);
				i++;
				str.clear();
				getline(input,str);
			}
		}
		if(str=="</Bus::nx>")
			break;
	}
}
예제 #14
0
void getAClineData(ifstream& input,vector<ACline>& vecACline)
{//读取所有ACline
	if(!input)
		return;
	string str;
	
	while(1)
	{
		str.clear();
		getline(input,str);
		if(str=="<ACline::nx type=全数>")
		{//需要先读取很多行无用信息才能找到目标行,检索方法可以考虑改进
			int i=0;
			str.clear();
			getline(input,str);
			vector<string> vecAClineHeader=split(str);
			
			int AClineNameColumn(0);//识别表头
			int AClineVoltColumn(0);
			int AClineRColumn(0);
			int AClineXColumn(0);
			int AClineBColumn(0);
			int AClineI_nodeColumn(0);
			int AClineJ_nodeColumn(0);
			int AClineI_PColumn(0);
			int AClineI_QColumn(0);
			int AClineJ_PColumn(0);
			int AClineJ_QColumn(0);
			int AClineImaxColumn(0);
			int AClineAreaColumn(0);
			int AClineI_offColumn(0);
			int AClineJ_offColumn(0);

			for(size_t t=0;t<vecAClineHeader.size();++t)
			{//考虑用枚举替换,更清晰
				if(vecAClineHeader[t]=="name")
				{
					AClineNameColumn=t;
				}
				else if(vecAClineHeader[t]=="volt")
				{
					AClineVoltColumn=t;
				}
				else if(vecAClineHeader[t]=="R")
				{
					AClineRColumn=t;
				}
				else if(vecAClineHeader[t]=="X")
				{
					AClineXColumn=t;
				}
				else if(vecAClineHeader[t]=="B")
				{
					AClineBColumn=t;
				}
				else if(vecAClineHeader[t]=="I_node")
				{
					AClineI_nodeColumn=t;
				}
				else if(vecAClineHeader[t]=="J_node")
				{
					AClineJ_nodeColumn=t;
				}
				else if(vecAClineHeader[t]=="I_P")
				{
					AClineI_PColumn=t;
				}
				else if(vecAClineHeader[t]=="I_Q")
				{
					AClineI_QColumn=t;
				}
				else if(vecAClineHeader[t]=="J_P")
				{
					AClineJ_PColumn=t;
				}
				else if(vecAClineHeader[t]=="J_Q")
				{
					AClineJ_QColumn=t;
				}
				else if(vecAClineHeader[t]=="Imax")
				{
					AClineImaxColumn=t;
				}
				else if(vecAClineHeader[t]=="area")
				{
					AClineAreaColumn=t;
				}
				else if(vecAClineHeader[t]=="I_off")
				{
					AClineI_offColumn=t;
				}
				else if(vecAClineHeader[t]=="J_off")
				{
					AClineJ_offColumn=t;
				}
				else
					continue;
			}
			
			const int AClineNameColumnConst=AClineNameColumn;
			const int AClineVoltColumnConst=AClineVoltColumn;
			const int AClineRColumnConst=AClineRColumn;
			const int AClineXColumnConst=AClineXColumn;
			const int AClineBColumnConst=AClineBColumn;
			const int AClineI_nodeColumnConst=AClineI_nodeColumn;
			const int AClineJ_nodeColumnConst=AClineJ_nodeColumn;
			const int AClineI_PColumnConst=AClineI_PColumn;
			const int AClineI_QColumnConst=AClineI_QColumn;
			const int AClineJ_PColumnConst=AClineJ_PColumn;
			const int AClineJ_QColumnConst=AClineJ_QColumn;
			const int AClineImaxColumnConst=AClineImaxColumn;
			const int AClineAreaColumnConst=AClineAreaColumn;
			const int AClineI_offColumnConst=AClineI_offColumn;
			const int AClineJ_offColumnConst=AClineJ_offColumn;
			//记录所需要行列的位置

			str.clear();//其中一行数据是不需要的,先清除一行数据
			getline(input,str);
			str.clear();
			getline(input,str);
			
			while(str!="</ACline::nx>")
			{
				vector<string> vec=split(str);
				//所有数据都已经存放在vec中,接下来是选出有用数据,对数所进行转换
				int volt=stringToInt(vec[AClineVoltColumnConst]);
				string name=vec[AClineNameColumnConst];
				double r=stringToDouble(vec[AClineRColumnConst]);
				double x=stringToDouble(vec[AClineXColumnConst]);
				double b=stringToDouble(vec[AClineBColumnConst]);
				string i_nodename=vec[AClineI_nodeColumnConst];
				string j_nodename=vec[AClineJ_nodeColumnConst];
				double i_p=stringToDouble(vec[AClineI_PColumnConst]);
				double i_q=stringToDouble(vec[AClineI_QColumnConst]);
				double j_p=stringToDouble(vec[AClineJ_PColumnConst]);
				double j_q=stringToDouble(vec[AClineJ_QColumnConst]);
				double imax=stringToDouble(vec[AClineImaxColumnConst]);				
				string area=vec[AClineAreaColumnConst];
				bool iOff=stringToBool(vec[AClineI_offColumnConst]);
				bool jOff=stringToBool(vec[AClineJ_offColumnConst]);
				
				//判断ACline两端节点是否都在Bus表内,并找到对应的拓扑节点编号,满足则为有用信息
				/*int i_node=0;
				int j_node=0;//拓扑节点编号
				
				//理论上是不可能存在相同节点的
				if(i_nodename==j_nodename)continue;
				
				for(vector<Bus>::iterator iter=vecBus.begin();iter!=vecBus.end();++iter)
				{
					if(i_nodename==iter->getBusName())
						i_node=iter->getBusCode();
					else if(j_nodename==iter->getBusName())
						j_node=iter->getBusCode();
				}*/

				//在bus表中找到对应的节点才创建ACline对象
			
				ACline acline=createACline(i,name,volt,r,x,b,i_nodename,j_nodename,
						i_p,i_q,j_p,j_q,imax,area,iOff,jOff);
				size_t t=0;
				for(;t<vecACline.size();++t)
				{//判断是否存在相同支路,其实没必要检索整个容器,只需检索前若干个
				//其实没必要判断,不会出现相同支路
					if(vecACline[t]==acline)
					{
						str.clear();
						getline(input,str);
						break;
					}
				}
				if(t<vecACline.size())continue;
				vecACline.push_back(acline);
				i++;
				
				str.clear();
				getline(input,str);
			}
		}
		if(str=="</ACline::nx>")
			break;
	}
}
예제 #15
0
void getLoadData(ifstream& input,vector<Load>& vecLoad)
{//读取所有节点或其他信息函数
	if(!input)
		return;
	string str;
	
	while(1)
	{
		str.clear();
		getline(input,str);
		if(str=="<Load::nx type=全数>")
		{
		
			str.clear();
			getline(input,str);
			vector<string> vecLoadHeader=split(str);
			
			int loadVoltColumn(0);//识别表头
			int loadEqColumn(0);
			int loadNodeColumn(0);
			int loadPColumn(0);
			int loadQColumn(0);
			int loadOffColumn(0);
	
			for(size_t t=0;t<vecLoadHeader.size();++t)
			{
				if(vecLoadHeader[t]=="volt")
				{
					loadVoltColumn=t;
				}
				else if(vecLoadHeader[t]=="Eq")
				{
					loadEqColumn=t;
				}
				else if(vecLoadHeader[t]=="node")
				{
					loadNodeColumn=t;
				}
				else if(vecLoadHeader[t]=="P")
				{
					loadPColumn=t;
				}
				else if(vecLoadHeader[t]=="Q")
				{
					loadQColumn=t;
				}
				else if(vecLoadHeader[t]=="off")
				{
					loadOffColumn=t;
				}
		
				else
					continue;
			}
			const int loadVoltColumnConst=loadVoltColumn;
			const int loadEqColumnConst=loadEqColumn;
			const int loadNodeColumnConst=loadNodeColumn;
			const int loadPColumnConst=loadPColumn;
			const int loadQColumnConst=loadQColumn;
			const int loadOffColumnConst=loadOffColumn;
			
			//记录所需要行列的位置

			str.clear();//其中一行数据是不需要的,先清除一行数据
			getline(input,str);
			str.clear();
			getline(input,str);
			
			while(str!="</Load::nx>")
			{
				vector<string> vec=split(str);
				//所有数据都已经存放在vec中,接下来是选出有用数据,对数所进行转换
				int volt=stringToInt(vec[loadVoltColumnConst]);
				int eq=stringToInt(vec[loadEqColumnConst]);
				string node=vec[loadNodeColumnConst];
				double p=stringToDouble(vec[loadPColumnConst]);
				double q=stringToDouble(vec[loadQColumnConst]);
				bool off=stringToBool(vec[loadOffColumnConst]);
				Load load=createLoad(volt,eq,node,p,q,off);
				/*size_t t=0;
				for(;t<vecLoad.size();++t)
				{
					if(vecLoad[t]==load)
					{
						str.clear();
						getline(input,str);
						break;
					}
				}
				if(t<vecLoad.size())continue;*/
				vecLoad.push_back(load);
				
				str.clear();
				getline(input,str);
			}
		}
		if(str=="</Load::nx>")
			break;
	}
}
예제 #16
0
void SceneManagerCMPlay::Config(string directory)
{
	sceneBranch = TextTree::FileToRead(directory);

	for (vector<Branch>::iterator branch = sceneBranch.childBranches.begin(); branch != sceneBranch.childBranches.end(); ++branch)
	{
		if (branch->branchName == "SpatialPartition")
		{
			// create a spatial partition manager if it is not defined
			if (spatialPartitionManager == NULL)
			{
				spatialPartitionManager = new SpatialPartitionManager();
			}

			int type = 0;
			Vector3 partitionDimension;
			Vector2 partitionDimension2D;
			bool numPartitionBased = true;

			std::cout << "Setting up spatial partitioning" << std::endl;
			for (vector<Attribute>::iterator attri = branch->attributes.begin(); attri != branch->attributes.end(); ++attri)
			{
				Attribute tempAttri = *attri;
				string attriName = tempAttri.name;
				string attriValue = tempAttri.value;

				if (attriName == "Type")
				{
					type = stoi(attriValue);
				}

				else if (attriName == "WorldStart")
				{
					if (type == 3)
					{
						stringToVector(attriValue, world3DStart);
					}

					else
					{
						stringToVector(attriValue, world2DStart);
					}
				}

				else if (attriName == "WorldEnd")
				{
					if (type == 3)
					{
						stringToVector(attriValue, world3DEnd);
					}

					else
					{
						stringToVector(attriValue, world2DEnd);
					}
				}

				else if (attriName == "Partitions")
				{
					if (type == 3)
					{
						stringToVector(attriValue, partitionDimension);
					}

					else
					{
						stringToVector(attriValue, partitionDimension2D);
					}
				}

				else if (attriName == "PartitionBased")
				{
					stringToBool(attriValue, numPartitionBased);
				}
			}

			// 3D spatial partition
			if (type == 3)
			{
				spatialPartitionManager->Init(world3DStart, world3DEnd, partitionDimension, numPartitionBased, resourceManager.retrieveMesh("DEBUG_CUBE"));
			}

			// assume its 2D
			else
			{
				spatialPartitionManager->Init(world2DStart, world2DEnd, partitionDimension2D, numPartitionBased, resourceManager.retrieveMesh("DEBUG_QUAD"));
			}
		}

		else if (branch->branchName == "SceneNode")
		{
			std::cout << "Creating scenenode container!" << std::endl;

			for (vector<Attribute>::iterator attri = branch->attributes.begin(); attri != branch->attributes.end(); ++attri)
			{
				Attribute tempAttri = *attri;
				string attriName = tempAttri.name;
				string attriValue = tempAttri.value;

				if (attriName == "Container")
				{
					GameObject3D* object;
					SceneNode* node;
					int containerSize = stoi(tempAttri.value);
					for (int i = 0; i < containerSize; ++i)
					{
						object = new GameObject3D;
						node = new SceneNode;

						node->SetGameObject(object);

						nodeList.push_back(node);
					}
				}
			}
		}
	}
}
예제 #17
0
int action(QDomElement c, QFormatScheme *f, QHash<QString, int>& pids, int fid = 0)
{
	QString paren, spid, spt, sfid;
	
	sfid = c.attribute("format");
	
	if ( sfid.count() )
	{
		fid |= QNFAAction::Highlight | QNFAAction::format(f->id(sfid));
	}
	
	paren = c.attribute("parenthesis");
	
	if ( paren.count() )
	{
		spid = paren.section(':', 0, -2);
		spt = paren.section(':', -1, -1);
		
		if ( spt.endsWith("@nomatch") )
		{
			spt.chop(8);
		} else {
			fid |= QNFAAction::MatchParen;
		}
		
		if ( spid.count() )
		{
			/*qDebug("paren : [%s|%s] => 0x%x",
					qPrintable(spid), qPrintable(spt),
					(spt == "open" ? QNFAAction::ParenOpen : QNFAAction::ParenClose) | pid(spid, pids));
			*/
			
			if ( spt == "open" )
				fid |= QNFAAction::ParenOpen;
			else if ( spt == "close" )
				fid |= QNFAAction::ParenClose;
			else if ( spt == "boundary" )
				fid |= QNFAAction::ParenOpen | QNFAAction::ParenClose;

			fid |= QNFAAction::parenthesis(pid(spid, pids));
			
			/*
			qDebug("paren : [%s|%s] => 0x%x",
					qPrintable(spid), qPrintable(spt),
					fid & QNFAAction::ParenMask);
			*/
		}
	}
	
	if ( stringToBool(c.attribute("indent"), false) )
		fid |= QNFAAction::Indent;
	
	if ( stringToBool(c.attribute("fold"), false) )
		fid |= QNFAAction::Fold;
	
	// TODO : determine ambiguity automatically
	if ( stringToBool(c.attribute("ambiguous"), false) )
		fid |= QNFAAction::Ambiguous;
	
	return fid;
}
예제 #18
0
void ResourcePool::processMesh(string config)
{
	Branch meshBranch = TextTree::FileToRead(config);

	for (vector<Branch>::iterator branch = meshBranch.childBranches.begin(); branch != meshBranch.childBranches.end(); ++branch)
	{
		string meshName = branch->branchName;
		Color meshColor;

		enum MISC_VARIABLE
		{
			VAR_LENGTH,
			VAR_WIDTH,
			VAR_HEIGHT,
			VAR_RADIUS,
			VAR_INNER_RADIUS,
			VAR_OUTER_RADIUS,
			VAR_SLICES,
			VAR_STACKS,
			VAR_ANIM_TIME,
			MAX_VAR,
		};

		float meshVar[MAX_VAR];
		for (int i = 0; i < MAX_VAR; ++i)
		{
			meshVar[i] = 1.0f;
		}

		string meshVarNames[MAX_VAR] =
		{
			"Length",
			"Width",
			"Height",
			"Radius",
			"InnerRadius",
			"OuterRadius",
			"Slices",
			"Stacks",
		};

		// default 2D mesh variables
		int meshPosX = 0;
		int meshPosY = 0;

		int meshTextRow = 0;
		int meshTextCol = 0;

		// Spirte Animation
		int meshSpriteRow = 0;
		int meshSpriteCol = 0;

		// Tile sheet
		int meshTileRow = 0;
		int meshTileCol = 0;

		string directory = "";
		string meshType = "";

		unsigned textureID = 0;

		for (vector<Attribute>::iterator attri = branch->attributes.begin(); attri != branch->attributes.end(); ++attri)
		{
			Attribute tempAttri = *attri;
			string attriName = tempAttri.name;
			string attriValue = tempAttri.value;

			if (attriName == "ColorValue")
			{
				Vector3 tempColor;

				stringToVector(attriValue, tempColor);

				meshColor.Set(tempColor.x, tempColor.y, tempColor.z);
			}

			if (attriName == "ColorName")
			{
				meshColor = retrieveColor(attriValue);
			}

			else if (attriName == "Type")
			{
				meshType = attriValue;
			}

			else if (attriName == "Texture")
			{ 
				textureID = this->retrieveTexture(attriValue);
			}

			else if (attriName == "Directory")
			{
				directory = attriValue;
			}

			else if (attriName == "SpriteRow")
			{
				meshSpriteRow = stoi(attriValue);
			}

			else if (attriName == "SpriteCol")
			{
				meshSpriteCol = stoi(attriValue);
			}

			else if (attriName == "TextRow")
			{
				meshTextRow = stoi(attriValue);
			}

			else if (attriName == "TextCol")
			{
				meshTextCol = stoi(attriValue);
			}

			else if (attriName == "PosX")
			{
				meshPosX = stoi(attriValue);
			}

			else if (attriName == "PosY")
			{
				meshPosY = stoi(attriValue);
			}

			else if (attriName == "TileRow")
			{
				meshTileRow = stoi(attriValue);
			}

			else if (attriName == "TileCol")
			{
				meshTileCol = stoi(attriValue);
			}

			else
			{
				for (int k = 0; k < MAX_VAR; ++k)
				{
					if (attriName == meshVarNames[k])
					{
						meshVar[k] = stof(attriValue);
						break;
					}
				}
			}
		}

		// process data, generate mesh using meshbuilder
		Mesh* mesh = NULL;

		if (meshType == "Axis")
		{
			mesh = MeshBuilder::GenerateAxes(meshName, meshVar[VAR_LENGTH], meshVar[VAR_HEIGHT], meshVar[VAR_WIDTH]);
		}

		else if (meshType == "Ray")
		{
			mesh = MeshBuilder::GenerateRay(meshName, meshVar[VAR_LENGTH]);
		}

		else if (meshType == "Quad")
		{
			mesh = MeshBuilder::GenerateQuad(meshName, meshColor, meshVar[VAR_LENGTH], meshVar[VAR_WIDTH]);
		}

		else if (meshType == "Cube")
		{
			mesh = MeshBuilder::GenerateCube(meshName, meshColor, meshVar[VAR_LENGTH]);
		}

		else if (meshType == "Circle")
		{
			mesh = MeshBuilder::GenerateCircle(meshName, meshColor, (unsigned)meshVar[VAR_SLICES], meshVar[VAR_RADIUS]);
		}

		else if (meshType == "DebugQuad")
		{
			mesh = MeshBuilder::GenerateDebugQuad(meshName, meshColor, meshVar[VAR_LENGTH]);
		}

		else if (meshType == "DebugCircle")
		{
			mesh = MeshBuilder::GenerateDebugCircle(meshName, meshColor, (unsigned)meshVar[VAR_SLICES], meshVar[VAR_RADIUS]);
		}

		else if (meshType == "DebugCube")
		{
			mesh = MeshBuilder::GenerateDebugCube(meshName, meshColor, meshVar[VAR_LENGTH]);
		}

		else if (meshType == "Sphere")
		{
			mesh = MeshBuilder::GenerateSphere(meshName, meshColor, (unsigned)meshVar[VAR_STACKS], (unsigned)meshVar[VAR_SLICES], meshVar[VAR_RADIUS]);
		}

		else if (meshType == "Skyplane")
		{
			mesh = MeshBuilder::GenerateSkyPlane(meshName, meshColor, (unsigned)meshVar[VAR_SLICES], (float)meshVar[VAR_INNER_RADIUS], (float)meshVar[VAR_OUTER_RADIUS], (float)meshTileRow, (float)meshTileCol);
		}

		else if (meshType == "Terrain")
		{
			HEIGHTMAP tempHeightmap;
			tempHeightmap.name = meshName;
			mesh = MeshBuilder::GenerateTerrain(meshName, directory, tempHeightmap.heightMap);

			if (this->addHeightmap(tempHeightmap.name, tempHeightmap))
			{
				std::cout << "Successfully added new heightmap!" << std::endl;
			}
		}

		else if (meshType == "Obj")
		{
			mesh = MeshBuilder::GenerateOBJ(meshName, directory);
		}

		else if (meshType == "Text")
		{
			mesh = MeshBuilder::GenerateText(meshName, meshTextRow, meshTextCol);
		}

		else if (meshType == "2D")
		{
			mesh = MeshBuilder::Generate2DMesh(meshName, meshColor, (int)meshVar[VAR_WIDTH], (int)meshVar[VAR_HEIGHT]);
		}

		else if (meshType == "SpriteAnimation")
		{
			mesh = MeshBuilder::GenerateSpriteAnimation(meshName, meshSpriteRow, meshSpriteCol);

			SpriteAnimation *sa = dynamic_cast<SpriteAnimation*>(mesh);

			Branch tempBranch = *branch;
			// handle animations variables
			for (vector<Branch>::iterator childbranch = tempBranch.childBranches.begin(); childbranch != tempBranch.childBranches.end(); ++childbranch)
			{
				int id = 0;
				int startFrame = 0;
				int endFrame = 0;
				bool repeat = false;
				bool pause = false;
				float animationTime = 0.f;

				for (vector<Attribute>::iterator childAttri = childbranch->attributes.begin(); childAttri != childbranch->attributes.end(); ++childAttri)
				{
					Attribute tempAttri = *childAttri;
					string attriName = tempAttri.name;
					string attriValue = tempAttri.value;

					if (attriName == "ID")
					{
						id = stoi(attriValue);
					}

					else if (attriName == "StartFrame")
					{
						startFrame = stoi(attriValue);
					}

					else if (attriName == "EndFrame")
					{
						endFrame = stoi(attriValue);
					}

					else if (attriName == "Repeat")
					{
						stringToBool(attriValue, repeat);
					}

					else if (attriName == "Pause")
					{
						stringToBool(attriValue, pause);
					}

					else if (attriName == "AnimationTime")
					{
						animationTime = stof(attriValue);
					}
				}

				if (sa)
				{
					Animation* anime = new Animation();
					anime->Set(id, startFrame, endFrame, repeat, pause, animationTime);
					sa->animations.push_back(anime);
				}
			}

			//sort (sa->animations.begin(), sa->animations.end());
		}

		else if (meshType == "TileSheet")
		{
			mesh = MeshBuilder::GenerateTileSheet(meshName, meshTileRow, meshTileCol);
		}

		// push back mesh
		if (mesh != NULL)
		{
			if (textureID != 0)
			{
				mesh->textureID = textureID;
			}

			if (addMesh(branch->branchName, mesh))
			{
				std::cout << "Successfully added new mesh!" << std::endl;
			}
		}
	}
}
예제 #19
0
파일: init.c 프로젝트: MLton/mlton
int processAtMLton (GC_state s, int start, int argc, char **argv,
                    char **worldFile) {
  int i;

  i = start;
  while (s->controls.mayProcessAtMLton
         and i < argc
         and (0 == strcmp (argv [i], "@MLton"))) {
    bool done;

    i++;
    done = FALSE;
    while (!done) {
      if (i == argc)
        die ("Missing -- at end of @MLton args.");
      else {
        char *arg;

        arg = argv[i];
        if (0 == strcmp (arg, "copy-generational-ratio")) {
          i++;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton copy-generational-ratio missing argument.");
          s->controls.ratios.copyGenerational = stringToFloat (argv[i++]);
          unless (1.0 < s->controls.ratios.copyGenerational)
            die ("@MLton copy-generational-ratio argument must be greater than 1.0.");
        } else if (0 == strcmp (arg, "copy-ratio")) {
          i++;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton copy-ratio missing argument.");
          s->controls.ratios.copy = stringToFloat (argv[i++]);
          unless (1.0 < s->controls.ratios.copy)
            die ("@MLton copy-ratio argument must be greater than 1.0.");
        } else if (0 == strcmp (arg, "fixed-heap")) {
          i++;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton fixed-heap missing argument.");
          s->controls.fixedHeap = align (stringToBytes (argv[i++]),
                                         2 * s->sysvals.pageSize);
        } else if (0 == strcmp (arg, "gc-messages")) {
          i++;
          s->controls.messages = TRUE;
        } else if (0 == strcmp (arg, "gc-summary")) {
          i++;
          s->controls.summary = TRUE;
        } else if (0 == strcmp (arg, "gc-summary-file")) {
          i++;
          if (i == argc || (0 == strcmp (argv[i], "--")))
            die ("@MLton gc-summary-file missing argument.");
          s->controls.summary = TRUE;
          s->controls.summaryFile = fopen(argv[i++], "w");
          if (s->controls.summaryFile == NULL) {
            die ("Invalid @MLton gc-summary-file %s (%s).", argv[i-1], strerror(errno));
          }
        } else if (0 == strcmp (arg, "grow-ratio")) {
          i++;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton grow-ratio missing argument.");
          s->controls.ratios.grow = stringToFloat (argv[i++]);
          unless (1.0 < s->controls.ratios.grow)
            die ("@MLton grow-ratio argument must be greater than 1.0.");
        } else if (0 == strcmp (arg, "hash-cons")) {
          i++;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton hash-cons missing argument.");
          s->controls.ratios.hashCons = stringToFloat (argv[i++]);
          unless (0.0 <= s->controls.ratios.hashCons
                  and s->controls.ratios.hashCons <= 1.0)
            die ("@MLton hash-cons argument must be between 0.0 and 1.0.");
        } else if (0 == strcmp (arg, "live-ratio")) {
          i++;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton live-ratio missing argument.");
          s->controls.ratios.live = stringToFloat (argv[i++]);
          unless (1.0 < s->controls.ratios.live)
            die ("@MLton live-ratio argument must be greater than 1.0.");
        } else if (0 == strcmp (arg, "load-world")) {
          unless (s->controls.mayLoadWorld)
            die ("May not load world.");
          i++;
          s->amOriginal = FALSE;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton load-world missing argument.");
          *worldFile = argv[i++];
        } else if (0 == strcmp (arg, "mark-compact-generational-ratio")) {
          i++;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton mark-compact-generational-ratio missing argument.");
          s->controls.ratios.markCompactGenerational = stringToFloat (argv[i++]);
          unless (1.0 < s->controls.ratios.markCompactGenerational)
            die ("@MLton mark-compact-generational-ratio argument must be greater than 1.0.");
        } else if (0 == strcmp (arg, "mark-compact-ratio")) {
          i++;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton mark-compact-ratio missing argument.");
          s->controls.ratios.markCompact = stringToFloat (argv[i++]);
          unless (1.0 < s->controls.ratios.markCompact)
            die ("@MLton mark-compact-ratio argument must be greater than 1.0.");
        } else if (0 == strcmp (arg, "max-heap")) {
          i++;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton max-heap missing argument.");
          s->controls.maxHeap = align (stringToBytes (argv[i++]),
                                       2 * s->sysvals.pageSize);
        } else if (0 == strcmp (arg, "may-page-heap")) {
          i++;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton may-page-heap missing argument.");
          s->controls.mayPageHeap = stringToBool (argv[i++]);
        } else if (0 == strcmp (arg, "no-load-world")) {
          i++;
          s->controls.mayLoadWorld = FALSE;
        } else if (0 == strcmp (arg, "nursery-ratio")) {
          i++;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton nursery-ratio missing argument.");
          s->controls.ratios.nursery = stringToFloat (argv[i++]);
          unless (1.0 < s->controls.ratios.nursery)
            die ("@MLton nursery-ratio argument must be greater than 1.0.");
        } else if (0 == strcmp (arg, "ram-slop")) {
          i++;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton ram-slop missing argument.");
          s->controls.ratios.ramSlop = stringToFloat (argv[i++]);
        } else if (0 == strcmp (arg, "show-sources")) {
          showSources (s);
          exit (0);
        } else if (0 == strcmp (arg, "stop")) {
          i++;
          s->controls.mayProcessAtMLton = FALSE;
        } else if (0 == strcmp (arg, "stack-current-grow-ratio")) {
          i++;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton stack-current-grow-ratio missing argument.");
          s->controls.ratios.stackCurrentGrow = stringToFloat (argv[i++]);
          unless (1.0 < s->controls.ratios.stackCurrentGrow)
            die ("@MLton stack-current-grow-ratio argument must greater than 1.0.");
        } else if (0 == strcmp (arg, "stack-current-max-reserved-ratio")) {
          i++;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton stack-current-max-reserved-ratio missing argument.");
          s->controls.ratios.stackCurrentMaxReserved = stringToFloat (argv[i++]);
          unless (1.0 < s->controls.ratios.stackCurrentMaxReserved)
            die ("@MLton stack-current-max-reserved-ratio argument must greater than 1.0.");
        } else if (0 == strcmp (arg, "stack-current-permit-reserved-ratio")) {
          i++;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton stack-current-permit-reserved-ratio missing argument.");
          s->controls.ratios.stackCurrentPermitReserved = stringToFloat (argv[i++]);
          unless (1.0 < s->controls.ratios.stackCurrentPermitReserved)
            die ("@MLton stack-current-permit-reserved-ratio argument must greater than 1.0.");
        } else if (0 == strcmp (arg, "stack-current-shrink-ratio")) {
          i++;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton stack-current-shrink-ratio missing argument.");
          s->controls.ratios.stackCurrentShrink = stringToFloat (argv[i++]);
          unless (0.0 <= s->controls.ratios.stackCurrentShrink
                  and s->controls.ratios.stackCurrentShrink <= 1.0)
            die ("@MLton stack-current-shrink-ratio argument must be between 0.0 and 1.0.");
        } else if (0 == strcmp (arg, "stack-max-reserved-ratio")) {
          i++;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton stack-max-reserved-ratio missing argument.");
          s->controls.ratios.stackMaxReserved = stringToFloat (argv[i++]);
          unless (1.0 < s->controls.ratios.stackMaxReserved)
            die ("@MLton stack-max-reserved-ratio argument must greater than 1.0.");
        } else if (0 == strcmp (arg, "stack-shrink-ratio")) {
          i++;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton stack-shrink-ratio missing argument.");
          s->controls.ratios.stackShrink = stringToFloat (argv[i++]);
          unless (0.0 <= s->controls.ratios.stackShrink
                  and s->controls.ratios.stackShrink <= 1.0)
            die ("@MLton stack-shrink-ratio argument must be between 0.0 and 1.0.");
        } else if (0 == strcmp (arg, "use-mmap")) {
          i++;
          if (i == argc || 0 == strcmp (argv[i], "--"))
            die ("@MLton use-mmap missing argument.");
          GC_setCygwinUseMmap (stringToBool (argv[i++]));
        } else if (0 == strcmp (arg, "--")) {
          i++;
          done = TRUE;
        } else if (i > 1)
          die ("Strange @MLton arg: %s", argv[i]);
        else done = TRUE;
      }
    }
  }
  return i;
}
예제 #20
0
static void parse(PmuXML & pmuXml, const char * const xml)
{
    mxml_node_t *root = mxmlLoadString(NULL, xml, MXML_NO_CALLBACK);

    for (mxml_node_t *node = mxmlFindElement(root, root, TAG_PMU, NULL, NULL, MXML_DESCEND); node != NULL;
            node = mxmlFindElement(node, root, TAG_PMU, NULL, NULL, MXML_DESCEND)) {
        const char * const pmncName = mxmlElementGetAttr(node, ATTR_PMNC_NAME);
        const char * const cpuidStr = mxmlElementGetAttr(node, ATTR_CPUID);
        int cpuid;
        if (!stringToInt(&cpuid, cpuidStr, 0)) {
            logg.logError("The cpuid for '%s' in pmu XML is not an integer", pmncName);
            handleException();
        }
        const char * const coreName = mxmlElementGetAttr(node, ATTR_CORE_NAME);
        const char * const dtName = mxmlElementGetAttr(node, ATTR_DT_NAME);
        const char * const speName = mxmlElementGetAttr(node, ATTR_SPE_NAME);
        const char * const pmncCountersStr = mxmlElementGetAttr(node, ATTR_PMNC_COUNTERS);
        const char * const profileStr = mxmlElementGetAttr(node, AATR_PROFILE);
        int pmncCounters;
        if (!stringToInt(&pmncCounters, pmncCountersStr, 0)) {
            logg.logError("The pmnc_counters for '%s' in pmu XML is not an integer", pmncName);
            handleException();
        }
        if (pmncName == NULL || cpuid == 0 || coreName == NULL || pmncCounters == 0) {
            logg.logError("A pmu from the pmu XML is missing one or more of the required attributes (%s, %s, %s and %s)", ATTR_PMNC_NAME, ATTR_CPUID, ATTR_CORE_NAME, ATTR_PMNC_COUNTERS);
            handleException();
        }

        //Check whether the pmu is v8, needed when hardware is 64 bit but kernel is 32 bit.
        bool isV8 = false;
        if (profileStr != nullptr) {
            if (profileStr[0] == '8') {
                isV8 = true;
            }
        }

        logg.logMessage("Found <%s %s=\"%s\" %s=\"%s\" %s=\"0x%05x\" %s=\"%d\" />",
                        TAG_PMU,
                        ATTR_CORE_NAME, coreName,
                        ATTR_PMNC_NAME, pmncName,
                        ATTR_CPUID, cpuid,
                        ATTR_PMNC_COUNTERS, pmncCounters);

        pmuXml.cpus.emplace_back(strdup(coreName), strdup(pmncName), lib::strdup_null(dtName),
                                 lib::strdup_null(speName), cpuid, pmncCounters, isV8);
    }

    for (mxml_node_t *node = mxmlFindElement(root, root, TAG_UNCORE_PMU, NULL, NULL, MXML_DESCEND); node != NULL;
            node = mxmlFindElement(node, root, TAG_UNCORE_PMU, NULL, NULL, MXML_DESCEND)) {
        const char * const pmncName = mxmlElementGetAttr(node, ATTR_PMNC_NAME);
        const char * const coreName = mxmlElementGetAttr(node, ATTR_CORE_NAME);
        const char * const pmncCountersStr = mxmlElementGetAttr(node, ATTR_PMNC_COUNTERS);
        int pmncCounters;
        if (!stringToInt(&pmncCounters, pmncCountersStr, 0)) {
            logg.logError("The pmnc_counters for '%s' in pmu XML is not an integer", pmncName);
            handleException();
        }
        const char * const hasCyclesCounterStr = mxmlElementGetAttr(node, ATTR_HAS_CYCLES_COUNTER);
        const bool hasCyclesCounter = stringToBool(hasCyclesCounterStr, true);
        if (pmncName == NULL || coreName == NULL || pmncCounters == 0) {
            logg.logError("An uncore_pmu from the pmu XML is missing one or more of the required attributes (%s, %s and %s)", ATTR_PMNC_NAME, ATTR_CORE_NAME, ATTR_PMNC_COUNTERS);
            handleException();
        }

        // check if the path contains a wildcard
        if (strstr(pmncName, UNCORE_PMNC_NAME_WILDCARD) == nullptr)
        {
            // no - just add one item
            logg.logMessage("Found <%s %s=\"%s\" %s=\"%s\" %s=\"%s\" %s=\"%d\" />",
                            TAG_UNCORE_PMU,
                            ATTR_CORE_NAME, coreName,
                            ATTR_PMNC_NAME, pmncName,
                            ATTR_HAS_CYCLES_COUNTER, hasCyclesCounter ? "true" : "false",
                            ATTR_PMNC_COUNTERS, pmncCounters);

            pmuXml.uncores.emplace_back(strdup(coreName), strdup(pmncName), pmncCounters, hasCyclesCounter);
        }
        else
        {
            // yes - add actual matching items from filesystem
            bool matched = false;
            std::unique_ptr<DIR, int (*)(DIR*)> dir { opendir(PERF_DEVICES), closedir };
            if (dir != nullptr) {
                struct dirent * dirent;
                while ((dirent = readdir(dir.get())) != NULL) {
                    if (matchPMUName(pmncName, dirent->d_name)) {
                        // matched dirent
                        logg.logMessage("Found <%s %s=\"%s\" %s=\"%s\" %s=\"%s\" %s=\"%d\" />",
                                        TAG_UNCORE_PMU,
                                        ATTR_CORE_NAME, coreName,
                                        ATTR_PMNC_NAME, dirent->d_name,
                                        ATTR_HAS_CYCLES_COUNTER, hasCyclesCounter ? "true" : "false",
                                        ATTR_PMNC_COUNTERS, pmncCounters);
                        new UncorePmu(strdup(coreName), strdup(dirent->d_name), pmncCounters, hasCyclesCounter);
                        matched = true;
                    }
                }
            }

            if (!matched) {
                logg.logMessage("No matching devices for wildcard <%s %s=\"%s\" %s=\"%s\" %s=\"%s\" %s=\"%d\" />",
                                TAG_UNCORE_PMU,
                                ATTR_CORE_NAME, coreName,
                                ATTR_PMNC_NAME, pmncName,
                                ATTR_HAS_CYCLES_COUNTER, hasCyclesCounter ? "true" : "false",
                                ATTR_PMNC_COUNTERS, pmncCounters);
            }
        }
    }

    mxmlDelete(root);
}
예제 #21
0
/*!
  Returns true if rememberDimensions value is checked in configuration.

  \sa setRememberDimensions
  */
bool CcfConfig::isRememberDimensionsSet() const
{
    QString result = mConfiguration->value("remember dimensions on exit");
    return stringToBool(result);
}
예제 #22
0
Property Property::fromXMLNode(const QDomElement &element)
{
    if (element.tagName() == "Property")
    {
        Property p;
        p.setName(element.attribute("name"));
        p.setDocName(element.attribute("docName"));
        p.setDocBrief(element.attribute("docBrief"));
        p.setDocDetail(element.attribute("docDetail"));
        p.setType(element.attribute("type"));
        p.setTypeStringName(element.attribute("typeStringName"));
        p.setDefaultValue(QVariant(element.attribute("defaultValue")));
        p.setRevision(element.attribute("revision").toInt());
        p.setMember(stringToBool(element.attribute("member")));
        p.setRead(stringToBool(element.attribute("read")));
        p.setWrite(stringToBool(element.attribute("write")));
        p.setReset(stringToBool(element.attribute("reset")));
        p.setNotify(stringToBool(element.attribute("notify")));
        p.setEnabled(stringToBool(element.attribute("enabled")));
        p.setDesignable(stringToBool(element.attribute("designable")));
        p.setScriptable(stringToBool(element.attribute("scriptable")));
        p.setStored(stringToBool(element.attribute("stored")));
        p.setUser(stringToBool(element.attribute("user")));
        p.setConstant(stringToBool(element.attribute("constant")));
        p.setFinal(stringToBool(element.attribute("final")));
        return p;
    }
    else
    {
        return Property();
    }
}
예제 #23
0
void getUnit(ifstream& input,vector<Unit>& vecUnit)
{
	if(!input)
		return;
	string str;
	
	while(1)
	{
		str.clear();
		getline(input,str);
		if(str=="<Unit::nx type=全数>")
		{//需要先读取很多行无用信息才能找到目标行,检索方法可以考虑改进
			str.clear();
			getline(input,str);
			vector<string> vecUnitHeader=split(str);
			
			int UnitEqColumn(0);//识别表头
			int UnitV_RateColumn(0);
			int UnitP_RateColumn(0);
			int UnitTopoNodeColumn(0);
			int UnitPColumn(0);
			int UnitQColumn(0);
			int UnitUeColumn(0);
			int UnitAngColumn(0);
			int UnitOffColumn(0);
			int UnitP_HColumn(0);
			int UnitP_LColumn(0);
			int UnitQ_HColumn(0);
			int UnitQ_LColumn(0);
			int UnitVoltColumn(0);
			
			for(size_t t=0;t<vecUnitHeader.size();++t)
			{//考虑switch,更清晰
				if(vecUnitHeader[t]=="Eq")
				{
					UnitEqColumn=t;
				}
				else if(vecUnitHeader[t]=="V_Rate")
				{
					UnitV_RateColumn=t;
				}
				else if(vecUnitHeader[t]=="P_Rate")
				{
					UnitP_RateColumn=t;
				}
				else if(vecUnitHeader[t]=="node")
				{
					UnitTopoNodeColumn=t;
				}
				else if(vecUnitHeader[t]=="P")
				{
					UnitPColumn=t;
				}
				else if(vecUnitHeader[t]=="Q")
				{
					UnitQColumn=t;
				}
				else if(vecUnitHeader[t]=="Ue")
				{
					UnitUeColumn=t;
				}
				else if(vecUnitHeader[t]=="Ang")
				{
					UnitAngColumn=t;
				}
				else if(vecUnitHeader[t]=="off")
				{
					UnitOffColumn=t;
				}
				else if(vecUnitHeader[t]=="P_H")
				{
					UnitP_HColumn=t;
				}
				else if(vecUnitHeader[t]=="P_L")
				{
					UnitP_LColumn=t;
				}
				else if(vecUnitHeader[t]=="Q_H")
				{
					UnitQ_HColumn=t;
				}
				else if(vecUnitHeader[t]=="Q_L")
				{
					UnitQ_LColumn=t;
				}
				else if(vecUnitHeader[t]=="Volt")
				{
					UnitVoltColumn=t;
				}
				else
					continue;
			}
			
			const int UnitEqColumnConst=UnitEqColumn;//识别表头
			const int UnitV_RateColumnConst=UnitV_RateColumn;
			const int UnitP_RateColumnConst=UnitP_RateColumn;
			const int UnitTopoNodeColumnConst=UnitTopoNodeColumn;
			const int UnitPColumnConst=UnitPColumn;
			const int UnitQColumnConst=UnitQColumn;
			const int UnitUeColumnConst=UnitUeColumn;
			const int UnitAngColumnConst=UnitAngColumn;
			const int UnitOffColumnConst=UnitOffColumn;
			const int UnitP_HColumnConst=UnitP_HColumn;
			const int UnitP_LColumnConst=UnitP_LColumn;
			const int UnitQ_HColumnConst=UnitQ_HColumn;
			const int UnitQ_LColumnConst=UnitQ_LColumn;
			const int UnitVoltColumnConst=UnitVoltColumn;
			//记录所需要行列的位置

			str.clear();//其中一行数据是不需要的,先清除一行数据
			getline(input,str);
			str.clear();
			getline(input,str);
			
			while(str!="</Unit::nx>")
			{
				vector<string> vec=split(str);
				//所有数据都已经存放在vec中,接下来是选出有用数据,对数所进行转换
				bool eq=stringToBool(vec[UnitEqColumnConst]);
				double v_Rate=stringToDouble(vec[UnitV_RateColumnConst]);
				double p_Rate=stringToDouble(vec[UnitP_RateColumnConst]);
				string topoNode=vec[UnitTopoNodeColumnConst];
				double p=stringToDouble(vec[UnitPColumnConst]);
				double q=stringToDouble(vec[UnitQColumnConst]);
				double ue=stringToDouble(vec[UnitUeColumnConst]);
				double ang=stringToDouble(vec[UnitAngColumnConst]);
				bool off=stringToBool(vec[UnitOffColumnConst]);
				double p_H=stringToDouble(vec[UnitP_HColumnConst]);
				double p_L=stringToDouble(vec[UnitP_LColumnConst]);
				double q_H=stringToDouble(vec[UnitQ_HColumnConst]);
				double q_L=stringToDouble(vec[UnitQ_LColumnConst]);
				int volt=stringToInt(vec[UnitVoltColumnConst]);
				
				//在bus表中找到对应的节点才创建ACline对象			
				Unit unit=createUnit(eq,v_Rate,p_Rate,topoNode,p,q,ue,ang,off,
										p_H,p_L,q_H,q_L,volt);

				vecUnit.push_back(unit);

				str.clear();
				getline(input,str);
			}
		}
		if(str=="</Unit::nx>")
			break;
	}
}
예제 #24
0
bool TrackerConfig::getBoolParam(const std::string& sXPathExpr) const
{
    return stringToBool(getParam(sXPathExpr));
}
예제 #25
0
void getTransData(ifstream& input,vector<Transformer>& vecTrans)
{//读取所有节点或其他信息函数
	if(!input)
		return;
	string str;
	
	while(1)
	{
		str.clear();
		getline(input,str);
		if(str=="<Transformer::nx type=全数>")
		{
			str.clear();
			getline(input,str);
			vector<string> vecTransHeader=split(str);
			
			//识别表头
			int transCodeColumn(0);
			int transTypeColumn(0);
			int transI_VolColumn(0);
			int transK_VolColumn(0);
			int transJ_VolColumn(0);
			int transI_SColumn(0);
			int transK_SColumn(0);
			int transJ_SColumn(0);
			int transItap_HColumn(0);
			int transItap_LColumn(0);
			int transItap_EColumn(0);
			int transItap_CColumn(0);
			int transItap_VColumn(0);
			int transKtap_HColumn(0);
			int transKtap_LColumn(0);
			int transKtap_EColumn(0);
			int transKtap_CColumn(0);
			int transKtap_VColumn(0);
			int transJtap_VColumn(0);
			int transRiColumn(0);
			int transXiColumn(0);
			int transRkColumn(0);
			int transXkColumn(0);
			int transRjColumn(0);
			int transXjColumn(0);
			int transI_nodeColumn(0);
			int transK_nodeColumn(0);
			int transJ_nodeColumn(0);
			int transI_PColumn(0);
			int transI_QColumn(0);
			int transK_PColumn(0);
			int transK_QColumn(0);
			int transJ_PColumn(0);
			int transJ_QColumn(0);
			int transI_tapColumn(0);
			int transK_tapColumn(0);
			int transI_offColumn(0);
			int transK_offColumn(0);
			int transJ_offColumn(0);

			for(size_t t=0;t<vecTransHeader.size();++t)
			{
				if(vecTransHeader[t]=="id")
				{
					transCodeColumn=t;
				}
				else if(vecTransHeader[t]=="type")
				{
					transTypeColumn=t;
				}
				else if(vecTransHeader[t]=="I_Vol")
				{
					transI_VolColumn=t;
				}
				else if(vecTransHeader[t]=="K_Vol")
				{
					transK_VolColumn=t;
				}
				else if(vecTransHeader[t]=="J_Vol")
				{
					transJ_VolColumn=t;
				}
				else if(vecTransHeader[t]=="I_S")
				{
					transI_SColumn=t;
				}
				else if(vecTransHeader[t]=="K_S")
				{
					transK_SColumn=t;
				}
				else if(vecTransHeader[t]=="J_S")
				{
					transJ_SColumn=t;
				}
				else if(vecTransHeader[t]=="Itap_H")
				{
					transItap_HColumn=t;
				}
				else if(vecTransHeader[t]=="Itap_L")
				{
					transItap_LColumn=t;
				}
				else if(vecTransHeader[t]=="Itap_E")
				{
					transItap_EColumn=t;
				}
				else if(vecTransHeader[t]=="Itap_C")
				{
					transItap_CColumn=t;
				}
				else if(vecTransHeader[t]=="Itap_V")
				{
					transItap_VColumn=t;
				}
				else if(vecTransHeader[t]=="Ktap_H")
				{
					transKtap_HColumn=t;
				}
				else if(vecTransHeader[t]=="Ktap_L")
				{
					transKtap_LColumn=t;
				}
				else if(vecTransHeader[t]=="Ktap_E")
				{
					transKtap_EColumn=t;
				}
				else if(vecTransHeader[t]=="Ktap_C")
				{
					transKtap_CColumn=t;
				}
				else if(vecTransHeader[t]=="Ktap_V")
				{
					transKtap_VColumn=t;
				}
				else if(vecTransHeader[t]=="Jtap_V")
				{
					transJtap_VColumn=t;
				}
				else if(vecTransHeader[t]=="Ri")
				{
					transRiColumn=t;
				}
				else if(vecTransHeader[t]=="Xi")
				{
					transXiColumn=t;
				}
				else if(vecTransHeader[t]=="Rk")
				{
					transRkColumn=t;
				}
				else if(vecTransHeader[t]=="Xk")
				{
					transXkColumn=t;
				}
				else if(vecTransHeader[t]=="Rj")
				{
					transRjColumn=t;
				}
				else if(vecTransHeader[t]=="Xj")
				{
					transXjColumn=t;
				}
				else if(vecTransHeader[t]=="I_node")
				{
					transI_nodeColumn=t;
				}
				else if(vecTransHeader[t]=="K_node")
				{
					transK_nodeColumn=t;
				}
				else if(vecTransHeader[t]=="J_node")
				{
					transJ_nodeColumn=t;
				}
				else if(vecTransHeader[t]=="I_P")
				{
					transI_PColumn=t;
				}
				else if(vecTransHeader[t]=="I_Q")
				{
					transI_QColumn=t;
				}
				else if(vecTransHeader[t]=="K_P")
				{
					transK_PColumn=t;
				}
				else if(vecTransHeader[t]=="K_Q")
				{
					transK_QColumn=t;
				}
				else if(vecTransHeader[t]=="J_P")
				{
					transJ_PColumn=t;
				}
				else if(vecTransHeader[t]=="J_Q")
				{
					transJ_QColumn=t;
				}
				else if(vecTransHeader[t]=="I_tap")
				{
					transI_tapColumn=t;
				}
				else if(vecTransHeader[t]=="K_tap")
				{
					transK_tapColumn=t;
				}
				else if(vecTransHeader[t]=="I_off")
				{
					transI_offColumn=t;
				}	
				else if(vecTransHeader[t]=="K_off")
				{
					transK_offColumn=t;
				}	
				else if(vecTransHeader[t]=="J_off")
				{
					transJ_offColumn=t;
				}					
				else
					continue;
			}
			
			const int transCodeColumnConst=transCodeColumn;
			const int transTypeColumnConst=transTypeColumn;
			const int transI_VolColumnConst=transI_VolColumn;
			const int transK_VolColumnConst=transK_VolColumn;
			const int transJ_VolColumnConst=transJ_VolColumn;
			const int transI_SColumnConst=transI_SColumn;
			const int transK_SColumnConst=transK_SColumn;
			const int transJ_SColumnConst=transJ_SColumn;
			const int transItap_HColumnConst=transItap_HColumn;
			const int transItap_LColumnConst=transItap_LColumn;
			const int transItap_EColumnConst=transItap_EColumn;
			const int transItap_CColumnConst=transItap_CColumn;
			const int transItap_VColumnConst=transItap_VColumn;
			const int transKtap_HColumnConst=transKtap_HColumn;
			const int transKtap_LColumnConst=transKtap_LColumn;
			const int transKtap_EColumnConst=transKtap_EColumn;
			const int transKtap_CColumnConst=transKtap_CColumn;
			const int transKtap_VColumnConst=transKtap_VColumn;
			const int transJtap_VColumnConst=transJtap_VColumn;
			const int transRiColumnConst=transRiColumn;
			const int transXiColumnConst=transXiColumn;
			const int transRkColumnConst=transRkColumn;
			const int transXkColumnConst=transXkColumn;
			const int transRjColumnConst=transRjColumn;
			const int transXjColumnConst=transXjColumn;
			const int transI_nodeColumnConst=transI_nodeColumn;
			const int transK_nodeColumnConst=transK_nodeColumn;
			const int transJ_nodeColumnConst=transJ_nodeColumn;
			const int transI_PColumnConst=transI_PColumn;
			const int transI_QColumnConst=transI_QColumn;
			const int transK_PColumnConst=transK_PColumn;
			const int transK_QColumnConst=transK_QColumn;
			const int transJ_PColumnConst=transJ_PColumn;
			const int transJ_QColumnConst=transJ_QColumn;
			const int transI_tapColumnConst=transI_tapColumn;
			const int transK_tapColumnConst=transK_tapColumn;
			const int transI_offColumnConst=transI_offColumn;
			const int transK_offColumnConst=transK_offColumn;
			const int transJ_offColumnConst=transJ_offColumn;
			//记录所需要行列的位置

			str.clear();//其中一行数据是不需要的,先清除一行数据
			getline(input,str);
			str.clear();
			getline(input,str);
			
			while(str!="</Transformer::nx>")
			{
				vector<string> vec=split(str);
				//所有数据都已经存放在vec中,接下来是选出有用数据,对数所进行转换
				int code=stringToInt(vec[transCodeColumnConst]);
				int type=stringToInt(vec[transTypeColumnConst]);
				int i_vol=stringToInt(vec[transI_VolColumnConst]);
				int k_vol=stringToInt(vec[transK_VolColumnConst]);
				int j_vol=stringToInt(vec[transJ_VolColumnConst]);
				int i_s=stringToInt(vec[transI_SColumnConst]);
				int k_s=stringToInt(vec[transK_SColumnConst]);
				int j_s=stringToInt(vec[transJ_SColumnConst]);
				int itap_h=stringToInt(vec[transItap_HColumnConst]);
				int itap_l=stringToInt(vec[transItap_LColumnConst]);
				int itap_e=stringToInt(vec[transItap_EColumnConst]);
				double itap_c=stringToDouble(vec[transItap_CColumnConst]);
				int itap_v=stringToInt(vec[transItap_VColumnConst]);
				int ktap_h=stringToInt(vec[transKtap_HColumnConst]);
				int ktap_l=stringToInt(vec[transKtap_LColumnConst]);
				int ktap_e=stringToInt(vec[transKtap_EColumnConst]);
				double ktap_c=stringToDouble(vec[transKtap_CColumnConst]);
				int ktap_v=stringToInt(vec[transKtap_VColumnConst]);
				int jtap_v=stringToInt(vec[transJtap_VColumnConst]);
				double ri=stringToDouble(vec[transRiColumnConst]);
				double xi=stringToDouble(vec[transXiColumnConst]);
				double rk=stringToDouble(vec[transRkColumnConst]);
				double xk=stringToDouble(vec[transXkColumnConst]);
				double rj=stringToDouble(vec[transRjColumnConst]);
				double xj=stringToDouble(vec[transXjColumnConst]);
				
				string i_node=vec[transI_nodeColumnConst];
				// string i_node="abcefdfdfaf";
				string k_node=vec[transK_nodeColumnConst];
				string j_node=vec[transJ_nodeColumnConst];
				
				double i_p=stringToDouble(vec[transI_PColumnConst]);
				double i_q=stringToDouble(vec[transI_QColumnConst]);
				double k_p=stringToDouble(vec[transK_PColumnConst]);
				double k_q=stringToDouble(vec[transK_QColumnConst]);
				double j_p=stringToDouble(vec[transJ_PColumnConst]);
				double j_q=stringToDouble(vec[transJ_QColumnConst]);
				int i_tap=stringToInt(vec[transI_tapColumnConst]);
				int k_tap=stringToInt(vec[transK_tapColumnConst]);
				
				bool iOff=stringToBool(vec[transI_offColumnConst]);
				bool kOff=stringToBool(vec[transK_offColumnConst]);
				bool jOff=stringToBool(vec[transJ_offColumnConst]);

				
				//判断Transformer两端节点是否都在Bus表内,并找到对应的拓扑节点编号,满足则为有用信息
				/*int i_node=0;
				int j_node=0;//拓扑节点编号
				for(vector<Bus>::iterator iter=vecBus.begin();iter!=vecBus.end();++iter)
				{
					if( i_nodename==(*iter).getBusName() )
						i_node=(*iter).getBusCode();
					if( j_nodename==(*iter).getBusName() )
						j_node=(*iter).getBusCode();
				}*/				
				
				Transformer trans=createTransformer( code, type, i_vol, k_vol, j_vol, i_s, k_s, j_s,
				itap_h, itap_l, itap_e, itap_c, itap_v, ktap_h, ktap_l, ktap_e, ktap_c, ktap_v, jtap_v,
				ri, xi, rk, xk, rj, xj, i_node, k_node, j_node, i_p, i_q, k_p, k_q, j_p, j_q,
				i_tap, k_tap , iOff, kOff, jOff);
				/*size_t t=0;
				for(;t<vecTrans.size();++t)
				{
					if(vecTrans[t]==trans)
					{
						str.clear();
						getline(input,str);
						break;
					}
				}
				if(t<vecTrans.size())continue;*/
				vecTrans.push_back(trans);
				
				str.clear();
				getline(input,str);
			}
		}
		if(str=="</Transformer::nx>")
			break;
	}
}
예제 #26
0
/*!
  Returns true is configuration says that window should be maximised.

  \sa setMaximised
  */
bool CcfConfig::isMaximised() const
{
    QString result = mConfiguration->value("maximised");
    return stringToBool(result);
}