| GiNaC 1.8.9
    | 
Archiving of GiNaC expressions. More...
Go to the source code of this file.
| Classes | |
| class | GiNaC::archive_node | 
| This class stores all properties needed to record/retrieve the state of one object of class basic (or a derived class).  More... | |
| struct | GiNaC::archive_node::property_info | 
| Information about a stored property.  More... | |
| struct | GiNaC::archive_node::property | 
| Archived property (data type, name and associated data)  More... | |
| struct | GiNaC::archive_node::archive_node_cit_range | 
| class | GiNaC::unarchive_table_t | 
| class | GiNaC::archive | 
| This class holds archived versions of GiNaC expressions (class ex).  More... | |
| struct | GiNaC::archive::archived_ex | 
| Archived expression descriptor.  More... | |
| Namespaces | |
| namespace | GiNaC | 
| Macros | |
| #define | GINAC_DECLARE_UNARCHIVER(classname) | 
| Helper macros to register a class with (un)archiving (a.k.a. | |
| #define | GINAC_BIND_UNARCHIVER(classname) | 
| Typedefs | |
| typedef unsigned | GiNaC::archive_node_id | 
| Numerical ID value to refer to an archive_node. | |
| typedef unsigned | GiNaC::archive_atom | 
| Numerical ID value to refer to a string. | |
| typedef basic *(* | GiNaC::synthesize_func) () | 
| typedef std::map< std::string, synthesize_func > | GiNaC::unarchive_map_t | 
| Functions | |
| std::ostream & | GiNaC::operator<< (std::ostream &os, const archive &ar) | 
| Write archive to binary data stream. | |
| std::istream & | GiNaC::operator>> (std::istream &is, archive &ar) | 
| Read archive from binary data stream. | |
| Variables | |
| static unarchive_table_t | GiNaC::unarch_table_instance | 
| #define GINAC_DECLARE_UNARCHIVER | ( | classname | ) | 
Helper macros to register a class with (un)archiving (a.k.a.
(de)serialization).
Usage: put
GINAC_DECLARE_UNARCHIVER(myclass);
into the header file (in the global or namespace scope), and
GINAC_BIND_UNARCHIVER(myclass);
into the source file.
Effect: the ‘myclass’ (being a class derived directly or indirectly from GiNaC::basic) can be archived and unarchived.
Note: you need to use GINAC_{DECLARE,BIND}_UNARCHIVER incantations in order to make your class (un)archivable even if your class does not overload ‘read_archive’ method. Sorry for inconvenience.
How it works:
The ‘basic’ class has a ‘read_archive’ virtual method which reads an expression from archive. Derived classes can overload that method. There's a small problem, though. On unarchiving all we have is a set of named byte streams. In C++ the class name (as written in the source code) has nothing to do with its actual type. Thus, we need establish a correspondence ourselves. To do so we maintain a ‘class_name’ => ‘function_pointer’ table (see the unarchive_table_t class above). Every function in this table is supposed to create a new object of the ‘class_name’ type. The ‘archive_node’ class uses that table to construct an object of correct type. Next it invokes read_archive virtual method of newly created object, which does the actual job.
Note: this approach is very simple-minded (it does not handle classes with same names from different namespaces, multiple inheritance, etc), but it happens to work surprisingly well.
| #define GINAC_BIND_UNARCHIVER | ( | classname | ) |