/usr/include/boost/msm/back
Edit: /usr/include/boost/msm/back/history_policies.hpp (5678B)
// Copyright 2008 Christophe Henry
// henry UNDERSCORE christophe AT hotmail DOT com
// This is an extended version of the state machine available in the boost::mpl library
// Distributed under the same license as the original.
// Copyright for the original version:
// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed
// under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_MSM_BACK_HISTORY_POLICIES_H
#define BOOST_MSM_BACK_HISTORY_POLICIES_H
#include
namespace boost { namespace msm { namespace back
{
// policy classes
// Default: no history used
template
class NoHistoryImpl
{
public:
NoHistoryImpl(){}
~NoHistoryImpl(){}
void set_initial_states(int* const initial_states)
{
for (int i=0;i
const int* history_entry(Event const& )
{
// always come back to the original state
return m_initialStates;
}
NoHistoryImpl& operator=(NoHistoryImpl const& rhs)
{
for (int i=0; i
bool process_deferred_events(Event const&)const
{
return false;
}
template
void serialize(Archive & ar, const unsigned int)
{
ar & m_initialStates;
}
private:
int m_initialStates[NumberOfRegions];
};
// not UML standard. Always activates history, no matter which event generated the transition
template
class AlwaysHistoryImpl
{
public:
AlwaysHistoryImpl(){}
~AlwaysHistoryImpl(){}
void set_initial_states(int* const initial_states)
{
for (int i=0;i
const int* history_entry(Event const& )
{
// always load back the last active state
return m_initialStates;
}
AlwaysHistoryImpl& operator=(AlwaysHistoryImpl const& rhs)
{
for (int i=0; i
bool process_deferred_events(Event const&)const
{
return true;
}
template
void serialize(Archive & ar, const unsigned int)
{
ar & m_initialStates;
}
private:
int m_initialStates[NumberOfRegions];
};
// UML Shallow history. For deep history, just use this policy for all the contained state machines
template
class ShallowHistoryImpl
{
public:
ShallowHistoryImpl(){}
~ShallowHistoryImpl(){}
void set_initial_states(int* const initial_states)
{
for (int i=0;i
const int* history_entry(Event const&)
{
if ( ::boost::mpl::contains::value)
{
return m_currentStates;
}
// not one of our events, no history
return m_initialStates;
}
ShallowHistoryImpl& operator=(ShallowHistoryImpl const& rhs)
{
for (int i=0; i
bool process_deferred_events(Event const&)const
{
return ::boost::mpl::contains::value;
}
template
void serialize(Archive & ar, const unsigned int)
{
ar & m_initialStates;
ar & m_currentStates;
}
private:
int m_initialStates[NumberOfRegions];
int m_currentStates[NumberOfRegions];
};
struct NoHistory
{
typedef int history_policy;
template
struct apply
{
typedef NoHistoryImpl type;
};
};
struct AlwaysHistory
{
typedef int history_policy;
template
struct apply
{
typedef AlwaysHistoryImpl type;
};
};
template
struct ShallowHistory
{
typedef int history_policy;
template
struct apply
{
typedef ShallowHistoryImpl type;
};
};
} } }//boost::msm::back
#endif //BOOST_MSM_BACK_HISTORY_POLICIES_H