/usr/include/claw/automaton.hpp is in libclaw-dev 1.7.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | /*
CLAW - a C++ Library Absolutely Wonderful
CLAW is a free library without any particular aim but being useful to
anyone.
Copyright (C) 2005-2011 Julien Jorge
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
contact: julien.jorge@gamned.org
*/
/**
* \file automaton.hpp
* \brief A basic automaton structure.
* \author Julien Jorge
*/
#ifndef __CLAW_AUTOMATON_HPP__
#define __CLAW_AUTOMATON_HPP__
#include <map>
#include <vector>
#include <claw/avl.hpp>
namespace claw
{
//***************************** automate ************************************
/**
* \brief Basic automaton structure.
*
* An automaton is a quintuplet (A, E, I ,F, T) where
* - A is the set of symbols,
* - E is the set of states,
* - I is the set of initial states,
* - F is the set of finalstates,
* - T is the set of transitions (labeled edges)
*
* \b Template \b parameters
* - \a State The type of the states.
* - \a Edge The type of the symbols in the alphabet.
*/
template<class State, class Edge, class StateComp = std::less<State>,
class EdgeComp = std::less<Edge> >
class automaton
{
public:
/** \brief The type of the states. */
typedef State state_type;
/** \brief The type of the symbols on the edges. */
typedef Edge edge_type;
/** \brief The type of the operator used to compare states. */
typedef StateComp state_compare;
/** \brief The type of the operator used to compare edge symbols. */
typedef EdgeComp edge_compare;
/** \brief The neighbours list associates states to edge symbols.*/
typedef std::multimap<edge_type, state_type, edge_compare> neighbours_list;
/** \brief Each state is given a set of reachable states with a neighbours
list. */
typedef std::map<state_type, neighbours_list, state_compare> adjacent_list;
/** \brief The return type of the methods returning states. */
typedef std::vector<state_type> result_state_list;
/** \brief The return type of the methods returning edges. */
typedef std::vector<edge_type> result_edge_list;
public:
void add_edge( const state_type& s1, const state_type& s2,
const edge_type& e );
void remove_edge( const state_type& s1, const state_type& s2,
const edge_type& e );
void add_state( const state_type& s );
void add_initial_state( const state_type& s );
void add_final_state( const state_type& s );
bool state_exists( const state_type& s ) const;
bool state_is_final( const state_type& s ) const;
bool state_is_initial( const state_type& s ) const;
void states( result_state_list& v ) const;
void final_states( result_state_list& v ) const;
void initial_states( result_state_list& v ) const;
void alphabet( result_edge_list& v ) const;
template<class InputIterator>
bool match(InputIterator first, InputIterator last) const;
unsigned int states_count() const;
void reachables( const state_type& s, const edge_type& e,
result_state_list& l ) const;
void reachables( const state_type& s,
result_state_list& l ) const;
void edges( const state_type& s1, const state_type& s2,
result_edge_list& l ) const;
void edges( const state_type& s1, const edge_type& edge,
result_edge_list& l ) const;
private:
template<class InputIterator>
bool match_aux(const state_type& s, InputIterator first,
InputIterator last) const;
private:
/** \brief The predicate used to compare states. */
static state_compare s_state_compare;
/** \brief The set of symbols in the alphabet. */
avl<edge_type, edge_compare> m_alphabet;
/** \brief The set of initial states. */
avl<state_type, state_compare> m_initial_states;
/** \brief The set of final states. */
avl<state_type, state_compare> m_final_states;
/** \brief The adjacency list (the set of transitions). */
adjacent_list m_states;
}; // automaton
} // namespace claw
#include <claw/impl/automaton.tpp>
#endif // __CLAW_AUTOMATON_HPP__
|