Example #1
0
void JsonReader::feed(std::string const & str) {
  for (std::string::const_iterator i(str.begin()); i != str.end(); ++i) {
    feed(* i);
  }
}
Example #2
0
void Neuron::feed_forward(const values_t& input)
{
    feed(input);
    activate();
}
Example #3
0
void JsonReader::feed(char const * const buffer, std::size_t const length) {
  for (std::size_t i(static_cast <std::size_t>(0u)); i < length; ++i) {
    char const ch(buffer[i]);
    feed(ch);
  }
}
Example #4
0
void Initialize(void)
{


	// 				Setting the Phased Lock Loop (PLL)
	//               ----------------------------------
	//
	// Olimex LPC-P2148 has a 12.0000 mhz crystal
	//
	// We'd like the LPC2148 to run at 60 mhz (has to be an even multiple of crystal)
	//
	// According to the Philips LPC2148 manual:   M = cclk / Fosc	where:	M    = PLL multiplier (bits 0-4 of PLLCFG)
	//																		cclk = 60000000 hz
	//																		Fosc = 12000000 hz
	//
	// Solving:	M = 60000000 / 12000000 = 5
	//
	//			Note: M - 1 must be entered into bits 0-4 of PLLCFG (assign 4 to these bits)
	//
	//
	// The Current Controlled Oscilator (CCO) must operate in the range 156 mhz to 320 mhz
	//
	// According to the Philips LPC2148 manual:	Fcco = cclk * 2 * P    where:	Fcco = CCO frequency
	//																			cclk = 60000000 hz
	//																			P = PLL divisor (bits 5-6 of PLLCFG)
	//
	// Solving:	Fcco = 60000000 * 2 * P
	//			P = 2  (trial value)
	//			Fcco = 60000000 * 2 * 2
	//			Fcc0 = 240000000 hz    (good choice for P since it's within the 156 mhz to 320 mhz range)
	//
	// From Table 22 (page 34) of Philips LPC2148 manual    P = 2, PLLCFG bits 5-6 = 1  (assign 1 to these bits)
	//
	// Finally:      PLLCFG = 0  01  00100  =  0x24
	//
	// Final note: to load PLLCFG register, we must use the 0xAA followed 0x55 write sequence to the PLLFEED register
	//             this is done in the short function feed() below
	//

	// Setting Multiplier and Divider values
  	PLLCFG = 0x24;
  	feed();

	// Enabling the PLL */
	PLLCON = 0x1;
	feed();

	// Wait for the PLL to lock to set frequency
	while(!(PLLSTAT & PLOCK)) ;

	// Connect the PLL as the clock source
	PLLCON = 0x3;
	feed();

	// Enabling MAM and setting number of clocks used for Flash memory fetch (4 cclks in this case)
	MAMTIM = 0x3;
	MAMCR = 0x2;

	// Setting peripheral Clock (pclk) to System Clock (cclk)
	VPBDIV = 0x1;
}
Example #5
0
void Neuron::feed_forward(const layer_t& layer)
{
    feed(layer);
    activate();
}
Example #6
0
void VTermMM::feed(char c, VTermModifier mod)
{
  char key[] = { c, NULL };
  feed(key, mod);
}
Example #7
0
/*!
 * Получение фида \b user.
 *
 * Если фид не существует, то он будет создан, при создании будет задана маска прав доступа 0400.
 */
FeedPtr Hosts::user() const
{
  return feed(FEED_NAME_USER, 0444);
}
parser::parser(string line)
{
    feed(line);
}
Example #9
0
int Mpg123Decoder::decode()
{
	int size = 0;
	bool done = false;

	while (size < bufferSize && !done && !eof)
	{
		size_t numbytes = 0;

		int r = mpg123_read(handle, (unsigned char *) buffer + size, bufferSize - size, &numbytes);

		switch (r)
		{
		case MPG123_NEW_FORMAT:
		{
			size += numbytes;
			long rate = 0;
			int encoding = 0;
			int ret = mpg123_getformat(handle, &rate, &channels, &encoding);
			if (rate == 0)
				rate = sampleRate;
			else
				sampleRate = rate;
			if (channels == 0)
				channels = MPG123_STEREO;
			if (encoding == 0)
				encoding = MPG123_ENC_SIGNED_16;
			ret = mpg123_format(handle, rate, channels, encoding);
			if (ret != MPG123_OK)
				throw love::Exception("Could not set output format.");
		}
		continue;
		case MPG123_NEED_MORE:
		{
			size += numbytes;
			int v = feed(8192);

			switch (v)
			{
			case MPG123_OK:
				continue;
			case MPG123_DONE:
				if (numbytes == 0)
					eof = true;
				break;
			default:
				done = true;
			}

			continue;
		}
		case MPG123_OK:
			size += numbytes;
			continue;
		case MPG123_DONE:
			// Apparently, mpg123_read does not return MPG123_DONE, but
			// let's keep it here anyway.
			eof = true;
		default:
			done = true;
			break;
		}
	}

	return size;
}
int main( int argc, char** argv ) {
    CommandlineOptionHandler coh( argc, argv );
    typedef pair< MC2String, MC2String > OptionPair;

    uint32 format = MAX_UINT32;

    const OptionPair options[] = {
        make_pair( "--datexii_as", "Vägverket DatexII Accident Service" ),
        make_pair( "--datexii_eis", "Vägverket DatexII Emergency Info Service" ),
        make_pair( "--datexii_rws", "Vägverket DatexII Road Work Service" ),
        make_pair( "--datexii_tmx", "Vägverket DatexII Traffic Message Service" ),
    };

    coh.addSingleChoiceOption( "-f",
                               options,
                               options + sizeof (options) / sizeof (*options),
                               &format, MAX_UINT32,
                               "Sets the type of data to read." );

    coh.setTailHelp("[files]");

    if ( ! coh.parse() ) {
        mc2log << error << "Failed to parse command line!" << endl;
        return 1;
    }

    if ( ! Properties::setPropertyFileName( coh.getPropertyFileName() ) ) {
        mc2log << error << "TrafficServer: No such file or directory: '"
               << coh.getPropertyFileName() << "'" << endl;
        return 2;
    }

    // Initialize the XML system
    XMLTool::XMLInit xmlInit;

    vector<MC2String> files;
    for ( uint32 i = 0; i < coh.getTailLength(); ++i ) {
        files.push_back( coh.getTail( i ) );
    }


    FileTrafficFeed feed( files );
    // we need files!
    if ( feed.eos() ) {
        mc2log << error << "No feed!" << endl;
        return 3;
    }

    auto_ptr<TrafficParser> parser( createParser( format ) );

    if ( ! parser.get() ) {
        mc2log << error << "Failed to create parser" << endl;
        return 4;
    }

    while ( ! feed.eos() ) {

        // get data and parse situations

        TrafficFeed::Data data;
        if ( ! feed.getData( data ) ) {
            mc2log << error << "Failed to get feed." << endl;
            break;
        }

        TrafficParser::Situations situations;
        if ( ! parser->parse( data, situations ) ) {
            mc2log << error << "Failed to parse feed." << endl;
            return 5;
        }

        if ( situations.empty() ) {
            mc2log << error << "No situations parsed from feed." << endl;
            return 6;
        }

        mc2log << "Situations parsed: " << situations.size() << endl;

        STLUtility::deleteValues( situations );
    }

    return 0;
}
Example #11
0
/**********************************************************
                      Initialize
**********************************************************/

#define PLOCK 0x400

static void feed(void)
{
	PLLFEED = 0xAA;
	PLLFEED = 0x55;
}


#ifdef	LPC214x

void Initialize(void)  
{
	
 
	// 				Setting the Phased Lock Loop (PLL)
	//               ----------------------------------
	//
	// Olimex LPC-P2148 has a 12.0000 mhz crystal
	//
	// We'd like the LPC2148 to run at 60 mhz (has to be an even multiple of crystal)
	// 
	// According to the Philips LPC2148 manual:   M = cclk / Fosc	where:	M    = PLL multiplier (bits 0-4 of PLLCFG)
	//																		cclk = 60000000 hz
	//																		Fosc = 12000000 hz
	//
	// Solving:	M = 60000000 / 12000000 = 5           
	//
	//			Note: M - 1 must be entered into bits 0-4 of PLLCFG (assign 4 to these bits)
	//
	//
	// The Current Controlled Oscilator (CCO) must operate in the range 156 mhz to 320 mhz
	//
	// According to the Philips LPC2148 manual:	Fcco = cclk * 2 * P    where:	Fcco = CCO frequency 
	//																			cclk = 60000000 hz
	//																			P = PLL divisor (bits 5-6 of PLLCFG)
	//
	// Solving:	Fcco = 60000000 * 2 * P
	//			P = 2  (trial value)
	//			Fcco = 60000000 * 2 * 2
	//			Fcc0 = 240000000 hz    (good choice for P since it's within the 156 mhz to 320 mhz range)
	//
	// From Table 22 (page 34) of Philips LPC2148 manual    P = 2, PLLCFG bits 5-6 = 1  (assign 1 to these bits)
	//
	// Finally:      PLLCFG = 0  01  00100  =  0x24
	//
	// Final note: to load PLLCFG register, we must use the 0xAA followed 0x55 write sequence to the PLLFEED register
	//             this is done in the short function feed() below
	//
   
	// Setting Multiplier and Divider values
  	PLLCFG = 0x24;
  	feed();
  
	// Enabling the PLL */	
	PLLCON = 0x1;
	feed();
  
	// Wait for the PLL to lock to set frequency
	while(!(PLLSTAT & PLOCK)) ;
  
	// Connect the PLL as the clock source
	PLLCON = 0x3;
	feed();
  
	// Enabling MAM and setting number of clocks used for Flash memory fetch
	MAMTIM = 0x3;
	MAMCR = 0x2;
  
	// Setting peripheral Clock (pclk) to System Clock (cclk)
	VPBDIV = 0x1;
}

#else

