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

Event handling not compatible with inheritance #239

Closed
cboittin opened this issue Nov 18, 2014 · 2 comments
Closed

Event handling not compatible with inheritance #239

cboittin opened this issue Nov 18, 2014 · 2 comments
Milestone

Comments

@cboittin
Copy link

When inheriting Agents or Behaviors, the parent event handlers are never trigerred. For example, the following code (with Child as BootAgent) only outputs :

Child initializing
ChildBehavior caught MyEvent
import io.sarl.core.Behaviors
import io.sarl.core.Initialize
import io.sarl.core.InnerContextAccess
import io.sarl.core.Lifecycle
import io.sarl.core.Logging
import io.sarl.core.DefaultContextInteractions

event MyEvent {}

behavior ParentBehavior {
    on MyEvent {
        println("ParentBehavior caught MyEvent")
    }
}

behavior ChildBehavior extends ParentBehavior {
    on MyEvent {
        println("ChildBehavior caught MyEvent")
    }
}

agent Parent {

    on Initialize {
        println("Parent initializing")
    }
}

agent Child extends Parent {
    uses Behaviors, DefaultContextInteractions

    on Initialize {
        println("Child initializing")

        this.registerBehavior(new ChildBehavior(this))

        this.defaultContext.defaultSpace.emit(new MyEvent)
    }
}

agent BootAgent {
    uses Lifecycle, InnerContextAccess, Logging

    on Initialize {
        info("Initializing BootAgent")
        this.spawnInContext(Child, this.innerContext, "test")
    }
}
@gallandarakhneorg
Copy link
Member

This issue should be fixed after the issue #34.

@gallandarakhneorg
Copy link
Member

See #339

@gallandarakhneorg gallandarakhneorg added this to the 0.3 milestone Nov 13, 2015
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

2 participants