#include <CNCL/ReaderTbl.h>
CN_READERTBL
CNCL
None
None
CNReaderTbl
provides a table of all persistent classes
(Reader-Table
) and a second table of id's ID-Table
. Both
tables are realized as dynamic hash-tables.
The first one uses the classname as key for registering in the table, the object stored in it is the reader function pointer (the adress of the reader-function). This table is for checking if a class is registered to be persistent and for calling the reader constructor when objects are taken from the stream.
The other table uses the id as key and stores the according object to this id. The table is used during two occasions. First whenever an object is written to the stream the id is stored in this table. When the same object should be stored again it will be recognized. In addition to the id a special delimitation character is used for indicating this. When the objects are taken from the stream all objects and their old id are stored in this table again. When this special delimitation character apears on the stream the object can be taken out of the table by its id. Thus it is possible to restore containers even if one object appears several times at different locations, e.g at a double linked list.
Constructors:
CNReaderTbl(char* classname, Reader_ptr reader_ptr);
classname
is
added to the table.
Additional types provided by CNReaderTbl
are:
typedef CNObject*(*Reader_ptr)(CNPstream&);
The functions provided by CNReaderTbl
are:
static Reader_ptr reader_pointer_by_classname(char* classname);
classname
is registered in
the Reader Table and returns the according Reader_ptr. If it is not
registered, a fatal error is yielded.
static bool is_in(long id_key);
id_key
is in the id table.
static void add_to_id_tbl(long id_key, CNObject* obj);
static void add_to_id_tbl(long id_key, CNObject& obj);
obj
to the id table with id_key
as its key.
static CNObject* get_from_id_tbl(long id_key);
id_key
as the key.
static void reset_id_tbl();
write-to-stream
to the
read_from_stream
sequence.
Go to the first, previous, next, last section, table of contents.