Vcsn  2.3a
Be Rational
vcsn::rat::dot_printer< ExpSet > Class Template Reference

Pretty-printer for rational expressions. More...

#include <dot.hh>

Inheritance diagram for vcsn::rat::dot_printer< ExpSet >:
Collaboration diagram for vcsn::rat::dot_printer< ExpSet >:

Classes

struct  visit_tuple
 

Public Types

using expressionset_t = ExpSet
 
using super_t = typename expressionset_t::const_visitor
 
using self_t = dot_printer
 
using context_t = context_t_of< expressionset_t >
 
using identities_t = typename expressionset_t::identities_t
 
using labelset_t = labelset_t_of< context_t >
 
using label_t = label_t_of< context_t >
 
using weight_t = weight_t_of< context_t >
 
using node_t = typename super_t::node_t
 Actual node, without indirection. More...
 
using value_t = typename node_t::value_t
 A shared_ptr to node_t. More...
 
template<type_t Type>
using constant_t = typename super_t::template constant_t< Type >
 
template<type_t Type>
using unary_t = typename super_t::template unary_t< Type >
 
template<type_t Type>
using variadic_t = typename super_t::template variadic_t< Type >
 

Public Member Functions

 dot_printer (const expressionset_t &rs, std::ostream &out, bool physical=false)
 A printer. More...
 
template<typename OtherExpSet >
 dot_printer (const expressionset_t &rs, dot_printer< OtherExpSet > &other)
 Construct from another dot_printer. More...
 
void format (format fmt)
 Set output format. More...
 
std::ostream & operator() (const value_t &v)
 Entry point: print v as a complete Dot graph. More...
 

Static Public Member Functions

static constexpr const charme ()
 Name of this algorithm, for error messages. More...
 

Private Types

using name_t = unsigned
 A type to label the node. More...
 
using tuple_t = typename super_t::tuple_t
 
using names_t = std::unordered_map< const void *, name_t >
 If physical_ is enabled, register the identifiers of the nodes. More...
 

Private Member Functions

name_t print_ (const value_t &v)
 Easy recursion: print an expression and return its ID. More...
 
name_t print_ (const node_t &v)
 Easy recursion: print an expression and return its ID. More...
 
 VCSN_RAT_VISIT (add, v)
 
 VCSN_RAT_VISIT (atom, v)
 
 VCSN_RAT_VISIT (complement, v)
 
 VCSN_RAT_VISIT (compose, v)
 
 VCSN_RAT_VISIT (conjunction, v)
 
 VCSN_RAT_VISIT (infiltrate, v)
 
 VCSN_RAT_VISIT (ldivide, v)
 
 VCSN_RAT_VISIT (lweight, v)
 
 VCSN_RAT_VISIT (mul, v)
 
 VCSN_RAT_VISIT (one, v)
 
 VCSN_RAT_VISIT (rweight, v)
 
 VCSN_RAT_VISIT (shuffle, v)
 
 VCSN_RAT_VISIT (star, v)
 
 VCSN_RAT_VISIT (transposition, v)
 
 VCSN_RAT_VISIT (zero, v)
 
void visit (const tuple_t &v, std::true_type) override
 
template<typename Node >
std::pair< name_t, bool > name_ (const Node &n)
 The identifier for this node, and a Boolean stating whether we should traverse (again) this node. More...
 
template<rat::exp::type_t Type>
void print_ (const constant_t< Type > &n, const char *op)
 Print a nullary node. More...
 
template<rat::exp::type_t Type>
void print_ (const unary_t< Type > &n, const char *op)
 Print a unary node. More...
 
template<rat::exp::type_t Type>
void print_ (const variadic_t< Type > &n, const char *op)
 Print a variadic node. More...
 
name_t print_ (const weight_t &w)
 Print a weight. More...
 
void print_ (const lweight_t &n)
 Print a left-weight. More...
 
void print_ (const rweight_t &n)
 Print a right-weight. More...
 
void print_ (const atom_t &n)
 Print a label. More...
 

