Public Types | Public Member Functions | Protected Attributes

opennwa::details::StateStorage Class Reference

This class is used to keep track of the states of an NWA. More...

List of all members.

Public Types

typedef ClientInfo Client
typedef StateSet::const_iterator const_iterator
typedef StateSet::iterator iterator
typedef ref_ptr< ClientClientInfoRefPtr

Public Member Functions

 StateStorage ()
 StateStorage (StateStorage const &other)
StateStorageoperator= (const StateStorage &other)
ClientInfoRefPtr getClientInfo (State state) const
 access the client information associated with the given state
void setClientInfo (State state, const ClientInfoRefPtr c)
 Q: If the state doesn't exit should we add the state(and assign it the given info)?
void clearStates ()
 removes all states
void clearInitialStates ()
 removes all initial states
void clearFinalStates ()
 removes all final states
bool isState (State state) const
 tests whether the given state is a member of this collection
bool isInitialState (State initialState) const
 tests whether the given state is an initial state of this collection
bool isFinalState (State finalState) const
 tests whether the given state is a final state of this collection
bool addState (State state)
 add the given state
bool addInitialState (State initialState)
 add the given initial state
bool addFinalState (State finalState)
 add the given final state
void addAll (const StateStorage &stateSet)
 add all states in the given collection to this collection of states
void addAllStates (const StateStorage &stateSet)
 add all the states in the given StateStorage
void addAllInitialStates (const StateStorage &stateSet)
 add all the initial states in the given StateStorage
void addAllFinalStates (const StateStorage &stateSet)
 add all the final states in the given StateStorage
bool removeState (State state)
 remove the given state
bool removeInitialState (State initialState)
 remove the given initial state
bool removeFinalState (State finalState)
 remove the given final state
std::ostream & print (std::ostream &o) const
 print the collection of states
bool operator== (const StateStorage &other) const
 tests whether this collection of states is equivalent to the collection of states 'other'
const_iterator beginStates () const
 provides access to the states in the collection
const_iterator beginInitialStates () const
 provides access to the initial states in the collection
const_iterator beginFinalStates () const
 provides access to the final states in the collection
const_iterator endStates () const
 provides access to the states in the collection
const_iterator endInitialStates () const
 provides access to the initial states in the collection
const_iterator endFinalStates () const
 provides access to the final states in the collection
const StateSetgetStates () const
 provides access to all states in the collection
const StateSetgetInitialStates () const
 provides access to the names of all the initial states in the collection
const StateSetgetFinalStates () const
 provides access to the names of all final states in the collection
size_t sizeStates () const
 returns the number of states in this collection
size_t largestState () const
size_t sizeInitialStates () const
 returns the number of initial states in this collection
size_t sizeFinalStates () const
 returns the number of final states in this collection
void dupState (State orig, State dup)
 gives 'dup' all the state properties of 'orig'

Protected Attributes

StateSet states
StateSet initialStates
StateSet finalStates
std::map< State, ClientInfoRefPtrstateInfos

Detailed Description

This class is used to keep track of the states of an NWA.


Member Typedef Documentation

typedef StateSet::const_iterator opennwa::details::StateStorage::const_iterator
typedef StateSet::iterator opennwa::details::StateStorage::iterator

Constructor & Destructor Documentation

opennwa::details::StateStorage::StateStorage (  ) 
opennwa::details::StateStorage::StateStorage ( StateStorage const &  other  ) 

Member Function Documentation

StateStorage & opennwa::details::StateStorage::operator= ( const StateStorage other  ) 
StateStorage::ClientInfoRefPtr opennwa::details::StateStorage::getClientInfo ( State  state  )  const

access the client information associated with the given state

This method provides access to the client information associated with this state.

Parameters:
- state: the state whose client information to retrieve
Returns:
the client information associated with the given state
Parameters:
- state: the state whose client information to retrieve
Returns:
the client information associated with the given state

References stateInfos.

Referenced by addAllStates(), and opennwa::Nwa::getClientInfo().

void opennwa::details::StateStorage::setClientInfo ( State  state,
const ClientInfoRefPtr  c 
)

Q: If the state doesn't exit should we add the state(and assign it the given info)?

set the client information associated with the given state

set the client information associated with the given state This method sets the client information associated with the given state to the client information provided. Note: If there is already some client information associated with the given state it is lost.

Parameters:
- state: the state whose client information to set
- c: the desired client information for this state
- state: the state whose client information to set
- c: the desired client information for this state

References addState(), isState(), and stateInfos.

