Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer > Class Template Reference

Class that writes and reads a graph (in a very elementary way) as XML. More...

#include <xml_graph.H>

Collaboration diagram for Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >:
[legend]

Public Member Functions

 Xml_Graph (Node_Reader &_node_reader, Arc_Reader &_arc_reader, Node_Writer &_node_writer, Arc_Writer &_arc_writer)
 Build a reader/writer that shares the caller's functors.
 
 Xml_Graph (Node_Reader &&_node_reader=Node_Reader(), Arc_Reader &&_arc_reader=Arc_Reader(), Node_Writer &&_node_writer=Node_Writer(), Arc_Writer &&_arc_writer=Arc_Writer())
 Build a reader/writer that owns its functors.
 
 Xml_Graph (const Xml_Graph &other)
 Copy constructor.
 
const std::string & get_graph_name () const
 
void set_graph_name (const std::string &_graph_name)
 
const std::string & get_node_name () const
 
void set_node_name (const std::string &_node_name)
 
const std::string & get_arc_name () const
 
void set_arc_name (const std::string &_arc_name)
 
GT operator() (const std::string &file_name)
 
void operator() (GT &g, const std::string &file_name)
 

Static Public Member Functions

template<class F >
static std::optional< F > copy_own (const std::optional< F > &src)
 Copy an other reader/writer whose functor may not be copy-constructible.
 

Private Member Functions

GT read_graph (xmlpp::TextReader &reader)
 
GT read (const std::string &file_name)
 
void write_graph (GT &g, xmlpp::Document &doc)
 
void write (GT &g, const std::string &file_name)
 

Private Attributes

std::string graph_name
 
std::string node_name
 
std::string arc_name
 
std::optional< Node_Reader > own_node_reader
 
std::optional< Arc_Reader > own_arc_reader
 
std::optional< Node_Writer > own_node_writer
 
std::optional< Arc_Writer > own_arc_writer
 
Node_Reader & node_reader
 
Arc_Reader & arc_reader
 
Node_Writer & node_writer
 
Arc_Writer & arc_writer
 

Detailed Description

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
class Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >

Class that writes and reads a graph (in a very elementary way) as XML.

Parameters
GTthe graph type.
Node_Readerthe function that reads a node's attributes.
Arc_Readerthe function that reads an arc's attributes.
Node_Writerthe function that writes a node's attributes.
Arc_Writerthe function that writes an arc's attributes.
Author
Alejandro J. Mujica

Definition at line 125 of file xml_graph.H.

Constructor & Destructor Documentation

◆ Xml_Graph() [1/3]

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::Xml_Graph ( Node_Reader &  _node_reader,
Arc_Reader &  _arc_reader,
Node_Writer &  _node_writer,
Arc_Writer &  _arc_writer 
)
inline

Build a reader/writer that shares the caller's functors.

The functors are neither copied nor owned: they must outlive this object, and any state they accumulate is visible to the caller.

Parameters
[in]_node_readerreads the attributes of a node
[in]_arc_readerreads the attributes of an arc
[in]_node_writerwrites the attributes of a node
[in]_arc_writerwrites the attributes of an arc

Definition at line 298 of file xml_graph.H.

◆ Xml_Graph() [2/3]

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::Xml_Graph ( Node_Reader &&  _node_reader = Node_Reader(),
Arc_Reader &&  _arc_reader = Arc_Reader(),
Node_Writer &&  _node_writer = Node_Writer(),
Arc_Writer &&  _arc_writer = Arc_Writer() 
)
inline

Build a reader/writer that owns its functors.

The functors (by default, the Dft_* ones) are moved into this object. Before, only a reference to these temporaries was kept, and it dangled as soon as the constructor returned.

Parameters
[in]_node_readerreads the attributes of a node
[in]_arc_readerreads the attributes of an arc
[in]_node_writerwrites the attributes of a node
[in]_arc_writerwrites the attributes of an arc

Definition at line 318 of file xml_graph.H.

◆ Xml_Graph() [3/3]

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::Xml_Graph ( const Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer > &  other)
inline

Copy constructor.

Owned functors are copied, so the copy does not refer to other's; shared functors stay shared with the caller. A functor type that is movable but not copy-constructible is only a problem if other actually owns it (see copy_own); merely being of such a type does not stop other from being copied while it shares its functors.

Parameters
[in]otherreader/writer to copy
Exceptions
std::runtime_errorsee copy_own

Definition at line 370 of file xml_graph.H.

Member Function Documentation

◆ copy_own()

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
template<class F >
static std::optional< F > Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::copy_own ( const std::optional< F > &  src)
inlinestatic

Copy an other reader/writer whose functor may not be copy-constructible.

Template Parameters
Fthe functor's own type (Node_Reader, ...).
Parameters
[in]srcthe corresponding own_* member of other.
Returns
a copy of src, if F is copy-constructible.
Exceptions
std::runtime_errorif F is not copy-constructible and src holds a value (a copyable other can still always be shared, even if it owns a non-copy-constructible functor: only copying such an owned functor is impossible).

Definition at line 345 of file xml_graph.H.

References ah_runtime_error_if.

◆ get_arc_name()

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
const std::string & Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::get_arc_name ( ) const
inline

◆ get_graph_name()

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
const std::string & Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::get_graph_name ( ) const
inline

◆ get_node_name()

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
const std::string & Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::get_node_name ( ) const
inline

◆ operator()() [1/2]

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
GT Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::operator() ( const std::string &  file_name)
inline

◆ operator()() [2/2]

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
void Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::operator() ( GT &  g,
const std::string &  file_name 
)
inline

◆ read()

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
GT Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::read ( const std::string &  file_name)
inlineprivate

◆ read_graph()

◆ set_arc_name()

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
void Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::set_arc_name ( const std::string &  _arc_name)
inline

◆ set_graph_name()

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
void Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::set_graph_name ( const std::string &  _graph_name)
inline

◆ set_node_name()

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
void Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::set_node_name ( const std::string &  _node_name)
inline

◆ write()

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
void Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::write ( GT &  g,
const std::string &  file_name 
)
inlineprivate

◆ write_graph()

Member Data Documentation

◆ arc_name

◆ arc_reader

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
Arc_Reader& Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::arc_reader
private

◆ arc_writer

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
Arc_Writer& Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::arc_writer
private

◆ graph_name

◆ node_name

◆ node_reader

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
Node_Reader& Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::node_reader
private

◆ node_writer

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
Node_Writer& Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::node_writer
private

◆ own_arc_reader

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
std::optional<Arc_Reader> Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::own_arc_reader
private

Definition at line 137 of file xml_graph.H.

◆ own_arc_writer

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
std::optional<Arc_Writer> Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::own_arc_writer
private

Definition at line 139 of file xml_graph.H.

◆ own_node_reader

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
std::optional<Node_Reader> Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::own_node_reader
private

Definition at line 136 of file xml_graph.H.

◆ own_node_writer

template<AlephGraph GT, class Node_Reader = Dft_Node_Reader<GT>, class Arc_Reader = Dft_Arc_Reader<GT>, class Node_Writer = Dft_Node_Writer<GT>, class Arc_Writer = Dft_Arc_Writer<GT>>
std::optional<Node_Writer> Aleph::Xml_Graph< GT, Node_Reader, Arc_Reader, Node_Writer, Arc_Writer >::own_node_writer
private

Definition at line 138 of file xml_graph.H.


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