Exemple #1
0
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 );
		}
	}
}
Exemple #2
0
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 );
	}
}
Exemple #3
0
void ShapePalette::initPcPortraits( ConfigLang *config ) {
	vector<ConfigNode*> *v = config->getDocument()->
	                         getChildrenByName( "portraits" );
	vector<ConfigNode*> *vv = ( *v )[0]->
	                          getChildrenByName( "portrait" );

	for ( unsigned int i = 0; i < vv->size(); i++ ) {
		ConfigNode *node = ( *vv )[i];

		session->getGameAdapter()->setUpdate( _( "Loading Shapes" ), i, vv->size() );

		string image = node->getValueAsString( "image" );
		string sex = node->getValueAsString( "sex" );
		if ( strstr( image.c_str(), "death" ) ) {
			deathPortraitTexture.load( image );
		} else {
			int sexNum = ( sex == "M" ?
			               Constants::SEX_MALE :
			               Constants::SEX_FEMALE );
			Texture tex;
			tex.load( image );
			portraitTextures[sexNum].push_back( tex );
		}
	}
}
/**
 * @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);
}
Exemple #5
0
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;
  }
}
Exemple #6
0
bool ConfigNode::set(std::string& key, ConfigNode* ptr, bool createMissing)
{
  m_type = CONFIG_NODE_LIST;

  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)
    {
      if (createMissing == false)
      {
        return false;
      }
      else
      {
        m_list[keyA] = new ConfigNode;
      }
    }

    tmp = m_list[keyA];
    return tmp->set(keyB, ptr, createMissing);
  }
  else
  {
    m_index++;
    m_list[key] = ptr;
    return true;
  }
}
/**
 * @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();
}
// 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;
}
Exemple #9
0
/// 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;
}
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();
}
Exemple #11
0
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;
}
Exemple #12
0
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!");

}
/**
 * @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);
}
/**
 *@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();
}
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;
}
/**
 * @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"));
}
Exemple #17
0
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;
}
Exemple #18
0
// Constructor
CoherentMdsmModule::CoherentMdsmModule(const ConfigNode& config)
  : AbstractModule(config), _samples(0), _gettime(0), _counter(0), _iteration(0)
{
    // Configure MDSM Module
    QString _filepath = config.getOption("observationfile", "filepath");
    _invertChannels = (bool) config.getOption("invertChannels", "value", "1").toUInt();

    // Process Survey parameters (through observation file)
    _obs = processObservationParameters(_filepath);

    // Start up MDSM
    _input_buffer = initialiseMDSM(_obs);
}
Exemple #19
0
ConfigNode
ConfigNode::lookup(
  const ConfigNode &value)
  const
{
  if (value.IsDefined() && value.IsScalar() && IsDefined() && IsMap()) {
    ConfigNode v = (*this)[value.Scalar()];
    if (v) {
      return v;
    }
  }
  return value;
}
Exemple #20
0
bool KeyedConfigList::validate(ConfigNode node)
{
	if(!node.IsSequence())
	{
		config_log.error() << "Section '" << m_path
		                   << "' expects a list of values.\n";
		return false;
	}

	int n = -1;
	bool ok = true;
	for(auto it = node.begin(); it != node.end(); ++it)
	{
		n += 1;

		if(!it->IsMap())
		{
			config_log.error() << "The " << n << "th item of section '" << m_path
			                   << "' does not have key/value config variables.\n";
			ok = false;
			continue;
		}

		ConfigNode element = *it;
		if(!element[m_key])
		{
			config_log.error() << "The " << n << "th item of section '" << m_path
			                   << "' did not specify the attribute '" << m_key << "'.\n";
			ok = false;
			continue;
		}

		string key = element[m_key].as<std::string>();
		auto found_grp = m_children.find(key);
		if(found_grp == m_children.end())
		{
			config_log.error() << "The value '" << key << "' is not valid for attribute '"
			                   << m_key << "' of section '" << m_path << "'.\n";
			print_keys();
			ok = false;
			continue;
		}

		if(!found_grp->second->validate(element))
		{
			ok = false;
		}
	}

	return ok;
}
Exemple #21
0
ConfigNode* ConfigNode::get(std::string& key, bool createMissing)
{
  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))
    {
      tmp = m_list[keyA];
    }
    else
    {
      if (createMissing == false)
      {
        return false;
      }
      else
      {
        tmp = new ConfigNode();
        m_list[keyA] = tmp;
      }
    }

    return tmp->get(keyB, createMissing);
  }
  else
  {
    if (m_list.count(key) == 0)
    {
      if (createMissing == true)
      {
        m_list[key] = new ConfigNode;
      }
      else
      {
        return false;
      }
    }

    return m_list[key];
  }
}
Exemple #22
0
void ShapePalette::initSystemTextures( ConfigLang *config ) {
	vector<ConfigNode*> *v = config->getDocument()->
	                         getChildrenByName( "system_textures" );
	ConfigNode *node = ( *v )[0];

	char tmp[3000];
	strcpy( tmp, node->getValueAsString( "path" ) );

	char *p = strtok( tmp, "," );
	while ( p ) {
		loadSystemTexture( p );
		p = strtok( NULL, "," );
	}
}
// Initialises the pipeline, creating required modules and data blobs, and requesting remote data.
void K7UdpPipeline::init()
{
    ConfigNode c = config(QString("K7UdpPipeline"));
    _totalIterations = c.getOption("totalIterations", "value", "0").toInt();
    std::cout << "K7UdpPipeline::init(): " << _totalIterations << " iterations of the pipeline" << std::endl;

    // Create the pipeline modules and any local data blobs.
    _rfiClipper = (RFI_Clipper *) createModule("RFI_Clipper");
    _stokesIntegrator = (StokesIntegrator *) createModule("StokesIntegrator");
    _intStokes = (SpectrumDataSetStokes *) createBlob("SpectrumDataSetStokes");
    _weightedIntStokes = (WeightedSpectrumDataSet*) createBlob("WeightedSpectrumDataSet");
    // Request remote data.
    requestRemoteData("SpectrumDataSetStokes");
}
/**
 * @details
 * Constructs the LOFAR UDP emulator.
 */