Referenced by opennwa::Nwa::_private_determinize_(), opennwa::Nwa::_private_intersect_(), opennwa::Nwa::_private_star_(), addAllStates(), and opennwa::Nwa::setClientInfo().

void opennwa::details::StateStorage::clearStates (  ) 

removes all states

This method removes all states from this collection. It also removes all initial states and final states.

References clearFinalStates(), clearInitialStates(), stateInfos, and states.

Referenced by opennwa::Nwa::clearStates(), and operator=().

void opennwa::details::StateStorage::clearInitialStates (  ) 

removes all initial states

This method removes all states from the initial state set, but does not remove any states from the state set.

References initialStates.

Referenced by opennwa::Nwa::clearInitialStates(), and clearStates().

void opennwa::details::StateStorage::clearFinalStates (  ) 

removes all final states

This method removes all states from the final state set, but does not remove any states from the state set.

References finalStates.

Referenced by opennwa::Nwa::clearFinalStates(), and clearStates().

bool opennwa::details::StateStorage::isState ( State  state  )  const

tests whether the given state is a member of this collection

This method determines whether the given state is a member of this collection. It returns true if the state is a member and false otherwise.

Parameters:
- state: the state to test
Returns:
true if the state is a member of this collection of states
Parameters:
- state: the state to test
Returns:
true if the state is a member of this collection of states, false otherwise

References states.

Referenced by opennwa::Nwa::isState(), and setClientInfo().

bool opennwa::details::StateStorage::isInitialState ( State  initialState  )  const

tests whether the given state is an initial state of this collection

This method determines whether the given state is an initial state of this collection. It returns true if the state is an initial state and false otherwise.

Parameters:
- initialState: the state to test
Returns:
true if the state is an initial state of this collection, false otherwise
Parameters:
- initialState: the state to test
Returns:
true if the state is an initial state of this collection, false otherwise

References initialStates.

Referenced by dupState(), and opennwa::Nwa::isInitialState().

bool opennwa::details::StateStorage::isFinalState ( State  finalState  )  const

tests whether the given state is a final state of this collection

This method determines whether the given state is a final state of this collection. It returns true if the state is a final state and false otherwise.

Parameters:
- finalState: the state to test
Returns:
true if the state is a final state of this collection, false otherwise
Parameters:
- finalState: the state to test
Returns:
true if the state is a final state of this collection, false otherwise

References finalStates.

Referenced by dupState(), and opennwa::Nwa::isFinalState().

bool opennwa::details::StateStorage::addState ( State  state  ) 

add the given state

This method adds the given state. If the state already exists, false is returned. Otherwise, true is returned.

Parameters:
- state: the state to add
Returns:
false if the state already exists, true otherwise
Parameters:
- state: the state to add
Returns:
false if the state already exists, true otherwise

References states.

Referenced by opennwa::Nwa::_private_star_(), addAllStates(), addFinalState(), addInitialState(), opennwa::Nwa::addState(), opennwa::Nwa::duplicateState(), opennwa::Nwa::duplicateStateOutgoing(), and setClientInfo().

bool opennwa::details::StateStorage::addInitialState ( State  initialState  ) 

add the given initial state

This method adds the given state to this collection of states(if it does not already exist). The given initial state is then added to the initial states. If the state is already an initial state, false is returned. Otherwise, true is returned.

Parameters:
- initialState: the initial state to add
Returns:
false if the state is already an initial state, true otherwise
Parameters:
- initialState: the initial state to add
Returns:
false if the state is already an initial state, true otherwise

References addState(), and initialStates.

Referenced by addAllInitialStates(), opennwa::Nwa::addInitialState(), and dupState().

bool opennwa::details::StateStorage::addFinalState ( State  finalState  ) 

add the given final state

This method adds the given state to this collection of states(if it does not already exist). The given final state is then added to the final states. If the state is already a final state, false is returned. Otherwise, true is returned.

Parameters:
- finalState: the final state to add
Returns:
false if the state is already a final state, true otherwise
Parameters:
- finalState: the final state to add
Returns:
false if the state is already a final state, true otherwise

References addState(), and finalStates.

Referenced by addAllFinalStates(), opennwa::Nwa::addFinalState(), and dupState().

void opennwa::details::StateStorage::addAll ( const StateStorage stateSet  ) 

add all states in the given collection to this collection of states

This method adds all of the states in the given collection of states to this collection of states.

Parameters:
- stateSet: the collection of states to add to this collection of states
- stateSet: the collection of states to add to this collection of states

References addAllFinalStates(), addAllInitialStates(), and addAllStates().