Private Attributes

std::ostream & out_
 Output stream. More...
 
class format fmt_
 Output format. More...
 
const expressionset_trs_
 The expressionset. More...
 
bool physical_ = false
 Whether to display the physical DAG rather than the logical tree. More...
 
std::shared_ptr< names_tnames_ = std::make_shared<names_t>()
 A shared_ptr, to support tuples. More...
 
std::shared_ptr< unsigned > count_ = std::make_shared<unsigned>(0)
 The node counter, used to name the nodes. More...
 
name_t last_name_
 The name of the last visited node. More...
 
const charlweight_ = nullptr
 External product. More...
 
const charrweight_ = nullptr
 
const charldivide_ = nullptr
 Quotient. More...
 
const charadd_ = nullptr
 The expression operators. More...
 
const charcomplement_ = nullptr
 
const charcompose_ = nullptr
 
const charconjunction_ = nullptr
 
const charinfiltrate_ = nullptr
 
const charmul_ = nullptr
 
const charshuffle_ = nullptr
 
const charstar_ = nullptr
 
const chartransposition_ = nullptr
 
const chartuple_ = nullptr
 Tuple tape separator. More...
 
const charzero_ = nullptr
 The constants. More...
 
const charone_ = nullptr
 

Friends

template<typename OtherExpSet >
class dot_printer
 Make it possible to view members from dot_printer's with a different template parameter. More...
 

Detailed Description

template<typename ExpSet>
class vcsn::rat::dot_printer< ExpSet >

Pretty-printer for rational expressions.

Definition at line 18 of file dot.hh.

Member Typedef Documentation

template<typename ExpSet>
template<type_t Type>
using vcsn::rat::dot_printer< ExpSet >::constant_t = typename super_t::template constant_t<Type>

Definition at line 37 of file dot.hh.

template<typename ExpSet>
using vcsn::rat::dot_printer< ExpSet >::context_t = context_t_of<expressionset_t>

Definition at line 26 of file dot.hh.

template<typename ExpSet>
using vcsn::rat::dot_printer< ExpSet >::expressionset_t = ExpSet

Definition at line 22 of file dot.hh.

template<typename ExpSet>
using vcsn::rat::dot_printer< ExpSet >::identities_t = typename expressionset_t::identities_t

Definition at line 27 of file dot.hh.

template<typename ExpSet>
using vcsn::rat::dot_printer< ExpSet >::label_t = label_t_of<context_t>

Definition at line 29 of file dot.hh.

template<typename ExpSet>
using vcsn::rat::dot_printer< ExpSet >::labelset_t = labelset_t_of<context_t>

Definition at line 28 of file dot.hh.

template<typename ExpSet>
using vcsn::rat::dot_printer< ExpSet >::name_t = unsigned
private

A type to label the node.

Definition at line 160 of file dot.hh.

template<typename ExpSet>
using vcsn::rat::dot_printer< ExpSet >::names_t = std::unordered_map<const void*, name_t>
private

If physical_ is enabled, register the identifiers of the nodes.

Definition at line 385 of file dot.hh.

template<typename ExpSet>
using vcsn::rat::dot_printer< ExpSet >::node_t = typename super_t::node_t

Actual node, without indirection.

Definition at line 33 of file dot.hh.

template<typename ExpSet>
using vcsn::rat::dot_printer< ExpSet >::self_t = dot_printer

Definition at line 24 of file dot.hh.

template<typename ExpSet>
using vcsn::rat::dot_printer< ExpSet >::super_t = typename expressionset_t::const_visitor

Definition at line 23 of file dot.hh.

template<typename ExpSet>
using vcsn::rat::dot_printer< ExpSet >::tuple_t = typename super_t::tuple_t
private

Definition at line 191 of file dot.hh.

template<typename ExpSet>
template<type_t Type>
using vcsn::rat::dot_printer< ExpSet >::unary_t = typename super_t::template unary_t<Type>

Definition at line 39 of file dot.hh.