LofarUdpEmulator::LofarUdpEmulator(const ConfigNode& configNode)
: AbstractUdpEmulator(configNode)
{
    // Load data (packet) parameters from the configuration.
    _subbandsPerPacket = configNode.getOption("packet", "subbands", "1").toInt();
    _samplesPerPacket = configNode.getOption("packet", "samples", "1").toInt();
    _nrPolarisations = configNode.getOption("packet", "polarisations", "2").toInt();
    _clock = configNode.getOption("params", "clock").toInt();
    int sampleSize = configNode.getOption("packet", "sampleSize", "8").toInt();

    // Load Emulator parameters. (Interval = microseconds between sending packets)
    _interval = configNode.getOption("packet", "interval", "100000").toULong();
    _startDelay = configNode.getOption("packet", "startDelay", "0").toInt();
    _nPackets = configNode.getOption("packet", "nPackets", "-1").toInt();

    // Setup emulator class variables.
    switch (sampleSize)
    {
        case 8: { _sampleType = i8complex;  break; }
        case 16:{ _sampleType = i16complex; break; }
        default: throw QString("LofarUdpEmulator: Unsupported sample size.");
    }
    _blockid = _samplesPerPacket; // blockid offset
    _timestamp = 1;
    _packetCounter = 0;
    _packetSize = sizeof(UDPPacket);

    // Fill the packet.
    setPacketHeader(0);
    fillPacket();
}
Exemple #25
0
ConfigNode::ConfigNode(const ConfigNode& other)
{
	switch (other.type) {
		case ConfigNodeType::String:
			*this = other.asString();
			break;
		case ConfigNodeType::Sequence:
			*this = other.asSequence();
			break;
		case ConfigNodeType::Map:
			*this = other.asMap();
			break;
		case ConfigNodeType::Int:
			*this = other.asInt();
			break;
		case ConfigNodeType::Float:
			*this = other.asFloat();
			break;
		case ConfigNodeType::Int2:
			*this = other.asVector2i();
			break;
		case ConfigNodeType::Float2:
			*this = other.asVector2f();
			break;
		case ConfigNodeType::Bytes:
			*this = other.asBytes();
			break;
		case ConfigNodeType::Undefined:
			break;
		default:
			throw Exception("Unknown configuration node type.", HalleyExceptions::Resources);
	}
}
void PumaOutputTest::test_configuration()
{
    try {
    { // Use Case:
      // No Configuration given
      // Expect:
      // Be able to construct the object
      QString xml;
      ConfigNode c;
      PumaOutput out( c );
    }
    { // Use Case:
      // Configuration with a file
      // Expect:
      // File to be generated
      QString xml = "<PumaOutput>\n"
                    "<file name=\"" + _filename + "\" />\n"
                    "</PumaOutput>";
      ConfigNode c;
      c.setFromString(xml);
      {
          PumaOutput out( c );
          out.send("data", &_dummyData );
      }
      QFile f(_filename);
      CPPUNIT_ASSERT( f.exists() );
      CPPUNIT_ASSERT_EQUAL( _dummyData.size(), (int)f.size() );
    }
    { // Use Case:
      // Configuration with a host
      // Expect:
      // Attempt to connect to host
      ClientTestServer testHost;
      QString xml = "<PumaOutput>\n"
                    "<conncetion host=\"" + testHost.hostname() + "\" port=\""
                    + testHost.port() + "\" />\n"
                    "</PumaOutput>";
      ConfigNode c;
      c.setFromString(xml);
      PumaOutput out( c );
      out.send("data", &_dummyData );
      CPPUNIT_ASSERT_EQUAL( _dummyData.size(), (int)testHost.dataReceived().size() );
    }
    }
    catch( QString& s )
    {
        CPPUNIT_FAIL(s.toStdString());
    }
}
Exemple #27
0
DBStateServer::DBStateServer(RoleConfig roleconfig) : StateServer(roleconfig),
    m_db_channel(database_channel.get_rval(m_roleconfig)), m_next_context(0)
{
    ConfigNode ranges = dbss_config.get_child_node(ranges_config, roleconfig);
    for(auto it = ranges.begin(); it != ranges.end(); ++it) {
        channel_t min = range_min.get_rval(*it);
        channel_t max = range_max.get_rval(*it);
        MessageDirector::singleton.subscribe_range(this, min, max);
    }

    std::stringstream name;
    name << "DBSS(Database: " << m_db_channel << ")";
    m_log = new LogCategory("dbss", name.str());
    set_con_name(name.str());
}
Exemple #28
0
void ShapePalette::initSounds( ConfigLang *config ) {
	vector<ConfigNode*> *v = config->getDocument()->
	                         getChildrenByName( "sounds" );
	vector<ConfigNode*> *vv = ( *v )[0]->
	                          getChildrenByName( "sound" );
	for ( unsigned int i = 0; i < vv->size(); i++ ) {
		ConfigNode *node = ( *vv )[i];

		session->getGameAdapter()->setUpdate( _( "Loading Sounds" ), i, vv->size() );

		string name = node->getValueAsString( "name" );
		string sound = node->getValueAsString( "sound" );
		getSession()->getSound()->storeSound( name, sound );
	}
}
int main(int argc, char ** argv)
{
    // Create a QCoreApplication.
    QCoreApplication app(argc, argv);

    // Create a Pelican configuration object (this assumes that a Pelican
    // configuration XML file is supplied as the first command line argument)
    if (argc != 2) {
        std::cerr << "Please supply an XML config file." << std::endl;
        return 0;
    }
    //QString configFile(argv[1]);
    //Config config(configFile);
    Config config = createConfig(argc, argv);

    try {
        // Create a Pelican server.
        PelicanServer server(&config);

        // Attach the chunker to server.
        server.addStreamChunker("ABChunker");

        // Create a communication protocol object and attach it to the server
        // on port 15000.
        AbstractProtocol *protocol =  new PelicanProtocol;

        // Get the transmission port address
        Config::TreeAddress address;
        address << Config::NodeId("server", "");
        ConfigNode configNode = config.get(address);
        quint16 txPort = (quint16) configNode.getOption("tx", "port").toUInt();
        std::cout << "Using port " << txPort << "." << std::endl;
        server.addProtocol(protocol, txPort);

        // Start the server.
        server.start();

        // When the server is ready enter the QCoreApplication event loop.
        while (!server.isReady()) {}
        return app.exec();
    }
    // Catch any error messages from Pelican.
    catch (const QString& err)
    {
        std::cerr << "Error: " << err.toStdString() << std::endl;
        return 1;
    }
}
Exemple #30
0
void Material::setParameter(const std::string & name,const std::vector<std::string> & value)
{
	ConfigNode * child = root->findChild(name,false);
	if(child ==  NULL)
	{
		child = new ConfigNode(root,name);
	}
	child->clearValues();
	std::vector<std::string>::const_iterator it = value.begin();
	while(it != value.end())
	{
		child->addValue(*it);
		it++;
	}

}