#define PLL_N			2UL
#define PLL_M			72UL
#define CCLK_DIV		4
#define USBCLKDivValue	5UL  /* Fosc is divides by USBCLKDivValue+1 to make48MHz		*/
void Initialize(void)  
{
#if	0
    MEMMAP = 0x1;			/* remap to internal flash */
	PCONP |= 0x80000000;		/* Turn On USB PCLK */
#endif
 
	// 				Setting the Phased Lock Loop (PLL)
	//               ----------------------------------
	//
	// CQ-FRK-NXP LPC2388 has a 12.0000 mhz crystal
	//
	// We'd like the LPC2388 to run at 72 mhz (has to be an even multiple of crystal)
	// 
	// According to the Philips LPC2148 manual:   M = cclk / Fosc	where:	M    = PLL multiplier (bits 0-4 of PLLCFG)
	//																		cclk = 60000000 hz
	//																		Fosc = 12000000 hz
	//
	// Solving:	M = 60000000 / 12000000 = 5           
	//
	//			Note: M - 1 must be entered into bits 0-4 of PLLCFG (assign 4 to these bits)
	//
	//
	// The Current Controlled Oscilator (CCO) must operate in the range 156 mhz to 320 mhz
	//
	// According to the Philips LPC2148 manual:	Fcco = cclk * 2 * P    where:	Fcco = CCO frequency 
	//																			cclk = 60000000 hz
	//																			P = PLL divisor (bits 5-6 of PLLCFG)
	//
	// Solving:	Fcco = 60000000 * 2 * P
	//			P = 2  (trial value)
	//			Fcco = 60000000 * 2 * 2
	//			Fcc0 = 240000000 hz    (good choice for P since it's within the 156 mhz to 320 mhz range)
	//
	// From Table 22 (page 34) of Philips LPC2148 manual    P = 2, PLLCFG bits 5-6 = 1  (assign 1 to these bits)
	//
	// Finally:      PLLCFG = 0  01  00100  =  0x24
	//
	// Final note: to load PLLCFG register, we must use the 0xAA followed 0x55 write sequence to the PLLFEED register
	//             this is done in the short function feed() below
	//
   
	if ( PLLSTAT & (1 << 25) ) {
		PLLCON = 1;				/* Disconnect PLL output if PLL is in use */
		PLLFEED = 0xAA;
		PLLFEED = 0x55;
	}
	// Setting Multiplier and Divider values
	PLLCFG = ((PLL_N - 1) << 16) | (PLL_M - 1);	/* Re-configure PLL */
  	feed();
  
	// Enabling the PLL */	
	PLLCON = 0x1;
	feed();
  
	// Wait for the PLL to lock to set frequency
	while ((PLLSTAT & (1 << 26)) == 0);	/* Wait for PLL locked */
//	while(!(PLLSTAT & PLOCK)) ;
  
	CCLKCFG = CCLK_DIV-1;	/* Select CCLK frequency (divide ratio of hclk) */
    USBCLKCFG = USBCLKDivValue;		/* usbclk = 48 MHz */
	// Connect the PLL as the clock source
	PLLCON = 0x3;
	feed();
  
	MAMCR = 0;				/* Configure MAM for 72MHz operation */
	// Enabling MAM and setting number of clocks used for Flash memory fetch
	MAMTIM = 0x3;
	MAMCR = 0x2;
  
	PCLKSEL0 = 0x00000000;	/* Select peripheral clock */
	PCLKSEL1 = 0x00000000;

	ClearVector();

	SCS |= 1;				/* Enable FIO0 and FIO1 */

	FIO1PIN2 = 0x04;		/* -|-|-|-|-|LED|-|- */
	FIO1DIR2 = 0x04;
	PINMODE3 = 0x00000020;

#if	0
	/* Initialize Timer0 as 1kHz interval timer */
	RegisterVector(TIMER0_INT, Isr_TIMER0, PRI_LOWEST, CLASS_IRQ);
	T0CTCR = 0;
	T0MR0 = 18000 - 1;	/* 18M / 1k = 18000 */
	T0MCR = 0x3;		/* Clear TC and Interrupt on MR0 match */
	T0TCR = 1;

	IrqEnable();
#endif

//	uart0_init(INIT_BAUDRATE);
	// Setting peripheral Clock (pclk) to System Clock (cclk)
}
Example #12
0
feed parser::parse_url(const std::string& url, time_t lastmodified, const std::string& etag, newsbeuter::remote_api * api, const std::string& cookie_cache) {
	std::string buf;
	CURLcode ret;

	CURL * easyhandle = curl_easy_init();
	if (!easyhandle) {
		throw exception(_("couldn't initialize libcurl"));
	}

	if (ua) {
		curl_easy_setopt(easyhandle, CURLOPT_USERAGENT, ua);
	}
	if (api) {
		api->configure_handle(easyhandle);
	}
	curl_easy_setopt(easyhandle, CURLOPT_URL, url.c_str());
	curl_easy_setopt(easyhandle, CURLOPT_SSL_VERIFYPEER, 0);
	curl_easy_setopt(easyhandle, CURLOPT_WRITEFUNCTION, my_write_data);
	curl_easy_setopt(easyhandle, CURLOPT_WRITEDATA, &buf);
	curl_easy_setopt(easyhandle, CURLOPT_NOSIGNAL, 1);
	curl_easy_setopt(easyhandle, CURLOPT_FOLLOWLOCATION, 1);
	curl_easy_setopt(easyhandle, CURLOPT_MAXREDIRS, 10);
	curl_easy_setopt(easyhandle, CURLOPT_FAILONERROR, 1);
	curl_easy_setopt(easyhandle, CURLOPT_ENCODING, "gzip, deflate");
	if (cookie_cache != "") {
		curl_easy_setopt(easyhandle, CURLOPT_COOKIEFILE, cookie_cache.c_str());
		curl_easy_setopt(easyhandle, CURLOPT_COOKIEJAR, cookie_cache.c_str());
	}
	if (to != 0)
		curl_easy_setopt(easyhandle, CURLOPT_TIMEOUT, to);

	if (prx)
		curl_easy_setopt(easyhandle, CURLOPT_PROXY, prx);

	if (prxauth) {
		curl_easy_setopt(easyhandle, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
		curl_easy_setopt(easyhandle, CURLOPT_PROXYUSERPWD, prxauth);
	}

	curl_easy_setopt(easyhandle, CURLOPT_PROXYTYPE, prxtype);

	header_values hdrs = { 0, "" };

	curl_slist * custom_headers = NULL;

	if (lastmodified != 0) {
		curl_easy_setopt(easyhandle, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
		curl_easy_setopt(easyhandle, CURLOPT_TIMEVALUE, lastmodified);
		curl_easy_setopt(easyhandle, CURLOPT_HEADERDATA, &hdrs);
		curl_easy_setopt(easyhandle, CURLOPT_HEADERFUNCTION, handle_headers);
	}
	if (etag.length() > 0) {
		custom_headers = curl_slist_append(custom_headers, utils::strprintf("If-None-Match: %s", etag.c_str()).c_str());
		curl_easy_setopt(easyhandle, CURLOPT_HTTPHEADER, custom_headers);
		curl_easy_setopt(easyhandle, CURLOPT_HEADERDATA, &hdrs);
		curl_easy_setopt(easyhandle, CURLOPT_HEADERFUNCTION, handle_headers);
	}

	ret = curl_easy_perform(easyhandle);

	lm = hdrs.lastmodified;
	et = hdrs.etag;

	if (custom_headers) {
		curl_slist_free_all(custom_headers);
	}

	LOG(LOG_DEBUG, "rsspp::parser::parse_url: ret = %d", ret);

	long status;
	curl_easy_getinfo(easyhandle, CURLINFO_HTTP_CONNECTCODE, &status);

	if (status >= 400) {
		LOG(LOG_USERERROR, _("Error: trying to download feed `%s' returned HTTP status code %ld."), url.c_str(), status);
	}

	curl_easy_cleanup(easyhandle);

	if (ret != 0) {
		LOG(LOG_ERROR, "rsspp::parser::parse_url: curl_easy_perform returned err %d: %s", ret, curl_easy_strerror(ret));
		throw exception(curl_easy_strerror(ret));
	}

	LOG(LOG_INFO, "parser::parse_url: retrieved data for %s: %s", url.c_str(), buf.c_str());

	if (buf.length() > 0) {
		LOG(LOG_DEBUG, "parser::parse_url: handing over data to parse_buffer()");
		return parse_buffer(buf.c_str(), buf.length(), url.c_str());
	}

	return feed();
}
Example #13
0
int OSM_Model400::calculate( )
{
    // Return value, assume successful
    int retVal = 0;

    // Vectors for internal component streams
    OSM_Vector x( nSize() );       // net crusher contents
    OSM_Vector y( nSize() );       // material classified for breakage
    OSM_Vector z( nSize() );       // breakage products of y

    // Calculate classification function: C[]
    calculateC( );

    // Create contents matrix if required
    if( contents.rows()!=nComp() || contents.columns()!=nSize() )
    {
        contents.dimension( nComp(), nSize() );
    }

    //-- Main Loop - loop over components in the feed -----------------------

    for( int comp=0; comp<nComp(); comp++ )
    {
        // Aliases to component vectors
        OSM_Vector& feedC = feed()[comp];
        OSM_Vector& prodC = product()[comp];
        OSM_Vector& x     = contents[comp];

        if( feedC.sum() > 0 )                   // Component present ?
        {
            calculateA( comp );                 // Make appearance function
            double misconvergence = 1e20;       // Force misconvergence
            long iteration = 0;                 // No iterations yet

            //-- Iteration Loop - until converged or maximum iterations -----

            while( misconvergence>tolerance && iteration<maxIteration )
            {
                // classify material for breakage y = C(x)
                y.loadProduct( C, x );

                // obtain breakage products z = A(y)
                makeDaughters( y, z );

                // obtain next iteration of recycle: x = feed + z
                misconvergence = x.loadSumWithCompare( feedC, z );

                // a successful iteration (hopefully)
                iteration++;
            }
            // product component by balance
            prodC.loadSubtraction( x, y );
        }
        else
        {
            // product component is 0
            prodC = 0;
        }
    }
    // indicate success
    return retVal;
}
Example #14
0
File: saver.cpp Project: garinh/cs
  bool Terrain2FactorySaver::WriteDown (iBase *obj, iDocumentNode *parent,
					iStreamSource *ssource)
  {
    if (!parent) return false; //you never know...

    if (obj)
    {
      csRef<iDocumentNode> paramsNode = 
	parent->CreateNodeBefore(CS_NODE_ELEMENT, 0);
      paramsNode->SetValue("params");

      csRef<iTerrainFactory> tfact = 
	scfQueryInterface<iTerrainFactory> (obj);
      if (!tfact) return false;

      {
	iTerrainRenderer* render (tfact->GetRenderer());
	csRef<iFactory> renderFact (scfQueryInterfaceSafe<iFactory> (render));
	if (renderFact.IsValid())
	{
	  csRef<iDocumentNode> node = 
	    paramsNode->CreateNodeBefore (CS_NODE_ELEMENT, 0);
	  node->SetValue ("renderer");
	  node->CreateNodeBefore (CS_NODE_TEXT, 0)
	    ->SetValue (renderFact->QueryClassID());
	}
      }
      {
	iTerrainCollider* collide (tfact->GetCollider());
	csRef<iFactory> collideFact (scfQueryInterfaceSafe<iFactory> (collide));
	if (collideFact.IsValid())
	{
	  csRef<iDocumentNode> node = 
	    paramsNode->CreateNodeBefore (CS_NODE_ELEMENT, 0);
	  node->SetValue ("collider");
	  node->CreateNodeBefore (CS_NODE_TEXT, 0)
	    ->SetValue (collideFact->QueryClassID());
	}
      }
      {
	iTerrainDataFeeder* feed (tfact->GetFeeder());
	csRef<iFactory> feedFact (scfQueryInterfaceSafe<iFactory> (feed));
	if (feedFact.IsValid())
	{
	  csRef<iDocumentNode> node = 
	    paramsNode->CreateNodeBefore (CS_NODE_ELEMENT, 0);
	  node->SetValue ("feeder");
	  node->CreateNodeBefore (CS_NODE_TEXT, 0)
	    ->SetValue (feedFact->QueryClassID());
	}
      }
      {
        csRef<iDocumentNode> node = 
          paramsNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
        node->SetValue ("maxloadedcells");
        node->CreateNodeBefore (CS_NODE_TEXT, 0)
	  ->SetValueAsInt ((int)tfact->GetMaxLoadedCells());
      }

      iTerrainFactoryCell* defaultCell = tfact->GetDefaultCell();

      csRef<iDocumentNode> cellsNode = 
        paramsNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
      cellsNode->SetValue ("cells");

      {
        csRef<iDocumentNode> defaultNode = 
          cellsNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
        defaultNode->SetValue ("celldefault");

	{
	  csRef<iDocumentNode> node = 
	    defaultNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
	  node->SetValue ("gridsize");
	  node->SetAttributeAsInt ("width", defaultCell->GetGridWidth());
	  node->SetAttributeAsInt ("height", defaultCell->GetGridHeight());
	}

	{
	  csRef<iDocumentNode> node = 
	    defaultNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
	  node->SetValue ("materialmapsize");
	  node->SetAttributeAsInt ("width", defaultCell->GetMaterialMapWidth());
	  node->SetAttributeAsInt ("height", defaultCell->GetMaterialMapHeight());
	}

	{
	  csRef<iDocumentNode> node = 
	    defaultNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
	  node->SetValue ("size");
	  synldr->WriteVector (node, defaultCell->GetSize());
	}

	{
	  iMaterialWrapper* basemat = defaultCell->GetBaseMaterial();
	  if (basemat)
	  {
	    csRef<iDocumentNode> node = 
	      defaultNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
	    node->SetValue ("basematerial");
	    node->CreateNodeBefore (CS_NODE_TEXT, 0)
	     ->SetValue (basemat->QueryObject()->GetName());
	  }
	}

	synldr->WriteBool (defaultNode, "materialmappersistent",
	  defaultCell->GetMaterialPersistent(), false);

	{
	  iTerrainRenderer* render = tfact->GetRenderer();
	  csRef<iTerrainCellRenderProperties> defRenderProp =
	    render ? render->CreateProperties () : 0;

	  csRef<iDocumentNode> node = 
	    defaultNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
	  node->SetValue ("renderproperties");
	  if (!SaveRenderProperties (node, defaultCell->GetRenderProperties(),
	      defRenderProp))
	    defaultNode->RemoveNode (node);
	}

	{
	  iTerrainDataFeeder* feeder = tfact->GetFeeder();
	  csRef<iTerrainCellFeederProperties> defFeedProp =
	    feeder ? feeder->CreateProperties () : 0;

	  csRef<iDocumentNode> node = 
	    defaultNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
	  node->SetValue ("feederproperties");
	  if (!SaveFeederProperties (node, defaultCell->GetFeederProperties(),
	      defFeedProp))
	    defaultNode->RemoveNode (node);
	}

	{
	  iTerrainCollider* collider = tfact->GetCollider();
	  csRef<iTerrainCellCollisionProperties> defCollProp =
	    collider ? collider->CreateProperties () : 0;

	  csRef<iDocumentNode> node = 
	    defaultNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
	  node->SetValue ("colliderproperties");
	  if (!SaveProperties (node, defaultCell->GetCollisionProperties(),
	      (iTerrainCellCollisionProperties*)defCollProp))
	    defaultNode->RemoveNode (node);
	}
      }

      size_t numCells = tfact->GetCellCount();
      for (size_t c = 0; c < numCells; c++)
      {
	iTerrainFactoryCell* cell = tfact->GetCell (c);

        csRef<iDocumentNode> cellNode = 
          cellsNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
        cellNode->SetValue ("cell");
	const char* name = cell->GetName();
	if (name != 0)
	{
	  csRef<iDocumentNode> node = 
	    cellNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
	  node->SetValue ("name");
	  node->CreateNodeBefore (CS_NODE_TEXT, 0)
	    ->SetValue (name);
	}

	{
	  csRef<iDocumentNode> node = 
	    cellNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
	  node->SetValue ("position");
	  synldr->WriteVector (node, cell->GetPosition());
	}

	if ((defaultCell->GetGridWidth() != cell->GetGridWidth())
	    || (defaultCell->GetGridHeight() != cell->GetGridHeight()))
	{
	  csRef<iDocumentNode> node = 
	    cellNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
	  node->SetValue ("gridsize");
	  node->SetAttributeAsInt ("width", cell->GetGridWidth());
	  node->SetAttributeAsInt ("height", cell->GetGridHeight());
	}

	if ((defaultCell->GetMaterialMapWidth() != cell->GetMaterialMapWidth())
	    || (defaultCell->GetMaterialMapHeight() != cell->GetMaterialMapHeight()))
	{
	  csRef<iDocumentNode> node = 
	    cellNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
	  node->SetValue ("materialmapsize");
	  node->SetAttributeAsInt ("width", cell->GetMaterialMapWidth());
	  node->SetAttributeAsInt ("height", cell->GetMaterialMapHeight());
	}

	if (defaultCell->GetSize() != cell->GetSize())
	{
	  csRef<iDocumentNode> node = 
	    cellNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
	  node->SetValue ("size");
	  synldr->WriteVector (node, cell->GetSize());
	}

	if ((cell->GetBaseMaterial() != 0)
	    && (defaultCell->GetBaseMaterial() != cell->GetBaseMaterial()))
	{
	  csRef<iDocumentNode> node = 
	    cellNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
	  node->SetValue ("basematerial");
	  node->CreateNodeBefore (CS_NODE_TEXT, 0)
	    ->SetValue (cell->GetBaseMaterial()->QueryObject()->GetName());
	}

	synldr->WriteBool (cellNode, "materialmappersistent",
	  cell->GetMaterialPersistent(), defaultCell->GetMaterialPersistent());

	{
	  csRef<iDocumentNode> node = 
	    cellNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
	  node->SetValue ("renderproperties");
	  if (!SaveRenderProperties (node, cell->GetRenderProperties(),
	      defaultCell->GetRenderProperties()))
	    cellNode->RemoveNode (node);
	}

	{
	  csRef<iDocumentNode> node = 
	    cellNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
	  node->SetValue ("feederproperties");
	  if (!SaveFeederProperties (node, cell->GetFeederProperties(),
	      defaultCell->GetFeederProperties()))
	    cellNode->RemoveNode (node);
	}

	{
	  csRef<iDocumentNode> node = 
	    cellNode->CreateNodeBefore(CS_NODE_ELEMENT, 0);
	  node->SetValue ("colliderproperties");
	  if (!SaveProperties (node, cell->GetCollisionProperties(),
	      defaultCell->GetCollisionProperties()))
	    cellNode->RemoveNode (node);
	}
      }

    }
    return true;
  }
Example #15
0
 void fps::operator ++() {
     feed();
 }
Example #16
0
// Consume a newline character from the token stream and
// update the current location accordingly.
inline void
consume_newline(Lexer& lex, std::size_t n) {
  consume(lex, n);
  feed(lex);
}
Example #17
0
 void fps::operator ++(int dummy) {
     feed();
 }
void Adafruit_Thermal::test(){
  println("Hello World!");
  feed(2);
}
Example #19
0
void SincFilter::processAudio(const double *inputs, double *outputs, jack_nframes_t time)
{
    feed(inputs[0]);
    outputs[0] = process();
}
Example #20
0
/*!
 * Получение фида \b hosts.
 *
 * Если фид не существует, то он будет создан, при создании будет задана маска прав доступа 0400.
 */
FeedPtr Hosts::feed() const
{
  return feed(FEED_NAME_HOSTS, 0600);
}