template<typename ExpSet>
using vcsn::rat::dot_printer< ExpSet >::value_t = typename node_t::value_t

A shared_ptr to node_t.

Definition at line 35 of file dot.hh.

template<typename ExpSet>
template<type_t Type>
using vcsn::rat::dot_printer< ExpSet >::variadic_t = typename super_t::template variadic_t<Type>

Definition at line 41 of file dot.hh.

template<typename ExpSet>
using vcsn::rat::dot_printer< ExpSet >::weight_t = weight_t_of<context_t>

Definition at line 30 of file dot.hh.

Constructor & Destructor Documentation

template<typename ExpSet>
vcsn::rat::dot_printer< ExpSet >::dot_printer ( const expressionset_t rs,
std::ostream &  out,
bool  physical = false 
)
inline

A printer.

Parameters
rsthe expressionset
outthe output stream
physicalwhether to display the physical DAG rather than the logical tree.

Definition at line 52 of file dot.hh.

template<typename ExpSet>
template<typename OtherExpSet >
vcsn::rat::dot_printer< ExpSet >::dot_printer ( const expressionset_t rs,
dot_printer< OtherExpSet > &  other 
)
inline

Construct from another dot_printer.

Used to "fork" new printers in the case of tuples, with sharing of the state.

Definition at line 66 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::out_.

Member Function Documentation

template<typename ExpSet>
static constexpr const char* vcsn::rat::dot_printer< ExpSet >::me ( )
inlinestatic

Name of this algorithm, for error messages.

Definition at line 44 of file dot.hh.

template<typename ExpSet>
template<typename Node >
std::pair<name_t, bool> vcsn::rat::dot_printer< ExpSet >::name_ ( const Node &  n)
inlineprivate

The identifier for this node, and a Boolean stating whether we should traverse (again) this node.

Definition at line 249 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::names_, and vcsn::rat::dot_printer< ExpSet >::physical_.

Referenced by vcsn::rat::dot_printer< ExpSet >::visit_tuple< Dummy >::operator()(), and vcsn::rat::dot_printer< ExpSet >::print_().

template<typename ExpSet>
std::ostream& vcsn::rat::dot_printer< ExpSet >::operator() ( const value_t v)
inline

Entry point: print v as a complete Dot graph.

Definition at line 146 of file dot.hh.

References vcsn::decendl(), vcsn::iendl(), vcsn::incendl(), vcsn::rat::dot_printer< ExpSet >::out_, and vcsn::rat::dot_printer< ExpSet >::print_().

Here is the call graph for this function:

template<typename ExpSet>
name_t vcsn::rat::dot_printer< ExpSet >::print_ ( const value_t v)
inlineprivate
template<typename ExpSet>
name_t vcsn::rat::dot_printer< ExpSet >::print_ ( const node_t v)
inlineprivate

Easy recursion: print an expression and return its ID.

Definition at line 169 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::last_name_.

template<typename ExpSet>
template<rat::exp::type_t Type>
void vcsn::rat::dot_printer< ExpSet >::print_ ( const constant_t< Type > &  n,
const char op 
)
inlineprivate

Print a nullary node.

Definition at line 264 of file dot.hh.

References vcsn::iendl(), vcsn::rat::dot_printer< ExpSet >::last_name_, vcsn::rat::dot_printer< ExpSet >::name_(), and vcsn::rat::dot_printer< ExpSet >::out_.

Here is the call graph for this function:

template<typename ExpSet>
template<rat::exp::type_t Type>
void vcsn::rat::dot_printer< ExpSet >::print_ ( const unary_t< Type > &  n,
const char op 
)
inlineprivate

Print a unary node.

Definition at line 278 of file dot.hh.

References vcsn::iendl(), vcsn::rat::dot_printer< ExpSet >::last_name_, vcsn::rat::dot_printer< ExpSet >::name_(), vcsn::rat::dot_printer< ExpSet >::out_, and vcsn::rat::dot_printer< ExpSet >::print_().

Here is the call graph for this function:

template<typename ExpSet>
template<rat::exp::type_t Type>
void vcsn::rat::dot_printer< ExpSet >::print_ ( const variadic_t< Type > &  n,
const char op 
)
inlineprivate

Print a variadic node.

Definition at line 294 of file dot.hh.

References vcsn::iendl(), vcsn::rat::dot_printer< ExpSet >::last_name_, vcsn::rat::dot_printer< ExpSet >::name_(), vcsn::rat::dot_printer< ExpSet >::out_, vcsn::rat::dot_printer< ExpSet >::print_(), and vcsn::detail::transform().

Here is the call graph for this function:

template<typename ExpSet>
name_t vcsn::rat::dot_printer< ExpSet >::print_ ( const weight_t w)
inlineprivate

Print a weight.

Definition at line 315 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::fmt_, vcsn::format::for_weights(), vcsn::iendl(), vcsn::rat::dot_printer< ExpSet >::name_(), vcsn::rat::dot_printer< ExpSet >::out_, vcsn::res, and vcsn::rat::dot_printer< ExpSet >::rs_.

Here is the call graph for this function:

template<typename ExpSet>
void vcsn::rat::dot_printer< ExpSet >::print_ ( const lweight_t &  n)
inlineprivate

Print a left-weight.

Definition at line 326 of file dot.hh.

References vcsn::iendl(), vcsn::rat::dot_printer< ExpSet >::last_name_, vcsn::rat::dot_printer< ExpSet >::lweight_, vcsn::rat::dot_printer< ExpSet >::name_(), vcsn::rat::dot_printer< ExpSet >::out_, and vcsn::rat::dot_printer< ExpSet >::print_().

Here is the call graph for this function:

template<typename ExpSet>
void vcsn::rat::dot_printer< ExpSet >::print_ ( const rweight_t &  n)
inlineprivate

Print a right-weight.

Definition at line 343 of file dot.hh.

References vcsn::iendl(), vcsn::rat::dot_printer< ExpSet >::last_name_, vcsn::rat::dot_printer< ExpSet >::name_(), vcsn::rat::dot_printer< ExpSet >::out_, vcsn::rat::dot_printer< ExpSet >::print_(), and vcsn::rat::dot_printer< ExpSet >::rweight_.

Here is the call graph for this function:

template<typename ExpSet>
void vcsn::rat::dot_printer< ExpSet >::print_ ( const atom_t &  n)
inlineprivate

Print a label.

Definition at line 360 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::fmt_, vcsn::format::for_labels(), vcsn::iendl(), vcsn::rat::dot_printer< ExpSet >::last_name_, vcsn::rat::dot_printer< ExpSet >::name_(), vcsn::rat::dot_printer< ExpSet >::out_, and vcsn::rat::dot_printer< ExpSet >::rs_.

Here is the call graph for this function:

template<typename ExpSet>
vcsn::rat::dot_printer< ExpSet >::VCSN_RAT_VISIT ( add  ,
v   
)
inlineprivate

Definition at line 175 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::add_, vcsn::rat::dot_printer< ExpSet >::print_(), and vcsn::v.

Here is the call graph for this function:

template<typename ExpSet>
vcsn::rat::dot_printer< ExpSet >::VCSN_RAT_VISIT ( atom  ,
v   
)
inlineprivate

Definition at line 176 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::print_(), and vcsn::v.

Here is the call graph for this function:

template<typename ExpSet>
vcsn::rat::dot_printer< ExpSet >::VCSN_RAT_VISIT ( complement  ,
v   
)
inlineprivate

Definition at line 177 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::complement_, vcsn::rat::dot_printer< ExpSet >::print_(), and vcsn::v.

Here is the call graph for this function:

template<typename ExpSet>
vcsn::rat::dot_printer< ExpSet >::VCSN_RAT_VISIT ( compose  ,
v   
)
inlineprivate

Definition at line 178 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::compose_, vcsn::rat::dot_printer< ExpSet >::print_(), and vcsn::v.

Here is the call graph for this function:

template<typename ExpSet>
vcsn::rat::dot_printer< ExpSet >::VCSN_RAT_VISIT ( conjunction  ,
v   
)
inlineprivate

Definition at line 179 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::conjunction_, vcsn::rat::dot_printer< ExpSet >::print_(), and vcsn::v.

Here is the call graph for this function:

template<typename ExpSet>
vcsn::rat::dot_printer< ExpSet >::VCSN_RAT_VISIT ( infiltrate  ,
v   
)
inlineprivate

Definition at line 180 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::infiltrate_, vcsn::rat::dot_printer< ExpSet >::print_(), and vcsn::v.

Here is the call graph for this function:

template<typename ExpSet>
vcsn::rat::dot_printer< ExpSet >::VCSN_RAT_VISIT ( ldivide  ,
v   
)
inlineprivate

Definition at line 181 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::ldivide_, vcsn::rat::dot_printer< ExpSet >::print_(), and vcsn::v.

Here is the call graph for this function:

template<typename ExpSet>
vcsn::rat::dot_printer< ExpSet >::VCSN_RAT_VISIT ( lweight  ,
v   
)
inlineprivate

Definition at line 182 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::print_(), and vcsn::v.

Here is the call graph for this function:

template<typename ExpSet>
vcsn::rat::dot_printer< ExpSet >::VCSN_RAT_VISIT ( mul  ,
v   
)
inlineprivate

Definition at line 183 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::mul_, vcsn::rat::dot_printer< ExpSet >::print_(), and vcsn::v.

Here is the call graph for this function:

template<typename ExpSet>
vcsn::rat::dot_printer< ExpSet >::VCSN_RAT_VISIT ( one  ,
v   
)
inlineprivate

Definition at line 184 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::one_, vcsn::rat::dot_printer< ExpSet >::print_(), and vcsn::v.

Here is the call graph for this function:

template<typename ExpSet>
vcsn::rat::dot_printer< ExpSet >::VCSN_RAT_VISIT ( rweight  ,
v   
)
inlineprivate

Definition at line 185 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::print_(), and vcsn::v.

Here is the call graph for this function:

template<typename ExpSet>
vcsn::rat::dot_printer< ExpSet >::VCSN_RAT_VISIT ( shuffle  ,
v   
)
inlineprivate

Definition at line 186 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::print_(), vcsn::rat::dot_printer< ExpSet >::shuffle_, and vcsn::v.

Here is the call graph for this function:

template<typename ExpSet>
vcsn::rat::dot_printer< ExpSet >::VCSN_RAT_VISIT ( star  ,
v   
)
inlineprivate

Definition at line 187 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::print_(), vcsn::rat::dot_printer< ExpSet >::star_, and vcsn::v.

Here is the call graph for this function:

template<typename ExpSet>
vcsn::rat::dot_printer< ExpSet >::VCSN_RAT_VISIT ( transposition  ,
v   
)
inlineprivate

Definition at line 188 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::print_(), vcsn::rat::dot_printer< ExpSet >::transposition_, and vcsn::v.

Here is the call graph for this function:

template<typename ExpSet>
vcsn::rat::dot_printer< ExpSet >::VCSN_RAT_VISIT ( zero  ,
v   
)
inlineprivate

Definition at line 189 of file dot.hh.

References vcsn::rat::dot_printer< ExpSet >::print_(), vcsn::v, and vcsn::rat::dot_printer< ExpSet >::zero_.

Here is the call graph for this function:

template<typename ExpSet>
void vcsn::rat::dot_printer< ExpSet >::visit ( const tuple_t v,
std::true_type   
)
inlineoverrideprivate

Definition at line 239 of file dot.hh.

References vcsn::v.

Friends And Related Function Documentation

template<typename ExpSet>
template<typename OtherExpSet >
friend class dot_printer
friend

Make it possible to view members from dot_printer's with a different template parameter.

Definition at line 80 of file dot.hh.

Member Data Documentation

template<typename ExpSet>
const char* vcsn::rat::dot_printer< ExpSet >::add_ = nullptr
private

The expression operators.

Definition at line 401 of file dot.hh.

Referenced by vcsn::rat::dot_printer< ExpSet >::format(), and vcsn::rat::dot_printer< ExpSet >::VCSN_RAT_VISIT().

template<typename ExpSet>
const char* vcsn::rat::dot_printer< ExpSet >::complement_ = nullptr
private
template<typename ExpSet>
const char* vcsn::rat::dot_printer< ExpSet >::compose_ = nullptr
private
template<typename ExpSet>
const char* vcsn::rat::dot_printer< ExpSet >::conjunction_ = nullptr
private
template<typename ExpSet>
std::shared_ptr<unsigned> vcsn::rat::dot_printer< ExpSet >::count_ = std::make_shared<unsigned>(0)
private

The node counter, used to name the nodes.

A shared_ptr, to support tuples.

Definition at line 391 of file dot.hh.

template<typename ExpSet>
class format vcsn::rat::dot_printer< ExpSet >::fmt_
private

Output format.

Definition at line 376 of file dot.hh.

Referenced by vcsn::rat::dot_printer< ExpSet >::format(), and vcsn::rat::dot_printer< ExpSet >::print_().

template<typename ExpSet>
const char* vcsn::rat::dot_printer< ExpSet >::infiltrate_ = nullptr
private
template<typename ExpSet>
name_t vcsn::rat::dot_printer< ExpSet >::last_name_
private

The name of the last visited node.

Definition at line 393 of file dot.hh.

Referenced by vcsn::rat::dot_printer< ExpSet >::visit_tuple< Dummy >::operator()(), and vcsn::rat::dot_printer< ExpSet >::print_().

template<typename ExpSet>
const char* vcsn::rat::dot_printer< ExpSet >::ldivide_ = nullptr
private
template<typename ExpSet>
const char* vcsn::rat::dot_printer< ExpSet >::lweight_ = nullptr
private

External product.

Definition at line 396 of file dot.hh.

Referenced by vcsn::rat::dot_printer< ExpSet >::format(), and vcsn::rat::dot_printer< ExpSet >::print_().

template<typename ExpSet>
const char* vcsn::rat::dot_printer< ExpSet >::mul_ = nullptr
private
template<typename ExpSet>
std::shared_ptr<names_t> vcsn::rat::dot_printer< ExpSet >::names_ = std::make_shared<names_t>()
private

A shared_ptr, to support tuples.

Definition at line 387 of file dot.hh.

Referenced by vcsn::rat::dot_printer< ExpSet >::name_().

template<typename ExpSet>
const char* vcsn::rat::dot_printer< ExpSet >::one_ = nullptr
private
template<typename ExpSet>
bool vcsn::rat::dot_printer< ExpSet >::physical_ = false
private

Whether to display the physical DAG rather than the logical tree.

Definition at line 382 of file dot.hh.

Referenced by vcsn::rat::dot_printer< ExpSet >::name_().

template<typename ExpSet>
const expressionset_t& vcsn::rat::dot_printer< ExpSet >::rs_
private
template<typename ExpSet>
const char* vcsn::rat::dot_printer< ExpSet >::rweight_ = nullptr
private
template<typename ExpSet>
const char* vcsn::rat::dot_printer< ExpSet >::shuffle_ = nullptr
private
template<typename ExpSet>
const char* vcsn::rat::dot_printer< ExpSet >::star_ = nullptr
private
template<typename ExpSet>
const char* vcsn::rat::dot_printer< ExpSet >::transposition_ = nullptr
private
template<typename ExpSet>
const char* vcsn::rat::dot_printer< ExpSet >::tuple_ = nullptr
private
template<typename ExpSet>
const char* vcsn::rat::dot_printer< ExpSet >::zero_ = nullptr
private

The constants.

Definition at line 415 of file dot.hh.

Referenced by vcsn::rat::dot_printer< ExpSet >::format(), and vcsn::rat::dot_printer< ExpSet >::VCSN_RAT_VISIT().


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