-
Notifications
You must be signed in to change notification settings - Fork 6
add: TimerSystem. Timer-based event handling API. #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The current callback signature 'bool(void)' is a draft. Further commit should generalize it, considering:
|
| * \file timer.hpp | ||
| * \author Sahak Grigoryan <sahakgrigoryan.am@gmail.com> | ||
| * | ||
| * \brief Class definition: TimerSystem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All code in the Garden project use Apache 2.0 license. Please add here license info, if you agree to use this license for your code.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
| /** | ||
| * \brief Timer metadata structure. | ||
| */ | ||
| struct TimerHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Entity Component System (ECS) paradigm this should be a TimerComponent, please see the ComponentSystem<> usage. With current implementation we can't attach this timer to an entity.
| /** | ||
| * \brief Runs and manages all timer handlers; "Timer" ordered event handler. | ||
| */ | ||
| void runTimers(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be private, because it's subscribed to the "Timer" event which managed by the Manager.
| /** | ||
| * \brief Wrapper method over memory pool releasing memory for handler objects. | ||
| */ | ||
| void disposeTimers(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All systems have built-in virtual disposeComponents() function, please see the ComponentsSystem<> for reference.
| // ensure: (lowest supported time ratio) <= millisecond | ||
| static_assert(std::ratio_less_equal_v<ClockType::period, std::milli>); | ||
| ECSM_SUBSCRIBE_TO_EVENT("Timer", TimerSystem::runTimers); | ||
| ECSM_SUBSCRIBE_TO_EVENT("Timer", TimerSystem::disposeTimers); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see the ComponentsSystem<> disposeComponents() function for reference.
I think we should use strings for timer function callback, like it's done in the PhysicsSystem for sensor collider events: garden/include/garden/system/physics.hpp Line 364 in eeab52b
garden/source/system/physics.cpp Lines 1236 to 1242 in eeab52b
|
Implements #64