text = """
#include <time.h>
#include <sys/time.h>

inline double timeF()
{
  struct timeval t;
  if( gettimeofday( &t, NULL ) )
    exit( -1 );
  return t.tv_sec + 1E-6 * t.tv_usec;
}
	double prevTime = timeF()-period;

	long long nanosecsTimer = (long long)(1000000000*period/10);
	struct timespec dt;
	dt.tv_sec  = nanosecsTimer / 1000000000;
	dt.tv_nsec = nanosecsTimer % 1000000000;

		if(period){
			double curTime = timeF();
			if(prevTime + period > curTime){nanosleep( &dt, NULL );i--;continue;}
			prevTime += period;
		}
"""
text2 = """
		hourP = hour;
		minuteP = minute;
		secondP = second;
		hour = 0;
		minute = 0;
		second = 0;

		for(short i=0;i<14;i++){
			hour<<=1;
			hour|=(outputs[i]->GetValue() ? 1 : 0);
		}
		for(short i=14;i<28;i++){
			minute<<=1;
			minute|=(outputs[i]->GetValue() ? 1 : 0);
		}
		for(short i=28;i<42;i++){
			second<<=1;
			second|=(outputs[i]->GetValue() ? 1 : 0);
		}

		if(second!=secondP || minute!=minuteP || hour!=hourP){
			print_time(hour,minute,second);
		}
"""

for l in text2.split("\n") :
	print "\tf << \""+l.replace("\"","\\\"") + "\" << endl;"
