edu.ksu.cis.projects.bogor.module
Class DefaultStateManager

java.lang.Object
  extended by edu.ksu.cis.projects.bogor.module.DefaultStateManager
All Implemented Interfaces:
ISelfDescribingModule, IModule, IStateManager, Disposable

public class DefaultStateManager
extends Object
implements IStateManager, ISelfDescribingModule

Version:
CVS $Revision: 1.24 $ $Date: 2005/05/31 03:15:33 $
Author:
Robby , Matt Hoosier

Field Summary
protected  int bitsPerCreatedTypeId
           
protected  int bitsPerLocDesc
           
protected  int bitsPerLockCount
           
protected  int bitsPerNonPrimitiveValue
           
protected  int bitsPerThreadId
           
protected  ObjectIntTable<StaticByteArray> compressedStateStateIdMap
           
protected  int nextStateId
           
protected  PrintWriter pw
           
protected  IStateFactory sf
           
protected  SymbolTable symbolTable
           
protected  IValueFactory vf
           
 
Constructor Summary
DefaultStateManager()
           
 
Method Summary
 IMessageStore connect(IBogorConfiguration bc)
          Connects this modules to other modules.
 void dispose()
          Remove references.
 String getCopyrightNotice()
          Returns the copyright notice for this module.
protected  ObjectIntTable<INonPrimitiveValue> getNonPrimitiveValueIdTable(IState s, ArrayList<INonPrimitiveValue> heap, IntIntTable threadOrderMap)
           
 Pair<Domain,Boolean> getOptionDomain(String id)
           
 Collection<Triple<String,Boolean,OptionScope>> getOptionIds()
           
 IState getState(int stateId)
           
 int getStateCount()
           
 Collection<String> getSuggestedValues(String id, IBogorConfiguration bc, SymbolTable st)
           
protected  IntIntTable getThreadOrderMap(IState s)
           
 IStoreStateResult hasState(IState s)
           
protected  StaticByteArray linearize(IState s)
           
protected  void linearizeGlobals(IState s, ObjectIntTable<INonPrimitiveValue> nonPrimitiveValueIdMap, IntIntTable threadOrderMap, BitBuffer bb)
           
protected  void linearizeHeap(ArrayList<INonPrimitiveValue> heap, ObjectIntTable<INonPrimitiveValue> nonPrimitiveValueIdMap, IntIntTable threadOrderMap, BitBuffer bb)
          Flatten the heap to a bit-vector representation.
protected  void linearizeThreads(IState s, ObjectIntTable<INonPrimitiveValue> nonPrimitiveValueIdMap, IntIntTable threadOrderMap, BitBuffer bb)
           
 IMessageStore setOptions(String key, Properties configuration)
          Sets the options for this module.
 IStoreStateResult storeState(IState s)
           
 boolean validate(String id, String value, IBogorConfiguration bc, SymbolTable st, Collection<FileMessage> errors)
          Checks whether the value of a configuration option is legal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

symbolTable

protected SymbolTable symbolTable

vf

protected IValueFactory vf

sf

protected IStateFactory sf

pw

protected PrintWriter pw

compressedStateStateIdMap

protected ObjectIntTable<StaticByteArray> compressedStateStateIdMap

nextStateId

protected int nextStateId

bitsPerThreadId

protected int bitsPerThreadId

bitsPerLocDesc

protected int bitsPerLocDesc

bitsPerCreatedTypeId

protected int bitsPerCreatedTypeId

bitsPerNonPrimitiveValue

protected int bitsPerNonPrimitiveValue

bitsPerLockCount

protected int bitsPerLockCount
Constructor Detail

DefaultStateManager

public DefaultStateManager()
Method Detail

getCopyrightNotice

public String getCopyrightNotice()
Description copied from interface: IModule
Returns the copyright notice for this module.

Specified by:
getCopyrightNotice in interface IModule
Returns:
The copyright notice for this module. Returns null if no additional notice is necessary.

setOptions

public IMessageStore setOptions(String key,
                                Properties configuration)
Description copied from interface: IModule
Sets the options for this module.

Specified by:
setOptions in interface IModule
Parameters:
key - The key (prefix) for this module options. Must be non-null. The key is used for module specific options.
configuration - The options for all modules. Must be non-null.

getState

public IState getState(int stateId)
Specified by:
getState in interface IStateManager

getStateCount

public int getStateCount()
Specified by:
getStateCount in interface IStateManager

connect

public IMessageStore connect(IBogorConfiguration bc)
Description copied from interface: IModule
Connects this modules to other modules.

Specified by:
connect in interface IModule
Parameters:
bc - The Bogor configuration containing modules to connect to. Must be non-null.

dispose

public void dispose()
Description copied from interface: Disposable
Remove references. Once called, avoid using this object.

Specified by:
dispose in interface Disposable

hasState

public IStoreStateResult hasState(IState s)
Specified by:
hasState in interface IStateManager

storeState

public IStoreStateResult storeState(IState s)
Specified by:
storeState in interface IStateManager

getNonPrimitiveValueIdTable

protected ObjectIntTable<INonPrimitiveValue> getNonPrimitiveValueIdTable(IState s,
                                                                         ArrayList<INonPrimitiveValue> heap,
                                                                         IntIntTable threadOrderMap)

linearize

protected StaticByteArray linearize(IState s)

getThreadOrderMap

protected IntIntTable getThreadOrderMap(IState s)

linearizeGlobals

protected void linearizeGlobals(IState s,
                                ObjectIntTable<INonPrimitiveValue> nonPrimitiveValueIdMap,
                                IntIntTable threadOrderMap,
                                BitBuffer bb)

linearizeHeap

protected void linearizeHeap(ArrayList<INonPrimitiveValue> heap,
                             ObjectIntTable<INonPrimitiveValue> nonPrimitiveValueIdMap,
                             IntIntTable threadOrderMap,
                             BitBuffer bb)
Flatten the heap to a bit-vector representation.

Parameters:
heap - The ordered set of reachable heap-allocated objects in the BIR program.
nonPrimitiveValueIdMap - Mapping from the heap objects to their canonical ordering.
threadOrderMap - Mapping of thread descriptors (int) to their position in a canonical ordering (int).
bb - The target into which the linearized representation of the heap will be written.

linearizeThreads

protected void linearizeThreads(IState s,
                                ObjectIntTable<INonPrimitiveValue> nonPrimitiveValueIdMap,
                                IntIntTable threadOrderMap,
                                BitBuffer bb)

getOptionIds

public Collection<Triple<String,Boolean,OptionScope>> getOptionIds()
Specified by:
getOptionIds in interface ISelfDescribingModule
Returns:
a set of tuples whose first element says the name of the option, and whose second element says whether the option is required, and whose third element says whether the option is private to this module (and thus prefixed by the interface implemented, e.g., edu.ksu.cis.projects.bogor.module.ISearcher) or global in scope (and thus no qualifier is prepended).

getOptionDomain

public Pair<Domain,Boolean> getOptionDomain(String id)
Specified by:
getOptionDomain in interface ISelfDescribingModule
Returns:
a tuple whose first element says the domain of the option values, and whose second element says whether the option is multivalued (that is, a comma-separated list)

getSuggestedValues

public Collection<String> getSuggestedValues(String id,
                                             IBogorConfiguration bc,
                                             SymbolTable st)
Specified by:
getSuggestedValues in interface ISelfDescribingModule

validate

public boolean validate(String id,
                        String value,
                        IBogorConfiguration bc,
                        SymbolTable st,
                        Collection<FileMessage> errors)
Description copied from interface: ISelfDescribingModule
Checks whether the value of a configuration option is legal.

Specified by:
validate in interface ISelfDescribingModule
Parameters:
id - the option's name, as returned by the first tuple element of an item returned by ISelfDescribingModule.getOptionIds()
value - the value of the option, or null if unconfigued
st - the symbol table for the BIR model
errors - a container into which errors should be put. Implementors should not assume that errors is empty upon entry into this method; it may aggregate the results of calling validate on many ISelfDescribingModule instances.
Returns:
true iff the option is supported and its value is legal