Purpose:
|
Implements a method for saving past states.
|
|
Derivation:
|
HISTORY_STREAM : ACIS_OBJECT : -
|
|
SAT Identifier:
|
"history_stream"
|
|
Filename:
|
kern/kernel/kerndata/bulletin/bulletin.hxx
|
|
Description:
|
Externally useful functions to control roll back.
|
|
|
Starts a new bulletin board. At the outermost level of checkpointing, removes any failed previous bulletin board and constructs a new one to run sequentially with any previous successful ones. At any other level of checkpointing, if the argument is
FALSE, it takes no action, so that the current bulletin board continues in use. If the argument is
TRUE, in effect it pushes a new bulletin board on a stack, whence it may subsequently be removed by a matching
close_bulletin_board, restoring everything to its previous state.
|
|
References:
|
KERN
|
ATTRIB_HISTORY, DELTA_STATE, DELTA_STATE_LIST, ENTITY, ENTITY_LIST
|
|
by KERN
|
ATTRIB_HISTORY, BULLETIN_BOARD, DELTA_STATE, HISTORY_MANAGER, model_context
|
|
Data:
|
public ATTRIB_HISTORY* attribute;
|
|
Persistent only to make a connection during save and restore.
|
|
|
public DELTA_STATE *active_ds;
|
|
Pointer to the active delta state.
|
|
|
public DELTA_STATE *current_ds;
|
|
Pointer to the current delta state.
|
|
|
public DELTA_STATE *root_ds;
|
|
Pointer to the root delta state.
|
|
|
public DELTA_STATE_LIST* merged_states;
|
|
Pointer to a list of delta states merged into this list.
|
|
|
public ENTITY_LIST* active_check_list;
|
|
Used in checking the history stream.
|
|
|
public STATE_ID current_state;
|
|
Current state.
|
|
|
public STATE_ID next_state;
|
|
Acts as a state number server giving a new (unused) state number on request. When model is rolled back to earlier state, the current state number is reset to the state number of the earlier state, but subsequent new states are taken from next_state. State numbers increment from 1.
|
|
|
public int logging_level;
|
|
The number of api_begin's minus the number of api_end's made so far. In effect, this is the current API nesting level.
|
|
|
public logical link_states;
|
|
Indicates if there are link states. Used by api_stop_modeler.
|
|
|
public unsigned max_states_to_keep;
|
|
Limit on the number of states to be kept to control the memory used by a stream. Enforced in note_state by pruning. Hidden states are not counted.
|
|
Constructor:
|
public: HISTORY_STREAM::HISTORY_STREAM
();
|
|
|
C++ allocation constructor requests memory for this object but does not populate it.
|
|
|
|
|
Destructor:
|
public: HISTORY_STREAM::~HISTORY_STREAM
();
|
|
|
C++ destructor, deleting a
HISTORY_STREAM.
|
|
|
|
Methods:
|
public: void HISTORY_STREAM::add
(
|
|
|
DELTA_STATE*
|
// delta state
|
|
|
);
|
|
|
Add delta state to history stream.
|
|
|
|
|
|
|
public: void
|
|
|
HISTORY_STREAM::add_create_bulletins_to_root_ds (
|
|
|
ENTITY_LIST& survivors,
|
|
|
// survivors
|
|
|
logical remove_existing_from_survivors// remove
|
|
|
|
|
|
|
// or not
|
|
|
);
|
|
|
Adds create bulletins to root
DELTA_STATE, for use when pruning or saving and restoring empty histories.
|
|
|
|
|
|
|
public: logical HISTORY_STREAM::assign_tag
(
|
|
|
const ENTITY* ent,
|
// entity
|
|
|
tag_id_type id
|
// tag
|
|
|
);
|
|
|
Assign a tag to an entity.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::attach
(
|
|
|
DELTA_STATE*,
|
// delta state
|
|
|
DELTA_STATE*
|
// delta state
|
|
|
);
|
|
|
Attach two delta states to one another in history stream.
|
|
|
|
|
|
|
public: logical HISTORY_STREAM::can_roll_back
();
|
|
|
Simple test to see whether stream can be rolled back.
|
|
|
|
|
|
|
public: logical HISTORY_STREAM::can_roll_forward
();
|
|
|
Simple test to see whether stream can be rolled forward.
|
|
|
|
|
|
|
public:outcome
|
|
|
HISTORY_STREAM::check_tags_validity (); ;
|
|
|
Function to verify the stream is correct.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::clear
();
|
|
|
Re-initialize to an empty stream with just the
root_dssys_error if
logging_level is not equal to zero.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::clear_history_ptrs
();;
|
|
|
Clear reference to this history from entities in delta state.
|
|
|
|
|
|
|
public: BULLETIN_BOARD*
|
|
|
HISTORY_STREAM::current_bb ();
|
|
|
Obtains access to the current bulletin board for update functions.
|
|
|
|
|
|
|
public: DELTA_STATE*
|
|
|
HISTORY_STREAM::current_delta_state ();
|
|
|
Returns pointer to current value of the
DELTA_STATE.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::debug
(
|
|
|
int id
|
// id for delta states
|
|
|
|
= 0,
|
|
|
int ent_level
|
// bulletin board
|
|
|
|
= 0,
|
// debugging level
|
|
|
int level
|
// delta state
|
|
|
|
= 1,
|
// debugging level
|
|
|
FILE* fp
|
// debug file pointer
|
|
|
|
= debug_file_ptr
|
|
|
);
|
|
|
Prints debugging information about the history stream.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::delete_delta_states
();
|
|
|
Removes delta states from the history stream.
|
|
|
|
|
|
|
public: HISTORY_STREAM* HISTORY_STREAM::detach
(
|
|
|
DELTA_STATE*
|
// delta state
|
|
|
);
|
|
|
Detaches the given bulletin from the given bulletin board.
|
|
|
|
|
|
|
public: logical
|
|
|
HISTORY_STREAM::distribution_on () const;
|
|
|
Returns the
distribute_flag value.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::dump
(
|
|
|
int level
|
// number of levels
|
|
|
|
= 0
|
|
|
);
|
|
|
Number of history stream levels to save to output file.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::find_entities
(
|
|
|
enum ENTITY_TYPE,
|
// type of entity
|
|
|
ENTITY_LIST& elist
|
// entity list
|
|
|
);
|
|
|
Finds the entity from the history stream based on type.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::find_entities
(
|
|
|
is_function,
|
// flag for an if entity
|
|
|
ENTITY_LIST& elist
|
// entity list
|
|
|
);
|
|
|
Finds the entity from the history stream based on functionality.
|
|
|
|
|
|
|
public: DELTA_STATE*
|
|
|
HISTORY_STREAM::get_active_ds ();
|
|
|
Retrieves the active
DELTA_STATE.
|
|
|
|
|
|
|
public: DELTA_STATE*
|
|
|
HISTORY_STREAM::get_current_ds ();
|
|
|
Gets the current
DELTA_STATE.
|
|
|
|
|
|
|
public: STATE_ID
|
|
|
HISTORY_STREAM::get_current_state ();
|
|
|
Gets the current state.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::get_delta_state
(
|
|
|
STATE_ID& cs,
|
// current state
|
|
|
STATE_ID& ns,
|
// next state
|
|
|
DELTA_STATE*& ds
|
// delta state
|
|
|
);
|
|
|
Retrieves the delta state matching the state parameters.
|
|
|
|
|
|
|
public: ENTITY* HISTORY_STREAM::get_entity_from_tag
(
|
|
|
tag_id_type tag_no,
|
|
// tag
|
|
|
outcome& result
|
|
// result
|
|
|
|
= * (outcome*)NULL_REF
|
|
|
);;
|
|
|
Get an
ENTITY from the given tag.
|
|
|
|
|
|
|
public: int HISTORY_STREAM::get_logging_level
();
|
|
|
The logging level is the number of api_begin calls minus the number of api_end calls, and represents the current nesting of api calls.
|
|
|
|
|
|
|
public: DELTA_STATE* HISTORY_STREAM::get_root_ds
();
|
|
|
Retrieves the root
DELTA_STATE.
|
|
|
|
|
|
|
public: DELTA_STATE*
|
|
|
HISTORY_STREAM::get_state_from_id (
|
|
|
STATE_ID id
|
// tag
|
|
|
);
|
|
|
Get the delta state from a given tag.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::get_tagged_entities
(
|
|
|
ENTITY_LIST& elist
|
// entity list
|
|
|
);;
|
|
|
Function to verify the stream is correct.
|
|
|
|
|
|
|
public: void
|
|
|
HISTORY_STREAM::initialize_delta_states ();
|
|
|
Resets the delta states to beginning.
|
|
|
|
|
|
|
public: logical HISTORY_STREAM::in_stream
(
|
|
|
DELTA_STATE* ds
|
// delta state
|
|
|
);
|
|
|
Determines whether a given state is in this stream.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::list_delta_states
(
|
|
|
DELTA_STATE_LIST& dslist
|
// delta state list
|
|
|
);
|
|
|
Lists the delta states.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::merge
(
|
|
|
HISTORY_STREAM*
|
// history stream
|
|
|
);
|
|
|
Merge this delta state in this history stream.
|
|
|
|
|
|
|
public: logical HISTORY_STREAM::mixed_streams
(
|
|
|
HISTORY_STREAM*& alternate_hs
|
// alternate
|
|
|
|
|
|
|
// stream
|
|
|
);;
|
|
|
Function to verify the stream is correct.
|
|
|
|
|
|
|
public: STATE_ID HISTORY_STREAM::new_state
();
|
|
|
Create a new modeler state identifier.
|
|
|
|
|
|
|
public:HISTORY_STREAM*
|
|
|
HISTORY_STREAM::next_stream () const ;
|
|
|
Get the next stream.
|
|
|
|
|
|
|
public:logical
|
|
|
HISTORY_STREAM::owns_entities () const ;
|
|
|
Read the flag for owning entities.
|
|
|
|
|
|
|
public: HISTORY_STREAM*
|
|
|
HISTORY_STREAM::previous_stream () const;
|
|
|
Get the previous stream.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::prune
(
|
|
|
DELTA_STATE* ds
|
// delta state
|
|
|
);
|
|
|
Snips the graph of
DELTA_STATEs just before the given state and deletes the piece that does not include
active_ds. Thus one can prune forward branches by passing a state after
active_ds. One can prune past history by passing
active_ds or one prior to it. It is impossible to prune away
active_ds.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::prune_following
();
|
|
|
Prune away all states after
active_ds. There is no
numToSave here because we don't know what branch to chop if there is a branch. This is not believed to be a practical limitation.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::prune_inactive
();
|
|
|
The active path runs from the root, to the current state of the model (active_ds). This routine prunes away states not in the active path.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::prune_inactive_branch
(
|
|
|
DELTA_STATE* ds
|
// delta state
|
|
|
);
|
|
|
The active path runs from the root, to the current state of the model (active_ds). This routine prunes away states not in the active path, limiting the prune to inactive branches.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::prune_previous
(
|
|
|
int numToSave
|
// number to save
|
|
|
);
|
|
|
Prune away the earlier parts of the stream, saving
active_ds and
numToSave earlier states. This can be used to control the memory required for history by limiting the number of states to keep.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::remove
(
|
|
|
DELTA_STATE*
|
// delta state
|
|
|
);
|
|
|
Remove a bulletin board from this delta state.
|
|
|
|
|
|
|
public: ENTITY*
|
|
|
HISTORY_STREAM::remove_tag_reference (
|
|
|
tag_id_type tag_no
|
// entity id
|
|
|
);;
|
|
|
Remove an ENTITY from the
TAG array.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::reset_state
(
|
|
|
STATE_ID n
|
// state to reset to
|
|
|
);
|
|
|
Resets the modeler state to the given state.
|
|
|
|
|
|
|
public: logical HISTORY_STREAM::restore
();
|
|
|
Restores history stream.
|
|
|
read_int
|
Current State
|
|
read_int
|
Next State
|
|
read_int
|
Maximum states to keep
|
|
if(restore_version_number >= ENTITY_TAGS_VERSION)
|
|
read_int
|
new next tag
|
|
read_pointer
|
Pointer to record in SAT file with the current DELTA_STATE
|
|
read_pointer
|
Pointer to record in SAT file with the active DELTA_STATE
|
|
read_pointer
|
Pointer to record in SAT file with the root DELTA_STATE
|
|
read_pointer
|
Pointer to record in SAT file with ATTRIB_HISTORY
|
|
read_data
|
|
|
|
Intended for unknown data
|
|
|
|
|
|
|
public: tag_id_type
|
|
|
HISTORY_STREAM::restore_tag_reference (
|
|
|
const ENTITY* ent
|
// entity
|
|
|
);
|
|
|
Add an ENTITY to the TAG array.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::roll_links
(
|
|
|
DELTA_STATE*
|
// delta state
|
|
|
);
|
|
|
This function manages the links between delta states during roll. For internal use only.
|
|
|
|
|
|
|
public: logical HISTORY_STREAM::save
(
|
|
|
ENTITY_LIST& elist,
|
|
// entity list
|
|
|
HISTORY_STREAM_LIST& hslist,// history stream
|
|
|
|
|
|
// list
|
|
|
DELTA_STATE_LIST& dslist
|
|
// delta state list
|
|
|
);
|
|
|
Saves the id level, next state, maximum states to keep, pointers to the current delta state, active delta state, and root delta state, and attributes.
|
|
|
|
|
|
|
public: logical HISTORY_STREAM::set_current_state
(
|
|
|
STATE_ID cs,
|
// current state
|
|
|
DELTA_STATE* ds
|
// delta state
|
|
|
);
|
|
|
Sets the current state to the given ID in the
DELTA_STATE.
|
|
|
|
|
|
|
public: logical HISTORY_STREAM::set_delta_state
(
|
|
|
STATE_ID cs,
|
// current state
|
|
|
STATE_ID ns,
|
// next state
|
|
|
DELTA_STATE* ds
|
// delta state
|
|
|
);
|
|
|
Sets the current delta state to the given state.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::set_distribute_flag
(
|
|
|
logical o
|
// distribution flag
|
|
|
);;
|
|
|
Set the flag for distribution.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::set_max_states_to_keep
(
|
|
|
int
|
|
// number to set
|
|
|
);
|
|
|
Establishes the maximum number of states to keep in history stream. Additional states above this maximum are pruned.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::set_owners
();
|
|
|
Resets the owning stream after moving states between streams.
|
|
|
|
|
|
|
public: void HISTORY_STREAM::set_owns_entities
(
|
|
|
logical o
|
// owning flag
|
|
|
);
|
|
|
Set the flag for owning entities.
|
|
|
|
|
|
|
public: logical HISTORY_STREAM::set_state_linking
(
|
|
|
logical sl
|
// state link flag
|
|
|
);
|
|
|
Sets the state link.
|
|
|
|
|
|
|
public: int HISTORY_STREAM::size
(
|
|
|
logical include_backups
|
// backup entities
|
|
|
|
= TRUE
|
// counted if TRUE
|
|
|
) const;
|
|
|
Returns the amount of space taken by this history stream. This includes all the history stream structure and optionally the backup entities, but not the active entities.
|
|
|
|
|
|
|
public: tag_id_type HISTORY_STREAM::tag
(
|
|
|
const ENTITY* ent,
|
// entity
|
|
|
logical check
|
// perform checks
|
|
|
|
= TRUE,
|
// or not
|
|
|
tag_id_type required_id
|
// required flag
|
|
|
|
= -1
|
|
|
);
|
|
|
Return the tag on an
ENTITY in the
HISTORY_STREAM.
|
|
Internal Use:
|
fix_pointers, full_size
|
|
|
|
|
Related Fncs:
|
abort_bb, change_state, clear_rollback_ptrs, close_bulletin_board, current_bb, current_delta_state, debug_delta_state, delete_all_delta_states, delete_ds_branch, get_default_stream, initialize_delta_states, open_bulletin_board, release_bb, set_default_stream
|