Commit in projects/lcsim/trunk/conditions/src/main/java/org/lcsim/conditions/readers on MAIN | |||
BaseClasspathConditionsReader.java | +51 | -4 | 3067 -> 3068 |
Add more functionality to this ConditionsReader class.
--- projects/lcsim/trunk/conditions/src/main/java/org/lcsim/conditions/readers/BaseClasspathConditionsReader.java 2014-03-31 19:32:50 UTC (rev 3067) +++ projects/lcsim/trunk/conditions/src/main/java/org/lcsim/conditions/readers/BaseClasspathConditionsReader.java 2014-03-31 21:28:19 UTC (rev 3068) @@ -3,6 +3,7 @@
import java.io.IOException; import java.io.InputStream;
+import org.lcsim.conditions.ConditionsManager;
import org.lcsim.conditions.ConditionsReader; /**
@@ -11,14 +12,19 @@
*/ public class BaseClasspathConditionsReader extends ConditionsReader {
- private String _resourcePath;
+ private String _resourcePath;
+ String propFileName = "detector.properties";
- String propFileName = "detector.properties";
+ int _runNumber = -1; + String _detectorName;
+ public BaseClasspathConditionsReader() { + } +
public BaseClasspathConditionsReader(String resourcePath) throws IOException { _resourcePath = resourcePath;
- // This shouldn't be here but some (insane) logic in ConditionsReader depends on it for now.
+ // This shouldn't be here but some convoluted logic in ConditionsReader depends on it for now.
if (getClass().getResourceAsStream("/" + _resourcePath + "/" + propFileName) == null) { throw new IOException("Unable to find " + _resourcePath + "/" + propFileName + " on the classpath."); }
@@ -42,7 +48,48 @@
} return in; }
-
+ + /** + * Set the base path for this reader to search for classpath resources. + * @param resourcePath the resource path + */ + public void setResourcePath(String resourcePath) { + _resourcePath = resourcePath; + } + + /** + * Update this reader for possibly new detector or run number. + * This reader caches the detector name and run number, and this method will + * return new if either is different from the cached values. + * @return true if new detector or run number + */ + public boolean update(ConditionsManager manager, String detectorName, int run) throws IOException { + + boolean update = false; + + // Check detector name. + if (_detectorName == null || _detectorName != detectorName) { + _detectorName = detectorName; + update = true; + System.out.println(this.getClass().getSimpleName() + ".update - new detector " + _detectorName); + } + + // Check run number. + if (run != _runNumber) { + update = true; + System.out.println(this.getClass().getSimpleName() + ".update - new run " + run); + } + + System.out.println(this.getClass().getSimpleName() + ".update - " + update); + + return update; + } + + /** + * Close the reader. + * For this type, it is a no-op. + * @throws IOException never + */
public void close() throws IOException { } }
\ No newline at end of file
Use REPLY-ALL to reply to list
To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1