Merge remote-tracking branch 'origin/development'

This commit is contained in:
John Wellbelove 2017-12-22 20:12:30 +00:00
commit e9a8e3f55f
6 changed files with 25 additions and 91 deletions

View File

@ -1,5 +1,5 @@
name=Embedded Template Library
version=10.8.1
version=10.8.2
author= John Wellbelove <john.wellbelove@etlcpp.com>
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
sentence=A C++ template library tailored for embedded systems.

View File

@ -144,7 +144,7 @@ namespace etl
public:
/// Allows ifsm_state functions to be private.
friend class fsm_helper;
friend class etl::fsm;
//*******************************************
/// Gets the id for this state.
@ -195,46 +195,10 @@ namespace etl
ifsm_state& operator =(const ifsm_state&);
};
//***************************************************************************
/// Helper class for FSM.
/// Allows ifsm_state functions to be private.
//***************************************************************************
class fsm_helper
{
public:
//*******************************************
inline void set_fsm_context(etl::ifsm_state& state,
etl::fsm& context)
{
state.set_fsm_context(context);
}
//*******************************************
inline fsm_state_id_t process_event(etl::ifsm_state& state,
etl::imessage_router& source,
const etl::imessage& message)
{
return state.process_event(source, message);
}
//*******************************************
inline fsm_state_id_t on_enter_state(etl::ifsm_state& state)
{
return state.on_enter_state();
}
//*******************************************
inline void on_exit_state(etl::ifsm_state& state)
{
state.on_exit_state();
}
};
//***************************************************************************
/// The FSM class.
//***************************************************************************
class fsm : public etl::imessage_router, protected etl::fsm_helper
class fsm : public etl::imessage_router
{
public:
@ -261,7 +225,7 @@ namespace etl
for (etl::fsm_state_id_t i = 0; i < size; ++i)
{
ETL_ASSERT((state_list[i] != nullptr), ETL_ERROR(etl::fsm_null_state_exception));
fsm_helper::set_fsm_context(*state_list[i], *this);
state_list[i]->set_fsm_context(*this);
}
}
@ -278,7 +242,7 @@ namespace etl
p_state = state_list[0];
ETL_ASSERT(p_state != nullptr, ETL_ERROR(etl::fsm_null_state_exception));
fsm_helper::on_enter_state(*p_state);
p_state->on_enter_state();
}
}
@ -296,7 +260,7 @@ namespace etl
//*******************************************
void receive(etl::imessage_router& source, const etl::imessage& message)
{
etl::fsm_state_id_t next_state_id = fsm_helper::process_event(*p_state, source, message);
etl::fsm_state_id_t next_state_id = p_state->process_event(source, message);
ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception));
etl::ifsm_state* p_next_state = state_list[next_state_id];
@ -306,10 +270,10 @@ namespace etl
{
do
{
fsm_helper::on_exit_state(*p_state);
p_state->on_exit_state();
p_state = p_next_state;
next_state_id = fsm_helper::on_enter_state(*p_state);
next_state_id = p_state->on_enter_state();
ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception));
p_next_state = state_list[next_state_id];
@ -379,7 +343,6 @@ namespace etl
etl::fsm_state_id_t number_of_states; ///< The number of states.
};
//***************************************************************************
// The definition for all 16 message types.
//***************************************************************************

View File

@ -156,7 +156,7 @@ namespace etl
public:
/// Allows ifsm_state functions to be private.
friend class fsm_helper;
friend class etl::fsm;
//*******************************************
/// Gets the id for this state.
@ -207,46 +207,10 @@ namespace etl
ifsm_state& operator =(const ifsm_state&);
};
//***************************************************************************
/// Helper class for FSM.
/// Allows ifsm_state functions to be private.
//***************************************************************************
class fsm_helper
{
public:
//*******************************************
inline void set_fsm_context(etl::ifsm_state& state,
etl::fsm& context)
{
state.set_fsm_context(context);
}
//*******************************************
inline fsm_state_id_t process_event(etl::ifsm_state& state,
etl::imessage_router& source,
const etl::imessage& message)
{
return state.process_event(source, message);
}
//*******************************************
inline fsm_state_id_t on_enter_state(etl::ifsm_state& state)
{
return state.on_enter_state();
}
//*******************************************
inline void on_exit_state(etl::ifsm_state& state)
{
state.on_exit_state();
}
};
//***************************************************************************
/// The FSM class.
//***************************************************************************
class fsm : public etl::imessage_router, protected etl::fsm_helper
class fsm : public etl::imessage_router
{
public:
@ -273,7 +237,7 @@ namespace etl
for (etl::fsm_state_id_t i = 0; i < size; ++i)
{
ETL_ASSERT((state_list[i] != nullptr), ETL_ERROR(etl::fsm_null_state_exception));
fsm_helper::set_fsm_context(*state_list[i], *this);
state_list[i]->set_fsm_context(*this);
}
}
@ -290,7 +254,7 @@ namespace etl
p_state = state_list[0];
ETL_ASSERT(p_state != nullptr, ETL_ERROR(etl::fsm_null_state_exception));
fsm_helper::on_enter_state(*p_state);
p_state->on_enter_state();
}
}
@ -308,7 +272,7 @@ namespace etl
//*******************************************
void receive(etl::imessage_router& source, const etl::imessage& message)
{
etl::fsm_state_id_t next_state_id = fsm_helper::process_event(*p_state, source, message);
etl::fsm_state_id_t next_state_id = p_state->process_event(source, message);
ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception));
etl::ifsm_state* p_next_state = state_list[next_state_id];
@ -318,10 +282,10 @@ namespace etl
{
do
{
fsm_helper::on_exit_state(*p_state);
p_state->on_exit_state();
p_state = p_next_state;
next_state_id = fsm_helper::on_enter_state(*p_state);
next_state_id = p_state->on_enter_state();
ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception));
p_next_state = state_list[next_state_id];
@ -393,7 +357,6 @@ namespace etl
/*[[[cog
import cog
cog.outl("")
################################################
# The first definition for all of the events.
################################################

View File

@ -399,7 +399,6 @@ namespace etl
//*************************************************************************
/// Allocate an object from the pool.
/// Uses the default constructor.
/// If asserts or exceptions are enabled and there are no more free items an
/// etl::pool_no_allocation if thrown, otherwise a nullptr is returned.
/// Static asserts if the specified type is too large for the pool.

View File

@ -1,7 +1,15 @@
10.8.2
Finite State Machine
Tidied code. Removed unecessary class.
===============================================================================
10.8.1
Pool
Changed alignof to etl::alignment_of
===============================================================================
10.8.0
Added etl::variant_pool as a replacement for etl::factory.

View File

@ -19,7 +19,7 @@
<Keyword>Win32Proj</Keyword>
<RootNamespace>unittest</RootNamespace>
<ProjectName>etl</ProjectName>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@ -77,6 +77,7 @@
<AdditionalIncludeDirectories>../../unittest-cpp/UnitTest++/;../../src;../../src/c;../../test</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
<MultiProcessorCompilation>false</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>