Program Listing for File TimedEvent.h#
↰ Return to documentation for file (include/Karana/SOADyn/TimedEvent.h)
/*
*Copyright(c)2024-2026KaranaDynamicsPtyLtd.Allrightsreserved.
*
*NOTICETOUSER:
*
*Thissourcecodeand/ordocumentation(the"LicensedMaterials")is
*theconfidentialandproprietaryinformationofKaranaDynamicsInc.
*UseoftheseLicensedMaterialsisgovernedbythetermsandconditions
*ofaseparatesoftwarelicenseagreementbetweenKaranaDynamicsandthe
*Licensee("LicenseAgreement").Unlessexpresslypermittedunderthat
*agreement,anyreproduction,modification,distribution,ordisclosure
*oftheLicensedMaterials,inwholeorinpart,toanythirdparty
*withoutthepriorwrittenconsentofKaranaDynamicsisstrictlyprohibited.
*
*THELICENSEDMATERIALSAREPROVIDED"ASIS"WITHOUTWARRANTYOFANYKIND.
*KARANADYNAMICSDISCLAIMSALLWARRANTIES,EXPRESSORIMPLIED,INCLUDING
*BUTNOTLIMITEDTOWARRANTIESOFMERCHANTABILITY,NON-INFRINGEMENT,AND
*FITNESSFORAPARTICULARPURPOSE.
*
*INNOEVENTSHALLKARANADYNAMICSBELIABLEFORANYDAMAGESWHATSOEVER,
*INCLUDINGBUTNOTLIMITEDTOLOSSOFPROFITS,DATA,ORUSE,EVENIF
*ADVISEDOFTHEPOSSIBILITYOFSUCHDAMAGES,WHETHERINCONTRACT,TORT,
*OROTHERWISEARISINGOUTOFORINCONNECTIONWITHTHELICENSEDMATERIALS.
*
*U.S.GovernmentEndUsers:TheLicensedMaterialsarea"commercialitem"
*asdefinedat48C.F.R.2.101,andareprovidedtotheU.S.Government
*onlyasacommercialenditemunderthetermsofthislicense.
*
*AnyuseoftheLicensedMaterialsinindividualorcommercialsoftwaremust
*include,intheuserdocumentationandinternalsourcecodecomments,
*thisNotice,Disclaimer,andU.S.GovernmentUseProvision.
*/
#pragmaonce
#include"Karana/KCore/Base.h"
#include"Karana/Math/Defs.h"
#include<functional>
namespaceKarana::Dynamics{
namespacekm=Karana::Math;
namespacekc=Karana::Core;
usingf=std::function<void(constkm::Ktime&t)>;
classTimedEvent:publickc::Base{
friendclassScheduler;
public:
TimedEvent(std::string_viewname,constkm::Ktime&t,ffn,boolpre_hop);
TimedEvent(constTimedEvent&);
TimedEvent(TimedEvent&&)noexcept;
statickc::ks_ptr<TimedEvent>
create(std::string_viewname,constkm::Ktime&t,ffn,boolpre_hop);
std::stringdumpString(std::string_viewprefix="",
constDumpOptions*options=nullptr)constoverride;
boolreschedule();
ffn;
intpriority=0;
km::Ktimeperiod{0};
std::function<std::optional<km::Ktime>(constkm::Ktime&)>reschedule_fn;
booloperator>(constTimedEvent&other)const;
boolisPreHop()const;
constkm::Ktime&nextEventTime()const;
private:
bool_rescheduleAt(constkm::Ktime&t,booltime_moved_backward);
bool_pre_hop;
km::Ktime_t;
};
}//namespaceKarana::Dynamics