当前位置: 首页>>代码示例>>C++>>正文


C++ ConfigNode类代码示例

本文整理汇总了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 );
		}
	}
}
开发者ID:q4a,项目名称:scourge,代码行数:29,代码来源:monster.cpp

示例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 );
	}
}
开发者ID:q4a,项目名称:scourge,代码行数:35,代码来源:shapepalette.cpp

示例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);
}
开发者ID:chrisjwilliams,项目名称:pelican-katburst,代码行数:34,代码来源:PPFChanneliser.cpp

示例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;
  }
}
开发者ID:deoxxa,项目名称:config-c--,代码行数:34,代码来源:node.cpp

示例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();
}
开发者ID:chrisjwilliams,项目名称:pelican,代码行数:10,代码来源:AbstractUdpEmulator.cpp

示例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;
}
开发者ID:mserylak,项目名称:pelican-katburst,代码行数:60,代码来源:K7Chunker.cpp

示例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;
}
开发者ID:jintaoluo,项目名称:MDSM,代码行数:9,代码来源:GuppiAdapter.cpp

示例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();
}
开发者ID:chrisjwilliams,项目名称:pelican-katburst,代码行数:8,代码来源:StokesIntegrator.cpp

示例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;
}
开发者ID:Unkn0wn-0nes,项目名称:Astron,代码行数:57,代码来源:ConfigGroup.cpp

示例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!");

}
开发者ID:rulk,项目名称:StingRay,代码行数:9,代码来源:Material.cpp

示例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);
}
开发者ID:pelican,项目名称:pelican-astro,代码行数:61,代码来源:ZenithModelVisibilities.cpp

示例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();
}
开发者ID:chrisjwilliams,项目名称:pelican-katburst,代码行数:12,代码来源:DedispersionAnalyser.cpp

示例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;
}
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:11,代码来源:appcontext.cpp

示例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"));
}
开发者ID:chrisjwilliams,项目名称:pelican,代码行数:15,代码来源:ConfigNodeTest.cpp

示例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;
}
开发者ID:beku,项目名称:libelektra,代码行数:12,代码来源:printvisitor.cpp


注:本文中的ConfigNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。