Referenced by opennwa::Nwa::_private_star_(), and opennwa::Nwa::combineWith().

void opennwa::details::StateStorage::addAllStates ( const StateStorage stateSet  ) 

add all the states in the given StateStorage

This method adds all of the given states to the state set.

Parameters:
- stateSet: the StateStorage that contains the states to add
- stateSet: the StateStorage that contains the states to add

References addState(), beginStates(), endStates(), getClientInfo(), and setClientInfo().

Referenced by addAll(), and opennwa::Nwa::addAllStates().

void opennwa::details::StateStorage::addAllInitialStates ( const StateStorage stateSet  ) 

add all the initial states in the given StateStorage

This method adds all of the given initial states to the initial state set (and thus to the state set if they are not already elements of the state set).

Parameters:
- stateSet: the StateStorage that contains the states to add
- stateSet: the StateStorage that contains the states to add

References addInitialState(), beginInitialStates(), and endInitialStates().

Referenced by addAll(), and opennwa::Nwa::addAllInitialStates().

void opennwa::details::StateStorage::addAllFinalStates ( const StateStorage stateSet  ) 

add all the final states in the given StateStorage

This method adds all of the given final states to the final state set (and thus to the state set if they are not already elements of the state set).

Parameters:
- stateSet: the StateStorage that contains the states to add
- stateSet: the StateStorage that contains the states to add

References addFinalState(), beginFinalStates(), and endFinalStates().

Referenced by addAll(), and opennwa::Nwa::addAllFinalStates().

bool opennwa::details::StateStorage::removeState ( State  state  ) 

remove the given state

This method removes the given state. If the state does not exist, false is returned. Otherwise, true is returned. Note: If the given state is an initial state or a final state, it is also removed from that set.

Parameters:
- state: the state to remove
Returns:
false if this state does not exist, true otherwise
Parameters:
- state: the state to remove
Returns:
false if this state does not exist, true otherwise

References removeFinalState(), removeInitialState(), and states.

Referenced by opennwa::Nwa::removeState().

bool opennwa::details::StateStorage::removeInitialState ( State  initialState  ) 

remove the given initial state

This method removes the given initial state. If the state is not an initial state, false is returned. Otherwise, true is returned. Note: The state is not removed from the state set.

Parameters:
- initialState: the initial state to remove
Returns:
false if this state is not an initial state, true otherwise
Parameters:
- initialState: the initial state to remove
Returns:
false if this state is not an initial state, true otherwise

References initialStates.

Referenced by opennwa::Nwa::removeInitialState(), and removeState().

bool opennwa::details::StateStorage::removeFinalState ( State  finalState  ) 

remove the given final state

This method removes the given final state. If the state is not a final state, false is returned. Otherwise, true is returned. Note: The state is not removed from the state set.

Parameters:
- finalState: the final state to remove false if this state is not a final state, true otherwise
- finalState: the final state to remove false if this state is not a final state, true otherwise

References finalStates.

Referenced by opennwa::Nwa::removeFinalState(), and removeState().

std::ostream & opennwa::details::StateStorage::print ( std::ostream &  o  )  const [virtual]

print the collection of states

This method prints out the keys associated with the state set to the output stream provided.

Parameters:
- o: the output stream to print to
Returns:
the output stream that was printed to
Parameters:
- o: the output stream to print to
Returns:
the output stream that was printed to

Implements wali::Printable.

References beginFinalStates(), beginInitialStates(), beginStates(), endFinalStates(), endInitialStates(), endStates(), and wali::printKey().

Referenced by opennwa::Nwa::print().

bool opennwa::details::StateStorage::operator== ( const StateStorage other  )  const

tests whether this collection of states is equivalent to the collection of states 'other'

This method tests the equivalence of this set of states and the set of states 'other'.

Parameters:
- other: the StateStorage to compare this StateStorage to
Returns:
true if this StateStorage is equivalent to the StateStorage 'other'
Parameters:
- other: the StateStorage to compare this StateStorage to
Returns:
true if this StateStorage is equivalent to the StateStorage 'other'

References finalStates, initialStates, and states.

StateStorage::const_iterator opennwa::details::StateStorage::beginStates (  )  const

provides access to the states in the collection

This method provides access to the states in this collection through an iterator.

Returns:
the starting point of an iterator through the states
the starting point of an iterator through the states

References states.

Referenced by addAllStates(), opennwa::Nwa::beginStates(), and print().

StateStorage::const_iterator opennwa::details::StateStorage::beginInitialStates (  )  const

