int main(int argc, char *argv[]) { Callback callback; callback.call(); callback.setCallback(externalFunction); callback.call(); callback.setCallback(NULL); callback.call(); return 0; }
static void run_exti_callback(int irq) { Callback *callback = exti_callbacks[irq]; if (callback) callback->call(); EXTI->PR = (1 << irq); }
static void tim_handler(int num) { IRQFunction irqfunc; TIM_TypeDef *tim = timers[num]; uint16_t sr = tim->SR; Callback *callback = NULL; if (sr & TIM_SR_UIF) { callback = overflowcallbacks[num-1]; tim->SR &= ~TIM_SR_UIF; } else if (sr & TIM_SR_CC1IF) { callback = callbacks[num-1][0]; tim->SR &= ~TIM_SR_CC1IF; } else if (sr & TIM_SR_CC2IF) { callback = callbacks[num-1][1]; tim->SR &= ~TIM_SR_CC2IF; } else if (sr & TIM_SR_CC3IF) { callback = callbacks[num-1][2]; tim->SR &= ~TIM_SR_CC3IF; } else if (sr & TIM_SR_CC4IF) { callback = callbacks[num-1][3]; tim->SR &= ~TIM_SR_CC4IF; } if (callback != NULL) callback->call(); }
void pgen::generateTerrain(const int res, float* hmap, float* bmap, float* value, Callback& callback) { const int octaves = log2(res); noise::module::RidgedMulti noise_mountains; noise_mountains.SetFrequency(2.0); noise_mountains.SetOctaveCount(octaves); noise_mountains.SetNoiseQuality(noise::QUALITY_BEST); noise_mountains.SetSeed(time(NULL)); noise::module::Perlin noise_hills_base; noise_hills_base.SetFrequency(2.0); noise_hills_base.SetOctaveCount(octaves); noise_hills_base.SetNoiseQuality(noise::QUALITY_BEST); noise_hills_base.SetSeed(time(NULL)); noise::module::ScaleBias noise_hills; noise_hills.SetSourceModule(0,noise_hills_base); noise_hills.SetScale(0.3); noise_hills.SetBias(-0.75); noise::module::Perlin noise_mix; noise_mix.SetFrequency(1.0); noise_mix.SetOctaveCount(octaves); noise_mix.SetNoiseQuality(noise::QUALITY_BEST); noise_mix.SetSeed(time(NULL)); noise_mix.SetPersistence(0.25); noise::module::Select noise_final; noise_final.SetSourceModule(0,noise_hills); noise_final.SetSourceModule(1,noise_mountains); noise_final.SetControlModule(noise_mix); noise_final.SetBounds(0.0,1000.0); noise_final.SetEdgeFalloff(0.125); //float* a = new float[res*res]; for(int x=0; x<res; x++) { for(int y=0; y<res; y++) { hmap[x*res+y] = noise_final.GetValue(x/(float)res+0.5,y/(float)res+0.5,0.5); bmap[x*res+y] = (noise_mix.GetValue(x/(float)res+0.5,y/(float)res+0.5,0.5)+1.0)/2.0; } if(x%10==0) { *value = x/(float)res; callback.call(); } } }
void TextData::registerFileNameListener(Callback<const String&>::Ptr fileNameCallback) { fileNameListeners.registerCallback(fileNameCallback); fileNameCallback->call(utf8FileNameForDisplay); }
void TextData::registerModifiedFlagListener(Callback<bool>::Ptr modifiedFlagCallback) { changedModifiedFlagListeners.registerCallback(modifiedFlagCallback); modifiedFlagCallback->call(modifiedFlag); }
void TextData::registerLengthListener(Callback<long>::Ptr lengthCallback) { lengthListeners.registerCallback(lengthCallback); lengthCallback->call(getLength()); }
void TextData::registerReadOnlyListener(Callback<bool>::Ptr readOnlyCallback) { readOnlyListeners.registerCallback(readOnlyCallback); readOnlyCallback->call(isReadOnlyFlag); }
void CommandDoNothing::execute(Callback & done) { done.call(); }