GiNaC 1.8.10
GiNaC::archive_node Class Reference

This class stores all properties needed to record/retrieve the state of one object of class basic (or a derived class). More...

#include <archive.h>

Classes

struct  property_info
 Information about a stored property. More...
struct  property
 Archived property (data type, name and associated data). More...
struct  archive_node_cit_range

Public Types

enum  property_type { PTYPE_BOOL , PTYPE_UNSIGNED , PTYPE_STRING , PTYPE_NODE }
 Property data types. More...
typedef std::vector< property_infopropinfovector
typedef std::vector< property >::const_iterator archive_node_cit

Public Member Functions

 archive_node (archive &ar)
 archive_node (archive &ar, const ex &expr)
 Recursively construct archive node from expression.
const archive_nodeoperator= (const archive_node &other)
 Assignment operator of archive_node.
void add_bool (const std::string &name, bool value)
 Add property of type "bool" to node.
void add_unsigned (const std::string &name, unsigned value)
 Add property of type "unsigned int" to node.
void add_string (const std::string &name, const std::string &value)
 Add property of type "string" to node.
void add_ex (const std::string &name, const ex &value)
 Add property of type "ex" to node.
bool find_bool (const std::string &name, bool &ret, unsigned index=0) const
 Retrieve property of type "bool" from node.
bool find_unsigned (const std::string &name, unsigned &ret, unsigned index=0) const
 Retrieve property of type "unsigned" from node.
bool find_string (const std::string &name, std::string &ret, unsigned index=0) const
 Retrieve property of type "string" from 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_node_cit find_last (const std::string &name) const
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.
bool find_ex (const std::string &name, ex &ret, lst &sym_lst, unsigned index=0) const
 Retrieve property of type "ex" from 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 property at the given location.
const archive_nodefind_ex_node (const std::string &name, unsigned index=0) const
 Retrieve property of type "ex" from node, returning the node of the sub-expression.
void get_properties (propinfovector &v) const
 Return vector of properties stored in node.
ex unarchive (lst &sym_lst) const
 Convert archive node to GiNaC expression.
bool has_same_ex_as (const archive_node &other) const
 Check if the archive_node stores the same expression as another archive_node.
bool has_ex () const
ex get_ex () const
void forget ()
 Delete cached unarchived expressions from node (for debugging).
void printraw (std::ostream &os) const
 Output archive_node to stream in ugly raw format (for debugging).

Private Attributes

archivea
 Reference to the archive to which this node belongs.
std::vector< propertyprops
 Vector of stored properties.
bool has_expression
 Flag indicating whether a cached unarchived representation of this node exists.
ex e
 The cached unarchived representation of this node (if any).

Friends

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

Detailed Description

This class stores all properties needed to record/retrieve the state of one object of class basic (or a derived class).

Each property is addressed by its name and data type.

Definition at line 47 of file archive.h.

Member Typedef Documentation

◆ propinfovector

Definition at line 72 of file archive.h.

◆ archive_node_cit

Definition at line 83 of file archive.h.

Member Enumeration Documentation

◆ property_type

Property data types.

Enumerator
PTYPE_BOOL 
PTYPE_UNSIGNED 
PTYPE_STRING 
PTYPE_NODE 

Definition at line 54 of file archive.h.

Constructor & Destructor Documentation

◆ archive_node() [1/2]

GiNaC::archive_node::archive_node ( archive & ar)
inline

Definition at line 88 of file archive.h.

References a, and has_expression.

Referenced by add_ex(), find_ex_node(), has_same_ex_as(), operator<<, operator=(), and operator>>.

◆ archive_node() [2/2]

GiNaC::archive_node::archive_node ( archive & ar,
const ex & expr )

Recursively construct archive node from expression.

Definition at line 337 of file archive.cpp.

References a, GiNaC::ex::bp, e, and has_expression.

Member Function Documentation

◆ operator=()

const archive_node & GiNaC::archive_node::operator= ( const archive_node & other)

Assignment operator of archive_node.

Definition at line 324 of file archive.cpp.

References archive_node(), e, has_expression, and props.

◆ add_bool()

void GiNaC::archive_node::add_bool ( const std::string & name,
bool value )

Add property of type "bool" to node.

Definition at line 393 of file archive.cpp.

References a, props, and PTYPE_BOOL.

Referenced by GiNaC::minkmetric::archive(), GiNaC::spinidx::archive(), GiNaC::tensepsilon::archive(), and GiNaC::varidx::archive().

◆ add_unsigned()

void GiNaC::archive_node::add_unsigned ( const std::string & name,
unsigned value )

◆ add_string()

void GiNaC::archive_node::add_string ( const std::string & name,
const std::string & value )

Add property of type "string" to node.

Definition at line 403 of file archive.cpp.

References a, props, and PTYPE_STRING.

Referenced by GiNaC::basic::archive(), GiNaC::constant::archive(), GiNaC::function::archive(), GiNaC::numeric::archive(), and GiNaC::symbol::archive().

◆ add_ex()

◆ find_bool()

bool GiNaC::archive_node::find_bool ( const std::string & name,
bool & ret,
unsigned index = 0 ) const

Retrieve property of type "bool" from node.

Returns
"true" if property was found, "false" otherwise

Definition at line 416 of file archive.cpp.

References a, props, and PTYPE_BOOL.

Referenced by GiNaC::minkmetric::read_archive(), GiNaC::spinidx::read_archive(), GiNaC::tensepsilon::read_archive(), and GiNaC::varidx::read_archive().

◆ find_unsigned()

bool GiNaC::archive_node::find_unsigned ( const std::string & name,
unsigned & ret,
unsigned index = 0 ) const

