GiNaC 1.8.7
Classes | Public Types | Public Member Functions | Private Attributes | Friends | List of all members
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  archive_node_cit_range
 
struct  property
 Archived property (data type, name and associated data) More...
 
struct  property_info
 Information about a stored property. More...
 

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

Private Attributes

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

Friends

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

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 48 of file archive.h.

Member Typedef Documentation

◆ propinfovector

Definition at line 73 of file archive.h.

◆ archive_node_cit

typedef std::vector<property>::const_iterator GiNaC::archive_node::archive_node_cit

Definition at line 84 of file archive.h.

Member Enumeration Documentation

◆ property_type

Property data types.

Enumerator
PTYPE_BOOL 
PTYPE_UNSIGNED 
PTYPE_STRING 
PTYPE_NODE 

Definition at line 55 of file archive.h.

Constructor & Destructor Documentation

◆ archive_node() [1/2]

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

Definition at line 89 of file archive.h.

Referenced by add_ex().

◆ archive_node() [2/2]

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

Recursively construct archive node from expression.

Definition at line 339 of file archive.cpp.

References GiNaC::ex::bp.

Member Function Documentation

◆ operator=()

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

Assignment operator of archive_node.

Definition at line 326 of file archive.cpp.

References 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 395 of file archive.cpp.

References a, GiNaC::archive::atomize(), props, PTYPE_BOOL, and value.

◆ add_unsigned()

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

Add property of type "unsigned int" to node.

Definition at line 400 of file archive.cpp.

References a, GiNaC::archive::atomize(), props, PTYPE_UNSIGNED, and 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 405 of file archive.cpp.

References a, GiNaC::archive::atomize(), props, PTYPE_STRING, and value.

◆ add_ex()

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

Add property of type "ex" to node.

Definition at line 410 of file archive.cpp.

References a, GiNaC::archive::add_node(), archive_node(), GiNaC::archive::atomize(), props, PTYPE_NODE, and value.

Referenced by GiNaC::container< C >::archive().

◆ 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 418 of file archive.cpp.

References a, GiNaC::archive::atomize(), props, and PTYPE_BOOL.

◆ 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 436 of file archive.cpp.

References a, GiNaC::archive::atomize(), props, and PTYPE_UNSIGNED.

◆ 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 454 of file archive.cpp.

References a, GiNaC::archive::atomize(), props, PTYPE_STRING, and GiNaC::archive::unatomize().

Referenced by 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 357 of file archive.cpp.

References a, GiNaC::archive::atomize(), and props.

◆ find_last()

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

Definition at line 367 of file archive.cpp.

References a, GiNaC::archive::atomize(), 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 379 of file archive.cpp.

References a, GiNaC::archive::atomize(), GiNaC::archive_node::archive_node_cit_range::begin, GiNaC::archive_node::archive_node_cit_range::end, and props.

◆ find_ex()

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

Retrieve property of type "ex" from node.

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

Definition at line 477 of file archive.cpp.

References a, GiNaC::archive::atomize(), GiNaC::archive::get_node(), props, PTYPE_NODE, and unarchive().

◆ 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 472 of file archive.cpp.

References a, GiNaC::archive::get_node(), and unarchive().

◆ 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 495 of file archive.cpp.

References a, GiNaC::archive::atomize(), GiNaC::archive::get_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 512 of file archive.cpp.

References a, props, and GiNaC::archive::unatomize().

◆ unarchive()

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

Convert archive node to GiNaC expression.

Definition at line 544 of file archive.cpp.

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

Referenced by find_ex(), and find_ex_by_loc().

◆ 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 349 of file archive.cpp.

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

◆ has_ex()

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

Definition at line 146 of file archive.h.

References has_expression.

◆ get_ex()

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

Definition at line 147 of file archive.h.

References e.

◆ forget()

void GiNaC::archive_node::forget ( )

Delete cached unarchived expressions from node (for debugging).

Definition at line 616 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 664 of file archive.cpp.

References a, GiNaC::ex::bp, e, has_expression, props, PTYPE_BOOL, PTYPE_NODE, PTYPE_STRING, PTYPE_UNSIGNED, and GiNaC::archive::unatomize().

Friends And Related Function Documentation

◆ operator<<

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

Write archive_node to binary data stream.

Definition at line 200 of file archive.cpp.

◆ operator>>

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

Read archive_node from binary data stream.

Definition at line 245 of file archive.cpp.

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 160 of file archive.h.

Referenced by 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 163 of file archive.h.

Referenced by 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.