GiNaC  1.6.2
Classes | Public Member Functions | Private Types | Private Attributes | Friends
GiNaC::archive Class Reference

This class holds archived versions of GiNaC expressions (class ex). More...

#include <archive.h>

List of all members.

Classes

struct  archived_ex
 Archived expression descriptor. More...

Public Member Functions

 archive ()
 ~archive ()
 archive (const ex &e)
 Construct archive from expression using the default name "ex".
 archive (const ex &e, const char *n)
 Construct archive from expression using the specified name.
void archive_ex (const ex &e, const char *name)
 Archive an expression.
ex unarchive_ex (const lst &sym_lst, const char *name) const
 Retrieve expression from archive by name.
ex unarchive_ex (const lst &sym_lst, unsigned index=0) const
 Retrieve expression from archive by index.
ex unarchive_ex (const lst &sym_lst, std::string &name, unsigned index=0) const
 Retrieve expression and its name from archive by index.
unsigned num_expressions () const
 Return number of archived expressions.
const archive_nodeget_top_node (unsigned index=0) const
 Return reference to top node of an expression specified by index.
void clear ()
 Clear all archived expressions.
archive_node_id add_node (const archive_node &n)
 Add archive_node to archive if the corresponding expression is not already archived.
archive_nodeget_node (archive_node_id id)
 Retrieve archive_node by ID.
void forget ()
 Delete cached unarchived expressions in all archive_nodes (mainly for debugging).
void printraw (std::ostream &os) const
 Print archive to stream in ugly raw format (for debugging).
archive_atom atomize (const std::string &s) const
 Atomize a string (i.e.
const std::string & unatomize (archive_atom id) const
 Unatomize a string (i.e.

Private Types

typedef std::map< std::string,
archive_atom >::const_iterator 
inv_at_cit
 The map of from strings to indices of the atoms vectors allows for faster archiving.
typedef std::map< ex,
archive_node_id, ex_is_less >
::iterator 
mapit
 Map of stored expressions to nodes for faster archiving.

Private Attributes

std::vector< archive_nodenodes
 Vector of archived nodes.
std::vector< archived_exexprs
 Vector of archived expression descriptors.
std::vector< std::string > atoms
 Vector of atomized strings (using a vector allows faster unarchiving).
std::map< std::string,
archive_atom
inverse_atoms
std::map< ex, archive_node_id,
ex_is_less
exprtable

Friends

std::ostream & operator<< (std::ostream &os, const archive &ar)
 Write archive to binary data stream.
std::istream & operator>> (std::istream &is, archive &ar)
 Read archive from binary data stream.

Detailed Description

This class holds archived versions of GiNaC expressions (class ex).

An archive can be constructed from an expression and then written to a stream; or it can be read from a stream and then unarchived, yielding back the expression. Archives can hold multiple expressions which can be referred to by name or index number. The main component of the archive class is a vector of archive_nodes which each store one object of class basic (or a derived class).

Definition at line 249 of file archive.h.


Member Typedef Documentation

typedef std::map<std::string, archive_atom>::const_iterator GiNaC::archive::inv_at_cit [private]

The map of from strings to indices of the atoms vectors allows for faster archiving.

Definition at line 328 of file archive.h.

typedef std::map<ex, archive_node_id, ex_is_less>::iterator GiNaC::archive::mapit [private]

Map of stored expressions to nodes for faster archiving.

Definition at line 332 of file archive.h.


Constructor & Destructor Documentation

GiNaC::archive::archive ( ) [inline]

Definition at line 255 of file archive.h.

GiNaC::archive::~archive ( ) [inline]

Definition at line 256 of file archive.h.

GiNaC::archive::archive ( const ex e) [inline]

Construct archive from expression using the default name "ex".

Definition at line 259 of file archive.h.

References archive_ex().

GiNaC::archive::archive ( const ex e,
const char *  n 
) [inline]

Construct archive from expression using the specified name.

Definition at line 262 of file archive.h.

References archive_ex().


Member Function Documentation

void GiNaC::archive::archive_ex ( const ex e,
const char *  name 
)

Archive an expression.

Parameters:
ethe expression to be archived
namename under which the expression is stored

Definition at line 36 of file archive.cpp.

References add_node(), atomize(), and exprs.

Referenced by archive().

ex GiNaC::archive::unarchive_ex ( const lst sym_lst,
const char *  name 
) const

Retrieve expression from archive by name.

Parameters:
sym_lstlist of pre-defined symbols
namename of expression

Definition at line 79 of file archive.cpp.

References atomize(), exprs, and nodes.

ex GiNaC::archive::unarchive_ex ( const lst sym_lst,
unsigned  index = 0 
) const

Retrieve expression from archive by index.

Parameters:
sym_lstlist of pre-defined symbols
indexindex of expression
See also:
count_expressions

Definition at line 98 of file archive.cpp.

References exprs, and nodes.

ex GiNaC::archive::unarchive_ex ( const lst sym_lst,
std::string &  name,
unsigned  index = 0 
) const

Retrieve expression and its name from archive by index.

Parameters:
sym_lstlist of pre-defined symbols
namereceives the name of the expression
indexindex of expression
See also:
count_expressions

Definition at line 108 of file archive.cpp.

References exprs, nodes, and unatomize().

unsigned GiNaC::archive::num_expressions ( ) const

Return number of archived expressions.

Definition at line 121 of file archive.cpp.

References exprs.

const archive_node & GiNaC::archive::get_top_node ( unsigned  index = 0) const

Return reference to top node of an expression specified by index.

Definition at line 126 of file archive.cpp.

References exprs, and nodes.

void GiNaC::archive::clear ( )

Clear all archived expressions.

Definition at line 582 of file archive.cpp.

References atoms, exprs, exprtable, inverse_atoms, and nodes.

archive_node_id GiNaC::archive::add_node ( const archive_node n)

Add archive_node to archive if the corresponding expression is not already archived.

Returns:
ID of archived node

Definition at line 51 of file archive.cpp.

References exprtable, GiNaC::archive_node::get_ex(), GiNaC::archive_node::has_ex(), and nodes.

Referenced by GiNaC::archive_node::add_ex(), and archive_ex().

archive_node & GiNaC::archive::get_node ( archive_node_id  id)
void GiNaC::archive::forget ( )

Delete cached unarchived expressions in all archive_nodes (mainly for debugging).

Definition at line 593 of file archive.cpp.

References GiNaC::archive_node::forget(), and nodes.

void GiNaC::archive::printraw ( std::ostream &  os) const

Print archive to stream in ugly raw format (for debugging).

Definition at line 607 of file archive.cpp.

References atoms, exprs, nodes, and unatomize().

archive_atom GiNaC::archive::atomize ( const std::string &  s) const
const std::string & GiNaC::archive::unatomize ( archive_atom  id) const

Unatomize a string (i.e.

convert the ID number back to the string).

Definition at line 315 of file archive.cpp.

References atoms.

Referenced by GiNaC::archive_node::find_string(), GiNaC::archive_node::get_properties(), GiNaC::archive_node::printraw(), printraw(), and unarchive_ex().


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const archive ar 
) [friend]

Write archive to binary data stream.

Definition at line 214 of file archive.cpp.

std::istream& operator>> ( std::istream &  is,
archive ar 
) [friend]

Read archive from binary data stream.

Definition at line 261 of file archive.cpp.


Member Data Documentation

std::vector<archive_node> GiNaC::archive::nodes [private]

Vector of archived nodes.

Definition at line 304 of file archive.h.

Referenced by add_node(), clear(), forget(), get_node(), get_top_node(), GiNaC::operator<<(), GiNaC::operator>>(), printraw(), and unarchive_ex().

std::vector<archived_ex> GiNaC::archive::exprs [private]

Vector of archived expression descriptors.

Definition at line 316 of file archive.h.

Referenced by archive_ex(), clear(), get_top_node(), num_expressions(), GiNaC::operator<<(), GiNaC::operator>>(), printraw(), and unarchive_ex().

std::vector<std::string> GiNaC::archive::atoms [mutable, private]

Vector of atomized strings (using a vector allows faster unarchiving).

Definition at line 324 of file archive.h.

Referenced by atomize(), clear(), GiNaC::operator<<(), GiNaC::operator>>(), printraw(), and unatomize().

std::map<std::string, archive_atom> GiNaC::archive::inverse_atoms [mutable, private]

Definition at line 329 of file archive.h.

Referenced by atomize(), clear(), and GiNaC::operator>>().

std::map<ex, archive_node_id, ex_is_less> GiNaC::archive::exprtable [mutable, private]

Definition at line 333 of file archive.h.

Referenced by add_node(), and clear().


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

This page is part of the GiNaC developer's reference. It was generated automatically by doxygen. For an introduction, see the tutorial.