Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF > Class Template Reference

Graph serialization and deserialization class. More...

#include <io_graph.H>

Collaboration diagram for Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >:
[legend]

Public Member Functions

void set_verbose (bool v) noexcept
 Enable or disable verbose mode.
 
bool is_verbose () const noexcept
 Check if verbose mode is enabled.
 
void set_load_node (const Load_Node &ln)
 Set the node loading functor.
 
void set_store_node (const Store_Node &sn)
 Set the node storage functor.
 
void set_load_arc (const Load_Arc &la)
 Set the arc loading functor.
 
void set_store_arc (const Store_Arc &sa)
 Set the arc storage functor.
 
void set_node_filter (const NF &nf)
 Set the node filter for save operations.
 
void set_arc_filter (const AF &af)
 Set the arc filter for save operations.
 
 IO_Graph (GT &__g) noexcept
 Construct from graph reference.
 
 IO_Graph (GT *gptr) noexcept
 Construct from graph pointer.
 
void save (std::ofstream &output)
 Save graph to binary stream.
 
void load (std::ifstream &input)
 Load graph from binary stream.
 
void save_in_text_mode (std::ostream &output)
 Save graph to text stream.
 
void load_in_text_mode (std::istream &input)
 Load graph from text stream.
 

Private Attributes

GTg
 
Load_Node load_node = Load_Node()
 
Store_Node store_node = Store_Node()
 
Load_Arc load_arc = Load_Arc()
 
Store_Arc store_arc = Store_Arc()
 
NF node_filter = NF()
 
AF arc_filter = AF()
 
bool verbose_mode = false
 

Detailed Description

template<class GT, class Load_Node = Dft_Load_Node<GT>, class Store_Node = Dft_Store_Node<GT>, class Load_Arc = Dft_Load_Arc<GT>, class Store_Arc = Dft_Store_Arc<GT>, class NF = Aleph::Dft_Show_Node<GT>, class AF = Aleph::Dft_Show_Arc<GT>>
class Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >

Graph serialization and deserialization class.

IO_Graph provides methods for saving and loading graphs to/from binary and text streams. The serialization format is customizable through template parameters for node/arc load and store functors.

Template Parameters
GTGraph type (List_Graph, List_Digraph, etc.)
Load_NodeFunctor for loading node data. Must provide:
Store_NodeFunctor for storing node data. Must provide:
Load_ArcFunctor for loading arc data. Must provide:
Store_ArcFunctor for storing arc data. Must provide:
NFNode filter functor (only nodes passing filter are saved)
AFArc filter functor (only arcs passing filter are saved)
See also
Dft_Store_Node Default node storage implementation
Dft_Store_Arc Default arc storage implementation
Dft_Load_Node Default node loading implementation
Dft_Load_Arc Default arc loading implementation
Filter_Iterator For filter functor requirements

Definition at line 318 of file io_graph.H.

Constructor & Destructor Documentation

◆ IO_Graph() [1/2]

template<class GT , class Load_Node = Dft_Load_Node<GT>, class Store_Node = Dft_Store_Node<GT>, class Load_Arc = Dft_Load_Arc<GT>, class Store_Arc = Dft_Store_Arc<GT>, class NF = Aleph::Dft_Show_Node<GT>, class AF = Aleph::Dft_Show_Arc<GT>>
Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::IO_Graph ( GT __g)
inlineexplicitnoexcept

Construct from graph reference.

Parameters
__gReference to the graph to save/load

Definition at line 381 of file io_graph.H.

◆ IO_Graph() [2/2]

template<class GT , class Load_Node = Dft_Load_Node<GT>, class Store_Node = Dft_Store_Node<GT>, class Load_Arc = Dft_Load_Arc<GT>, class Store_Arc = Dft_Store_Arc<GT>, class NF = Aleph::Dft_Show_Node<GT>, class AF = Aleph::Dft_Show_Arc<GT>>
Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::IO_Graph ( GT gptr)
inlineexplicitnoexcept

Construct from graph pointer.

