Skip to content

Conversation

roigcarlo
Copy link
Member

📝 Description

  • Registry now expects for items to be registered with their bases
  • GetValue<T> now expects you to obtain the base value (Like current KratosComponents)
  • GetValueAs<T,C> now makes the cast so you can retrieve the actual downcasted object, if possible

Example:

class Process {};
class MyProcess : public Process {};
class MyBadProcess {};

ADD_REGISTRY_PROTOTYPE("Key", Process, MyProcess)

auto p = Registry::GetValue<Process>("Key.MyProcess.Prototype")  // Correct, p is of type Process
auto p = Registry::GetValue<MyProcess>("Key.MyProcess.Prototype")  // Compilation Error
auto p = Registry::GetValueAs<Process, MyProcess>("Key.MyProcess.Prototype")  // Correct, p is of type MyProcess
auto p = Registry::GetValueAs<Process, MyBadProcess>("Key.MyProcess.Prototype")  // Compilation Error (Process is not a base of MyBadProcess)

Test to check that GetValueAs with non derived classes cannot be compiled is super ugly and involves dark templates, so left it behind.

@roigcarlo roigcarlo requested review from a team as code owners September 19, 2023 09:37
rubenzorrilla

This comment was marked as resolved.

Co-authored-by: Rubén Zorrilla <rubenzorrillamartinez@hotmail.com>
@roigcarlo roigcarlo merged commit 8f253fb into master Sep 20, 2023
@roigcarlo roigcarlo deleted the core/registry-store-base branch September 20, 2023 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants