Top Up Prev Next Bottom Contents Index Search

10.4 Class KnownState

KnownState manages two lists of states, one to represent the types of states known to the system (integer, string, complex, array of floating, etc.), and one to represent certain predeclared global states. It is very much like KnownBlock in internal structure. Since it manages two lists, there are two kinds of constructors.

KnownState (State &state, const char* name); 
This constructor adds an entry to the state type list. For example,

static IntState proto; 
static KnownState entry(proto,"INT");
permits IntStates to be produced by cloning. The type argument must be in upper case, because of the way find works (see below). The second type of constructor takes three arguments:

KnownState (State &state, const char* name, const char* value); 
This constructor permits names to be added to the global state symbol list, for use in state expressions. For example, we have

static FloatState pi; 
KnownState k_pi(pi,"PI","3.14159265358979323846");
 
static const State* find (const char* type); 
The find method returns a pointer the appropriate prototype state in the state type list. The argument is always changed to upper case. A null pointer is returned if there is no match.

static const State* lookup (const char* name); 
The lookup method returns a pointer to the appropriate state in the global state list, or null if there is no match.

static State* clone (const char* type); 
The clone method takes a string, finds the appropriate state using find, and returns a clone of that block. A null pointer is returned if there is no match, and Error::error is also called.

static StringList nameList(); 
Return the names of all the known state types, separated by newlines.

static int nKnown(); 
Return the number of known states.



Top Up Prev Next Bottom Contents Index Search

Copyright © 1990-1997, University of California. All rights reserved.