Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:41:59

0001 // Copyright 2008 Christophe Henry
0002 // henry UNDERSCORE christophe AT hotmail DOT com
0003 // This is an extended version of the state machine available in the boost::mpl library
0004 // Distributed under the same license as the original.
0005 // Copyright for the original version:
0006 // Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed
0007 // under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at
0009 // http://www.boost.org/LICENSE_1_0.txt)
0010 
0011 #ifndef BOOST_MSM_BACK_TOOLS_H
0012 #define BOOST_MSM_BACK_TOOLS_H
0013 
0014 
0015 #include <string>
0016 #include <iostream>
0017 #include <boost/msm/back/common_types.hpp>
0018 #include <boost/msm/back/metafunctions.hpp>
0019 
0020 namespace boost { namespace msm { namespace back
0021 {
0022 
0023 // fills the array passed in with the state names in the correct order
0024 // the array must be big enough. To know the needed size, use mpl::size
0025 // on fsm::generate_state_set
0026 template <class stt>
0027 struct fill_state_names
0028 {
0029     fill_state_names(char const** names):m_names(names){}
0030     template <class StateType>
0031     void operator()(boost::msm::wrap<StateType> const&)
0032     {
0033         m_names[get_state_id<stt,StateType>::value]= typeid(StateType).name();
0034     }
0035 private:
0036     char const** m_names;
0037 };
0038 
0039 // fills the typeid-generated name of the given state in the string passed as argument
0040 template <class stt>
0041 struct get_state_name
0042 {
0043     get_state_name(std::string& name_to_fill, int state_id):m_name(name_to_fill),m_state_id(state_id){}
0044     template <class StateType>
0045     void operator()(boost::msm::wrap<StateType> const&)
0046     {
0047         if (get_state_id<stt,StateType>::value == m_state_id)
0048         {
0049             m_name = typeid(StateType).name();
0050         }
0051     }
0052 private:
0053     std::string&    m_name;
0054     int             m_state_id;
0055 };
0056 
0057 // displays the typeid of the given Type
0058 struct display_type 
0059 {
0060     template <class Type>
0061     void operator()(boost::msm::wrap<Type> const&)
0062     {
0063         std::cout << typeid(Type).name() << std::endl;
0064     }
0065 };
0066 
0067 } } }//boost::msm::back
0068 #endif //BOOST_MSM_BACK_TOOLS_H