LCOV - code coverage report
Current view: top level - lps/include/mcrl2/lps - stochastic_action_summand.h (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 22 24 91.7 %
Date: 2024-03-08 02:52:28 Functions: 10 11 90.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Author(s): Wieger Wesselink
       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             : /// \file mcrl2/lps/stochastic_action_summand.h
      10             : /// \brief add your file description here.
      11             : 
      12             : #ifndef MCRL2_LPS_STOCHASTIC_ACTION_SUMMAND_H
      13             : #define MCRL2_LPS_STOCHASTIC_ACTION_SUMMAND_H
      14             : 
      15             : #include "mcrl2/lps/action_summand.h"
      16             : 
      17             : namespace mcrl2 {
      18             : 
      19             : namespace lps {
      20             : 
      21             : /// \brief LPS summand containing a multi-action.
      22             : class stochastic_action_summand: public action_summand
      23             : {
      24             :   protected:
      25             :     /// \brief The distribution of the summand
      26             :     stochastic_distribution m_distribution;
      27             : 
      28             :   public:
      29             :     /// \brief Constructor.
      30          23 :     stochastic_action_summand()
      31          23 :     {}
      32             : 
      33             :     /// \brief Constructor.
      34       32617 :     stochastic_action_summand(const data::variable_list& summation_variables, const data::data_expression& condition, const lps::multi_action& action,
      35             :           const data::assignment_list& assignments, const stochastic_distribution& distribution)
      36       32617 :       : action_summand(summation_variables, condition, action, assignments), m_distribution(distribution)
      37       32617 :     {}
      38             : 
      39             :     /// \brief Constructor.
      40        1040 :     stochastic_action_summand(const action_summand& s)
      41        1040 :       : action_summand(s)
      42        1040 :     {}
      43             : 
      44             :     /// Move semantics
      45       30185 :     stochastic_action_summand(const stochastic_action_summand&) noexcept = default;
      46       66637 :     stochastic_action_summand(stochastic_action_summand&&) noexcept = default;
      47        2730 :     stochastic_action_summand& operator=(const stochastic_action_summand&) noexcept = default;
      48         329 :     stochastic_action_summand& operator=(stochastic_action_summand&&) noexcept = default;
      49             : 
      50             :     /// \brief Returns the distribution of this summand.
      51       48073 :     const stochastic_distribution& distribution() const
      52             :     {
      53       48073 :       return m_distribution;
      54             :     }
      55             : 
      56             :     /// \brief Returns the distribution of this summand.
      57        8603 :     stochastic_distribution& distribution()
      58             :     {
      59        8603 :       return m_distribution;
      60             :     }
      61             : 
      62             :     /// \brief Swaps the contents
      63             :     void swap(stochastic_action_summand& other)
      64             :     {
      65             :       action_summand::swap(other);
      66             :       using std::swap;
      67             :       swap(m_distribution, other.m_distribution);
      68             :     }
      69             : };
      70             : 
      71             : //--- start generated class stochastic_action_summand ---//
      72             : /// \\brief list of stochastic_action_summands
      73             : typedef atermpp::term_list<stochastic_action_summand> stochastic_action_summand_list;
      74             : 
      75             : /// \\brief vector of stochastic_action_summands
      76             : typedef std::vector<stochastic_action_summand>    stochastic_action_summand_vector;
      77             : 
      78             : // prototype declaration
      79             : std::string pp(const stochastic_action_summand& x);
      80             : 
      81             : /// \\brief Outputs the object to a stream
      82             : /// \\param out An output stream
      83             : /// \\param x Object x
      84             : /// \\return The output stream
      85             : inline
      86           0 : std::ostream& operator<<(std::ostream& out, const stochastic_action_summand& x)
      87             : {
      88           0 :   return out << lps::pp(x);
      89             : }
      90             : 
      91             : /// \\brief swap overload
      92             : inline void swap(stochastic_action_summand& t1, stochastic_action_summand& t2)
      93             : {
      94             :   t1.swap(t2);
      95             : }
      96             : //--- end generated class stochastic_action_summand ---//
      97             : 
      98             : /// \brief Comparison operator for action summands.
      99             : inline
     100             : bool operator<(const stochastic_action_summand& x, const stochastic_action_summand& y)
     101             : {
     102             :   if (x.distribution() == y.distribution())
     103             :   {
     104             :     return static_cast<const action_summand&>(x) < static_cast<const action_summand&>(y);
     105             :   }
     106             :   return x.distribution() < y.distribution();
     107             : }
     108             : 
     109             : /// \brief Equality operator of stochastic action summands
     110             : inline
     111             : bool operator==(const stochastic_action_summand& x, const stochastic_action_summand& y)
     112             : {
     113             :   return static_cast<const action_summand&>(x) == static_cast<const action_summand&>(y) && x.distribution() == y.distribution();
     114             : }
     115             : 
     116             : /// \brief Conversion to aterm_appl.
     117             : inline
     118          83 : atermpp::aterm_appl action_summand_to_aterm(const stochastic_action_summand& s)
     119             : {
     120             :   atermpp::aterm_appl result = atermpp::aterm_appl(core::detail::function_symbol_LinearProcessSummand(),
     121          83 :                        s.summation_variables(),
     122             :                        s.condition(),
     123             :                        s.multi_action(),
     124          83 :                        s.multi_action().time(),
     125          83 :                        s.assignments(),
     126             :                        s.distribution()
     127         249 :                      );
     128          83 :   return result;
     129             : }
     130             : 
     131             : } // namespace lps
     132             : 
     133             : } // namespace mcrl2
     134             : 
     135             : #endif // MCRL2_LPS_STOCHASTIC_ACTION_SUMMAND_H

Generated by: LCOV version 1.14