You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.4 KiB
61 lines
1.4 KiB
11 years ago
|
package mightypork.util.math.constraints;
|
||
11 years ago
|
|
||
|
|
||
|
/**
|
||
|
* <p>
|
||
|
* Interface for constraints that support digests. Digest is a small data object
|
||
11 years ago
|
* with final fields, typically primitive, used for processing (such as
|
||
|
* rendering or other very frequent operations).
|
||
11 years ago
|
* </p>
|
||
|
* <p>
|
||
|
* Taking a digest is expensive, so if it needs to be done often and the value
|
||
|
* changes are deterministic (such as, triggered by timing event or screen
|
||
|
* resize), it's useful to cache the last digest and reuse it until such an
|
||
|
* event occurs again.
|
||
|
* </p>
|
||
11 years ago
|
* <p>
|
||
|
* Implementing class typically needs a field to store the last digest, a flag
|
||
|
* that digest caching is enabled, and a flag that a digest is dirty.
|
||
|
* </p>
|
||
11 years ago
|
*
|
||
|
* @author MightyPork
|
||
|
* @param <D> digest class
|
||
|
*/
|
||
11 years ago
|
public interface Digestable<D> {
|
||
11 years ago
|
|
||
|
/**
|
||
11 years ago
|
* Take a digest. If digest caching is enabled and the cached digest is
|
||
|
* marked as dirty, a new one should be made.
|
||
11 years ago
|
*
|
||
|
* @return digest
|
||
|
*/
|
||
|
public D digest();
|
||
|
|
||
|
|
||
|
/**
|
||
|
* <p>
|
||
|
* Toggle digest caching.
|
||
|
* </p>
|
||
|
* <p>
|
||
|
* To trigger update of the cache, call the <code>poll()</code> method.
|
||
|
* </p>
|
||
|
*
|
||
|
* @param yes
|
||
|
*/
|
||
|
void enableDigestCaching(boolean yes);
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @return true if digest caching is enabled.
|
||
|
*/
|
||
|
boolean isDigestCachingEnabled();
|
||
|
|
||
|
|
||
|
/**
|
||
11 years ago
|
* If digest caching is enabled, mark current cached value as "dirty". Dirty
|
||
|
* digest should be re-created next time a value is requested.<br>
|
||
11 years ago
|
*/
|
||
11 years ago
|
void markDigestDirty();
|
||
11 years ago
|
|
||
|
}
|