api_restore_entity_list_with_history
List of: Functions
Subjects: History and Roll, SAT Save and Restore
Contents: Kernel

Action: Restores an entity_list from disk.

Prototype: outcome api_restore_entity_list_with_history (


FILE* file_ptr,
// open file





// descriptor


logical text_mode,
// TRUE if file is





// text, FALSE if





// binary


ENTITY_LIST& entities,
// returns entities





// made


HISTORY_STREAM_LIST& hslist, // returns history





// streams made


DELTA_STATE_LIST& dslist,
// returns delta





// states made


AcisOptions* ao = NULL // acis options


);

Includes: #include "kernel/acis.hxx"

#include "kernel/kernapi/api/api.hxx"

#include "kernel/kernapi/api/kernapi.hxx"

#include "kernel/kerndata/bulletin/bulletin.hxx"

#include "kernel/kerndata/lists/lists.hxx"

#include "baseutil/logical.h"

#include "kernel/kernapi/api/acis_options.hxx"

Description: The file pointer is an open file positioned at the point where this API begins the restore entity. When the restore is complete, the file will be correctly positioned at the end of the save entity. This allows an application to restore multiple entities intermixed with other application specific data in a single save file.


Establish in the calling routine whether the file is text or binary and set text_mode correctly.


Restoring a binary file is about twice as fast as restoring a text file; however, use binary files only when the file is created and read on the same version of the system running on the same type of machine.


When an entity is restored from a file, any unrecognized main entity types (BODY, CURVE, etc.) are skipped and any references to those entities are set to NULL. Unrecognized descendent entities of ATTRIB, SURFACE, or CURVE generate a new record for their immediate owner class and references to them become references to the new record. If a record for a derived class of ATTRIB is not recognized, an ATTRIB record results so that the chain of attributes for the entity owning the unrecognized attribute remains connected.


It is possible to restore entities made by versions having different sets of attribute classes. Attribute types common to the two versions are restored, but attributes of types unknown to the receiving version are ignored.


A warning is given if the version of the product receiving the model differs from the version that made the save file. It is an error if the current product is older than that recorded in the file.


Application data referring to DELTA_STATEs or HISTORY_STREAMs can be restored as in the following pseudo code.


class app_data {


DELTA_STATE* ds;


void save(DELTA_STATE_LIST& dslist) {



write_int(dslist.lookup(ds));


}


void restore(DELTA_STATE_LIST& dslist) {



ds = read_int();


}


void fix_pointers(DELTA_STATE_LIST& dslist) {



if( (int) < 0 ) {




ds = NULL;



} else {




ds = dslist[i];



}


}

};

DELTA_STATE_LIST dslist;

HISTORY_STREAM_LIST hslist;

ENTITY_LIST elist;

api_restore_entity_list_with_history


(file, TRUE, elist, hslist,dslist);


foreach(app_data* ap) {


ap->restore(dslist);

}

foreach(app_data* ap) {


ap->fix_pointers(dslist);

}


A similar procedure can be used when restoring application data that refers to history streams. See api_save_entity_list_with_history for an example of how to save the above app_data

Errors: Warning: Version number of this system differs from version that made the save file being read.



Warning: Record for unrecognized entity is being skipped. Unable to read file. Malformed save file.

Library: kernel

Filename: kern/kernel/kernapi/api/kernapi.hxx

Effect: Changes model
PDF/KERN/16FNA.PDF
HTM/DATA/KERN/KERN/16FNA/0134.HTM