formatting
[jalview.git] / src / jalview / api / AlignCalcManagerI.java
1 package jalview.api;
2
3 import jalview.datamodel.AlignmentAnnotation;
4
5 import java.util.List;
6
7 public interface AlignCalcManagerI
8 {
9
10   /**
11    * tell manager that a worker is initialised and has started to run
12    * 
13    * @param worker
14    */
15   void notifyStart(AlignCalcWorkerI worker);
16
17   /**
18    * check if a calculation of this type is already active
19    * 
20    * @param worker
21    * @return
22    */
23   boolean alreadyDoing(AlignCalcWorkerI worker);
24
25   /**
26    * tell manager that worker is now processing data
27    * 
28    * @param worker
29    */
30   boolean notifyWorking(AlignCalcWorkerI worker);
31
32   /**
33    * notify manager that the worker has completed, and results may be ready to
34    * collect
35    * 
36    * @param worker
37    */
38   void workerComplete(AlignCalcWorkerI worker);
39
40   /**
41    * indicate that a worker like this cannot run on the platform and shouldn't
42    * be started again
43    * 
44    * @param worker
45    */
46   void workerCannotRun(AlignCalcWorkerI worker);
47
48   /**
49    * indicate that a worker like this may be run on the platform.
50    * 
51    * @param worker
52    *          of class to be removed from the execution blacklist
53    */
54   void workerMayRun(AlignCalcWorkerI worker);
55
56   /**
57    * launch a new worker
58    * 
59    * @param worker
60    */
61   void startWorker(AlignCalcWorkerI worker);
62
63   /**
64    * 
65    * @param worker
66    * @return
67    */
68   boolean isWorking(AlignCalcWorkerI worker);
69
70   /**
71    * if any worker thread is operational, return true!
72    * 
73    * @return
74    */
75   boolean isWorking();
76
77   /**
78    * register a restartable worker
79    * 
80    * @param worker
81    */
82   void registerWorker(AlignCalcWorkerI worker);
83
84   /**
85    * restart any registered workers
86    */
87   void restartWorkers();
88
89   /**
90    * 
91    * @param alignmentAnnotation
92    * @return true if a currently registered and working worker indicates its
93    *         involvement with the given alignmentAnnotation
94    */
95   boolean workingInvolvedWith(AlignmentAnnotation alignmentAnnotation);
96
97   /**
98    * kick any known instances of the given worker class to update their
99    * annotation
100    * 
101    * @param workerClass
102    */
103   void updateAnnotationFor(Class workerClass);
104
105   /**
106    * return any registered workers of the given class
107    * 
108    * @param workerClass
109    * @return null or one or more workers of the given class
110    */
111   List<AlignCalcWorkerI> getRegisteredWorkersOfClass(Class workerClass);
112
113   /**
114    * start any workers of the given class
115    * 
116    * @param workerClass
117    * @return false if no workers of given class were registered (note -
118    *         blacklisted classes cannot be restarted, so this method will return
119    *         true for blacklisted workers)
120    */
121   boolean startRegisteredWorkersOfClass(Class workerClass);
122
123   /**
124    * work out if there is an instance of a worker that is *waiting* to start
125    * calculating
126    * 
127    * @param workingClass
128    * @return true if workingClass is already waiting to calculate. false if it
129    *         is calculating, or not queued.
130    */
131   boolean isPending(AlignCalcWorkerI workingClass);
132
133   /**
134    * deregister and otherwise remove any registered and working instances of the
135    * given worker type
136    * 
137    * @param typeToRemove
138    */
139   void removeRegisteredWorkersOfClass(Class typeToRemove);
140
141 }