LCOV - code coverage report
Current view: top level - lts/include/mcrl2/lts - lts_dot.h (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 0 16 0.0 %
Date: 2019-06-20 00:49:45 Functions: 0 14 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Author(s): Jan Friso Groote
       2             : // Copyright: see the accompanying file COPYING or copy at
       3             : // https://github.com/mCRL2org/mCRL2/blob/master/COPYING
       4             : //
       5             : // Distributed under the Boost Software License, Version 1.0.
       6             : // (See accompanying file LICENSE_1_0.txt or copy at
       7             : // http://www.boost.org/LICENSE_1_0.txt)
       8             : //
       9             : 
      10             : /** \file lts_dot.h
      11             :  *
      12             :  * \brief This file contains a class that contains labelled transition systems in dot format.
      13             :  * \details A labelled transition system in dot format is a transition system
      14             :  * with strings as state and transition labels.
      15             :  * \author Jan Friso Groote
      16             :  */
      17             : 
      18             : 
      19             : #ifndef MCRL2_LTS_LTS_DOT_H
      20             : #define MCRL2_LTS_LTS_DOT_H
      21             : 
      22             : #include <string>
      23             : #include <vector>
      24             : #include "mcrl2/utilities/logger.h"
      25             : #include "mcrl2/core/print.h"
      26             : #include "mcrl2/lts/probabilistic_arbitrary_precision_fraction.h"
      27             : #include "mcrl2/lts/probabilistic_lts.h"
      28             : #include "mcrl2/lts/action_label_string.h"
      29             : 
      30             : 
      31             : namespace mcrl2
      32             : {
      33             : namespace lts
      34             : {
      35             : 
      36             : /** \brief This class contains labels for states in dot format.
      37             :    \details A dot state label consists of two strings, the name of a state and a separate label.
      38             : */
      39           0 : class state_label_dot
      40             : {
      41             :   private:
      42             :     std::string m_state_name;
      43             :     std::string m_state_label;
      44             : 
      45             :   public:
      46             : 
      47             :     /** \brief The default constructor.
      48             :     */
      49           0 :     state_label_dot()
      50           0 :     {}
      51             : 
      52             :     /** \brief A constructor setting the name and label of this state label to the indicated values.
      53             :     */
      54           0 :     state_label_dot(const std::string& state_name,
      55           0 :                     const std::string& state_label):m_state_name(state_name),m_state_label(state_label)
      56           0 :     {}
      57             : 
      58             :     /** \brief This method sets the name of the state label to the string s.
      59             :     */
      60             :     void set_name(const std::string& s)
      61             :     {
      62             :       m_state_name=s;
      63             :     }
      64             : 
      65             :     /** \brief This method returns the string in the name field of a state label.
      66             :     */
      67           0 :     std::string name() const
      68             :     {
      69           0 :       return m_state_name;
      70             :     }
      71             : 
      72             :     /** \brief This method sets the label field of the state label to the string s.
      73             :     */
      74             :     void set_label(const std::string& s)
      75             :     {
      76             :       m_state_label=s;
      77             :     }
      78             : 
      79             :     /** \brief This method returns the label in the name field of a state label.
      80             :     */
      81           0 :     std::string label() const
      82             :     {
      83           0 :       return m_state_label;
      84             :     }
      85             : 
      86             :     /** \brief Standard comparison operator, comparing both the string in the name field, as well
      87             :               as the one in the label field.
      88             :     */
      89           0 :     bool operator ==(const state_label_dot& l) const
      90             :     {
      91           0 :       return m_state_name==l.name() && m_state_label==l.label();
      92             :     }
      93             : 
      94             :     /** \brief Standard inequality operator. Just the negation of equality
      95             :     */
      96           0 :     bool operator !=(const state_label_dot& l) const
      97             :     {
      98           0 :       return !(*this==l);
      99             :     }
     100             : };
     101             : 
     102             : /** \brief Pretty print function for a state_label_dot. Only prints the label field.
     103             : */
     104             : inline std::string pp(const state_label_dot& l)
     105             : {
     106             :   return l.label();
     107             : }
     108             : 
     109             : /** \brief A base class for the lts_dot labelled transition system.
     110             : */
     111             : 
     112             : namespace detail
     113             : {
     114             : 
     115           0 : class lts_dot_base
     116             : {
     117             :   public:
     118             :     /** \brief The lts_type of state_label_dot. In this case lts_dot.
     119             :     */
     120             :     lts_type type() const
     121             :     {
     122             :       return lts_dot;
     123             :     }
     124             : 
     125             :     /** \brief The standard swap function.
     126             :     */
     127             :     void swap(lts_dot_base&)
     128             :     {
     129             :       // Intentionally empty.
     130             :     }
     131             : 
     132             : };
     133             : 
     134             : } // end namespace detail
     135             : 
     136             : /** \brief A class to contain labelled transition systems in graphviz format.
     137             :     \details Action labels are strings, and state labels are pairs with a name field
     138             :              and an action fields. */
     139             : class lts_dot_t : public lts< state_label_dot, action_label_string, detail::lts_dot_base >
     140             : {
     141             : 
     142             :   public:
     143             : 
     144             :     /** \brief Save the labelled transition system to a stream.
     145             :      *  \param[in] os Stream which to write the lts to.
     146             :      */
     147             :     void save(std::ostream& os) const;
     148             : 
     149             :     /** \brief Save the labelled transition system to a file.
     150             :      *  \details Throws an error when the file cannot be opened.
     151             :      *  \param[in] filename Name of the file to which this lts is written.
     152             :      */
     153             :     void save(const std::string& filename) const;
     154             : };
     155             : 
     156             : 
     157             : /** \brief A class to contain labelled transition systems in graphviz format.
     158             :     \details Action labels are strings, and state labels are pairs with a name field
     159             :              and an action fields. */
     160           0 : class probabilistic_lts_dot_t : 
     161             :            public probabilistic_lts< 
     162             :                      state_label_dot, 
     163             :                      action_label_string, 
     164             :                      probabilistic_state<std::size_t, mcrl2::lts::probabilistic_arbitrary_precision_fraction>,
     165             :                      detail::lts_dot_base >
     166             : {
     167             : 
     168             :   public:
     169             : 
     170             :     /** \brief Save the labelled transition system to a stream.
     171             :      *  \param[in] os Stream which to write the lts to.
     172             :      */
     173             :     void save(std::ostream& os) const;
     174             : 
     175             :     /** \brief Save the labelled transition system to a file.
     176             :      *  \details Throws an error when the file cannot be opened.
     177             :      *  \param[in] filename Name of the file to which this lts is written.
     178             :      */
     179             :     void save(const std::string& filename) const;
     180             : };
     181             : 
     182             : 
     183             : 
     184             : } // namespace lts
     185             : } // namespace mcrl2
     186             : 
     187             : #endif

Generated by: LCOV version 1.12