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