provides access to the initial states in the collection

This method provides access to the initial states in this collection through an iterator.

Returns:
the starting point of an iterator through the initial states
the starting point of an iterator through the initial states

References initialStates.

Referenced by addAllInitialStates(), opennwa::Nwa::beginInitialStates(), and print().

StateStorage::const_iterator opennwa::details::StateStorage::beginFinalStates (  )  const

provides access to the final states in the collection

This method provides access to the final states in this collection through an iterator.

Returns:
the starting point of an iterator through the final states
the starting point of an iterator through the final states

References finalStates.

Referenced by addAllFinalStates(), opennwa::Nwa::beginFinalStates(), and print().

StateStorage::const_iterator opennwa::details::StateStorage::endStates (  )  const

provides access to the states in the collection

This method provides access to the states in the collection through an iterator.

Returns:
one place past the exit point of an iterator through the states
one place past the exit point of an iterator through the states

References states.

Referenced by addAllStates(), opennwa::Nwa::endStates(), and print().

StateStorage::const_iterator opennwa::details::StateStorage::endInitialStates (  )  const

provides access to the initial states in the collection

This method provides access to the initial states in the collection through an iterator.

Returns:
one place past the exit point of an iterator through the initial states
one place past the exit point of an iterator through the initial states

References initialStates.

Referenced by addAllInitialStates(), opennwa::Nwa::endInitialStates(), and print().

StateStorage::const_iterator opennwa::details::StateStorage::endFinalStates (  )  const

provides access to the final states in the collection

This method provides access to the final states in the collection through an iterator.

Returns:
one place past the exit point of an iterator through the final states
one place past the exit point of an iterator through the final states

References finalStates.

Referenced by addAllFinalStates(), opennwa::Nwa::endFinalStates(), and print().

const StateSet & opennwa::details::StateStorage::getStates (  )  const

provides access to all states in the collection

This method provides access to all states in this collection in the form of a set of states.

Returns:
a set containing all states in this collection
a set containing all states in this collection

References states.

Referenced by opennwa::Nwa::getStates().

const StateSet & opennwa::details::StateStorage::getInitialStates (  )  const

provides access to the names of all the initial states in the collection

This method provides access to the names of all the initial states in the collection in the form of a set of state names.

Returns:
a set containing the names of all initial states in the collection
a set containing the names of all initial states in the collection

References initialStates.

Referenced by opennwa::Nwa::getInitialStates().

const StateSet & opennwa::details::StateStorage::getFinalStates (  )  const

provides access to the names of all final states in the collection

This method provides access to the names of all the final states in the collection in the form of a set of state names.

Returns:
a set containing the names of all final states in the collection
a set containing the names of all final states in the collection

References finalStates.

Referenced by opennwa::Nwa::getFinalStates().

size_t opennwa::details::StateStorage::sizeStates (  )  const

returns the number of states in this collection

This method returns the number of states in this collection. Note: This will always be at least 1 as the stuck state is always a legitimate state.

Returns:
the number of states in this collection
the number of states in this collection

References states.

Referenced by opennwa::Nwa::sizeStates().

size_t opennwa::details::StateStorage::largestState (  )  const

References states.

Referenced by opennwa::Nwa::largestState().

size_t opennwa::details::StateStorage::sizeInitialStates (  )  const

returns the number of initial states in this collection

This method returns the number of initial states in this collection.

Returns:
the number of initial states in this collection
the number of initial states in this collection

References initialStates.

Referenced by opennwa::Nwa::sizeInitialStates().

size_t opennwa::details::StateStorage::sizeFinalStates (  )  const

returns the number of final states in this collection

This method returns the number of final states in this collection.

Returns:
the number of final states in this collection
the number of final states in this collection

References finalStates.

Referenced by opennwa::Nwa::sizeFinalStates().

void opennwa::details::StateStorage::dupState ( State  orig,
State  dup 
)

gives 'dup' all the state properties of 'orig'

This method checks all the state properties (initial/final) of 'orig' and assigns the same properties to 'dup'.

Parameters:
- orig: the state whose properties to duplicate
- dup: the state whose properties are being set

FIXME: suppose dup is final, orig is not; this won't remove finality of dup

Parameters:
- orig: the state whose properties to duplicate
- dup: the state whose properties are being set

References addFinalState(), addInitialState(), isFinalState(), and isInitialState().

Referenced by opennwa::Nwa::duplicateState(), and opennwa::Nwa::duplicateStateOutgoing().


Member Data Documentation


The documentation for this class was generated from the following files: