String CountdownConditionProvider::TryParseDescription( /* [in] */ IUri* conditionUri) { AutoPtr<IZenModeConfigHelper> helper; CZenModeConfigHelper::AcquireSingleton((IZenModeConfigHelper**)&helper); Int64 time; helper->TryParseCountdownConditionId(conditionUri, &time); if (time == 0) return String(NULL); AutoPtr<ISystem> sys; CSystem::AcquireSingleton((ISystem**)&sys); Int64 now; sys->GetCurrentTimeMillis(&now); AutoPtr<ICharSequence> span = DateUtils::GetRelativeTimeSpanString(time, now, IDateUtils::MINUTE_IN_MILLIS); String spanStr; span->ToString(&spanStr); String str; str = ""; str.AppendFormat("Scheduled for %s, %s in the future (%s), now=%s", Ts(time).string(), StringUtils::ToString(time - now).string(), spanStr.string(), Ts(now).string()); return str; }
ECode CountdownConditionProvider::OnSubscribe( /* [in] */ IUri* conditionId) { if (DEBUG) Slogger::D(TAG, "onSubscribe %p", conditionId); AutoPtr<IZenModeConfigHelper> helper; CZenModeConfigHelper::AcquireSingleton((IZenModeConfigHelper**)&helper); helper->TryParseCountdownConditionId(conditionId, &mTime); AutoPtr<IInterface> obj; mContext->GetSystemService(IContext::ALARM_SERVICE, (IInterface**)&obj); AutoPtr<IAlarmManager> alarms = IAlarmManager::Probe(obj); String str; IObject::Probe(conditionId)->ToString(&str); AutoPtr<IIntent> intent; CIntent::New(ACTION, (IIntent**)&intent); intent->PutExtra(EXTRA_CONDITION_ID, str); intent->SetFlags(IIntent::FLAG_RECEIVER_REGISTERED_ONLY); AutoPtr<IPendingIntentHelper> pendingIntentHelper; CPendingIntentHelper::AcquireSingleton((IPendingIntentHelper**)&pendingIntentHelper); AutoPtr<IPendingIntent> pendingIntent; pendingIntentHelper->GetBroadcast(mContext, REQUEST_CODE, intent, IPendingIntent::FLAG_UPDATE_CURRENT, (IPendingIntent**)&pendingIntent); alarms->Cancel(pendingIntent); if (mTime > 0) { AutoPtr<ISystem> sys; CSystem::AcquireSingleton((ISystem**)&sys); Int64 now; sys->GetCurrentTimeMillis(&now); AutoPtr<ICharSequence> span = DateUtils::GetRelativeTimeSpanString(mTime, now, IDateUtils::MINUTE_IN_MILLIS); if (mTime <= now) { // in the past, already false NotifyCondition(NewCondition(mTime, ICondition::STATE_FALSE)); } else { // in the future, set an alarm alarms->SetExact(IAlarmManager::RTC_WAKEUP, mTime, pendingIntent); } String spanStr; span->ToString(&spanStr); str = ""; str.AppendFormat("%s %s for %s, %s in the future (%s), now=%s", (mTime <= now ? "Not scheduling" : "Scheduling"), ACTION.string(), Ts(mTime).string(), StringUtils::ToString(mTime - now).string(), spanStr.string(), Ts(now).string()); if (DEBUG) Slogger::D(TAG, str); } return NOERROR; }
void v2f<BasicTurbulenceModel>::correctNut() { this->nut_ = min(CmuKEps_*sqr(k_)/epsilon_, this->Cmu_*v2_*Ts()); this->nut_.correctBoundaryConditions(); fv::options::New(this->mesh_).correct(this->nut_); BasicTurbulenceModel::correctNut(); }
data_type_t tuple(std::string const &name) { static_assert(sizeof...(Ts), "tuples cannot be zero-sized"); std::ostringstream types; int const _[]{ (types << Ts(name).second << ", ", 0)... }; static_cast<void>(_); types.seekp(-2, std::ios_base::end); types << " >"; return { name, "tuple< " + types.str() }; }
virtual void bar() { auto x = std::get<I>(std::make_tuple(Ts()...)); x.baz(); }
namespace RetainExprPacks { int f(int a, int b, int c); template<typename ...Ts> struct X {}; template<typename ...Ts> int g(X<Ts...>, decltype(f(Ts()...))); int n = g<int, int>(X<int, int, int>(), 0); }