23#ifndef GINAC_ARCHIVE_H
24#define GINAC_ARCHIVE_H
108 bool find_bool(
const std::string &name,
bool &ret,
unsigned index = 0)
const;
112 bool find_unsigned(
const std::string &name,
unsigned &ret,
unsigned index = 0)
const;
116 bool find_string(
const std::string &name, std::string &ret,
unsigned index = 0)
const;
126 archive_node_cit_range
find_property_range(
const std::string &name1,
const std::string &name2)
const;
130 bool find_ex(
const std::string &name,
ex &ret,
lst &sym_lst,
unsigned index = 0)
const;
150 void printraw(std::ostream &os)
const;
219#define GINAC_DECLARE_UNARCHIVER(classname) \
220class classname ## _unarchiver \
222 static int usecount; \
224 static GiNaC::basic* create(); \
225 classname ## _unarchiver(); \
226 ~ classname ## _unarchiver(); \
228static classname ## _unarchiver classname ## _unarchiver_instance
230#define GINAC_BIND_UNARCHIVER(classname) \
231classname ## _unarchiver::classname ## _unarchiver() \
233 static GiNaC::unarchive_table_t table; \
234 if (usecount++ == 0) { \
235 table.insert(std::string(#classname), \
236 &(classname ## _unarchiver::create)); \
239GiNaC::basic* classname ## _unarchiver::create() \
241 return new classname(); \
243classname ## _unarchiver::~ classname ## _unarchiver() { } \
244int classname ## _unarchiver::usecount = 0
290 ex unarchive_ex(
const lst &sym_lst, std::string &name,
unsigned index = 0)
const;
305 void printraw(std::ostream &os)
const;
329 mutable std::vector<std::string>
atoms;
333 typedef std::map<std::string, archive_atom>::const_iterator
inv_at_cit;
337 mutable std::map<ex, archive_node_id, ex_is_less>
exprtable;
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
void printraw(std::ostream &os) const
Output archive_node to stream in ugly raw format (for debugging).
std::vector< property > props
Vector of stored properties.
property_type
Property data types.
void get_properties(propinfovector &v) const
Return vector of properties stored in node.
bool has_expression
Flag indicating whether a cached unarchived representation of this node exists.
bool find_unsigned(const std::string &name, unsigned &ret, unsigned index=0) const
Retrieve property of type "unsigned" from node.
void add_unsigned(const std::string &name, unsigned value)
Add property of type "unsigned int" to node.
bool find_ex(const std::string &name, ex &ret, lst &sym_lst, unsigned index=0) const
Retrieve property of type "ex" from node.
bool has_same_ex_as(const archive_node &other) const
Check if the archive_node stores the same expression as another archive_node.
void find_ex_by_loc(archive_node_cit loc, ex &ret, lst &sym_lst) const
Retrieve property of type "ex" from the node if it is known that this node in fact contains such a pr...
bool find_bool(const std::string &name, bool &ret, unsigned index=0) const
Retrieve property of type "bool" from node.
void forget()
Delete cached unarchived expressions from node (for debugging).
std::vector< property >::const_iterator archive_node_cit
archive_node(archive &ar)
const archive_node & find_ex_node(const std::string &name, unsigned index=0) const
Retrieve property of type "ex" from node, returning the node of the sub-expression.
friend std::istream & operator>>(std::istream &is, archive_node &ar)
Read archive_node from binary data stream.
std::vector< property_info > propinfovector
bool find_string(const std::string &name, std::string &ret, unsigned index=0) const
Retrieve property of type "string" from node.
void add_ex(const std::string &name, const ex &value)
Add property of type "ex" to node.
void add_bool(const std::string &name, bool value)
Add property of type "bool" to node.
archive_node_cit_range find_property_range(const std::string &name1, const std::string &name2) const
Find a range of locations in the vector of properties.
friend std::ostream & operator<<(std::ostream &os, const archive_node &ar)
Write archive_node to binary data stream.
ex e
The cached unarchived representation of this node (if any).
archive_node_cit find_last(const std::string &name) const
const archive_node & operator=(const archive_node &other)
Assignment operator of archive_node.
archive_node_cit find_first(const std::string &name) const
Find the location in the vector of properties of the first/last property with a given name.
archive & a
Reference to the archive to which this node belongs.
ex unarchive(lst &sym_lst) const
Convert archive node to GiNaC expression.
void add_string(const std::string &name, const std::string &value)
Add property of type "string" to node.
This class holds archived versions of GiNaC expressions (class ex).
friend std::ostream & operator<<(std::ostream &os, const archive &ar)
Write archive to binary data stream.
archive_node_id add_node(const archive_node &n)
Add archive_node to archive if the corresponding expression is not already archived.
archive_atom atomize(const std::string &s) const
Atomize a string (i.e.
archive(const ex &e, const char *n)
Construct archive from expression using the specified name.
void forget()
Delete cached unarchived expressions in all archive_nodes (mainly for debugging).
ex unarchive_ex(const lst &sym_lst, const char *name) const
Retrieve expression from archive by name.
archive(const ex &e)
Construct archive from expression using the default name "ex".
void clear()
Clear all archived expressions.
void archive_ex(const ex &e, const char *name)
Archive an expression.
unsigned num_expressions() const
Return number of archived expressions.
const std::string & unatomize(archive_atom id) const
Unatomize a string (i.e.
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.
std::map< ex, archive_node_id, ex_is_less > exprtable
Map of stored expressions to nodes for faster archiving.
const archive_node & get_top_node(unsigned index=0) const
Return reference to top node of an expression specified by index.
friend std::istream & operator>>(std::istream &is, archive &ar)
Read archive from binary data stream.
std::vector< archive_node > nodes
Vector of archived nodes.
archive_node & get_node(archive_node_id id)
Retrieve archive_node by ID.
void printraw(std::ostream &os) const
Print archive to stream in ugly raw format (for debugging).
std::vector< archived_ex > exprs
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
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
Wrapper template for making GiNaC classes out of STL containers.
Lightweight wrapper for GiNaC's symbolic objects.
void insert(const std::string &classname, synthesize_func f)
synthesize_func find(const std::string &classname) const
static unarchive_map_t * unarch_map
Interface to GiNaC's light-weight expression handles.
unsigned archive_atom
Numerical ID value to refer to a string.
std::ostream & operator<<(std::ostream &os, const archive_node &n)
Write archive_node to binary data stream.
std::map< std::string, synthesize_func > unarchive_map_t
basic *(* synthesize_func)()
unsigned archive_node_id
Numerical ID value to refer to an archive_node.
static unarchive_table_t unarch_table_instance
std::istream & operator>>(std::istream &is, archive_node &n)
Read archive_node from binary data stream.
Archived expression descriptor.
archive_node_id root
ID of root node.
archived_ex(archive_atom n, archive_node_id node)
archive_atom name
Name of expression.
Information about a stored property.
property_info(property_type t, const std::string &n, unsigned c=1)
unsigned count
Number of occurrences.
std::string name
Name of property.
property_type type
Data type of property.
Archived property (data type, name and associated data)
property_type type
Data type of property.
property(archive_atom n, property_type t, unsigned v)
unsigned value
Stored value.
archive_atom name
Name of property.