Retrieve property of type "unsigned" from node.

Returns
"true" if property was found, "false" otherwise

Definition at line 434 of file archive.cpp.

References a, props, and PTYPE_UNSIGNED.

Referenced by GiNaC::clifford::read_archive(), GiNaC::color::read_archive(), GiNaC::fderivative::read_archive(), GiNaC::indexed::read_archive(), GiNaC::matrix::read_archive(), GiNaC::relational::read_archive(), GiNaC::symmetry::read_archive(), and GiNaC::wildcard::read_archive().

◆ find_string()

bool GiNaC::archive_node::find_string ( const std::string & name,
std::string & ret,
unsigned index = 0 ) const

Retrieve property of type "string" from node.

Returns
"true" if property was found, "false" otherwise

Definition at line 452 of file archive.cpp.

References a, props, and PTYPE_STRING.

Referenced by GiNaC::constant::read_archive(), GiNaC::function::read_archive(), GiNaC::numeric::read_archive(), GiNaC::symbol::read_archive(), and unarchive().

◆ find_first()

archive_node::archive_node_cit GiNaC::archive_node::find_first ( const std::string & name) const

Find the location in the vector of properties of the first/last property with a given name.

Definition at line 355 of file archive.cpp.

References a, and props.

◆ find_last()

archive_node::archive_node_cit GiNaC::archive_node::find_last ( const std::string & name) const

Definition at line 365 of file archive.cpp.

References a, and props.

◆ find_property_range()

archive_node::archive_node_cit_range GiNaC::archive_node::find_property_range ( const std::string & name1,
const std::string & name2 ) const

Find a range of locations in the vector of properties.

The result begins at the first property with name1 and ends one past the last property with name2.

Definition at line 377 of file archive.cpp.

References a, GiNaC::archive_node::archive_node_cit_range::begin, GiNaC::archive_node::archive_node_cit_range::end, and props.

Referenced by GiNaC::container< std::vector >::read_archive(), GiNaC::expairseq::read_archive(), GiNaC::matrix::read_archive(), and GiNaC::pseries::read_archive().

◆ find_ex()

bool GiNaC::archive_node::find_ex ( const std::string & name,
ex & ret,
lst & sym_lst,
unsigned index = 0 ) const

◆ find_ex_by_loc()

void GiNaC::archive_node::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 property at the given location.

This is much more efficient than the preceding function.

Definition at line 470 of file archive.cpp.

References a.

Referenced by GiNaC::container< std::vector >::read_archive(), GiNaC::expairseq::read_archive(), GiNaC::matrix::read_archive(), and GiNaC::pseries::read_archive().

◆ find_ex_node()

const archive_node & GiNaC::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.

Definition at line 493 of file archive.cpp.

References a, archive_node(), props, and PTYPE_NODE.

◆ get_properties()

void GiNaC::archive_node::get_properties ( propinfovector & v) const

Return vector of properties stored in node.

Definition at line 510 of file archive.cpp.

References a, and props.

◆ unarchive()

ex GiNaC::archive_node::unarchive ( lst & sym_lst) const

Convert archive node to GiNaC expression.

Definition at line 542 of file archive.cpp.

References GiNaC::status_flags::dynallocated, e, GiNaC::find_factory_fcn(), find_string(), and has_expression.

◆ has_same_ex_as()

bool GiNaC::archive_node::has_same_ex_as ( const archive_node & other) const

Check if the archive_node stores the same expression as another archive_node.

Returns
"true" if expressions are the same

Definition at line 347 of file archive.cpp.

References archive_node(), GiNaC::ex::bp, e, and has_expression.

◆ has_ex()

bool GiNaC::archive_node::has_ex ( ) const
inline

Definition at line 145 of file archive.h.

References has_expression.

Referenced by GiNaC::archive::add_node().

◆ get_ex()

ex GiNaC::archive_node::get_ex ( ) const
inline

Definition at line 146 of file archive.h.

References e.

Referenced by GiNaC::archive::add_node().

◆ forget()

void GiNaC::archive_node::forget ( )

Delete cached unarchived expressions from node (for debugging).

Definition at line 614 of file archive.cpp.

References e, and has_expression.

Referenced by GiNaC::archive::forget().

◆ printraw()

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

Output archive_node to stream in ugly raw format (for debugging).

Definition at line 662 of file archive.cpp.

References a, e, has_expression, props, PTYPE_BOOL, PTYPE_NODE, PTYPE_STRING, and PTYPE_UNSIGNED.

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const archive_node & ar )
friend

Write archive_node to binary data stream.

Definition at line 198 of file archive.cpp.

References archive_node(), props, and GiNaC::write_unsigned().

◆ operator>>

std::istream & operator>> ( std::istream & is,
archive_node & ar )
friend

Read archive_node from binary data stream.

Definition at line 243 of file archive.cpp.

References archive_node(), props, and GiNaC::read_unsigned().

Member Data Documentation

◆ a

archive& GiNaC::archive_node::a
private

◆ props

std::vector<property> GiNaC::archive_node::props
private

◆ has_expression

bool GiNaC::archive_node::has_expression
mutableprivate

Flag indicating whether a cached unarchived representation of this node exists.

Definition at line 159 of file archive.h.

Referenced by archive_node(), archive_node(), forget(), has_ex(), has_same_ex_as(), operator=(), printraw(), and unarchive().

◆ e

ex GiNaC::archive_node::e
mutableprivate

The cached unarchived representation of this node (if any).

Definition at line 162 of file archive.h.

Referenced by archive_node(), forget(), get_ex(), has_same_ex_as(), operator=(), printraw(), and unarchive().


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.