66f4036f95b9bf2bde5b72d5b9374af558feefb3
[jalview.git] / src / jalview / api / AlignCalcManagerI.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.api;
22
23 import jalview.datamodel.AlignmentAnnotation;
24
25 import java.util.List;
26
27 public interface AlignCalcManagerI
28 {
29
30   /**
31    * tell manager that a worker is initialised and has started to run
32    * 
33    * @param worker
34    */
35   void notifyStart(AlignCalcWorkerI worker);
36
37   /**
38    * check if a calculation of this type is already active
39    * 
40    * @param worker
41    * @return
42    */
43   boolean alreadyDoing(AlignCalcWorkerI worker);
44
45   /**
46    * tell manager that worker is now processing data
47    * 
48    * @param worker
49    */
50   boolean notifyWorking(AlignCalcWorkerI worker);
51
52   /**
53    * notify manager that the worker has completed, and results may be ready to
54    * collect
55    * 
56    * @param worker
57    */
58   void workerComplete(AlignCalcWorkerI worker);
59
60   /**
61    * indicate that a worker like this cannot run on the platform and shouldn't
62    * be started again
63    * 
64    * @param worker
65    */
66   void workerCannotRun(AlignCalcWorkerI worker);
67
68   /**
69    * indicate that a worker like this may be run on the platform.
70    * 
71    * @param worker
72    *          of class to be removed from the execution blacklist
73    */
74   void workerMayRun(AlignCalcWorkerI worker);
75
76   /**
77    * launch a new worker
78    * 
79    * @param worker
80    */
81   void startWorker(AlignCalcWorkerI worker);
82
83   /**
84    * 
85    * @param worker
86    * @return
87    */
88   boolean isWorking(AlignCalcWorkerI worker);
89
90   /**
91    * if any worker thread is operational, return true!
92    * 
93    * @return
94    */
95   boolean isWorking();
96
97   /**
98    * register a restartable worker
99    * 
100    * @param worker
101    */
102   void registerWorker(AlignCalcWorkerI worker);
103
104   /**
105    * restart any registered workers
106    */
107   void restartWorkers();
108
109   /**
110    * 
111    * @param alignmentAnnotation
112    * @return true if a currently registered and working worker indicates its
113    *         involvement with the given alignmentAnnotation
114    */
115   boolean workingInvolvedWith(AlignmentAnnotation alignmentAnnotation);
116
117   /**
118    * kick any known instances of the given worker class to update their
119    * annotation
120    * 
121    * @param workerClass
122    */
123   void updateAnnotationFor(Class workerClass);
124
125   /**
126    * return any registered workers of the given class
127    * 
128    * @param workerClass
129    * @return null or one or more workers of the given class
130    */
131   List<AlignCalcWorkerI> getRegisteredWorkersOfClass(Class workerClass);
132
133   /**
134    * start any workers of the given class
135    * 
136    * @param workerClass
137    * @return false if no workers of given class were registered (note -
138    *         blacklisted classes cannot be restarted, so this method will return
139    *         true for blacklisted workers)
140    */
141   boolean startRegisteredWorkersOfClass(Class workerClass);
142
143   /**
144    * work out if there is an instance of a worker that is *waiting* to start
145    * calculating
146    * 
147    * @param workingClass
148    * @return true if workingClass is already waiting to calculate. false if it
149    *         is calculating, or not queued.
150    */
151   boolean isPending(AlignCalcWorkerI workingClass);
152
153   /**
154    * deregister and otherwise remove any registered and working instances of the
155    * given worker type
156    * 
157    * @param typeToRemove
158    */
159   void removeRegisteredWorkersOfClass(Class typeToRemove);
160
161 }