Skip to content
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

Hook for default base Aspect-mapping on all systems #371

Closed
DaanVanYperen opened this issue Sep 18, 2015 · 8 comments
Closed

Hook for default base Aspect-mapping on all systems #371

DaanVanYperen opened this issue Sep 18, 2015 · 8 comments

Comments

@DaanVanYperen
Copy link
Collaborator

See below.

@junkdog
Copy link
Owner

junkdog commented Sep 18, 2015

We could create a hook for default base Aspect-mapping for all systems; holding it off until post-1.0, but I agree it'd be a better fit for contrib.

Something like:

Aspect.default().exclude(Disabled.class)

@DaanVanYperen
Copy link
Collaborator Author

oh me like! might be a good fit for core really.

@DaanVanYperen DaanVanYperen added this to the artemis-1.1.0 milestone Sep 18, 2015
@DaanVanYperen DaanVanYperen changed the title Consider Disabled component & providing shorthand Hook for default base Aspect-mapping on all systems Sep 23, 2015
@junkdog junkdog modified the milestones: artemis-1.4.0, artemis-1.3.0 Nov 12, 2015
@junkdog
Copy link
Owner

junkdog commented Nov 12, 2015

Aspect.default().exclude(Disabled.class)

The above would not play nice with multi-World configurations. Better to set the default aspect on the WorldConfiguration instead. But how to deal with aspects with and without the default aspect? Must be exposed by the AspectSubscriptionManager.

@junkdog junkdog modified the milestones: artemis-1.3.0, artemis-1.4.0 Nov 21, 2015
@junkdog
Copy link
Owner

junkdog commented Aug 16, 2016

ice-boxing

@junkdog junkdog closed this as completed Aug 16, 2016
@DaanVanYperen DaanVanYperen mentioned this issue Aug 16, 2016
16 tasks
@schosin
Copy link
Contributor

schosin commented Oct 31, 2019

I'd be interested in this feature as well as contributing. My use case is exaclty the the given example.
Before I found this issue, my approach would have been to add the default components to all/one/exclude unless that component is already part of the given aspect.

Examples:

  • default: Aspect.exclude(Disabled.class)
    system: Aspect.exclude(CompA.class)
    result: Aspect.exclude({Disabled.class, CompA.class})
  • default: Aspect.exclude(Disabled.class)
    system: Aspect.all(Disabled.class)
    result: Aspect.all(Disabled.class)
  • default: Aspect.exclude({Disabled.class, CompA.class})
    system: Aspect.all(Disabled.class)
    result: Aspect.exclude(CompA.class).all(Disabled.class).

I would also prefer defining the default aspect in the world configuration. For aspects with/without applying the default aspect, how about something like Aspect.Builder#defaults(boolean disabled), @AspectDescriptor(defaults = true|false), and something like @All(value = {...}, defaults = true|false) or a new annotation alltogether?

Greetings,
schosin

Edit: Ignore first commit below, pushed too early, did too much.

schosin added a commit to schosin/artemis-odb that referenced this issue Nov 4, 2019
schosin added a commit to schosin/artemis-odb that referenced this issue Nov 4, 2019
@schosin
Copy link
Contributor

schosin commented Nov 4, 2019

I've been working on this on my fork, and I had to touch more places than I anticipated.

Here's an overview what I've done:

  • Default aspect is configured via WorldConfiguration(Builder), by default applied to all subscriptions
  • Aspect.Builder
    • has a flag whether to apply defaults or not
    • has a couple of fields changed to package private for easier access in asm (not too happy about this)
  • AspectSubscriptionManager
    • has optional field for a default aspect, set by WorldConfiguration
    • applies the default aspect according to the parameter and builder
  • EntityTransmuter explicitly ignores default aspect regardless of the Aspect.Builder
  • WorldConfiguration/Builder have optional default aspect
  • AspectDescriptor: flag defaults() default true
  • Exclude: flag excludeDefaults() default false (not sure this is the best way for All/One/Exclude)
  • AspectFieldResolver updated for AspectDescriptor/Exclude
  • Updated / added a bunch of tests

This should result in no runtime changes for existing applications and a slight overhead for creations of EntitySubscriptions.
I have only worked in the artemis-core/artemis module. All tests are passing, but I'm not certain whether I forgot anything (plugins, serialization, fluid, gwt, ...).

I'm currently using those changes in a project of mine and I would open a PR depending on feedback and how my tests go.

@junkdog
Copy link
Owner

junkdog commented Nov 10, 2019

Interesting. Sorry for taking too long to respond.

This should result in no runtime changes for existing applications and a slight overhead for creations of EntitySubscriptions.

How much additional overhead are we talking about here? Does it show in the benchmarks?

@schosin
Copy link
Contributor

schosin commented Nov 10, 2019

Haven't run any benchmarks, that statement was solely based on the fact that all the work is done when creating a EntitySubscription.
The biggest impact might be in BaseEntitySystem#getSubscription, as that method always computes the aspect instead of using the field when already initialized. Was there any reason for doing that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants