Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

cgsuite
Class Context  view Context download Context.java

java.lang.Object
  extended bycgsuite.Context
Direct Known Subclasses:
Context.DefaultContext

public abstract class Context
extends java.lang.Object

Contains utility methods for communicating with the Combinatorial Game Suite interface. Plug-ins can use this class to reference the primary cache, generate output in mid-calculation, report warning and debugging messages, and otherwise communicate with the kernel.

Plug-in writers should call the static method getActiveContext 55 to obtain a reference to the Context object owned by the kernel. For example, to obtain a reference to the primary cache, use:

Context.getActiveContext().getPrimaryCache()

Plug-ins should never call setActiveContext 55 . It should only be called by stand-alone applications that use the CGSuite library and need additional control over cache management or output display.


Nested Class Summary
static class Context.DefaultContext
           
 
Field Summary
(package private) static Context activeContext
           
 
Constructor Summary
Context()
           
 
Method Summary
abstract  void checkKernelState()
           
abstract  java.lang.String createOutputString(java.lang.Object obj)
          Creates a string representation of the specified object.
abstract  void generateLogMessage(int level, java.lang.String source, java.lang.String message)
           
abstract  void generateOutput(java.lang.Object obj)
          Generates output for the specified object.
abstract  void generateWarning(java.lang.String warning)
          Generates a warning message.
static Context getActiveContext()
          Gets the Context used to communicate with the kernel.
abstract  java.util.Comparator getGameComparator()
          Gets a Comparator that can be used to compare any two objects of type Game.
abstract  java.util.Map getPrimaryCache()
          Gets a reference to the primary cache.
static void setActiveContext(Context context)
          Sets the active context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

activeContext

static Context activeContext
Constructor Detail

Context

public Context()
Method Detail

getPrimaryCache

public abstract java.util.Map getPrimaryCache()
Gets a reference to the primary cache. The primary cache is a hashtable that is shared between the CGSuite core library and all plug-ins. Plug-ins should prefer to use the primary cache rather than a private cache; this gives the kernel greater control over memory management.


getGameComparator

public abstract java.util.Comparator getGameComparator()
Gets a Comparator that can be used to compare any two objects of type Game.

This is useful primarily for games that have many other objects of type Game as sub-games. The comparator can be used to conduct more efficient searches and to provide consistent output.


createOutputString

public abstract java.lang.String createOutputString(java.lang.Object obj)
Creates a string representation of the specified object. An output handler for the object must be registered with the kernel (see the cgsuite.plugin package for details.)

Note that a game's toString method is often insufficient for this purpose. For example, the String that corresponds to a CanonicalGame depends on user-specific options.


generateOutput

public abstract void generateOutput(java.lang.Object obj)
Generates output for the specified object. The output is added to the kernel's output queue to be displayed at the next opportunity.

This method should be used by plug-ins that need to display output in mid-calculation.


generateWarning

public abstract void generateWarning(java.lang.String warning)
Generates a warning message.

This method should be used by plug-ins to report a warning - that is, an error that is not severe enough to justify aborting the calculation.


generateLogMessage

public abstract void generateLogMessage(int level,
                                        java.lang.String source,
                                        java.lang.String message)

checkKernelState

public abstract void checkKernelState()

getActiveContext

public static Context getActiveContext()
Gets the Context used to communicate with the kernel. Plug-ins should call this method to access the primary cache, display output and warnings, and otherwise access the CGSuite interface.


setActiveContext

public static void setActiveContext(Context context)
Sets the active context.

Warning to plug-in writers: Plug-ins should not call this method. It should only be called by stand-alone applications that use the CGSuite library and need additional control over cache management or output display.