Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
Timer.h
1// trax track library
2// AD 2016
3//
4// "the resolution of all the fruitless searches"
5//
6// Peter Gabriel
7//
8// Copyright (c) 2025 Trend Redaktions- und Verlagsgesellschaft mbH
9// Copyright (c) 2019 Marc-Michael Horstmann
10//
11// Permission is hereby granted to any person obtaining a copy of this software
12// and associated source code (the "Software"), to use, view, and study the
13// Software for personal or internal business purposes, subject to the following
14// conditions:
15//
16// 1. Redistribution, modification, sublicensing, or commercial use of the
17// Software is NOT permitted without prior written consent from the copyright
18// holder.
19//
20// 2. The Software is provided "AS IS", without warranty of any kind, express
21// or implied.
22//
23// 3. All copies of the Software must retain this license notice.
24//
25// For further information, please contact: horstmann.marc@trendverlag.de
26
27#pragma once
28
29#include "Configuration.h"
30#include "Units.h"
31#include "Identified.h"
32
33namespace trax{
34
35 struct Jack;
36 struct MultiPlug;
37 struct SocketRegistry;
38
44 struct Timer : Identified<Timer>
45 {
47 static dclspc std::unique_ptr<Timer> Make() noexcept;
48
49
51 virtual const char* TypeName() const noexcept = 0;
52
53
57 virtual void Start() noexcept = 0;
58
59
61 virtual bool IsStarted() const noexcept = 0;
62
63
68 virtual void Reset() noexcept = 0;
69
70
75 virtual void Pause() noexcept = 0;
76
77
83 virtual void Lapse( Time timeLapse ) = 0;
84
85
87 virtual Time Lapse() const = 0;
88
89
94 virtual void Periodic( bool bPeriodic ) = 0;
95
96
98 virtual bool Periodic() const = 0;
99
100
103 virtual void SetTime( Time time ) = 0;
104
105
107 virtual Time GetTime() const = 0;
108
109
111 virtual MultiPlug& PlugToStart() noexcept = 0;
112
113
115 virtual MultiPlug& PlugToReset() noexcept = 0;
116
117
119 virtual MultiPlug& PlugToPause() noexcept = 0;
120
121
124 virtual Jack& JackOnStart() noexcept = 0;
125
126
129 virtual Jack& JackOnReset() noexcept = 0;
130
131
134 virtual Jack& JackOnPause() noexcept = 0;
135
136
139 virtual Jack& JackOnTick() noexcept = 0;
140
141
144 virtual void RegisterSockets( SocketRegistry& registry ) = 0;
145
146
148 virtual void UnregisterSockets( SocketRegistry& registry ) = 0;
149
150
151 virtual void Update() = 0;
152 };
153
154
155 //struct TimerCollection : Collection<TimerCollection,Timer>
156 //{
157 // virtual void Update() = 0;
158 //};
159
160}
Value< Dimension< 0, 0, 1 > > Time
Time.
Definition DimensionedValues.h:329
Namespace of all the trax track libraries classes and methods.
Definition Collection.h:17
A jack a plug can get connected with.
Definition Jack.h:83
A MultiPlug provides a variable number of actual Plugs to one input slot.
Definition Plug.h:307
Interface for a registry that reconnects Plugs and Jacks according to their IDs.
Definition SocketRegistry.h:40
A timer to meassure time lapses.
Definition Timer.h:45
virtual void Lapse(Time timeLapse)=0
Sets the time span for the timer.
virtual MultiPlug & PlugToStart() noexcept=0
Plug whose pulses starts the timer.
virtual void RegisterSockets(SocketRegistry &registry)=0
Registers all the Plugs with the registry and supplies the Jacks with plug ids for connecting.
virtual void UnregisterSockets(SocketRegistry &registry)=0
Removes all references to Plugs and Jacks from the registry.
virtual Jack & JackOnTick() noexcept=0
If the timer decides that time is up it triggers a pulse in this Jack.
virtual void Reset() noexcept=0
Resets the timer.
virtual MultiPlug & PlugToPause() noexcept=0
Plug whose pulses pauses the timer.
virtual void Start() noexcept=0
Starts the timer.
virtual bool IsStarted() const noexcept=0
static dclspc std::unique_ptr< Timer > Make() noexcept
Makes a Timer object.
virtual Time GetTime() const =0
virtual Jack & JackOnStart() noexcept=0
If the timer is started, this Jack is triggered.
virtual const char * TypeName() const noexcept=0
virtual MultiPlug & PlugToReset() noexcept=0
Plug whose pulses resets the timer.
virtual Jack & JackOnPause() noexcept=0
If the timer is set to paused, this Jack is triggered.
virtual void Periodic(bool bPeriodic)=0
Sets wether the timer tick is happening only once or periodically.
virtual void SetTime(Time time)=0
Sets the currect time of the timer.
virtual Jack & JackOnReset() noexcept=0
If the timer is reset, this Jack is triggered.
virtual void Pause() noexcept=0
Pauses the timer.