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