Parameters
gptrPointer to the graph to save/load

Definition at line 386 of file io_graph.H.

Member Function Documentation

◆ is_verbose()

template<class GT , class Load_Node = Dft_Load_Node<GT>, class Store_Node = Dft_Store_Node<GT>, class Load_Arc = Dft_Load_Arc<GT>, class Store_Arc = Dft_Store_Arc<GT>, class NF = Aleph::Dft_Show_Node<GT>, class AF = Aleph::Dft_Show_Arc<GT>>
bool Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::is_verbose ( ) const
inlinenoexcept

Check if verbose mode is enabled.

Returns
True if verbose mode is enabled

Definition at line 346 of file io_graph.H.

References Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::verbose_mode.

◆ load()

template<class GT , class Load_Node = Dft_Load_Node<GT>, class Store_Node = Dft_Store_Node<GT>, class Load_Arc = Dft_Load_Arc<GT>, class Store_Arc = Dft_Store_Arc<GT>, class NF = Aleph::Dft_Show_Node<GT>, class AF = Aleph::Dft_Show_Arc<GT>>
void Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::load ( std::ifstream &  input)
inline

Load graph from binary stream.

Reads a graph from binary format. The graph is cleared and rebuilt with the loaded nodes and arcs.

Parameters
inputBinary input stream (must be opened with std::ios::binary)
Exceptions
std::runtime_errorIf read operations fail or stream is corrupted
Note
The target graph should be empty before loading.

Definition at line 469 of file io_graph.H.

References ah_runtime_error_if, Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::g, Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::load_arc, Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::load_node, Aleph::maps(), num_nodes, and Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::verbose_mode.

◆ load_in_text_mode()

template<class GT , class Load_Node = Dft_Load_Node<GT>, class Store_Node = Dft_Store_Node<GT>, class Load_Arc = Dft_Load_Arc<GT>, class Store_Arc = Dft_Store_Arc<GT>, class NF = Aleph::Dft_Show_Node<GT>, class AF = Aleph::Dft_Show_Arc<GT>>
void Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::load_in_text_mode ( std::istream &  input)
inline

Load graph from text stream.

Reads a graph from text format. The graph is cleared and rebuilt with the loaded nodes and arcs.

Parameters
inputText input stream
Exceptions
std::runtime_errorIf read operations fail or stream is corrupted
Note
The target graph should be empty before loading.

Definition at line 623 of file io_graph.H.

References ah_runtime_error_if, Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::g, Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::load_arc, Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::load_node, Aleph::maps(), num_nodes, and Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::verbose_mode.

◆ save()

template<class GT , class Load_Node = Dft_Load_Node<GT>, class Store_Node = Dft_Store_Node<GT>, class Load_Arc = Dft_Load_Arc<GT>, class Store_Arc = Dft_Store_Arc<GT>, class NF = Aleph::Dft_Show_Node<GT>, class AF = Aleph::Dft_Show_Arc<GT>>
void Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::save ( std::ofstream &  output)
inline

◆ save_in_text_mode()

template<class GT , class Load_Node = Dft_Load_Node<GT>, class Store_Node = Dft_Store_Node<GT>, class Load_Arc = Dft_Load_Arc<GT>, class Store_Arc = Dft_Store_Arc<GT>, class NF = Aleph::Dft_Show_Node<GT>, class AF = Aleph::Dft_Show_Arc<GT>>
void Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::save_in_text_mode ( std::ostream &  output)
inline

◆ set_arc_filter()

template<class GT , class Load_Node = Dft_Load_Node<GT>, class Store_Node = Dft_Store_Node<GT>, class Load_Arc = Dft_Load_Arc<GT>, class Store_Arc = Dft_Store_Arc<GT>, class NF = Aleph::Dft_Show_Node<GT>, class AF = Aleph::Dft_Show_Arc<GT>>
void Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::set_arc_filter ( const AF af)
inline

Set the arc filter for save operations.

Parameters
afArc filter functor (arcs passing filter are saved)

Definition at line 376 of file io_graph.H.

References Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::arc_filter, and Aleph::maps().

◆ set_load_arc()

template<class GT , class Load_Node = Dft_Load_Node<GT>, class Store_Node = Dft_Store_Node<GT>, class Load_Arc = Dft_Load_Arc<GT>, class Store_Arc = Dft_Store_Arc<GT>, class NF = Aleph::Dft_Show_Node<GT>, class AF = Aleph::Dft_Show_Arc<GT>>
void Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::set_load_arc ( const Load_Arc la)
inline

Set the arc loading functor.

Parameters
laArc loading functor to use

Definition at line 361 of file io_graph.H.

References Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::load_arc, and Aleph::maps().

◆ set_load_node()

template<class GT , class Load_Node = Dft_Load_Node<GT>, class Store_Node = Dft_Store_Node<GT>, class Load_Arc = Dft_Load_Arc<GT>, class Store_Arc = Dft_Store_Arc<GT>, class NF = Aleph::Dft_Show_Node<GT>, class AF = Aleph::Dft_Show_Arc<GT>>
void Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::set_load_node ( const Load_Node ln)
inline

Set the node loading functor.

Parameters
lnNode loading functor to use

Definition at line 351 of file io_graph.H.

References Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::load_node, and Aleph::maps().

◆ set_node_filter()

template<class GT , class Load_Node = Dft_Load_Node<GT>, class Store_Node = Dft_Store_Node<GT>, class Load_Arc = Dft_Load_Arc<GT>, class Store_Arc = Dft_Store_Arc<GT>, class NF = Aleph::Dft_Show_Node<GT>, class AF = Aleph::Dft_Show_Arc<GT>>
void Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::set_node_filter ( const NF nf)
inline

Set the node filter for save operations.

Parameters
nfNode filter functor (nodes passing filter are saved)

Definition at line 371 of file io_graph.H.

References Aleph::maps(), and Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::node_filter.

◆ set_store_arc()

template<class GT , class Load_Node = Dft_Load_Node<GT>, class Store_Node = Dft_Store_Node<GT>, class Load_Arc = Dft_Load_Arc<GT>, class Store_Arc = Dft_Store_Arc<GT>, class NF = Aleph::Dft_Show_Node<GT>, class AF = Aleph::Dft_Show_Arc<GT>>
void Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::set_store_arc ( const Store_Arc sa)
inline

Set the arc storage functor.

Parameters
saArc storage functor to use

Definition at line 366 of file io_graph.H.

References Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::store_arc.

◆ set_store_node()

template<class GT , class Load_Node = Dft_Load_Node<GT>, class Store_Node = Dft_Store_Node<GT>, class Load_Arc = Dft_Load_Arc<GT>, class Store_Arc = Dft_Store_Arc<GT>, class NF = Aleph::Dft_Show_Node<GT>, class AF = Aleph::Dft_Show_Arc<GT>>
void Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::set_store_node ( const Store_Node sn)
inline

Set the node storage functor.

Parameters
snNode storage functor to use

Definition at line 356 of file io_graph.H.

References Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::store_node.

◆ set_verbose()

template<class GT , class Load_Node = Dft_Load_Node<GT>, class Store_Node = Dft_Store_Node<GT>, class Load_Arc = Dft_Load_Arc<GT>, class Store_Arc = Dft_Store_Arc<GT>, class NF = Aleph::Dft_Show_Node<GT>, class AF = Aleph::Dft_Show_Arc<GT>>
void Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::set_verbose ( bool  v)
inlinenoexcept

Enable or disable verbose mode.

When enabled, progress information is printed to std::cout during save and load operations.

Parameters
vTrue to enable verbose output, false to disable

Definition at line 341 of file io_graph.H.

References Aleph::IO_Graph< GT, Load_Node, Store_Node, Load_Arc, Store_Arc, NF, AF >::verbose_mode.

Member Data Documentation

◆ arc_filter

◆ g

◆ load_arc

◆ load_node

◆ node_filter

◆ store_arc

◆ store_node

◆ verbose_mode


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