source: java/main/src/main/java/com/framsticks/core/Entity.java @ 78

Last change on this file since 78 was 78, checked in by psniegowski, 11 years ago

Add f0 parsing and f0->Model transformation.

File size: 1.3 KB
Line 
1package com.framsticks.core;
2
3import com.framsticks.util.*;
4import com.framsticks.util.Thread;
5import org.apache.log4j.Logger;
6
7/**
8 * @author Piotr Sniegowski
9 */
10public abstract class Entity extends Parameters implements Dispatcher {
11
12    private final static Logger LOGGER = Logger.getLogger(Entity.class.getName());
13
14    public Entity(Parameters parameters) {
15        super(parameters);
16        if (dispatcher == null) {
17            dispatcher = new Thread(name);
18        }
19    }
20
21    @Override
22    public final boolean isActive() {
23        return dispatcher.isActive();
24    }
25
26    @Override
27    public final void invokeLater(Runnable runnable) {
28        dispatcher.invokeLater(runnable);
29    }
30
31    protected void run() {
32        assert isActive();
33        LOGGER.info("running: " + this);
34    }
35
36    public final void configurePublic() throws Exception {
37        configure();
38    }
39
40    protected void configure() throws Exception {
41
42    }
43
44    public Dispatcher getDispatcher() {
45        return dispatcher;
46    }
47
48    public final void start() {
49        invokeLater(new Runnable() {
50            @Override
51            public void run() {
52                Entity.this.run();
53            }
54        });
55    }
56
57        public final void done() {
58                LOGGER.info("stopping entity");
59                if (owner != null) {
60                        owner.onDone();
61                }
62        }
63
64
65}
Note: See TracBrowser for help on using the repository browser.