本文整理汇总了C++中ConfigNode类的典型用法代码示例。如果您正苦于以下问题:C++ ConfigNode类的具体用法?C++ ConfigNode怎么用?C++ ConfigNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getChildrenByName
void Monster::initSounds( ConfigLang *config ) {
vector<ConfigNode*> *v = config->getDocument()->
getChildrenByName( "sound" );
for ( unsigned int i = 0; i < v->size(); i++ ) {
ConfigNode *node = ( *v )[i];
config->setUpdate( _( UPDATE_MESSAGE ), i, v->size() );
string monsterType_str = node->getValueAsString( "monster" );
map<int, vector<string>*> *currentSoundMap;
if ( soundMap.find( monsterType_str ) == soundMap.end() ) {
currentSoundMap = new map<int, vector<string>*>();
soundMap[monsterType_str] = currentSoundMap;
} else {
currentSoundMap = soundMap[monsterType_str];
}
char sounds[1000];
strcpy( sounds, node->getValueAsString( "attack" ) );
if ( strlen( sounds ) ) {
addSound( Constants::SOUND_TYPE_ATTACK, sounds, currentSoundMap );
}
strcpy( sounds, node->getValueAsString( "hit" ) );
if ( strlen( sounds ) ) {
addSound( Constants::SOUND_TYPE_HIT, sounds, currentSoundMap );
}
}
}
示例2: getChildrenByName
void ShapePalette::initVirtualShapes( ConfigLang *config ) {
vector<ConfigNode*> *v = config->getDocument()->
getChildrenByName( "3ds_shapes" );
vector<ConfigNode*> *vv = ( *v )[0]->
getChildrenByName( "virtual_shape" );
for ( unsigned int i = 0; i < vv->size(); i++ ) {
ConfigNode *node = ( *vv )[i];
session->getGameAdapter()->setUpdate( _( "Loading Shapes" ), i, vv->size() );
ShapeValues *sv = createShapeValues( node );
// dimensions
char tmp[100];
strcpy( tmp, node->getValueAsString( "dimensions" ) );
sv->width = atoi( strtok( tmp, "," ) );
sv->depth = atoi( strtok( NULL, "," ) );
sv->height = atoi( strtok( NULL, "," ) );
// hack: reuse 3ds offsets for map offset of virtual shapes
strcpy( tmp, node->getValueAsString( "offset" ) );
if ( strlen( tmp ) ) {
sv->o3ds_x = atof( strtok( tmp, "," ) );
sv->o3ds_y = atof( strtok( NULL, "," ) );
sv->o3ds_z = atof( strtok( NULL, "," ) );
}
strcpy( sv->refs, node->getValueAsString( "refs" ) );
sv->draws = node->getValueAsBool( "draws" );
// store it for now
shapeValueVector.push_back( sv );
}
}
示例3: _err
/**
* @details
* Constructor.
*
* @param[in] config XML configuration node.
*/
PPFChanneliser::PPFChanneliser(const ConfigNode& config)
: AbstractModule(config), _buffersInitialised(false)
{
// Get options from the XML configuration node.
_nChannels = config.getOption("outputChannelsPerSubband", "value", "512").toUInt();
_nThreads = config.getOption("processingThreads", "value", "2").toUInt();
unsigned nTaps = config.getOption("filter", "nTaps", "8").toUInt();
QString window = config.getOption("filter", "filterWindow", "kaiser").toLower();
// Set the number of processing threads.
omp_set_num_threads(_nThreads);
_iOldestSamples.resize(_nThreads, 0);
// Enforce even number of channels.
if (_nChannels != 1 && _nChannels%2 == 1)
throw _err("Number of channels needs to be even.");
// Generate the FIR coefficients;
_generateFIRCoefficients(window, nTaps);
// Allocate buffers used for holding the output of the FIR stage.
_filteredData.resize(_nThreads);
for (unsigned i = 0; i < _nThreads; ++i)
_filteredData[i].resize(_nChannels);
// Create the FFTW plan.
_createFFTWPlan(_nChannels, _fftPlan);
}
示例4: keyA
bool ConfigNode::has(std::string& key)
{
if (m_type != CONFIG_NODE_LIST)
{
return false;
}
size_t pos = key.find('.');
if (pos != std::string::npos)
{
std::string keyA(key.substr(0, pos));
std::string keyB(key.substr(pos+1));
ConfigNode* tmp;
if (m_list.count(keyA) == 0)
{
return false;
}
else
{
tmp = m_list[keyA];
return tmp->has(keyB);
}
}
else if (m_list.count(key) == 1)
{
return true;
}
else
{
return false;
}
}
示例5: AbstractEmulator
/**
* @details AbstractUdpEmulator
*/
AbstractUdpEmulator::AbstractUdpEmulator(const ConfigNode& configNode)
: AbstractEmulator()
{
_host = QHostAddress(configNode.getOption("connection", "host",
"127.0.0.1"));
_port = configNode.getOption("connection", "port", "2001").toShort();
}
示例6: AbstractChunker
// Construct the chunker.
K7Chunker::K7Chunker(const ConfigNode& config) : AbstractChunker(config)
{
// Check the configuration type matches the class name.
if (config.type() != "K7Chunker")
{
throw _err("K7Chunker::K7Chunker(): Invalid or missing XML configuration.");
}
// Packet dimensions.
_packetSize = sizeof(K7Packet);
_headerSize = sizeof(K7Packet::Header);
// Number of packets per chunk (pipeline iteration).
_nPackets = config.getOption("udpPacketsPerIteration", "value", "128").toUInt();
// Number of Nyquist-sampled values leaving F-engines per second.
_packetsPerSecond = 390625;
// Total number of channels per incoming packet.
_nChannels = config.getOption("channelsPerPacket", "value", "1024").toUInt();
// Channel range for the output stream (counted from 0).
_channelStart = config.getOption("stream", "channelStart", "0").toUInt();
_channelEnd = config.getOption("stream", "channelEnd", "1023").toUInt();
if ( (_channelEnd >= _nChannels) || (_channelStart >= _channelEnd) || (_channelStart < 0) || (_channelEnd < 0) )
{
throw _err("K7Chunker::K7Chunker(): Invalid channel ranges.");
}
std::cout << "K7Chunker::K7Chunker(): _channelStart " << _channelStart << std::endl;
std::cout << "K7Chunker::K7Chunker(): _channelEnd " << _channelEnd << std::endl;
// Calculate the size of the packet for the output stream...
_streamChannels = _channelEnd - _channelStart + 1;
std::cout << "K7Chunker::K7Chunker(): _streamChannels " << _streamChannels << std::endl;
// Since there is only one sample per packet and no raw polarizations but pseudo-Stokes both values are 1.
_packetSizeStream = _streamChannels * sizeof(uint64_t) + _headerSize;
std::cout << "K7Chunker::K7Chunker(): _packetSizeStream " << _packetSizeStream << std::endl;
// ...and the output streams.
_bytesStream = _packetSizeStream - _headerSize;
std::cout << "K7Chunker::K7Chunker(): _bytesStream " << _bytesStream << std::endl;
_byte1OfStream = _channelStart * sizeof(uint64_t);
std::cout << "K7Chunker::K7Chunker(): _byte1OfStream " << _byte1OfStream << std::endl;
// Initialise class variables.
_startTimestamp = 0;
_startAccumulation = 0;
_packetsAccepted = 0;
_packetsRejected = 0;
// Set the empty packet data for stream.
memset((void*)_emptyPacket.data, 0, _bytesStream);
_emptyPacket.header.UTCtimestamp = 0;
_emptyPacket.header.accumulationNumber = 0;
_emptyPacket.header.accumulationRate = 0;
// Set the chunk processed counter.
_chunksProcessed = 0;
_chunkerCounter = 0;
}
示例7: AbstractStreamAdapter
/// Constructs a new SigprocAdapter.
GuppiAdapter::GuppiAdapter(const ConfigNode& config)
: AbstractStreamAdapter(config)
{
_nPolarisations = config.getOption("numberOfPolarisations", "number", "2").toUInt();
_nSamples = config.getOption("samplesPerRead", "number", "1024").toUInt();
_nSamplesPerTimeBlock = config.getOption("outputChannelsPerSubband", "value", "8").toUInt();
_iteration = _dataIndex = _filesize = _processed = 0;
}
示例8: AbstractModule
StokesIntegrator::StokesIntegrator(const ConfigNode& config)
: AbstractModule(config)
{
// Get the size for the integration window(step) from the parameter file.
_windowSize = config.getOption("integrateTimeBins", "value", "1").toUInt();
_binChannels = config.getOption("integrateFrequencyChannels", "value", "1").toUInt();
}
示例9: validate
bool ConfigGroup::validate(ConfigNode node)
{
if(!node.IsMap())
{
if(m_name.length() > 0)
{
config_log.error() << "Section '" << m_path
<< "' has key/value config variables.\n";
}
else
{
config_log.error() << "Config sections must be at root of config file.\n";
}
return false;
}
bool ok = true;
for(auto it = node.begin(); it != node.end(); ++it)
{
string key = it->first.as<std::string>();
auto found_var = m_variables.find(key);
if(found_var != m_variables.end())
{
rtest r = found_var->second;
if(!r(node))
{
config_log.info() << "In Section '" << m_path << "', attribute '"
<< key << "' did not match constraint (see error).\n";
ok = false;
}
continue;
}
auto found_grp = m_children.find(key);
if(found_grp != m_children.end())
{
if(!found_grp->second->validate(node[key]))
{
ok = false;
}
continue;
}
if(m_name.length() > 0)
{
config_log.error() << "Section '" << m_path
<< "' has no attribute named '" << key << "'.\n";
}
else
{
config_log.error() << "Section '" << key << "' is not a valid config category.\n";
}
ok = false;
}
return ok;
}
示例10: constructTypeFromStrings
StreamData * Material::getParameter(const std::string & name,const std::string & type)
{
ConfigNode * node = root->findChild(name);
if (node != NULL )
return constructTypeFromStrings(type,node->getValues());
else
THROW(0,"Parameter:"+name+" of type:"+type+"was requested in material:"+getName()+" but was not found!");
}
示例11: _getConfiguration
/**
* @details
* Extracts configuration for the module from the XML node.
*/
void ZenithModelVisibilities::_getConfiguration(const ConfigNode& config)
{
// Read sources from the configuration node.
QDomNodeList sourceNodes = config.getDomElement().elementsByTagName("source");
for (int i = 0; i < sourceNodes.size(); i++) {
QDomElement sourceElement = sourceNodes.at(i).toElement();
QString cType = sourceElement.attribute("coordType", "J2000").toLower();
Source::coord_t coordType;
if (cType == "j2000")
coordType = Source::J2000;
else if (cType == "azel")
coordType = Source::AZEL;
else
throw QString("ZenithModelVisibilities: Unknown source coordinate type.");
double coord1 = sourceElement.attribute("coord1", "0.0").toDouble();
double coord2 = sourceElement.attribute("coord2", "0.0").toDouble();
coord1 *= math::deg2rad;
coord2 *= math::deg2rad;
QString aType = sourceElement.attribute("ampType", "polxy").toLower();
Source::amp_t ampType;
if (aType == "polxy")
ampType = Source::POL_XY;
else
throw QString("ZenithModelVisibilities: Unknown source amplitude type.");
double ampPolX = sourceElement.attribute("amp1", "0.0").toDouble();
double ampPolY = sourceElement.attribute("amp2", "0.0").toDouble();
Source s(coordType, coord1, coord2, ampType, ampPolX, ampPolY);
_sources.push_back(s);
}
// Read visibility blob dimension information from the configuration mode
// (the number of antennas is extracted from the antenna position data)
_freqRefChannel = config.getOption("frequencies", "referenceChannel","0").toInt();
_freqRef = config.getOption("frequencies", "reference", "0.0").toDouble();
_freqDelta = config.getOption("frequencies", "delta", "195312.5").toDouble();
// Get the channel and polarisation selection.
_channels = config.getUnsignedList("channels");
QString pol = config.getOption("polarisation", "value");
_polarisation = AstroConfig::getPolarisation(pol);
// Read astrometry site parameters and set the data structure.
double siteLongitude = config.getOption("siteLongitude", "value", "0").toDouble();
double siteLatitude = config.getOption("siteLatitude", "value", "0").toDouble();
siteLongitude *= math::deg2rad;
siteLatitude *= math::deg2rad;
double deltaUT = config.getOption("deltaUT", "value", "0").toDouble();
double pressure = config.getOption("pressure", "value", "1000").toDouble();
_astrometry->setSiteParameters(&_siteData, siteLongitude, siteLatitude,
deltaUT, pressure);
}
示例12: AbstractModule
/**
*@details DedispersionAnalyser
*/
DedispersionAnalyser::DedispersionAnalyser( const ConfigNode& config )
: AbstractModule( config )
{
// Get configuration options
//unsigned int nChannels = config.getOption("outputChannelsPerSubband", "value", "512").toUInt();
_detectionThreshold = config.getOption("detectionThreshold", "in_sigma", "6.0").toFloat();
_binPow2 = config.getOption("power2ForBinning", "value", "6").toUInt();
_useStokesStats = config.getOption("useStokesStats", "0_or_1").toUInt();
}
示例13: addInitParam
bool AppContext::addInitParam(const ConfigNode& val)
{
util::param_t::const_iterator name=val.getAttrs().find("name");
util::param_t::const_iterator value=val.getAttrs().find("value");
if(value == val.getAttrs().end() || name == val.getAttrs().end()) {
std::cerr<<"Application paramter is missing name or value"<<std::endl;
return false;
}
m_init_params.push_back(std::pair<std::string,std::string>(name->second,value->second));
return true;
}
示例14: test_setFromString
/**
* @details
*/
void ConfigNodeTest::test_setFromString()
{
QString xml = ""
"<node>"
"<property1 attribute=\"value1\"/>"
"<property2 attribute=\"value2\"/>"
"</node>";
ConfigNode node;
node.setFromString(xml);
CPPUNIT_ASSERT(node.getOption("property1", "attribute", "") == QString("value1"));
CPPUNIT_ASSERT(node.getOption("property2", "attribute", "") == QString("value2"));
}
示例15: visit
void PrintVisitor::visit(ConfigNode& node)
{
QStringList path = node.getPath().split("/");
QString name;
foreach (QString s, path)
name += " ";
name += node.getName();
std::cout << name.toStdString() << std::endl;
}