Factor out generated code (#1369)

Previously, generator code under include/etl/generators needed to be
synchronized with the generated files under include/etl explicitly.
Leading to errors in the CI checks if forgotten.

This change separates out the generated parts to cpp03 specific
snippets. This way, most code under include/etl is now directly editable,
with only some pre-C++11 code separated out to
include/etl/generators/*_cpp03_generator.h which still needs to be
re-generated on respective changes. But in many cases, this is not necessary.

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
This commit is contained in:
Roland Reichwein 2026-03-31 17:36:54 +02:00 committed by GitHub
parent 3c2a4d48a9
commit d17c0297ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
52 changed files with 10706 additions and 17580 deletions

View File

@ -26,28 +26,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#if 0
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
#endif
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
//***************************************************************************
// To generate to header file, run this at the command line.
// Note: You will need Python and COG installed.
//
// cog -d -e -ofsm.h -DHandlers=<n> fsm_generator.h
// Where <n> is the number of messages to support.
//
// e.g.
// To generate handlers for up to 16 events...
// cog -d -e -ofsm.h -DHandlers=16 fsm_generator.h
//
// See generate.bat
//***************************************************************************
#ifndef ETL_FSM_INCLUDED
#define ETL_FSM_INCLUDED
@ -88,12 +66,7 @@ namespace etl
template <typename, typename, etl::fsm_state_id_t, typename...>
class fsm_state;
#else
template <typename, typename, etl::fsm_state_id_t,
typename, typename, typename, typename,
typename, typename, typename, typename,
typename, typename, typename, typename,
typename, typename, typename, typename>
class fsm_state;
#include "private/fsm_fwd_decl_cpp03.h"
#endif
//***************************************************************************
@ -346,12 +319,7 @@ namespace etl
template <typename, typename, etl::fsm_state_id_t, typename...>
friend class fsm_state;
#else
template <typename, typename, etl::fsm_state_id_t,
typename, typename, typename, typename,
typename, typename, typename, typename,
typename, typename, typename, typename,
typename, typename, typename, typename>
friend class etl::fsm_state;
#include "private/fsm_friend_decl_cpp03.h"
#endif
//*******************************************
@ -994,896 +962,7 @@ namespace etl
};
#else
//*************************************************************************************************
// For C++03 and below.
//*************************************************************************************************
//***************************************************************************
// The definition for all 16 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void,
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
class fsm_state : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
case T11::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T11&>(message)); break;
case T12::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T12&>(message)); break;
case T13::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T13&>(message)); break;
case T14::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T14&>(message)); break;
case T15::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T15&>(message)); break;
case T16::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T16&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 15 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8,
typename T9, typename T10, typename T11, typename T12,
typename T13, typename T14, typename T15>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
case T11::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T11&>(message)); break;
case T12::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T12&>(message)); break;
case T13::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T13&>(message)); break;
case T14::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T14&>(message)); break;
case T15::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T15&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 14 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8,
typename T9, typename T10, typename T11, typename T12,
typename T13, typename T14>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
case T11::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T11&>(message)); break;
case T12::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T12&>(message)); break;
case T13::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T13&>(message)); break;
case T14::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T14&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 13 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8,
typename T9, typename T10, typename T11, typename T12,
typename T13>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
case T11::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T11&>(message)); break;
case T12::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T12&>(message)); break;
case T13::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T13&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 12 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8,
typename T9, typename T10, typename T11, typename T12>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
case T11::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T11&>(message)); break;
case T12::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T12&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 11 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8,
typename T9, typename T10, typename T11>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
case T11::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T11&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 10 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8,
typename T9, typename T10>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 9 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8,
typename T9>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 8 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, void, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 7 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, void, void, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 6 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 5 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 4 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, void, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 3 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, void, void, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 2 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, void, void, void, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 1 message type.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1>
class fsm_state<TContext, TDerived, STATE_ID_, T1, void, void, void, void, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 0 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_>
class fsm_state<TContext, TDerived, STATE_ID_, void, void, void, void, void, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
return p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message);
}
};
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8,
typename T9, typename T10, typename T11, typename T12,
typename T13, typename T14, typename T15, typename T16>
ETL_CONSTANT etl::fsm_state_id_t fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::STATE_ID;
#include "private/fsm_cpp03.h"
#endif
}

View File

@ -0,0 +1,199 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
//*************************************************************************************************
// For C++03 and below.
//*************************************************************************************************
/*[[[cog
import cog
################################################
# The first definition for all of the events.
################################################
cog.outl("//***************************************************************************")
cog.outl("// The definition for all %s message types." % Handlers)
cog.outl("//***************************************************************************")
cog.outl("template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,")
cog.out(" ")
for n in range(1, int(Handlers)):
cog.out(" typename T%s = void," % n)
if n % 4 == 0:
cog.outl("")
cog.out(" ")
cog.outl(" typename T%s = void>" % Handlers)
cog.outl("class fsm_state : public ifsm_state")
cog.outl("{")
cog.outl("public:")
cog.outl("")
cog.outl(" static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;")
cog.outl("")
cog.outl(" fsm_state()")
cog.outl(" : ifsm_state(STATE_ID)")
cog.outl(" {")
cog.outl(" }")
cog.outl("")
cog.outl("protected:")
cog.outl("")
cog.outl(" ~fsm_state()")
cog.outl(" {")
cog.outl(" }")
cog.outl("")
cog.outl(" TContext& get_fsm_context() const")
cog.outl(" {")
cog.outl(" return static_cast<TContext&>(ifsm_state::get_fsm_context());")
cog.outl(" }")
cog.outl("")
cog.outl("private:")
cog.outl("")
cog.outl(" etl::fsm_state_id_t process_event(const etl::imessage& message)")
cog.outl(" {")
cog.outl(" etl::fsm_state_id_t new_state_id;")
cog.outl(" etl::message_id_t event_id = message.get_message_id();")
cog.outl("")
cog.outl(" switch (event_id)")
cog.outl(" {")
for n in range(1, int(Handlers) + 1):
cog.out(" case T%d::ID:" % n)
cog.out(" new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T%d&>(message));" % n)
cog.outl(" break;")
cog.out(" default:")
cog.out(" new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message);")
cog.outl(" break;")
cog.outl(" }")
cog.outl("")
cog.outl(" return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);")
cog.outl(" }")
cog.outl("};")
####################################
# All of the other specialisations.
####################################
for n in range(int(Handlers) - 1, 0, -1):
cog.outl("")
cog.outl("//***************************************************************************")
if n == 1:
cog.outl("// Specialisation for %d message type." % n)
else:
cog.outl("// Specialisation for %d message types." % n)
cog.outl("//***************************************************************************")
cog.outl("template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,")
cog.out(" ")
for t in range(1, n):
cog.out(" typename T%d," % t)
if t % 4 == 0:
cog.outl("")
cog.out(" ")
cog.outl(" typename T%d>" % n)
cog.out("class fsm_state<TContext, TDerived, STATE_ID_,")
for t in range(1, n + 1):
cog.out(" T%d," % t)
if t % 16 == 0:
cog.outl("")
cog.out(" ")
for t in range(n + 1, int(Handlers)):
cog.out(" void,")
if t % 16 == 0:
cog.outl("")
cog.out(" ")
cog.outl(" void> : public ifsm_state")
cog.outl("{")
cog.outl("public:")
cog.outl("")
cog.outl(" static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;")
cog.outl("")
cog.outl(" fsm_state()")
cog.outl(" : ifsm_state(STATE_ID)")
cog.outl(" {")
cog.outl(" }")
cog.outl("")
cog.outl("protected:")
cog.outl("")
cog.outl(" ~fsm_state()")
cog.outl(" {")
cog.outl(" }")
cog.outl("")
cog.outl(" TContext& get_fsm_context() const")
cog.outl(" {")
cog.outl(" return static_cast<TContext&>(ifsm_state::get_fsm_context());")
cog.outl(" }")
cog.outl("")
cog.outl("private:")
cog.outl("")
cog.outl(" etl::fsm_state_id_t process_event(const etl::imessage& message)")
cog.outl(" {")
cog.outl(" etl::fsm_state_id_t new_state_id;")
cog.outl(" etl::message_id_t event_id = message.get_message_id();")
cog.outl("")
cog.outl(" switch (event_id)")
cog.outl(" {")
for n in range(1, n + 1):
cog.out(" case T%d::ID:" % n)
cog.out(" new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T%d&>(message));" % n)
cog.outl(" break;")
cog.out(" default:")
cog.out(" new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message);")
cog.outl(" break;")
cog.outl(" }")
cog.outl("")
cog.outl(" return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);")
cog.outl(" }")
cog.outl("};")
####################################
# Specialisation for zero messages.
####################################
cog.outl("")
cog.outl("//***************************************************************************")
cog.outl("// Specialisation for 0 message types.")
cog.outl("//***************************************************************************")
cog.outl("template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_>")
cog.out("class fsm_state<TContext, TDerived, STATE_ID_,")
for t in range(1, int(Handlers)):
cog.out(" void,")
if t % 16 == 0:
cog.outl("")
cog.out(" ")
cog.outl(" void> : public ifsm_state")
cog.outl("{")
cog.outl("public:")
cog.outl("")
cog.outl(" static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;")
cog.outl("")
cog.outl(" fsm_state()")
cog.outl(" : ifsm_state(STATE_ID)")
cog.outl(" {")
cog.outl(" }")
cog.outl("")
cog.outl("protected:")
cog.outl("")
cog.outl(" ~fsm_state()")
cog.outl(" {")
cog.outl(" }")
cog.outl("")
cog.outl(" TContext& get_fsm_context() const")
cog.outl(" {")
cog.outl(" return static_cast<TContext&>(ifsm_state::get_fsm_context());")
cog.outl(" }")
cog.outl("private:")
cog.outl("")
cog.outl(" etl::fsm_state_id_t process_event(const etl::imessage& message)")
cog.outl(" {")
cog.outl(" return p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message);")
cog.outl(" }")
cog.outl("};")
cog.outl("")
cog.outl("template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,")
cog.out(" ")
for n in range(1, int(Handlers)):
cog.out(" typename T%s," % n)
if n % 4 == 0:
cog.outl("")
cog.out(" ")
cog.outl(" typename T%s>" % Handlers)
cog.out("ETL_CONSTANT etl::fsm_state_id_t fsm_state<TContext, TDerived, STATE_ID_,")
for n in range(1, int(Handlers)):
cog.out(" T%s," % n)
cog.outl(" T%s>::STATE_ID;" % Handlers)
]]]*/
/*[[[end]]]*/

View File

@ -0,0 +1,18 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
/*[[[cog
import cog
cog.outl(" template <typename, typename, etl::fsm_state_id_t,")
cog.out(" ")
for n in range(1, int(Handlers)):
cog.out(" typename,")
if n % 4 == 0:
cog.outl("")
cog.out(" ")
cog.outl(" typename>")
]]]*/
/*[[[end]]]*/
friend class etl::fsm_state;

View File

@ -0,0 +1,18 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
/*[[[cog
import cog
cog.outl("template <typename, typename, etl::fsm_state_id_t,")
cog.out(" ")
for n in range(1, int(Handlers)):
cog.out(" typename,")
if n % 4 == 0:
cog.outl("")
cog.out(" ")
cog.outl(" typename>")
cog.outl("class fsm_state;")
]]]*/
/*[[[end]]]*/

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,13 @@
python3 -m cogapp -d -e -o../fsm.h -DHandlers=16 fsm_generator.h
python3 -m cogapp -d -e -o../message_router.h -DHandlers=16 message_router_generator.h
python3 -m cogapp -d -e -o../largest.h -DNTypes=16 largest_generator.h
python3 -m cogapp -d -e -o../smallest.h -DNTypes=16 smallest_generator.h
python3 -m cogapp -d -e -o../type_traits.h -DIsOneOf=16 type_traits_generator.h
python3 -m cogapp -d -e -o../type_lookup.h -DNTypes=16 type_lookup_generator.h
python3 -m cogapp -d -e -o../type_select.h -DNTypes=16 type_select_generator.h
python3 -m cogapp -d -e -o../message_packet.h -DHandlers=16 message_packet_generator.h
python3 -m cogapp -d -e -o../variant_pool.h -DNTypes=16 variant_pool_generator.h
python3 -m cogapp -d -e -o../private/fsm_fwd_decl_cpp03.h -DHandlers=16 fsm_fwd_decl_cpp03_generator.h
python3 -m cogapp -d -e -o../private/fsm_friend_decl_cpp03.h -DHandlers=16 fsm_friend_decl_cpp03_generator.h
python3 -m cogapp -d -e -o../private/fsm_cpp03.h -DHandlers=16 fsm_cpp03_generator.h
python3 -m cogapp -d -e -o../private/message_router_cpp03.h -DHandlers=16 message_router_cpp03_generator.h
python3 -m cogapp -d -e -o../private/largest_type_cpp03.h -DNTypes=16 largest_type_cpp03_generator.h
python3 -m cogapp -d -e -o../private/largest_alignment_cpp03.h -DNTypes=16 largest_alignment_cpp03_generator.h
python3 -m cogapp -d -e -o../private/largest_cpp03.h -DNTypes=16 largest_cpp03_generator.h
python3 -m cogapp -d -e -o../private/smallest_cpp03.h -DNTypes=16 smallest_cpp03_generator.h
python3 -m cogapp -d -e -o../private/type_traits_cpp03.h -DIsOneOf=16 type_traits_cpp03_generator.h
python3 -m cogapp -d -e -o../private/type_lookup_cpp03.h -DNTypes=16 type_lookup_cpp03_generator.h
python3 -m cogapp -d -e -o../private/type_select_cpp03.h -DNTypes=16 type_select_cpp03_generator.h
python3 -m cogapp -d -e -o../private/message_packet_cpp03.h -DHandlers=16 message_packet_cpp03_generator.h
python3 -m cogapp -d -e -o../private/variant_pool_cpp03.h -DNTypes=16 variant_pool_cpp03_generator.h

View File

@ -1 +1,3 @@
python3 -m cogapp -d -e -o../fsm.h -DHandlers=16 fsm_generator.h
python3 -m cogapp -d -e -o../private/fsm_fwd_decl_cpp03.h -DHandlers=16 fsm_fwd_decl_cpp03_generator.h
python3 -m cogapp -d -e -o../private/fsm_friend_decl_cpp03.h -DHandlers=16 fsm_friend_decl_cpp03_generator.h
python3 -m cogapp -d -e -o../private/fsm_cpp03.h -DHandlers=16 fsm_cpp03_generator.h

View File

@ -1 +1,3 @@
python3 -m cogapp -d -e -o../largest.h -DNTypes=16 largest_generator.h
python3 -m cogapp -d -e -o../private/largest_type_cpp03.h -DNTypes=16 largest_type_cpp03_generator.h
python3 -m cogapp -d -e -o../private/largest_alignment_cpp03.h -DNTypes=16 largest_alignment_cpp03_generator.h
python3 -m cogapp -d -e -o../private/largest_cpp03.h -DNTypes=16 largest_cpp03_generator.h

View File

@ -1 +1 @@
python3 -m cogapp -d -e -o../message_packet.h -DHandlers=16 message_packet_generator.h
python3 -m cogapp -d -e -o../private/message_packet_cpp03.h -DHandlers=16 message_packet_cpp03_generator.h

View File

@ -1 +1 @@
python3 -m cogapp -d -e -o../message_router.h -DHandlers=16 message_router_generator.h
python3 -m cogapp -d -e -o../private/message_router_cpp03.h -DHandlers=16 message_router_cpp03_generator.h

View File

@ -1 +1 @@
python3 -m cogapp -d -e -o../smallest.h -DNTypes=16 smallest_generator.h
python3 -m cogapp -d -e -o../private/smallest_cpp03.h -DNTypes=16 smallest_cpp03_generator.h

View File

@ -1 +1 @@
python3 -m cogapp -d -e -o../type_lookup.h -DNTypes=16 type_lookup_generator.h
python3 -m cogapp -d -e -o../private/type_lookup_cpp03.h -DNTypes=16 type_lookup_cpp03_generator.h

View File

@ -1 +1 @@
python3 -m cogapp -d -e -o../type_select.h -DNTypes=16 type_select_generator.h
python3 -m cogapp -d -e -o../private/type_select_cpp03.h -DNTypes=16 type_select_cpp03_generator.h

View File

@ -1 +1 @@
python3 -m cogapp -d -e -o../type_traits.h -DIsOneOf=16 type_traits_generator.h
python3 -m cogapp -d -e -o../private/type_traits_cpp03.h -DIsOneOf=16 type_traits_cpp03_generator.h

View File

@ -1 +1 @@
python3 -m cogapp -d -e -o../variant_pool.h -DNTypes=16 variant_pool_generator.h
python3 -m cogapp -d -e -o../private/variant_pool_cpp03.h -DNTypes=16 variant_pool_cpp03_generator.h

View File

@ -0,0 +1,66 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
/*[[[cog
import cog
cog.outl("//***************************************************************************")
cog.outl("/// Template to determine the largest alignment.")
cog.outl("/// Supports up to %s types." % int(NTypes))
cog.outl("/// Defines <b>value</b> which is the largest alignment of all the parameters.")
cog.outl("///\\ingroup largest")
cog.outl("//***************************************************************************")
cog.out("template <typename T1, ")
for n in range(2, int(NTypes)):
cog.out("typename T%s = void, " % n)
if n % 4 == 0:
cog.outl("")
cog.out(" ")
cog.outl("typename T%s = void>" % int(NTypes))
cog.outl("struct largest_alignment")
cog.outl("{")
cog.outl(" // Define 'largest_other' as 'largest_type' with all but the first parameter. ")
cog.out(" typedef typename largest_alignment<")
for n in range(2, int(NTypes)):
cog.out("T%s, " % n)
if n % 16 == 0:
cog.outl("")
cog.out(" ")
cog.outl("T%s>::type largest_other;" % int(NTypes))
cog.outl("")
cog.outl(" // Set 'type' to be the largest of the first parameter and any of the others.")
cog.outl(" // This is recursive.")
cog.outl(" typedef typename etl::conditional<(etl::alignment_of<T1>::value > etl::alignment_of<largest_other>::value), // Boolean")
cog.outl(" T1, // TrueType")
cog.outl(" largest_other> // FalseType")
cog.outl(" ::type type; // The largest type of the two.")
cog.outl("")
cog.outl(" // The largest alignment.")
cog.outl(" enum")
cog.outl(" {")
cog.outl(" value = etl::alignment_of<type>::value")
cog.outl(" };")
cog.outl("};")
cog.outl("")
cog.outl("//***************************************************************************")
cog.outl("// Specialisation for one template parameter.")
cog.outl("//***************************************************************************")
cog.outl("template <typename T1>")
cog.out("struct largest_alignment<T1, ")
for n in range(2, int(NTypes)):
cog.out("void, ")
if n % 8 == 0:
cog.outl("")
cog.out(" ")
cog.outl("void>")
cog.outl("{")
cog.outl(" typedef T1 type;")
cog.outl("")
cog.outl(" enum")
cog.outl(" {")
cog.outl(" value = etl::alignment_of<type>::value")
cog.outl(" };")
cog.outl("};")
]]]*/
/*[[[end]]]*/

View File

@ -0,0 +1,50 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
/*[[[cog
import cog
cog.outl("//***************************************************************************")
cog.outl("/// Template to determine the largest type, size and alignment.")
cog.outl("/// Supports up to %s types." % NTypes)
cog.outl("/// Defines <b>value</b> which is the largest type, size and alignment of all the parameters.")
cog.outl("///\\ingroup largest")
cog.outl("//***************************************************************************")
cog.out("template <typename T1, ")
for n in range(2, int(NTypes)):
cog.out("typename T%s = void, " % n)
if n % 4 == 0:
cog.outl("")
cog.out(" ")
cog.outl("typename T%s = void>" % NTypes)
cog.outl("struct largest")
cog.outl("{")
cog.out(" typedef typename etl::largest_type<")
for n in range(1, int(NTypes)):
cog.out("T%s, " % n)
if n % 16 == 0:
cog.outl("")
cog.out(" ")
cog.outl("T%s>::type type;" % NTypes)
cog.outl("")
cog.outl(" enum")
cog.outl(" {")
cog.out(" size = etl::largest_type<")
for n in range(1, int(NTypes)):
cog.out("T%s, " % n)
if n % 16 == 0:
cog.outl("")
cog.out(" ")
cog.outl("T%s>::size," % NTypes)
cog.out(" alignment = etl::largest_alignment<")
for n in range(1, int(NTypes)):
cog.out("T%s, " % n)
if n % 16 == 0:
cog.outl("")
cog.out(" ")
cog.outl("T%s>::value" % NTypes)
cog.outl(" };")
cog.outl("};")
]]]*/
/*[[[end]]]*/

View File

@ -1,452 +0,0 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2014 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
/*[[[cog
import cog
cog.outl("#if 0")
]]]*/
/*[[[end]]]*/
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
/*[[[cog
import cog
cog.outl("#endif")
]]]*/
/*[[[end]]]*/
/*[[[cog
import cog
cog.outl("//***************************************************************************")
cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.")
cog.outl("//***************************************************************************")
]]]*/
/*[[[end]]]*/
//***************************************************************************
// To generate to header file, run this at the command line.
// Note: You will need Python and COG installed.
//
// cog -d -e -olargest.h -DNTypes=<n> largest_generator.h
// Where <n> is the number of types to support.
//
// e.g.
// To generate handlers for up to 16 types...
// cog -d -e -olargest.h -DNTypes=16 largest_generator.h
//
// See generate.bat
//***************************************************************************
#ifndef ETL_LARGEST_INCLUDED
#define ETL_LARGEST_INCLUDED
///\defgroup largest largest
///\ingroup utilities
#include "platform.h"
#include "type_traits.h"
#include "smallest.h"
#include "static_assert.h"
namespace etl
{
#if ETL_USING_CPP11 && !defined(ETL_LARGEST_TYPE_FORCE_CPP03_IMPLEMENTATION)
//***************************************************************************
/// Template to determine the largest type and size.
/// Defines 'value_type' which is the type of the largest parameter.
/// Defines 'size' which is the size of the largest parameter.
///\ingroup largest
//***************************************************************************
template <typename T1, typename... TRest>
class largest_type
{
private:
// Define 'largest_other' as 'largest_type' with all but the first parameter.
using largest_other = typename largest_type<TRest...>::type;
public:
// Set 'type' to be the largest of the first parameter and any of the others.
// This is recursive.
using type = typename etl::conditional<(etl::size_of<T1>::value > etl::size_of<largest_other>::value), // Boolean
T1, // TrueType
largest_other> // FalseType
::type; // The largest type of the two.
// The size of the largest type.
enum
{
size = etl::size_of<type>::value
};
};
//***************************************************************************
// Specialisation for one template parameter.
//***************************************************************************
template <typename T1>
class largest_type<T1>
{
public:
using type = T1;
enum
{
size = etl::size_of<type>::value
};
};
#if ETL_USING_CPP11
template <typename... T>
using largest_type_t = typename largest_type<T...>::type;
#endif
#if ETL_USING_CPP17
template <typename... T>
constexpr size_t largest_type_v = largest_type<T...>::size;
#endif
#else
/*[[[cog
import cog
cog.outl("//***************************************************************************")
cog.outl("/// Template to determine the largest type and size.")
cog.outl("/// Supports up to %s types." % NTypes)
cog.outl("/// Defines 'value_type' which is the type of the largest parameter.")
cog.outl("/// Defines 'size' which is the size of the largest parameter.")
cog.outl("///\\ingroup largest")
cog.outl("//***************************************************************************")
cog.out("template <typename T1, ")
for n in range(2, int(NTypes)):
cog.out("typename T%s = void, " % n)
if n % 4 == 0:
cog.outl("")
cog.out(" ")
cog.outl("typename T%s = void>" % int(NTypes))
cog.outl("struct largest_type")
cog.outl("{")
cog.outl(" // Define 'largest_other' as 'largest_type' with all but the first parameter. ")
cog.out(" typedef typename largest_type<")
for n in range(2, int(NTypes)):
cog.out("T%s, " % n)
if n % 16 == 0:
cog.outl("")
cog.out(" ")
cog.outl("T%s>::type largest_other;" % int(NTypes))
cog.outl("")
cog.outl(" // Set 'type' to be the largest of the first parameter and any of the others.")
cog.outl(" // This is recursive.")
cog.outl(" typedef typename etl::conditional<(sizeof(T1) > sizeof(largest_other)), // Boolean")
cog.outl(" T1, // TrueType")
cog.outl(" largest_other> // FalseType")
cog.outl(" ::type type; // The largest type of the two.")
cog.outl("")
cog.outl(" // The size of the largest type.")
cog.outl(" enum")
cog.outl(" {")
cog.outl(" size = sizeof(type)")
cog.outl(" };")
cog.outl("};")
cog.outl("")
cog.outl("//***************************************************************************")
cog.outl("// Specialisation for one template parameter.")
cog.outl("//***************************************************************************")
cog.outl("template <typename T1>")
cog.out("struct largest_type<T1, ")
for n in range(2, int(NTypes)):
cog.out("void, ")
if n % 8 == 0:
cog.outl("")
cog.out(" ")
cog.outl("void>")
cog.outl("{")
cog.outl(" typedef T1 type;")
cog.outl("")
cog.outl(" enum")
cog.outl(" {")
cog.outl(" size = sizeof(type)")
cog.outl(" };")
cog.outl("};")
]]]*/
/*[[[end]]]*/
#endif
#if ETL_USING_CPP11 && !defined(ETL_LARGEST_ALIGNMENT_FORCE_CPP03_IMPLEMENTATION)
//***************************************************************************
/// Template to determine the largest alignment.
/// Defines <b>value</b> which is the largest alignment of all the parameters.
///\ingroup largest
//***************************************************************************
template <typename T1, typename... TRest>
struct largest_alignment
{
// Define 'largest_other' as 'largest_type' with all but the first parameter.
using largest_other = typename largest_alignment<TRest...>::type;
// Set 'type' to be the largest of the first parameter and any of the others.
// This is recursive.
using type = typename etl::conditional<(etl::alignment_of<T1>::value > etl::alignment_of<largest_other>::value), // Boolean
T1, // TrueType
largest_other> // FalseType
::type; // The largest type of the two.
// The largest alignment.
enum
{
value = etl::alignment_of<type>::value
};
};
//***************************************************************************
// Specialisation for one template parameter.
//***************************************************************************
template <typename T1>
struct largest_alignment<T1>
{
typedef T1 type;
enum
{
value = etl::alignment_of<type>::value
};
};
#if ETL_USING_CPP17
template <typename... T>
inline constexpr size_t largest_alignment_v = largest_alignment<T...>::value;
#endif
#else
/*[[[cog
import cog
cog.outl("//***************************************************************************")
cog.outl("/// Template to determine the largest alignment.")
cog.outl("/// Supports up to %s types." % int(NTypes))
cog.outl("/// Defines <b>value</b> which is the largest alignment of all the parameters.")
cog.outl("///\\ingroup largest")
cog.outl("//***************************************************************************")
cog.out("template <typename T1, ")
for n in range(2, int(NTypes)):
cog.out("typename T%s = void, " % n)
if n % 4 == 0:
cog.outl("")
cog.out(" ")
cog.outl("typename T%s = void>" % int(NTypes))
cog.outl("struct largest_alignment")
cog.outl("{")
cog.outl(" // Define 'largest_other' as 'largest_type' with all but the first parameter. ")
cog.out(" typedef typename largest_alignment<")
for n in range(2, int(NTypes)):
cog.out("T%s, " % n)
if n % 16 == 0:
cog.outl("")
cog.out(" ")
cog.outl("T%s>::type largest_other;" % int(NTypes))
cog.outl("")
cog.outl(" // Set 'type' to be the largest of the first parameter and any of the others.")
cog.outl(" // This is recursive.")
cog.outl(" typedef typename etl::conditional<(etl::alignment_of<T1>::value > etl::alignment_of<largest_other>::value), // Boolean")
cog.outl(" T1, // TrueType")
cog.outl(" largest_other> // FalseType")
cog.outl(" ::type type; // The largest type of the two.")
cog.outl("")
cog.outl(" // The largest alignment.")
cog.outl(" enum")
cog.outl(" {")
cog.outl(" value = etl::alignment_of<type>::value")
cog.outl(" };")
cog.outl("};")
cog.outl("")
cog.outl("//***************************************************************************")
cog.outl("// Specialisation for one template parameter.")
cog.outl("//***************************************************************************")
cog.outl("template <typename T1>")
cog.out("struct largest_alignment<T1, ")
for n in range(2, int(NTypes)):
cog.out("void, ")
if n % 8 == 0:
cog.outl("")
cog.out(" ")
cog.outl("void>")
cog.outl("{")
cog.outl(" typedef T1 type;")
cog.outl("")
cog.outl(" enum")
cog.outl(" {")
cog.outl(" value = etl::alignment_of<type>::value")
cog.outl(" };")
cog.outl("};")
]]]*/
/*[[[end]]]*/
#endif
//***************************************************************************
/// Defines a type that is as larger or larger than the specified type.
/// Will return the specified type is there is not a larger type.
///\\ingroup largest
//***************************************************************************
template <typename T>
struct larger_int_type
{
ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Must be an integral type");
typedef typename etl::smallest_int_for_bits<etl::integral_limits<typename etl::make_signed<T>::type>::bits + 1>::type type;
};
#if ETL_USING_CPP11
template <typename T>
using larger_int_type_t = typename larger_int_type<T>::type;
#endif
//***************************************************************************
/// Defines a type that is as larger or larger than the specified type.
/// Will return the specified type is there is not a larger type.
///\ingroup largest
//***************************************************************************
template <typename T>
struct larger_uint_type
{
ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Must be an integral type");
typedef typename etl::smallest_uint_for_bits<etl::integral_limits<typename etl::make_unsigned<T>::type>::bits + 1>::type type;
};
#if ETL_USING_CPP11
template <typename T>
using larger_uint_type_t = typename larger_uint_type<T>::type;
#endif
//***************************************************************************
/// Defines a type that is as larger or larger than the specified type.
/// Will return the specified type is there is not a larger type.
/// The returned type will be of the same sign.
///\ingroup largest
//***************************************************************************
template <typename T, bool IS_SIGNED = etl::is_signed<T>::value>
struct larger_type;
template <typename T>
struct larger_type<T, false>
{
ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Must be an integral type");
typedef typename etl::smallest_uint_for_bits<etl::integral_limits<T>::bits + 1>::type type;
};
template <typename T>
struct larger_type<T, true>
{
ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Must be an integral type");
typedef typename etl::smallest_int_for_bits<etl::integral_limits<T>::bits + 1>::type type;
};
#if ETL_USING_CPP11
template <typename T>
using larger_type_t = typename larger_type<T>::type;
#endif
#if ETL_USING_CPP11 && !defined(ETL_LARGEST_FORCE_CPP03_IMPLEMENTATION)
//***************************************************************************
/// Template to determine the largest type, size and alignment.
/// Defines <b>value</b> which is the largest type, size and alignment of all the parameters.
///\ingroup largest
//***************************************************************************
template <typename... T>
struct largest
{
using type = typename etl::largest_type<T...>::type;
enum
{
size = etl::largest_type<T...>::size,
alignment = etl::largest_alignment<T...>::value
};
};
#if ETL_USING_CPP11
template <typename... T>
using largest_t = typename largest<T...>::type;
#endif
#if ETL_USING_CPP17
template <typename... T>
inline constexpr size_t largest_size = largest<T...>::size;
#endif
#else
/*[[[cog
import cog
cog.outl("//***************************************************************************")
cog.outl("/// Template to determine the largest type, size and alignment.")
cog.outl("/// Supports up to %s types." % NTypes)
cog.outl("/// Defines <b>value</b> which is the largest type, size and alignment of all the parameters.")
cog.outl("///\\ingroup largest")
cog.outl("//***************************************************************************")
cog.out("template <typename T1, ")
for n in range(2, int(NTypes)):
cog.out("typename T%s = void, " % n)
if n % 4 == 0:
cog.outl("")
cog.out(" ")
cog.outl("typename T%s = void>" % NTypes)
cog.outl("struct largest")
cog.outl("{")
cog.out(" typedef typename etl::largest_type<")
for n in range(1, int(NTypes)):
cog.out("T%s, " % n)
if n % 16 == 0:
cog.outl("")
cog.out(" ")
cog.outl("T%s>::type type;" % NTypes)
cog.outl("")
cog.outl(" enum")
cog.outl(" {")
cog.out(" size = etl::largest_type<")
for n in range(1, int(NTypes)):
cog.out("T%s, " % n)
if n % 16 == 0:
cog.outl("")
cog.out(" ")
cog.outl("T%s>::size," % NTypes)
cog.out(" alignment = etl::largest_alignment<")
for n in range(1, int(NTypes)):
cog.out("T%s, " % n)
if n % 16 == 0:
cog.outl("")
cog.out(" ")
cog.outl("T%s>::value" % NTypes)
cog.outl(" };")
cog.outl("};")
]]]*/
/*[[[end]]]*/
#endif
}
#endif

View File

@ -0,0 +1,67 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
/*[[[cog
import cog
cog.outl("//***************************************************************************")
cog.outl("/// Template to determine the largest type and size.")
cog.outl("/// Supports up to %s types." % NTypes)
cog.outl("/// Defines 'type' which is the type of the largest parameter.")
cog.outl("/// Defines 'size' which is the size of the largest parameter.")
cog.outl("///\\ingroup largest")
cog.outl("//***************************************************************************")
cog.out("template <typename T1, ")
for n in range(2, int(NTypes)):
cog.out("typename T%s = void, " % n)
if n % 4 == 0:
cog.outl("")
cog.out(" ")
cog.outl("typename T%s = void>" % int(NTypes))
cog.outl("struct largest_type")
cog.outl("{")
cog.outl(" // Define 'largest_other' as 'largest_type' with all but the first parameter. ")
cog.out(" typedef typename largest_type<")
for n in range(2, int(NTypes)):
cog.out("T%s, " % n)
if n % 16 == 0:
cog.outl("")
cog.out(" ")
cog.outl("T%s>::type largest_other;" % int(NTypes))
cog.outl("")
cog.outl(" // Set 'type' to be the largest of the first parameter and any of the others.")
cog.outl(" // This is recursive.")
cog.outl(" typedef typename etl::conditional<(sizeof(T1) > sizeof(largest_other)), // Boolean")
cog.outl(" T1, // TrueType")
cog.outl(" largest_other> // FalseType")
cog.outl(" ::type type; // The largest type of the two.")
cog.outl("")
cog.outl(" // The size of the largest type.")
cog.outl(" enum")
cog.outl(" {")
cog.outl(" size = sizeof(type)")
cog.outl(" };")
cog.outl("};")
cog.outl("")
cog.outl("//***************************************************************************")
cog.outl("// Specialisation for one template parameter.")
cog.outl("//***************************************************************************")
cog.outl("template <typename T1>")
cog.out("struct largest_type<T1, ")
for n in range(2, int(NTypes)):
cog.out("void, ")
if n % 8 == 0:
cog.outl("")
cog.out(" ")
cog.outl("void>")
cog.outl("{")
cog.outl(" typedef T1 type;")
cog.outl("")
cog.outl(" enum")
cog.outl(" {")
cog.outl(" size = sizeof(type)")
cog.outl(" };")
cog.outl("};")
]]]*/
/*[[[end]]]*/

View File

@ -1,529 +1,7 @@
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2020 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
/*[[[cog
import cog
cog.outl("#if 0")
]]]*/
/*[[[end]]]*/
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
/*[[[cog
import cog
cog.outl("#endif")
]]]*/
/*[[[end]]]*/
/*[[[cog
import cog
cog.outl("//***************************************************************************")
cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.")
cog.outl("//***************************************************************************")
]]]*/
/*[[[end]]]*/
//***************************************************************************
// To generate to header file, run this at the command line.
// Note: You will need Python and COG installed.
//
// cog -d -e -omessage_packet.h -DHandlers=<n> message_packet_generator.h
// Where <n> is the number of messages to support.
//
// e.g.
// To generate handlers for up to 16 messages...
// cog -d -e -omessage_packet.h -DHandlers=16 message_packet_generator.h
//
// See generate.bat
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
#ifndef ETL_MESSAGE_PACKET_INCLUDED
#define ETL_MESSAGE_PACKET_INCLUDED
#include "platform.h"
#include "message.h"
#include "error_handler.h"
#include "static_assert.h"
#include "largest.h"
#include "alignment.h"
#include "utility.h"
#include "type_list.h"
#include <stdint.h>
namespace etl
{
#if ETL_USING_CPP17 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)
//***************************************************************************
// The definition for all message types.
//***************************************************************************
template <typename... TMessageTypes>
class message_packet
{
private:
template <typename T>
static constexpr bool IsMessagePacket = etl::is_same_v<etl::remove_const_t<etl::remove_reference_t<T>>, etl::message_packet<TMessageTypes...>>;
template <typename T>
static constexpr bool IsInMessageList = etl::is_one_of_v<etl::remove_const_t<etl::remove_reference_t<T>>, TMessageTypes...>;
template <typename T>
static constexpr bool IsIMessage = etl::is_same_v<etl::remove_const_t<etl::remove_reference_t<T>>, etl::imessage>;
public:
using message_types = etl::type_list<TMessageTypes...>;
//********************************************
#include "private/diagnostic_uninitialized_push.h"
constexpr message_packet() noexcept
: valid(false)
{
}
#include "private/diagnostic_pop.h"
//********************************************
///
//********************************************
#include "private/diagnostic_uninitialized_push.h"
template <typename T, typename = typename etl::enable_if<IsIMessage<T> || IsInMessageList<T>, int>::type>
explicit message_packet(T&& msg)
: valid(true)
{
if constexpr (IsIMessage<T>)
{
if (accepts(msg))
{
add_new_message(etl::forward<T>(msg));
valid = true;
}
else
{
valid = false;
}
ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception));
}
else if constexpr (IsInMessageList<T>)
{
add_new_message_type<T>(etl::forward<T>(msg));
}
else
{
ETL_STATIC_ASSERT(IsInMessageList<T>, "Message not in packet type list");
}
}
#include "private/diagnostic_pop.h"
//**********************************************
message_packet(const message_packet& other)
{
valid = other.is_valid();
if (valid)
{
add_new_message(other.get());
}
}
#if ETL_USING_CPP11
//**********************************************
message_packet(message_packet&& other)
{
valid = other.is_valid();
if (valid)
{
add_new_message(etl::move(other.get()));
}
}
#endif
//**********************************************
void copy(const message_packet& other)
{
valid = other.is_valid();
if (valid)
{
add_new_message(other.get());
}
}
//**********************************************
void copy(message_packet&& other)
{
valid = other.is_valid();
if (valid)
{
add_new_message(etl::move(other.get()));
}
}
//**********************************************
#include "private/diagnostic_uninitialized_push.h"
message_packet& operator =(const message_packet& rhs)
{
delete_current_message();
valid = rhs.is_valid();
if (valid)
{
add_new_message(rhs.get());
}
return *this;
}
#include "private/diagnostic_pop.h"
//**********************************************
#include "private/diagnostic_uninitialized_push.h"
message_packet& operator =(message_packet&& rhs)
{
delete_current_message();
valid = rhs.is_valid();
if (valid)
{
add_new_message(etl::move(rhs.get()));
}
return *this;
}
#include "private/diagnostic_pop.h"
//********************************************
~message_packet()
{
delete_current_message();
}
//********************************************
etl::imessage& get() ETL_NOEXCEPT
{
return *static_cast<etl::imessage*>(data);
}
//********************************************
const etl::imessage& get() const ETL_NOEXCEPT
{
return *static_cast<const etl::imessage*>(data);
}
//********************************************
bool is_valid() const
{
return valid;
}
//**********************************************
static ETL_CONSTEXPR bool accepts(etl::message_id_t id)
{
return (accepts_message<TMessageTypes::ID>(id) || ...);
}
//**********************************************
static ETL_CONSTEXPR bool accepts(const etl::imessage& msg)
{
return accepts(msg.get_message_id());
}
//**********************************************
template <etl::message_id_t Id>
static ETL_CONSTEXPR bool accepts()
{
return (accepts_message<TMessageTypes::ID, Id>() || ...);
}
//**********************************************
template <typename TMessage>
static ETL_CONSTEXPR
typename etl::enable_if<etl::is_base_of<etl::imessage, TMessage>::value, bool>::type
accepts()
{
return accepts<TMessage::ID>();
}
enum
{
SIZE = etl::largest<TMessageTypes...>::size,
ALIGNMENT = etl::largest<TMessageTypes...>::alignment
};
private:
//**********************************************
template <etl::message_id_t Id1, etl::message_id_t Id2>
static bool accepts_message()
{
return Id1 == Id2;
}
//**********************************************
template <etl::message_id_t Id1>
static bool accepts_message(etl::message_id_t id2)
{
return Id1 == id2;
}
//********************************************
#include "private/diagnostic_uninitialized_push.h"
void delete_current_message()
{
if (valid)
{
etl::imessage* pmsg = static_cast<etl::imessage*>(data);
#if ETL_HAS_VIRTUAL_MESSAGES
pmsg->~imessage();
#else
delete_message(pmsg);
#endif
}
}
#include "private/diagnostic_pop.h"
#if !ETL_HAS_VIRTUAL_MESSAGES
//********************************************
void delete_message(etl::imessage* pmsg)
{
(delete_message_type<TMessageTypes>(pmsg) || ...);
}
//********************************************
template <typename TType>
bool delete_message_type(etl::imessage* pmsg)
{
if (TType::ID == pmsg->get_message_id())
{
TType* p = static_cast<TType*>(pmsg);
p->~TType();
return true;
}
else
{
return false;
}
}
#endif
//********************************************
void add_new_message(const etl::imessage& msg)
{
(add_new_message_type<TMessageTypes>(msg) || ...);
}
//********************************************
void add_new_message(etl::imessage&& msg)
{
(add_new_message_type<TMessageTypes>(etl::move(msg)) || ...);
}
#include "private/diagnostic_uninitialized_push.h"
//********************************************
/// Only enabled for types that are in the typelist.
//********************************************
template <typename TMessage>
etl::enable_if_t<etl::is_one_of_v<etl::remove_const_t<etl::remove_reference_t<TMessage>>, TMessageTypes...>, void>
add_new_message_type(TMessage&& msg)
{
void* p = data;
new (p) etl::remove_reference_t<TMessage>((etl::forward<TMessage>(msg)));
}
#include "private/diagnostic_pop.h"
#include "private/diagnostic_uninitialized_push.h"
//********************************************
template <typename TType>
bool add_new_message_type(const etl::imessage& msg)
{
if (TType::ID == msg.get_message_id())
{
void* p = data;
new (p) TType(static_cast<const TType&>(msg));
return true;
}
else
{
return false;
}
}
#include "private/diagnostic_pop.h"
#include "private/diagnostic_uninitialized_push.h"
//********************************************
template <typename TType>
bool add_new_message_type(etl::imessage&& msg)
{
if (TType::ID == msg.get_message_id())
{
void* p = data;
new (p) TType(static_cast<TType&&>(msg));
return true;
}
else
{
return false;
}
}
#include "private/diagnostic_pop.h"
typename etl::aligned_storage<SIZE, ALIGNMENT>::type data;
bool valid;
};
//***************************************************************************
// The definition for no message types.
//***************************************************************************
template <>
class message_packet<>
{
private:
template <typename T>
static constexpr bool IsMessagePacket = etl::is_same_v<etl::remove_const_t<etl::remove_reference_t<T>>, etl::message_packet<>>;
template <typename T>
static constexpr bool IsInMessageList = false;
template <typename T>
static constexpr bool IsIMessage = etl::is_same_v<etl::remove_const_t<etl::remove_reference_t<T>>, etl::imessage>;
public:
using message_types = etl::type_list<>;
//********************************************
#include "private/diagnostic_uninitialized_push.h"
constexpr message_packet() noexcept
{
}
#include "private/diagnostic_pop.h"
//**********************************************
message_packet(const message_packet& /*other*/)
{
}
#if ETL_USING_CPP11
//**********************************************
message_packet(message_packet&& /*other*/)
{
}
#endif
//**********************************************
void copy(const message_packet& /*other*/)
{
}
//**********************************************
void copy(message_packet&& /*other*/)
{
}
//**********************************************
#include "private/diagnostic_uninitialized_push.h"
message_packet& operator =(const message_packet& /*rhs*/)
{
return *this;
}
#include "private/diagnostic_pop.h"
//**********************************************
#include "private/diagnostic_uninitialized_push.h"
message_packet& operator =(message_packet&& /*rhs*/)
{
return *this;
}
#include "private/diagnostic_pop.h"
//********************************************
~message_packet()
{
}
//********************************************
bool is_valid() const
{
return false;
}
//**********************************************
static ETL_CONSTEXPR bool accepts(etl::message_id_t /*id*/)
{
return false;
}
//**********************************************
static ETL_CONSTEXPR bool accepts(const etl::imessage& /*msg*/)
{
return false;
}
//**********************************************
template <etl::message_id_t Id>
static ETL_CONSTEXPR bool accepts()
{
return false;
}
//**********************************************
template <typename TMessage>
static ETL_CONSTEXPR
typename etl::enable_if<etl::is_base_of<etl::imessage, TMessage>::value, bool>::type
accepts()
{
return false;
}
enum
{
SIZE = 0,
ALIGNMENT = 1
};
};
//***************************************************************************
/// Helper to turn etl::type_list<TTypes...> into etl::message_packet<TTypes...>
template <typename TList>
struct message_packet_from_type_list;
template <typename... TTypes>
struct message_packet_from_type_list<etl::type_list<TTypes...>>
{
using type = etl::message_packet<TTypes...>;
};
template <typename TTypeList>
using message_packet_from_type_list_t = typename message_packet_from_type_list<TTypeList>::type;
#else
/*[[[cog
import cog
@ -611,7 +89,7 @@ namespace etl
cog.outl("{")
cog.outl("public:")
cog.outl("")
cog.outl("#if ETL_USING_CPP11")
cog.out(" using message_types = etl::type_list<")
for n in range(1, int(Handlers)):
@ -621,15 +99,15 @@ namespace etl
cog.outl("")
cog.outl(" //********************************************")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"diagnostic_uninitialized_push.h\"")
cog.outl(" ETL_CONSTEXPR message_packet() ETL_NOEXCEPT")
cog.outl(" : valid(false)")
cog.outl(" {")
cog.outl(" }")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#include \"diagnostic_pop.h\"")
cog.outl("")
cog.outl(" //********************************************")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"diagnostic_uninitialized_push.h\"")
cog.outl(" explicit message_packet(const etl::imessage& msg)")
cog.outl(" {")
cog.outl(" if (accepts(msg))")
@ -644,11 +122,11 @@ namespace etl
cog.outl("")
cog.outl(" ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception));")
cog.outl(" }")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#include \"diagnostic_pop.h\"")
cog.outl("")
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
cog.outl(" //********************************************")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"diagnostic_uninitialized_push.h\"")
cog.outl(" explicit message_packet(etl::imessage&& msg)")
cog.outl(" {")
cog.outl(" if (accepts(msg))")
@ -663,12 +141,12 @@ namespace etl
cog.outl("")
cog.outl(" ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception));")
cog.outl(" }")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#include \"diagnostic_pop.h\"")
cog.outl("#endif")
cog.outl("")
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS)")
cog.outl(" //********************************************")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"diagnostic_uninitialized_push.h\"")
cog.out(" template <typename TMessage, typename = typename etl::enable_if<!etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::message_packet<")
for n in range(1, int(Handlers)):
cog.out("T%s, " % n)
@ -683,10 +161,10 @@ namespace etl
cog.outl(" {")
generate_static_assert_cpp11(int(Handlers))
cog.outl(" }")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#include \"diagnostic_pop.h\"")
cog.outl("#else")
cog.outl(" //********************************************")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"diagnostic_uninitialized_push.h\"")
cog.outl(" template <typename TMessage>")
cog.out(" explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if<!etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::message_packet<")
for n in range(1, int(Handlers)):
@ -701,11 +179,11 @@ namespace etl
cog.outl(" {")
generate_static_assert_cpp03(int(Handlers))
cog.outl(" }")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#include \"diagnostic_pop.h\"")
cog.outl("#endif")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"diagnostic_uninitialized_push.h\"")
cog.outl(" message_packet(const message_packet& other)")
cog.outl(" : valid(other.is_valid())")
cog.outl(" {")
@ -714,11 +192,11 @@ namespace etl
cog.outl(" add_new_message(other.get());")
cog.outl(" }")
cog.outl(" }")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#include \"diagnostic_pop.h\"")
cog.outl("")
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
cog.outl(" //**********************************************")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"diagnostic_uninitialized_push.h\"")
cog.outl(" message_packet(message_packet&& other)")
cog.outl(" : valid(other.is_valid())")
cog.outl(" {")
@ -727,11 +205,11 @@ namespace etl
cog.outl(" add_new_message(etl::move(other.get()));")
cog.outl(" }")
cog.outl(" }")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#include \"diagnostic_pop.h\"")
cog.outl("#endif")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"diagnostic_uninitialized_push.h\"")
cog.outl(" message_packet& operator =(const message_packet& rhs)")
cog.outl(" {")
cog.outl(" delete_current_message();")
@ -743,11 +221,11 @@ namespace etl
cog.outl("")
cog.outl(" return *this;")
cog.outl(" }")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#include \"diagnostic_pop.h\"")
cog.outl("")
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
cog.outl(" //**********************************************")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"diagnostic_uninitialized_push.h\"")
cog.outl(" message_packet& operator =(message_packet&& rhs)")
cog.outl(" {")
cog.outl(" delete_current_message();")
@ -759,7 +237,7 @@ namespace etl
cog.outl("")
cog.outl(" return *this;")
cog.outl(" }")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#include \"diagnostic_pop.h\"")
cog.outl("#endif")
cog.outl("")
cog.outl(" //********************************************")
@ -829,7 +307,7 @@ namespace etl
cog.outl("private:")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" #include \"diagnostic_uninitialized_push.h\"")
cog.outl(" void delete_current_message()")
cog.outl(" {")
cog.outl(" if (valid)")
@ -843,7 +321,7 @@ namespace etl
cog.outl("#endif")
cog.outl(" }")
cog.outl(" }")
cog.outl(" #include \"private/diagnostic_pop.h\"")
cog.outl(" #include \"diagnostic_pop.h\"")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" void delete_message(etl::imessage* pmsg)")
@ -856,7 +334,7 @@ namespace etl
cog.outl(" default: ETL_ASSERT_FAIL(ETL_ERROR(unhandled_message_exception)); break;")
cog.outl(" }")
cog.outl(" }")
cog.outl("")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" void add_new_message(const etl::imessage& msg)")
cog.outl(" {")
@ -935,15 +413,15 @@ namespace etl
cog.outl("")
cog.outl(" //********************************************")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"diagnostic_uninitialized_push.h\"")
cog.outl(" ETL_CONSTEXPR message_packet() ETL_NOEXCEPT")
cog.outl(" : valid(false)")
cog.outl(" {")
cog.outl(" }")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#include \"diagnostic_pop.h\"")
cog.outl("")
cog.outl(" //********************************************")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"diagnostic_uninitialized_push.h\"")
cog.outl(" explicit message_packet(const etl::imessage& msg)")
cog.outl(" {")
cog.outl(" if (accepts(msg))")
@ -958,11 +436,11 @@ namespace etl
cog.outl("")
cog.outl(" ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception));")
cog.outl(" }")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#include \"diagnostic_pop.h\"")
cog.outl("")
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
cog.outl(" //********************************************")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"diagnostic_uninitialized_push.h\"")
cog.outl(" explicit message_packet(etl::imessage&& msg)")
cog.outl(" {")
cog.outl(" if (accepts(msg))")
@ -977,12 +455,12 @@ namespace etl
cog.outl("")
cog.outl(" ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception));")
cog.outl(" }")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#include \"diagnostic_pop.h\"")
cog.outl("#endif")
cog.outl("")
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS)")
cog.outl(" //********************************************")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"diagnostic_uninitialized_push.h\"")
cog.out(" template <typename TMessage, typename = typename etl::enable_if<!etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::message_packet<")
for t in range(1, n):
cog.out("T%s, " % t)
@ -997,10 +475,10 @@ namespace etl
cog.outl(" {")
generate_static_assert_cpp11(n)
cog.outl(" }")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#include \"diagnostic_pop.h\"")
cog.outl("#else")
cog.outl(" //********************************************")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"diagnostic_uninitialized_push.h\"")
cog.outl(" template <typename TMessage>")
cog.out(" explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if<!etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::message_packet<")
for t in range(1, n):
@ -1015,11 +493,11 @@ namespace etl
cog.outl(" {")
generate_static_assert_cpp03(n)
cog.outl(" }")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#include \"diagnostic_pop.h\"")
cog.outl("#endif")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"diagnostic_uninitialized_push.h\"")
cog.outl(" message_packet(const message_packet& other)")
cog.outl(" : valid(other.is_valid())")
cog.outl(" {")
@ -1028,11 +506,11 @@ namespace etl
cog.outl(" add_new_message(other.get());")
cog.outl(" }")
cog.outl(" }")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#include \"diagnostic_pop.h\"")
cog.outl("")
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
cog.outl(" //**********************************************")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"diagnostic_uninitialized_push.h\"")
cog.outl(" message_packet(message_packet&& other)")
cog.outl(" : valid(other.is_valid())")
cog.outl(" {")
@ -1041,11 +519,11 @@ namespace etl
cog.outl(" add_new_message(etl::move(other.get()));")
cog.outl(" }")
cog.outl(" }")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#include \"diagnostic_pop.h\"")
cog.outl("#endif")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"diagnostic_uninitialized_push.h\"")
cog.outl(" message_packet& operator =(const message_packet& rhs)")
cog.outl(" {")
cog.outl(" delete_current_message();")
@ -1057,11 +535,11 @@ namespace etl
cog.outl("")
cog.outl(" return *this;")
cog.outl(" }")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#include \"diagnostic_pop.h\"")
cog.outl("")
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
cog.outl(" //**********************************************")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"diagnostic_uninitialized_push.h\"")
cog.outl(" message_packet& operator =(message_packet&& rhs)")
cog.outl(" {")
cog.outl(" delete_current_message();")
@ -1073,7 +551,7 @@ namespace etl
cog.outl("")
cog.outl(" return *this;")
cog.outl(" }")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#include \"diagnostic_pop.h\"")
cog.outl("#endif")
cog.outl("")
cog.outl(" //********************************************")
@ -1143,7 +621,7 @@ namespace etl
cog.outl("private:")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" #include \"diagnostic_uninitialized_push.h\"")
cog.outl(" void delete_current_message()")
cog.outl(" {")
cog.outl(" if (valid)")
@ -1158,7 +636,7 @@ namespace etl
cog.outl("#endif")
cog.outl(" }")
cog.outl(" }")
cog.outl(" #include \"private/diagnostic_pop.h\"")
cog.outl(" #include \"diagnostic_pop.h\"")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" void delete_message(etl::imessage* pmsg)")
@ -1171,7 +649,7 @@ namespace etl
cog.outl(" default: ETL_ASSERT_FAIL(ETL_ERROR(unhandled_message_exception)); break;")
cog.outl(" }")
cog.outl(" }")
cog.outl("")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" void add_new_message(const etl::imessage& msg)")
cog.outl(" {")
@ -1263,7 +741,4 @@ namespace etl
bool valid;
};
#endif
}
#endif

View File

@ -0,0 +1,456 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
//*************************************************************************************************
// For C++03/98.
//*************************************************************************************************
/*[[[cog
import cog
################################################
# The first definition for all of the messages.
################################################
cog.outl("//***************************************************************************")
cog.outl("// The definition for all %s message types." % Handlers)
cog.outl("//***************************************************************************")
cog.outl("template <typename TDerived,")
cog.out(" ")
for n in range(1, int(Handlers)):
cog.out("typename T%s = void," % n)
if n % 4 == 0:
cog.outl("")
cog.out(" ")
else:
cog.out(" ")
cog.outl("typename T%s = void>" % int(Handlers))
cog.out("class message_router")
cog.outl(" : public imessage_router")
cog.outl("{")
cog.outl("public:")
cog.outl("")
cog.out(" typedef etl::message_packet<")
for n in range(1, int(Handlers)):
cog.out("T%s, " % n)
cog.outl("T%s> message_packet;" % int(Handlers))
cog.outl("")
cog.outl("#if ETL_USING_CPP11")
cog.out(" using message_types = etl::type_list<")
for n in range(1, int(Handlers)):
cog.out("T%s, " % n)
cog.outl("T%s>;" % int(Handlers))
cog.outl("#endif")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl(" message_router(etl::message_router_id_t id_)")
cog.outl(" : imessage_router(id_)")
cog.outl(" {")
cog.outl(" ETL_ASSERT(id_ <= etl::imessage_router::MAX_MESSAGE_ROUTER, ETL_ERROR(etl::message_router_illegal_id));")
cog.outl(" }")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl(" message_router(etl::message_router_id_t id_, etl::imessage_router& successor_)")
cog.outl(" : imessage_router(id_, successor_)")
cog.outl(" {")
cog.outl(" ETL_ASSERT(id_ <= etl::imessage_router::MAX_MESSAGE_ROUTER, ETL_ERROR(etl::message_router_illegal_id));")
cog.outl(" }")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl(" message_router()")
cog.outl(" : imessage_router(etl::imessage_router::MESSAGE_ROUTER)")
cog.outl(" {")
cog.outl(" }")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl(" message_router(etl::imessage_router& successor_)")
cog.outl(" : imessage_router(etl::imessage_router::MESSAGE_ROUTER, successor_)")
cog.outl(" {")
cog.outl(" }")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl(" using etl::imessage_router::receive;")
cog.outl("")
cog.outl(" void receive(const etl::imessage& msg) ETL_OVERRIDE")
cog.outl(" {")
cog.outl(" const etl::message_id_t id = msg.get_message_id();")
cog.outl("")
cog.outl("#include \"etl/private/diagnostic_array_bounds_push.h\"")
cog.outl(" switch (id)")
cog.outl(" {")
for n in range(1, int(Handlers) + 1):
cog.out(" case T%d::ID:" % n)
cog.out(" static_cast<TDerived*>(this)->on_receive(static_cast<const T%d&>(msg));" % n)
cog.outl(" break;")
cog.outl(" default:")
cog.outl(" {")
cog.outl(" if (has_successor())")
cog.outl(" {")
cog.outl(" get_successor().receive(msg);")
cog.outl(" }")
cog.outl(" else")
cog.outl(" {")
cog.outl(" static_cast<TDerived*>(this)->on_receive_unknown(msg);")
cog.outl(" }")
cog.outl(" break;")
cog.outl(" }")
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl(" }")
cog.outl("")
cog.outl(" template <typename TMessage>")
cog.out(" typename etl::enable_if<etl::is_message<TMessage>::value && etl::is_one_of<TMessage, ")
for n in range(1, int(Handlers)):
cog.out("T%s, " % n)
cog.outl("T%s>::value, void>::type" % int(Handlers))
cog.outl(" receive(const TMessage& msg)")
cog.outl(" {")
cog.outl("#include \"etl/private/diagnostic_array_bounds_push.h\"")
cog.outl(" static_cast<TDerived*>(this)->on_receive(msg);")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl(" }")
cog.outl("")
cog.outl(" template <typename TMessage>")
cog.out(" typename etl::enable_if<etl::is_message<TMessage>::value && !etl::is_one_of<TMessage, ")
for n in range(1, int(Handlers)):
cog.out("T%s, " % n)
cog.outl("T%s>::value, void>::type" % int(Handlers))
cog.outl(" receive(const TMessage& msg)")
cog.outl(" {")
cog.outl(" if (has_successor())")
cog.outl(" {")
cog.outl(" get_successor().receive(msg);")
cog.outl(" }")
cog.outl(" else")
cog.outl(" {")
cog.outl("#include \"etl/private/diagnostic_array_bounds_push.h\"")
cog.outl(" static_cast<TDerived*>(this)->on_receive_unknown(msg);")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl(" }")
cog.outl(" }")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl(" using imessage_router::accepts;")
cog.outl("")
cog.outl(" bool accepts(etl::message_id_t id) const ETL_OVERRIDE")
cog.outl(" {")
cog.outl(" switch (id)")
cog.outl(" {")
cog.out(" ")
for n in range(1, int(Handlers) + 1):
cog.out(" case T%d::ID:" % n)
if n % 8 == 0:
cog.outl("")
cog.out(" ")
cog.outl(" return true;")
cog.outl(" default:")
cog.outl(" {")
cog.outl(" if (has_successor())")
cog.outl(" {")
cog.outl(" return get_successor().accepts(id);")
cog.outl(" }")
cog.outl(" else")
cog.outl(" {")
cog.outl(" return false;")
cog.outl(" }")
cog.outl(" }")
cog.outl(" }")
cog.outl(" }")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" ETL_DEPRECATED bool is_null_router() const ETL_OVERRIDE")
cog.outl(" {")
cog.outl(" return false;")
cog.outl(" }")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" bool is_producer() const ETL_OVERRIDE")
cog.outl(" {")
cog.outl(" return true;")
cog.outl(" }")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" bool is_consumer() const ETL_OVERRIDE")
cog.outl(" {")
cog.outl(" return true;")
cog.outl(" }")
cog.outl("};")
####################################
# All of the other specialisations.
####################################
for n in range(int(Handlers) - 1, 0, -1):
cog.outl("")
cog.outl("//***************************************************************************")
if n == 1:
cog.outl("// Specialisation for %d message type." % n)
else:
cog.outl("// Specialisation for %d message types." % n)
cog.outl("//***************************************************************************")
cog.outl("template <typename TDerived,")
cog.out(" ")
for t in range(1, n):
cog.out("typename T%d," % t)
if t % 4 == 0:
cog.outl("")
cog.out(" ")
else:
cog.out(" ")
cog.outl("typename T%d>" % n)
cog.out("class message_router<TDerived, ")
for t in range(1, n + 1):
cog.out("T%d, " % t)
if t % 16 == 0:
cog.outl("")
cog.out(" ")
for t in range(n + 1, int(Handlers)):
cog.out("void, ")
if t % 16 == 0:
cog.outl("")
cog.out(" ")
cog.outl("void>")
cog.outl(" : public imessage_router")
cog.outl("{")
cog.outl("public:")
cog.outl("")
cog.out(" typedef etl::message_packet<")
for t in range(1, n):
cog.out("T%s, " % t)
cog.outl(" T%s> message_packet;" % n)
cog.outl("")
cog.outl("#if ETL_USING_CPP11")
cog.out(" using message_types = etl::type_list<")
for t in range(1, n):
cog.out("T%s, " % t)
cog.outl("T%s>;" % n)
cog.outl("#endif")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl(" message_router(etl::message_router_id_t id_)")
cog.outl(" : imessage_router(id_)")
cog.outl(" {")
cog.outl(" ETL_ASSERT(id_ <= etl::imessage_router::MAX_MESSAGE_ROUTER, ETL_ERROR(etl::message_router_illegal_id));")
cog.outl(" }")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl(" message_router(etl::message_router_id_t id_, etl::imessage_router& successor_)")
cog.outl(" : imessage_router(id_, successor_)")
cog.outl(" {")
cog.outl(" ETL_ASSERT(id_ <= etl::imessage_router::MAX_MESSAGE_ROUTER, ETL_ERROR(etl::message_router_illegal_id));")
cog.outl(" }")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl(" message_router()")
cog.outl(" : imessage_router(etl::imessage_router::MESSAGE_ROUTER)")
cog.outl(" {")
cog.outl(" }")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl(" message_router(etl::imessage_router& successor_)")
cog.outl(" : imessage_router(etl::imessage_router::MESSAGE_ROUTER, successor_)")
cog.outl(" {")
cog.outl(" }")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl(" using etl::imessage_router::receive;")
cog.outl("")
cog.outl(" void receive(const etl::imessage& msg) ETL_OVERRIDE")
cog.outl(" {")
cog.outl(" const etl::message_id_t id = msg.get_message_id();")
cog.outl("")
cog.outl("#include \"etl/private/diagnostic_array_bounds_push.h\"")
cog.outl(" switch (id)")
cog.outl(" {")
for t in range(1, n + 1):
cog.out(" case T%d::ID:" % t)
cog.out(" static_cast<TDerived*>(this)->on_receive(static_cast<const T%d&>(msg));" % t)
cog.outl(" break;")
cog.outl(" default:")
cog.outl(" {")
cog.outl(" if (has_successor())")
cog.outl(" {")
cog.outl(" get_successor().receive(msg);")
cog.outl(" }")
cog.outl(" else")
cog.outl(" {")
cog.outl(" static_cast<TDerived*>(this)->on_receive_unknown(msg);")
cog.outl(" }")
cog.outl(" break;")
cog.outl(" }")
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl(" }")
cog.outl("")
cog.outl(" template <typename TMessage>")
cog.out(" typename etl::enable_if<etl::is_message<TMessage>::value && etl::is_one_of<TMessage, ")
for t in range(1, n):
cog.out("T%s, " % t)
cog.outl("T%s>::value, void>::type" % n)
cog.outl(" receive(const TMessage& msg)")
cog.outl(" {")
cog.outl("#include \"etl/private/diagnostic_array_bounds_push.h\"")
cog.outl(" static_cast<TDerived*>(this)->on_receive(msg);")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl(" }")
cog.outl("")
cog.outl(" template <typename TMessage>")
cog.out(" typename etl::enable_if<etl::is_message<TMessage>::value && !etl::is_one_of<TMessage, ")
for t in range(1, n):
cog.out("T%s, " % t)
cog.outl("T%s>::value, void>::type" % n)
cog.outl(" receive(const TMessage& msg)")
cog.outl(" {")
cog.outl(" if (has_successor())")
cog.outl(" {")
cog.outl(" get_successor().receive(msg);")
cog.outl(" }")
cog.outl(" else")
cog.outl(" {")
cog.outl("#include \"etl/private/diagnostic_array_bounds_push.h\"")
cog.outl(" static_cast<TDerived*>(this)->on_receive_unknown(msg);")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl(" }")
cog.outl(" }")
cog.outl("")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl(" using imessage_router::accepts;")
cog.outl("")
cog.outl(" bool accepts(etl::message_id_t id) const ETL_OVERRIDE")
cog.outl(" {")
cog.outl(" switch (id)")
cog.outl(" {")
cog.out(" ")
for t in range(1, n + 1):
cog.out(" case T%d::ID:" % t)
if t % 8 == 0:
cog.outl("")
if t != n:
cog.out(" ")
cog.outl("")
cog.outl(" return true;")
cog.outl(" default:")
cog.outl(" {")
cog.outl(" if (has_successor())")
cog.outl(" {")
cog.outl(" return get_successor().accepts(id);")
cog.outl(" }")
cog.outl(" else")
cog.outl(" {")
cog.outl(" return false;")
cog.outl(" }")
cog.outl(" }")
cog.outl(" }")
cog.outl(" }")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" ETL_DEPRECATED bool is_null_router() const ETL_OVERRIDE")
cog.outl(" {")
cog.outl(" return false;")
cog.outl(" }")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" bool is_producer() const ETL_OVERRIDE")
cog.outl(" {")
cog.outl(" return true;")
cog.outl(" }")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" bool is_consumer() const ETL_OVERRIDE")
cog.outl(" {")
cog.outl(" return true;")
cog.outl(" }")
cog.outl("};")
]]]*/
/*[[[end]]]*/
//***************************************************************************
// Specialisation for 0 message types.
//***************************************************************************
template <typename TDerived>
class message_router<TDerived, void, void, void, void, void, void, void, void, void, void, void, void, void, void, void, void>
: public imessage_router
{
public:
typedef etl::message_packet<> message_packet;
#if ETL_USING_CPP11
using message_types = etl::type_list<>;
#endif
//**********************************************
message_router(etl::message_router_id_t id_)
: imessage_router(id_)
{
ETL_ASSERT(id_ <= etl::imessage_router::MAX_MESSAGE_ROUTER, ETL_ERROR(etl::message_router_illegal_id));
}
//**********************************************
message_router(etl::message_router_id_t id_, etl::imessage_router& successor_)
: imessage_router(id_, successor_)
{
ETL_ASSERT(id_ <= etl::imessage_router::MAX_MESSAGE_ROUTER, ETL_ERROR(etl::message_router_illegal_id));
}
//**********************************************
message_router()
: imessage_router(etl::imessage_router::MESSAGE_ROUTER)
{
}
//**********************************************
message_router(etl::imessage_router& successor_)
: imessage_router(etl::imessage_router::MESSAGE_ROUTER, successor_)
{
}
//**********************************************
using etl::imessage_router::receive;
void receive(const etl::imessage& msg) ETL_OVERRIDE
{
#include "etl/private/diagnostic_array_bounds_push.h"
if (has_successor())
{
get_successor().receive(msg);
}
#include "etl/private/diagnostic_pop.h"
}
//**********************************************
using imessage_router::accepts;
bool accepts(etl::message_id_t id) const ETL_OVERRIDE
{
if (has_successor())
{
return get_successor().accepts(id);
}
else
{
return false;
}
}
//********************************************
ETL_DEPRECATED bool is_null_router() const ETL_OVERRIDE
{
return false;
}
//********************************************
bool is_producer() const ETL_OVERRIDE
{
return true;
}
//********************************************
bool is_consumer() const ETL_OVERRIDE
{
return true;
}
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,91 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
/*[[[cog
import cog
cog.outl("//***************************************************************************")
cog.outl("/// Template to determine the smallest type and size.")
cog.outl("/// Supports up to %s types." % NTypes)
cog.outl("/// Defines 'value_type' which is the type of the smallest parameter.")
cog.outl("/// Defines 'size' which is the size of the smallest parameter.")
cog.outl("///\\ingroup smallest")
cog.outl("//***************************************************************************")
cog.out("template <typename T1, ")
for n in range(2, int(NTypes)):
cog.out("typename T%s = void, " % n)
if n % 4 == 0:
cog.outl("")
cog.out(" ")
cog.outl("typename T%s = void>" % int(NTypes))
cog.outl("struct smallest_type")
cog.outl("{")
cog.outl("private:")
cog.outl("")
cog.outl(" // Declaration.")
cog.outl(" template <bool Boolean, typename TrueType, typename FalseType>")
cog.outl(" struct choose_type;")
cog.outl("")
cog.outl(" // Specialisation for 'true'.")
cog.outl(" // Defines 'type' as 'TrueType'.")
cog.outl(" template <typename TrueType, typename FalseType>")
cog.outl(" struct choose_type<true, TrueType, FalseType>")
cog.outl(" {")
cog.outl(" typedef TrueType type;")
cog.outl(" };")
cog.outl("")
cog.outl(" // Specialisation for 'false'. ")
cog.outl(" // Defines 'type' as 'FalseType'.")
cog.outl(" template <typename TrueType, typename FalseType>")
cog.outl(" struct choose_type<false, TrueType, FalseType>")
cog.outl(" {")
cog.outl(" typedef FalseType type;")
cog.outl(" };")
cog.outl("")
cog.outl("public:")
cog.outl("")
cog.outl(" // Define 'smallest_other' as 'smallest_type' with all but the first parameter. ")
cog.out(" typedef typename smallest_type<")
for n in range(2, int(NTypes)):
cog.out("T%s, " % n)
if n % 16 == 0:
cog.outl("")
cog.out(" ")
cog.outl("T%s>::type smallest_other;" % int(NTypes))
cog.outl("")
cog.outl(" // Set 'type' to be the smallest of the first parameter and any of the others.")
cog.outl(" // This is recursive.")
cog.outl(" typedef typename choose_type<(sizeof(T1) < sizeof(smallest_other)), // Boolean")
cog.outl(" T1, // TrueType")
cog.outl(" smallest_other> // FalseType")
cog.outl(" ::type type; // The smallest type of the two.")
cog.outl("")
cog.outl(" // The size of the smallest type.")
cog.outl(" enum")
cog.outl(" {")
cog.outl(" size = sizeof(type)")
cog.outl(" };")
cog.outl("};")
cog.outl("")
cog.outl("//***************************************************************************")
cog.outl("// Specialisation for one template parameter.")
cog.outl("//***************************************************************************")
cog.outl("template <typename T1>")
cog.out("struct smallest_type<T1, ")
for n in range(2, int(NTypes)):
cog.out("void, ")
if n % 8 == 0:
cog.outl("")
cog.out(" ")
cog.outl("void>")
cog.outl("{")
cog.outl(" typedef T1 type;")
cog.outl("")
cog.outl(" enum")
cog.outl(" {")
cog.outl(" size = sizeof(type)")
cog.outl(" };")
cog.outl("};")
]]]*/
/*[[[end]]]*/

View File

@ -1,432 +0,0 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2014 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
/*[[[cog
import cog
cog.outl("#if 0")
]]]*/
/*[[[end]]]*/
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
/*[[[cog
import cog
cog.outl("#endif")
]]]*/
/*[[[end]]]*/
/*[[[cog
import cog
cog.outl("//***************************************************************************")
cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.")
cog.outl("//***************************************************************************")
]]]*/
/*[[[end]]]*/
//***************************************************************************
// To generate to header file, run this at the command line.
// Note: You will need Python and COG installed.
//
// cog -d -e -osmallest.h -DNTypes=<n> smallest_generator.h
// Where <n> is the number of types to support.
//
// e.g.
// To generate handlers for up to 16 types...
// cog -d -e -osmallest.h -DNTypes=16 smallest_generator.h
//
// See generate.bat
//***************************************************************************
#ifndef ETL_SMALLEST_INCLUDED
#define ETL_SMALLEST_INCLUDED
#include "platform.h"
#include "integral_limits.h"
#include <stdint.h>
///\defgroup smallest smallest
///\ingroup utilities
namespace etl
{
#if ETL_USING_CPP11 && !defined(ETL_SMALLEST_TYPE_FORCE_CPP03_IMPLEMENTATION)
//***************************************************************************
/// Template to determine the largest type and size.
/// Defines 'value_type' which is the type of the largest parameter.
/// Defines 'size' which is the size of the largest parameter.
///\ingroup largest
//***************************************************************************
template <typename T1, typename... TRest>
class smallest_type
{
private:
// Define 'smallest_other' as 'smallest_type' with all but the first parameter.
using smallest_other = typename smallest_type<TRest...>::type;
public:
// Set 'type' to be the smallest of the first parameter and any of the others.
// This is recursive.
using type = typename etl::conditional<(etl::size_of<T1>::value < etl::size_of<smallest_other>::value), // Boolean
T1, // TrueType
smallest_other> // FalseType
::type; // The smallest type of the two.
// The size of the smallest type.
enum
{
size = etl::size_of<type>::value
};
};
//***************************************************************************
// Specialisation for one template parameter.
//***************************************************************************
template <typename T1>
class smallest_type<T1>
{
public:
using type = T1;
enum
{
size = etl::size_of<type>::value
};
};
#if ETL_USING_CPP11
template <typename... T>
using smallest_type_t = typename smallest_type<T...>::type;
#endif
#if ETL_USING_CPP17
template <typename... T>
constexpr size_t smallest_type_v = smallest_type<T...>::size;
#endif
#else
/*[[[cog
import cog
cog.outl("//***************************************************************************")
cog.outl("/// Template to determine the smallest type and size.")
cog.outl("/// Supports up to %s types." % NTypes)
cog.outl("/// Defines 'value_type' which is the type of the smallest parameter.")
cog.outl("/// Defines 'size' which is the size of the smallest parameter.")
cog.outl("///\\ingroup smallest")
cog.outl("//***************************************************************************")
cog.out("template <typename T1, ")
for n in range(2, int(NTypes)):
cog.out("typename T%s = void, " % n)
if n % 4 == 0:
cog.outl("")
cog.out(" ")
cog.outl("typename T%s = void>" % int(NTypes))
cog.outl("struct smallest_type")
cog.outl("{")
cog.outl("private:")
cog.outl("")
cog.outl(" // Declaration.")
cog.outl(" template <bool Boolean, typename TrueType, typename FalseType>")
cog.outl(" struct choose_type;")
cog.outl("")
cog.outl(" // Specialisation for 'true'.")
cog.outl(" // Defines 'type' as 'TrueType'.")
cog.outl(" template <typename TrueType, typename FalseType>")
cog.outl(" struct choose_type<true, TrueType, FalseType>")
cog.outl(" {")
cog.outl(" typedef TrueType type;")
cog.outl(" };")
cog.outl("")
cog.outl(" // Specialisation for 'false'. ")
cog.outl(" // Defines 'type' as 'FalseType'.")
cog.outl(" template <typename TrueType, typename FalseType>")
cog.outl(" struct choose_type<false, TrueType, FalseType>")
cog.outl(" {")
cog.outl(" typedef FalseType type;")
cog.outl(" };")
cog.outl("")
cog.outl("public:")
cog.outl("")
cog.outl(" // Define 'smallest_other' as 'smallest_type' with all but the first parameter. ")
cog.out(" typedef typename smallest_type<")
for n in range(2, int(NTypes)):
cog.out("T%s, " % n)
if n % 16 == 0:
cog.outl("")
cog.out(" ")
cog.outl("T%s>::type smallest_other;" % int(NTypes))
cog.outl("")
cog.outl(" // Set 'type' to be the smallest of the first parameter and any of the others.")
cog.outl(" // This is recursive.")
cog.outl(" typedef typename choose_type<(sizeof(T1) < sizeof(smallest_other)), // Boolean")
cog.outl(" T1, // TrueType")
cog.outl(" smallest_other> // FalseType")
cog.outl(" ::type type; // The smallest type of the two.")
cog.outl("")
cog.outl(" // The size of the smallest type.")
cog.outl(" enum")
cog.outl(" {")
cog.outl(" size = sizeof(type)")
cog.outl(" };")
cog.outl("};")
cog.outl("")
cog.outl("//***************************************************************************")
cog.outl("// Specialisation for one template parameter.")
cog.outl("//***************************************************************************")
cog.outl("template <typename T1>")
cog.out("struct smallest_type<T1, ")
for n in range(2, int(NTypes)):
cog.out("void, ")
if n % 8 == 0:
cog.outl("")
cog.out(" ")
cog.outl("void>")
cog.outl("{")
cog.outl(" typedef T1 type;")
cog.outl("")
cog.outl(" enum")
cog.outl(" {")
cog.outl(" size = sizeof(type)")
cog.outl(" };")
cog.outl("};")
]]]*/
/*[[[end]]]*/
#endif
namespace private_smallest
{
//*************************************************************************
// Determine the type to hold the number of bits based on the index.
//*************************************************************************
template <int index>
struct best_fit_uint_type;
//*************************************************************************
// Less than or equal to 8 bits.
//*************************************************************************
template <>
struct best_fit_uint_type<0>
{
typedef uint_least8_t type;
};
//*************************************************************************
// 9 to 16 bits.
//*************************************************************************
template <>
struct best_fit_uint_type<1>
{
typedef uint_least16_t type;
};
//*************************************************************************
// 17 to 31 bits.
//*************************************************************************
template <>
struct best_fit_uint_type<2>
{
typedef uint_least32_t type;
};
#if ETL_USING_64BIT_TYPES
//*************************************************************************
// Greater than 32 bits.
//*************************************************************************
template <>
struct best_fit_uint_type<3>
{
typedef uint_least64_t type;
};
#endif
//*************************************************************************
// Determine the type to hold the number of bits based on the index.
//*************************************************************************
template <int index>
struct best_fit_int_type;
//*************************************************************************
// Less than or equal to 8 bits.
//*************************************************************************
template <>
struct best_fit_int_type<0>
{
typedef int_least8_t type;
};
//*************************************************************************
// 9 to 16 bits.
//*************************************************************************
template <>
struct best_fit_int_type<1>
{
typedef int_least16_t type;
};
//*************************************************************************
// 17 to 31 bits.
//*************************************************************************
template <>
struct best_fit_int_type<2>
{
typedef int_least32_t type;
};
#if ETL_USING_64BIT_TYPES
//*************************************************************************
// Greater than 32 bits.
//*************************************************************************
template <>
struct best_fit_int_type<3>
{
typedef int_least64_t type;
};
#endif
}
//***************************************************************************
/// Template to determine the smallest unsigned int type that can contain a
/// value with the specified number of bits.
/// Defines 'type' which is the type of the smallest unsigned integer.
///\ingroup smallest
//***************************************************************************
template <size_t NBITS>
struct smallest_uint_for_bits
{
private:
// Determines the index of the best unsigned type for the required number of bits.
static ETL_CONSTANT int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) +
((NBITS > 16) ? 1 : 0) +
((NBITS > 32) ? 1 : 0);
public:
typedef typename private_smallest::best_fit_uint_type<TYPE_INDEX>::type type;
};
template <size_t NBITS>
ETL_CONSTANT int smallest_uint_for_bits<NBITS>::TYPE_INDEX;
#if ETL_USING_CPP11
template <size_t NBITS>
using smallest_uint_for_bits_t = typename smallest_uint_for_bits<NBITS>::type;
#endif
//***************************************************************************
/// Template to determine the smallest signed int type that can contain a
/// value with the specified number of bits.
/// Defines 'type' which is the type of the smallest signed integer.
///\ingroup smallest
//***************************************************************************
template <size_t NBITS>
struct smallest_int_for_bits
{
private:
// Determines the index of the best unsigned type for the required number of bits.
static ETL_CONSTANT int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) +
((NBITS > 16) ? 1 : 0) +
((NBITS > 32) ? 1 : 0);
public:
typedef typename private_smallest::best_fit_int_type<TYPE_INDEX>::type type;
};
template <size_t NBITS>
ETL_CONSTANT int smallest_int_for_bits<NBITS>::TYPE_INDEX;
#if ETL_USING_CPP11
template <size_t NBITS>
using smallest_int_for_bits_t = typename smallest_int_for_bits<NBITS>::type;
#endif
//***************************************************************************
/// Template to determine the smallest unsigned int type that can contain the
/// specified unsigned value.
/// Defines 'type' which is the type of the smallest unsigned integer.
///\ingroup smallest
//***************************************************************************
template <uintmax_t VALUE>
struct smallest_uint_for_value
{
private:
// Determines the index of the best unsigned type for the required value.
static ETL_CONSTANT int TYPE_INDEX = ((VALUE > UINT_LEAST8_MAX) ? 1 : 0) +
((VALUE > UINT16_MAX) ? 1 : 0) +
((VALUE > UINT32_MAX) ? 1 : 0);
public:
typedef typename private_smallest::best_fit_uint_type<TYPE_INDEX>::type type;
};
template <uintmax_t VALUE>
ETL_CONSTANT int smallest_uint_for_value<VALUE>::TYPE_INDEX;
#if ETL_USING_CPP11
template <uintmax_t VALUE>
using smallest_uint_for_value_t = typename smallest_uint_for_value<VALUE>::type;
#endif
//***************************************************************************
/// Template to determine the smallest int type that can contain the
/// specified signed value.
/// Defines 'type' which is the type of the smallest signed integer.
///\ingroup smallest
//***************************************************************************
template <intmax_t VALUE>
struct smallest_int_for_value
{
private:
// Determines the index of the best signed type for the required value.
static ETL_CONSTANT int TYPE_INDEX = (((VALUE > intmax_t(INT_LEAST8_MAX)) || (VALUE < intmax_t(INT_LEAST8_MIN))) ? 1 : 0) +
(((VALUE > intmax_t(INT16_MAX)) || (VALUE < intmax_t(INT16_MIN))) ? 1 : 0) +
(((VALUE > intmax_t(INT32_MAX)) || (VALUE < intmax_t(INT32_MIN))) ? 1 : 0);
public:
typedef typename private_smallest::best_fit_int_type<TYPE_INDEX>::type type;
};
template <intmax_t VALUE>
ETL_CONSTANT int smallest_int_for_value<VALUE>::TYPE_INDEX;
#if ETL_USING_CPP11
template <intmax_t VALUE>
using smallest_int_for_value_t = typename smallest_int_for_value<VALUE>::type;
#endif
}
#endif

View File

@ -0,0 +1,109 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
/*[[[cog
import cog
cog.outl("//***************************************************************************")
cog.outl("// For %s types." % int(NTypes))
cog.outl("//***************************************************************************")
cog.outl("template <typename T1,")
for n in range(2, int(NTypes)):
cog.outl(" typename T%s = etl::type_id_pair<etl::null_type<0>, -%s>," %(n, n))
cog.outl(" typename T%s = etl::type_id_pair<etl::null_type<0>, -%s> >" %(NTypes, NTypes))
cog.outl("struct type_id_lookup")
cog.outl("{")
cog.outl("public:")
cog.outl("")
cog.outl(" //************************************")
cog.outl(" template <int Id>")
cog.outl(" struct type_from_id")
cog.outl(" {")
cog.outl(" typedef")
for n in range(1, int(NTypes) + 1):
cog.outl(" typename etl::conditional<Id == T%s::Id, typename T%s::type," %(n, n))
cog.out(" etl::null_type<0> >")
for n in range(1, int(NTypes) + 1):
if n == int(NTypes):
cog.outl("::type type;")
else:
cog.out("::type>")
if n % 4 == 0:
if n != int(NTypes):
cog.outl("")
cog.out(" ")
cog.outl("")
cog.outl(" ETL_STATIC_ASSERT(!(etl::is_same<etl::null_type<0>, type>::value), \"Invalid id\");")
cog.outl(" };")
cog.outl("")
cog.outl(" //************************************")
cog.outl(" enum")
cog.outl(" {")
cog.outl(" UNKNOWN = UINT_MAX")
cog.outl(" };")
cog.outl("")
cog.outl(" template <typename T>")
cog.outl(" struct id_from_type")
cog.outl(" {")
cog.outl(" enum")
cog.outl(" {")
cog.outl(" value =")
for n in range(1, int(NTypes) + 1) :
cog.outl(" (unsigned int) etl::is_same<T, typename T%s::type>::value ? (unsigned int)T%s::Id :" % (n, n))
cog.outl(" (unsigned int) UNKNOWN")
cog.outl(" };")
cog.outl("")
cog.outl(" ETL_STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), \"Invalid type\");")
cog.outl(" };")
cog.outl("")
cog.outl(" //************************************")
cog.outl(" template <typename T>")
cog.outl(" static unsigned int get_id_from_type(const T&)")
cog.outl(" {")
cog.outl(" return get_id_from_type<T>();")
cog.outl(" }")
cog.outl("")
cog.outl(" //************************************")
cog.outl(" template <typename T>")
cog.outl(" static unsigned int get_id_from_type()")
cog.outl(" {")
cog.outl(" return id_from_type<T>::value;")
cog.outl(" }")
cog.outl("};")
cog.outl("")
cog.outl("//***************************************************************************")
cog.outl("// For %s types." % int(NTypes))
cog.outl("//***************************************************************************")
cog.outl("template <typename T1,")
for n in range(2, int(NTypes)):
cog.outl(" typename T%s = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >," %n)
cog.outl(" typename T%s = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> > >" %NTypes)
cog.outl("struct type_type_lookup")
cog.outl("{")
cog.outl("public:")
cog.outl("")
cog.outl(" //************************************")
cog.outl(" template <typename T>")
cog.outl(" struct type_from_type")
cog.outl(" {")
cog.outl(" typedef")
for n in range(1, int(NTypes) + 1):
cog.outl(" typename etl::conditional<etl::is_same<T, typename T%s::type1>::value, typename T%s::type2," %(n, n))
cog.out(" etl::null_type<0> >")
for n in range(1, int(NTypes) + 1):
if n == int(NTypes):
cog.outl("::type type;")
else:
cog.out("::type>")
if n % 8 == 0:
if n != int(NTypes):
cog.outl("")
cog.out(" ")
cog.outl("")
cog.outl(" ETL_STATIC_ASSERT(!(etl::is_same<etl::null_type<0>, type>::value), \"Invalid type\");")
cog.outl(" };")
cog.outl("};")
]]]*/
/*[[[end]]]*/

View File

@ -1,337 +0,0 @@
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_TYPE_LOOKUP_INCLUDED
#define ETL_TYPE_LOOKUP_INCLUDED
#include "platform.h"
#include "type_traits.h"
#include "static_assert.h"
#include "integral_limits.h"
#include "null_type.h"
#include <limits.h>
/*[[[cog
import cog
cog.outl("#if 0")
]]]*/
/*[[[end]]]*/
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
/*[[[cog
import cog
cog.outl("#endif")
]]]*/
/*[[[end]]]*/
/*[[[cog
import cog
cog.outl("//***************************************************************************")
cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.")
cog.outl("//***************************************************************************")
]]]*/
/*[[[end]]]*/
namespace etl
{
//***************************************************************************
/// The type/id pair type to use for type/id lookup template parameters.
//***************************************************************************
template <typename T, int ID_>
struct type_id_pair
{
typedef T type;
enum
{
Id = ID_
};
};
//***************************************************************************
/// The type/type pair type to use for type/type lookup template parameters.
//***************************************************************************
template <typename T1, typename T2>
struct type_type_pair
{
typedef T1 type1;
typedef T2 type2;
};
#if ETL_USING_CPP11 && !defined(ETL_TYPE_SELECT_FORCE_CPP03_IMPLEMENTATION)
//***************************************************************************
// type_id_lookup
//***************************************************************************
template <typename... TTypes>
struct type_id_lookup
{
private:
// The type for no match.
struct nulltype {};
// For N type pairs.
template <int Id, typename T1, typename... TRest>
struct type_from_id_helper
{
using type = typename etl::conditional<Id == T1::Id,
typename T1::type,
typename type_from_id_helper<Id, TRest...>::type>::type;
};
// Specialisation for 1 type pair.
template <int Id, typename T1>
struct type_from_id_helper<Id, T1>
{
using type = typename etl::conditional<Id == T1::Id,
typename T1::type,
nulltype>::type;
};
public:
//************************************
// type_from_id
//************************************
template <int Id>
struct type_from_id
{
using type = typename type_from_id_helper<Id, TTypes...>::type;
static_assert(!(etl::is_same<nulltype, type>::value), "Invalid id");
};
template <int Id>
using type_from_id_t = typename type_from_id<Id>::type;
private:
static constexpr size_t UNKNOWN = etl::integral_limits<size_t>::max;
// For N type pairs.
template <typename T, typename T1, typename... TRest>
struct id_from_type_helper
{
static constexpr size_t value = etl::is_same<T, typename T1::type>::value ? size_t(T1::Id) : id_from_type_helper<T, TRest...>::value;
};
// Specialisation for 1 type pair.
template <typename T, typename T1>
struct id_from_type_helper<T, T1>
{
static constexpr size_t value = etl::is_same<T, typename T1::type>::value ? size_t(T1::Id) : UNKNOWN;
};
public:
//************************************
// id_from_type
//************************************
template <typename T>
struct id_from_type
{
static constexpr size_t value = id_from_type_helper<T, TTypes...>::value;
static_assert(value != UNKNOWN, "Invalid type");
};
#if ETL_USING_CPP17
template <typename T>
static constexpr size_t id_from_type_v = id_from_type<T>::value;
#endif
//************************************
template <typename T>
static unsigned int get_id_from_type(const T&)
{
return get_id_from_type<T>();
}
//************************************
template <typename T>
static unsigned int get_id_from_type()
{
return id_from_type<T>::value;
}
};
//***************************************************************************
// type_type_lookup
//***************************************************************************
template <typename... TTypes>
class type_type_lookup
{
private:
// The type for no match.
struct nulltype {};
template <typename T, typename T1, typename... TRest>
struct type_from_type_helper
{
using type = typename etl::conditional<etl::is_same<T, typename T1::type1>::value,
typename T1::type2,
typename type_from_type_helper<T, TRest...>::type>::type;
};
template <typename T, typename T1>
struct type_from_type_helper<T, T1>
{
using type = typename etl::conditional<etl::is_same<T, typename T1::type1>::value,
typename T1::type2,
nulltype>::type;
};
public:
template <typename T>
class type_from_type
{
public:
// The matched type or nulltype
using type = typename type_from_type_helper<T, TTypes...>::type;
static_assert(!etl::is_same<type, nulltype>::value, "Type match not found");
};
// Template alias.
template <typename T>
using type_from_type_t = typename type_from_type<T>::type;
};
#else
/*[[[cog
import cog
cog.outl("//***************************************************************************")
cog.outl("// For %s types." % int(NTypes))
cog.outl("//***************************************************************************")
cog.outl("template <typename T1,")
for n in range(2, int(NTypes)):
cog.outl(" typename T%s = etl::type_id_pair<etl::null_type<0>, -%s>," %(n, n))
cog.outl(" typename T%s = etl::type_id_pair<etl::null_type<0>, -%s> >" %(NTypes, NTypes))
cog.outl("struct type_id_lookup")
cog.outl("{")
cog.outl("public:")
cog.outl("")
cog.outl(" //************************************")
cog.outl(" template <int Id>")
cog.outl(" struct type_from_id")
cog.outl(" {")
cog.outl(" typedef")
for n in range(1, int(NTypes) + 1):
cog.outl(" typename etl::conditional<Id == T%s::Id, typename T%s::type," %(n, n))
cog.out(" etl::null_type<0> >")
for n in range(1, int(NTypes) + 1):
if n == int(NTypes):
cog.outl("::type type;")
else:
cog.out("::type>")
if n % 4 == 0:
if n != int(NTypes):
cog.outl("")
cog.out(" ")
cog.outl("")
cog.outl(" ETL_STATIC_ASSERT(!(etl::is_same<etl::null_type<0>, type>::value), \"Invalid id\");")
cog.outl(" };")
cog.outl("")
cog.outl(" //************************************")
cog.outl(" enum")
cog.outl(" {")
cog.outl(" UNKNOWN = UINT_MAX")
cog.outl(" };")
cog.outl("")
cog.outl(" template <typename T>")
cog.outl(" struct id_from_type")
cog.outl(" {")
cog.outl(" enum")
cog.outl(" {")
cog.outl(" value =")
for n in range(1, int(NTypes) + 1) :
cog.outl(" (unsigned int) etl::is_same<T, typename T%s::type>::value ? (unsigned int)T%s::Id :" % (n, n))
cog.outl(" (unsigned int) UNKNOWN")
cog.outl(" };")
cog.outl("")
cog.outl(" ETL_STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), \"Invalid type\");")
cog.outl(" };")
cog.outl("")
cog.outl(" //************************************")
cog.outl(" template <typename T>")
cog.outl(" static unsigned int get_id_from_type(const T&)")
cog.outl(" {")
cog.outl(" return get_id_from_type<T>();")
cog.outl(" }")
cog.outl("")
cog.outl(" //************************************")
cog.outl(" template <typename T>")
cog.outl(" static unsigned int get_id_from_type()")
cog.outl(" {")
cog.outl(" return id_from_type<T>::value;")
cog.outl(" }")
cog.outl("};")
cog.outl("")
cog.outl("//***************************************************************************")
cog.outl("// For %s types." % int(NTypes))
cog.outl("//***************************************************************************")
cog.outl("template <typename T1,")
for n in range(2, int(NTypes)):
cog.outl(" typename T%s = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >," %n)
cog.outl(" typename T%s = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> > >" %NTypes)
cog.outl("struct type_type_lookup")
cog.outl("{")
cog.outl("public:")
cog.outl("")
cog.outl(" //************************************")
cog.outl(" template <typename T>")
cog.outl(" struct type_from_type")
cog.outl(" {")
cog.outl(" typedef")
for n in range(1, int(NTypes) + 1):
cog.outl(" typename etl::conditional<etl::is_same<T, typename T%s::type1>::value, typename T%s::type2," %(n, n))
cog.out(" etl::null_type<0> >")
for n in range(1, int(NTypes) + 1):
if n == int(NTypes):
cog.outl("::type type;")
else:
cog.out("::type>")
if n % 8 == 0:
if n != int(NTypes):
cog.outl("")
cog.out(" ")
cog.outl("")
cog.outl(" ETL_STATIC_ASSERT(!(etl::is_same<etl::null_type<0>, type>::value), \"Invalid type\");")
cog.outl(" };")
cog.outl("};")
]]]*/
/*[[[end]]]*/
#endif
}
#endif

View File

@ -0,0 +1,73 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
/*[[[cog
import cog
cog.outl("")
cog.outl(" //***************************************************************************")
cog.outl(" // For %s types." % int(NTypes))
cog.outl(" //***************************************************************************")
cog.outl(" template <typename T0,")
for n in range(1, int(NTypes) - 1):
cog.outl(" typename T%s = void," % n)
cog.outl(" typename T%s = void>" %(int(NTypes) - 1))
cog.outl(" struct type_select")
cog.outl(" {")
cog.outl(" public:")
cog.outl("")
cog.outl(" template <size_t Id>")
cog.outl(" struct select")
cog.outl(" {")
cog.outl(" typedef typename etl::conditional<Id == 0, T0,")
for n in range(1, int(NTypes)) :
cog.outl(" typename etl::conditional<Id == %s, T%s," % (n, n))
cog.outl(" etl::null_type<0> >")
cog.out(" ")
for n in range(1, int(NTypes)) :
cog.out("::type>")
if n % 8 == 0:
cog.outl("")
cog.out(" ")
cog.outl("::type type;")
cog.outl("");
cog.outl(" ETL_STATIC_ASSERT(Id < %s, \"Invalid Id\");" % int(NTypes));
cog.outl(" };")
cog.outl(" };")
for s in range(int(NTypes) - 1, 0, -1):
cog.outl("")
cog.outl(" //***************************************************************************")
cog.outl(" // For %s types." % int(s))
cog.outl(" //***************************************************************************")
cog.out(" template <")
for n in range(0, s - 1):
cog.outl("typename T%s, " % n)
cog.out(" ")
cog.outl("typename T%s>" % (s - 1))
cog.out(" struct type_select<")
for n in range(0, s - 1):
cog.out("T%s, " % n)
cog.outl("T%s>" % (s - 1))
cog.outl(" {")
cog.outl(" public:")
cog.outl(" template <size_t Id>")
cog.outl(" struct select")
cog.outl(" {")
cog.outl(" typedef typename etl::conditional<Id == 0, T0,")
for n in range(1, s) :
cog.outl(" typename etl::conditional<Id == %s, T%s," % (n, n))
cog.outl(" etl::null_type<0> >")
cog.out(" ")
for n in range(1, s) :
cog.out("::type>")
if n % 8 == 0:
cog.outl("")
cog.out(" ")
cog.outl("::type type;")
cog.outl("");
cog.outl(" ETL_STATIC_ASSERT(Id < %s, \"Invalid Id\");" % s);
cog.outl(" };")
cog.outl(" };")
]]]*/
/*[[[end]]]*/

View File

@ -1,177 +0,0 @@
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2018 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_TYPE_SELECT_INCLUDED
#define ETL_TYPE_SELECT_INCLUDED
#include "platform.h"
#include "static_assert.h"
#include "type_traits.h"
#include "null_type.h"
/*[[[cog
import cog
cog.outl("#if 0")
]]]*/
/*[[[end]]]*/
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
/*[[[cog
import cog
cog.outl("#endif")
]]]*/
/*[[[end]]]*/
/*[[[cog
import cog
cog.outl("//***************************************************************************")
cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.")
cog.outl("//***************************************************************************")
]]]*/
/*[[[end]]]*/
namespace etl
{
#if ETL_USING_CPP11 && !defined(ETL_TYPE_SELECT_FORCE_CPP03_IMPLEMENTATION)
//***************************************************************************
// Variadic version.
//***************************************************************************
template <typename... TTypes>
struct type_select
{
private:
//***********************************
template <size_t Id, size_t Index, typename T1, typename... TRest>
struct type_select_helper
{
using type = typename etl::conditional<Id == Index,
T1,
typename type_select_helper<Id, Index + 1, TRest...>::type>::type;
};
//***********************************
template <size_t Id, size_t Index, typename T1>
struct type_select_helper<Id, Index, T1>
{
using type = T1;
};
public:
template <size_t Id>
struct select
{
static_assert(Id < sizeof...(TTypes), "Illegal type_select::select index");
using type = typename type_select_helper<Id, 0, TTypes...>::type;
};
template <size_t Id>
using select_t = typename select<Id>::type;
};
//***************************************************************************
// Select type alias
//***************************************************************************
template <size_t Index, typename... TTypes>
using type_select_t = typename etl::type_select<TTypes...>:: template select_t<Index>;
#else
/*[[[cog
import cog
cog.outl("//***************************************************************************")
cog.outl("// For %s types." % int(NTypes))
cog.outl("//***************************************************************************")
cog.outl("template <typename T0,")
for n in range(1, int(NTypes) - 1):
cog.outl(" typename T%s = void," % n)
cog.outl(" typename T%s = void>" %(int(NTypes) - 1))
cog.outl("struct type_select")
cog.outl("{")
cog.outl("public:")
cog.outl("")
cog.outl(" template <size_t Id>")
cog.outl(" struct select")
cog.outl(" {")
cog.outl(" typedef typename etl::conditional<Id == 0, T0,")
for n in range(1, int(NTypes)) :
cog.outl(" typename etl::conditional<Id == %s, T%s," % (n, n))
cog.outl(" etl::null_type<0> >")
cog.out(" ")
for n in range(1, int(NTypes)) :
cog.out("::type>")
if n % 8 == 0:
cog.outl("")
cog.out(" ")
cog.outl("::type type;")
cog.outl("");
cog.outl(" ETL_STATIC_ASSERT(Id < %s, \"Invalid Id\");" % int(NTypes));
cog.outl(" };")
cog.outl("};")
for s in range(int(NTypes) - 1, 0, -1):
cog.outl("")
cog.outl("//***************************************************************************")
cog.outl("// For %s types." % int(s))
cog.outl("//***************************************************************************")
cog.out("template <")
for n in range(0, s - 1):
cog.outl("typename T%s, " % n)
cog.out(" ")
cog.outl("typename T%s>" % (s - 1))
cog.out("struct type_select<")
for n in range(0, s - 1):
cog.out("T%s, " % n)
cog.outl("T%s>" % (s - 1))
cog.outl("{")
cog.outl("public:")
cog.outl(" template <size_t Id>")
cog.outl(" struct select")
cog.outl(" {")
cog.outl(" typedef typename etl::conditional<Id == 0, T0,")
for n in range(1, s) :
cog.outl(" typename etl::conditional<Id == %s, T%s," % (n, n))
cog.outl(" etl::null_type<0> >")
cog.out(" ")
for n in range(1, s) :
cog.out("::type>")
if n % 8 == 0:
cog.outl("")
cog.out(" ")
cog.outl("::type type;")
cog.outl("");
cog.outl(" ETL_STATIC_ASSERT(Id < %s, \"Invalid Id\");" % s);
cog.outl(" };")
cog.outl("};")
]]]*/
/*[[[end]]]*/
#endif
}
#endif

View File

@ -0,0 +1,28 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
/*[[[cog
import cog
cog.outl("//***************************************************************************")
cog.outl("/// Template to determine if a type is one of a specified list.")
cog.outl("///\\ingroup types")
cog.outl("template <typename T,")
cog.out(" ")
cog.out(" typename T1,")
for n in range(2, int(IsOneOf)):
cog.out(" typename T%s = void," % n)
if n % 4 == 0:
cog.outl("")
cog.out(" ")
cog.outl(" typename T%s = void>" % IsOneOf)
cog.outl("struct is_one_of")
cog.outl("{")
cog.outl(" static const bool value =")
for n in range(1, int(IsOneOf)):
cog.outl(" etl::is_same<T, T%s>::value ||" % n)
cog.outl(" etl::is_same<T, T%s>::value;" % IsOneOf)
cog.outl("};")
]]]*/
/*[[[end]]]*/

File diff suppressed because it is too large Load Diff

View File

@ -1,192 +1,7 @@
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
/*[[[cog
import cog
cog.outl("#if 0")
]]]*/
/*[[[end]]]*/
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
/*[[[cog
import cog
cog.outl("#endif")
]]]*/
/*[[[end]]]*/
/*[[[cog
import cog
cog.outl("//***************************************************************************")
cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.")
cog.outl("//***************************************************************************")
]]]*/
/*[[[end]]]*/
//***************************************************************************
// To generate to header file, run this at the command line.
// Note: You will need Python and COG installed.
//
// cog -d -e -ovariant_pool.h -DNTypes=<n> variant_pool_generator.h
// Where <n> is the number of types to support.
//
// e.g.
// To generate handlers for up to 16 types...
// cog -d -e -ovariant_pool.h -DNTypes=16 variant_pool_generator.h
//
// See generate.bat
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
#ifndef ETL_VARIANT_POOL_INCLUDED
#define ETL_VARIANT_POOL_INCLUDED
#include "platform.h"
#include "pool.h"
#include "type_traits.h"
#include "static_assert.h"
#include "largest.h"
#include <stdint.h>
namespace etl
{
#if ETL_USING_CPP11 && !defined(ETL_VARIANT_POOL_FORCE_CPP03_IMPLEMENTATION)
//***************************************************************************
template <size_t MAX_SIZE_, typename ... Ts>
class variant_pool
: public etl::generic_pool<etl::largest<Ts...>::size,
etl::largest<Ts...>::alignment,
MAX_SIZE_>
{
public:
typedef etl::generic_pool<etl::largest<Ts...>::size,
etl::largest<Ts...>::alignment,
MAX_SIZE_> base_t;
static const size_t MAX_SIZE = MAX_SIZE_;
//*************************************************************************
/// Default constructor.
//*************************************************************************
variant_pool()
{
}
//*************************************************************************
/// Creates the object from a type. Variadic parameter constructor.
//*************************************************************************
template <typename T, typename... Args>
T* create(Args&&... args)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, Ts...>::value), "Unsupported type");
return base_t::template create<T>(etl::forward<Args>(args)...);
}
//*************************************************************************
/// Destroys the object.
//*************************************************************************
template <typename T>
void destroy(const T* const p)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, Ts...>::value || etl::is_base_of_any<T, Ts...>::value), "Invalid type");
base_t::destroy(p);
}
//*************************************************************************
/// Returns the maximum number of items in the variant_pool.
//*************************************************************************
size_t max_size() const
{
return MAX_SIZE;
}
private:
variant_pool(const variant_pool&) ETL_DELETE;
variant_pool& operator =(const variant_pool&) ETL_DELETE;
};
//***************************************************************************
template <typename ... Ts>
class variant_pool_ext
: public etl::generic_pool_ext<etl::largest<Ts...>::size,
etl::largest<Ts...>::alignment>
{
public:
typedef etl::generic_pool_ext<etl::largest<Ts...>::size,
etl::largest<Ts...>::alignment> base_t;
//*************************************************************************
/// Default constructor.
//*************************************************************************
variant_pool_ext(typename base_t::element* buffer, size_t size)
: base_t(buffer, size)
{
}
//*************************************************************************
/// Creates the object from a type. Variadic parameter constructor.
//*************************************************************************
template <typename T, typename... Args>
T* create(Args&&... args)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, Ts...>::value), "Unsupported type");
return base_t::template create<T>(etl::forward<Args>(args)...);
}
//*************************************************************************
/// Destroys the object.
//*************************************************************************
template <typename T>
void destroy(const T* const p)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, Ts...>::value || etl::is_base_of_any<T, Ts...>::value), "Invalid type");
base_t::destroy(p);
}
//*************************************************************************
/// Returns the maximum number of items in the variant_pool.
//*************************************************************************
size_t max_size() const
{
return base_t::max_size();
}
private:
variant_pool_ext(const variant_pool_ext&) ETL_DELETE;
variant_pool_ext& operator =(const variant_pool_ext&) ETL_DELETE;
};
#else
//***************************************************************************
/*[[[cog
import cog
@ -443,7 +258,7 @@ namespace etl
/// Default constructor.
//*************************************************************************
variant_pool_ext(typename base_t::element* buffer, size_t size)
: base_t(buffer, size)
: base_t(buffer, size)
{
}
@ -604,9 +419,9 @@ namespace etl
//*************************************************************************
/// Returns the maximum number of items in the variant_pool.
//*************************************************************************
size_t max_size() const
{
return base_t::max_size();
size_t max_size() const
{
return base_t::max_size();
}
private:
@ -614,7 +429,4 @@ namespace etl
variant_pool_ext(const variant_pool_ext&) ETL_DELETE;
variant_pool_ext& operator =(const variant_pool_ext&) ETL_DELETE;
};
#endif
}
#endif

View File

@ -28,28 +28,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#if 0
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
#endif
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
//***************************************************************************
// To generate to header file, run this at the command line.
// Note: You will need Python and COG installed.
//
// cog -d -e -olargest.h -DNTypes=<n> largest_generator.h
// Where <n> is the number of types to support.
//
// e.g.
// To generate handlers for up to 16 types...
// cog -d -e -olargest.h -DNTypes=16 largest_generator.h
//
// See generate.bat
//***************************************************************************
#ifndef ETL_LARGEST_INCLUDED
#define ETL_LARGEST_INCLUDED
@ -121,50 +99,7 @@ namespace etl
#endif
#else
//***************************************************************************
/// Template to determine the largest type and size.
/// Supports up to 16 types.
/// Defines 'value_type' which is the type of the largest parameter.
/// Defines 'size' which is the size of the largest parameter.
///\ingroup largest
//***************************************************************************
template <typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
struct largest_type
{
// Define 'largest_other' as 'largest_type' with all but the first parameter.
typedef typename largest_type<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::type largest_other;
// Set 'type' to be the largest of the first parameter and any of the others.
// This is recursive.
typedef typename etl::conditional<(sizeof(T1) > sizeof(largest_other)), // Boolean
T1, // TrueType
largest_other> // FalseType
::type type; // The largest type of the two.
// The size of the largest type.
enum
{
size = sizeof(type)
};
};
//***************************************************************************
// Specialisation for one template parameter.
//***************************************************************************
template <typename T1>
struct largest_type<T1, void, void, void, void, void, void, void,
void, void, void, void, void, void, void, void>
{
typedef T1 type;
enum
{
size = sizeof(type)
};
};
#include "private/largest_type_cpp03.h"
#endif
#if ETL_USING_CPP11 && !defined(ETL_LARGEST_ALIGNMENT_FORCE_CPP03_IMPLEMENTATION)
@ -213,49 +148,7 @@ namespace etl
#endif
#else
//***************************************************************************
/// Template to determine the largest alignment.
/// Supports up to 16 types.
/// Defines <b>value</b> which is the largest alignment of all the parameters.
///\ingroup largest
//***************************************************************************
template <typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
struct largest_alignment
{
// Define 'largest_other' as 'largest_type' with all but the first parameter.
typedef typename largest_alignment<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::type largest_other;
// Set 'type' to be the largest of the first parameter and any of the others.
// This is recursive.
typedef typename etl::conditional<(etl::alignment_of<T1>::value > etl::alignment_of<largest_other>::value), // Boolean
T1, // TrueType
largest_other> // FalseType
::type type; // The largest type of the two.
// The largest alignment.
enum
{
value = etl::alignment_of<type>::value
};
};
//***************************************************************************
// Specialisation for one template parameter.
//***************************************************************************
template <typename T1>
struct largest_alignment<T1, void, void, void, void, void, void, void,
void, void, void, void, void, void, void, void>
{
typedef T1 type;
enum
{
value = etl::alignment_of<type>::value
};
};
#include "private/largest_alignment_cpp03.h"
#endif
//***************************************************************************
@ -353,26 +246,7 @@ namespace etl
#endif
#else
//***************************************************************************
/// Template to determine the largest type, size and alignment.
/// Supports up to 16 types.
/// Defines <b>value</b> which is the largest type, size and alignment of all the parameters.
///\ingroup largest
//***************************************************************************
template <typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
struct largest
{
typedef typename etl::largest_type<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::type type;
enum
{
size = etl::largest_type<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::size,
alignment = etl::largest_alignment<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value
};
};
#include "private/largest_cpp03.h"
#endif
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,895 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
//*************************************************************************************************
// For C++03 and below.
//*************************************************************************************************
//***************************************************************************
// The definition for all 16 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void,
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
class fsm_state : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
case T11::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T11&>(message)); break;
case T12::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T12&>(message)); break;
case T13::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T13&>(message)); break;
case T14::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T14&>(message)); break;
case T15::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T15&>(message)); break;
case T16::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T16&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 15 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8,
typename T9, typename T10, typename T11, typename T12,
typename T13, typename T14, typename T15>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
case T11::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T11&>(message)); break;
case T12::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T12&>(message)); break;
case T13::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T13&>(message)); break;
case T14::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T14&>(message)); break;
case T15::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T15&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 14 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8,
typename T9, typename T10, typename T11, typename T12,
typename T13, typename T14>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
case T11::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T11&>(message)); break;
case T12::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T12&>(message)); break;
case T13::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T13&>(message)); break;
case T14::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T14&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 13 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8,
typename T9, typename T10, typename T11, typename T12,
typename T13>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
case T11::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T11&>(message)); break;
case T12::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T12&>(message)); break;
case T13::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T13&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 12 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8,
typename T9, typename T10, typename T11, typename T12>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
case T11::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T11&>(message)); break;
case T12::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T12&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 11 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8,
typename T9, typename T10, typename T11>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
case T11::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T11&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 10 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8,
typename T9, typename T10>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
case T10::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T10&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 9 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8,
typename T9>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
case T9::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T9&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 8 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, void, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
case T8::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T8&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 7 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, void, void, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
case T7::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T7&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 6 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
case T6::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T6&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 5 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
case T5::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T5&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 4 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, void, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
case T4::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T4&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 3 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, void, void, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
case T3::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T3&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 2 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2>
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, void, void, void, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
case T2::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T2&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 1 message type.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1>
class fsm_state<TContext, TDerived, STATE_ID_, T1, void, void, void, void, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
etl::fsm_state_id_t new_state_id;
etl::message_id_t event_id = message.get_message_id();
switch (event_id)
{
case T1::ID: new_state_id = static_cast<TDerived*>(this)->on_event(static_cast<const T1&>(message)); break;
default: new_state_id = p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message); break;
}
return (new_state_id != Pass_To_Parent) ? new_state_id : (p_parent ? p_parent->process_event(message) : No_State_Change);
}
};
//***************************************************************************
// Specialisation for 0 message types.
//***************************************************************************
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_>
class fsm_state<TContext, TDerived, STATE_ID_, void, void, void, void, void, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
{
public:
static ETL_CONSTANT etl::fsm_state_id_t STATE_ID = STATE_ID_;
fsm_state()
: ifsm_state(STATE_ID)
{
}
protected:
~fsm_state()
{
}
TContext& get_fsm_context() const
{
return static_cast<TContext&>(ifsm_state::get_fsm_context());
}
private:
etl::fsm_state_id_t process_event(const etl::imessage& message)
{
return p_parent ? p_parent->process_event(message) : static_cast<TDerived*>(this)->on_event_unknown(message);
}
};
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8,
typename T9, typename T10, typename T11, typename T12,
typename T13, typename T14, typename T15, typename T16>
ETL_CONSTANT etl::fsm_state_id_t fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::STATE_ID;

View File

@ -0,0 +1,11 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
template <typename, typename, etl::fsm_state_id_t,
typename, typename, typename, typename,
typename, typename, typename, typename,
typename, typename, typename, typename,
typename, typename, typename, typename>
friend class etl::fsm_state;

View File

@ -0,0 +1,11 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
template <typename, typename, etl::fsm_state_id_t,
typename, typename, typename, typename,
typename, typename, typename, typename,
typename, typename, typename, typename,
typename, typename, typename, typename>
class fsm_state;

View File

@ -0,0 +1,48 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
//***************************************************************************
/// Template to determine the largest alignment.
/// Supports up to 16 types.
/// Defines <b>value</b> which is the largest alignment of all the parameters.
///\ingroup largest
//***************************************************************************
template <typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
struct largest_alignment
{
// Define 'largest_other' as 'largest_type' with all but the first parameter.
typedef typename largest_alignment<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::type largest_other;
// Set 'type' to be the largest of the first parameter and any of the others.
// This is recursive.
typedef typename etl::conditional<(etl::alignment_of<T1>::value > etl::alignment_of<largest_other>::value), // Boolean
T1, // TrueType
largest_other> // FalseType
::type type; // The largest type of the two.
// The largest alignment.
enum
{
value = etl::alignment_of<type>::value
};
};
//***************************************************************************
// Specialisation for one template parameter.
//***************************************************************************
template <typename T1>
struct largest_alignment<T1, void, void, void, void, void, void, void,
void, void, void, void, void, void, void, void>
{
typedef T1 type;
enum
{
value = etl::alignment_of<type>::value
};
};

View File

@ -0,0 +1,25 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
//***************************************************************************
/// Template to determine the largest type, size and alignment.
/// Supports up to 16 types.
/// Defines <b>value</b> which is the largest type, size and alignment of all the parameters.
///\ingroup largest
//***************************************************************************
template <typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
struct largest
{
typedef typename etl::largest_type<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::type type;
enum
{
size = etl::largest_type<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::size,
alignment = etl::largest_alignment<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value
};
};

View File

@ -0,0 +1,49 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
//***************************************************************************
/// Template to determine the largest type and size.
/// Supports up to 16 types.
/// Defines 'type' which is the type of the largest parameter.
/// Defines 'size' which is the size of the largest parameter.
///\ingroup largest
//***************************************************************************
template <typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
struct largest_type
{
// Define 'largest_other' as 'largest_type' with all but the first parameter.
typedef typename largest_type<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::type largest_other;
// Set 'type' to be the largest of the first parameter and any of the others.
// This is recursive.
typedef typename etl::conditional<(sizeof(T1) > sizeof(largest_other)), // Boolean
T1, // TrueType
largest_other> // FalseType
::type type; // The largest type of the two.
// The size of the largest type.
enum
{
size = sizeof(type)
};
};
//***************************************************************************
// Specialisation for one template parameter.
//***************************************************************************
template <typename T1>
struct largest_type<T1, void, void, void, void, void, void, void,
void, void, void, void, void, void, void, void>
{
typedef T1 type;
enum
{
size = sizeof(type)
};
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,73 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
//***************************************************************************
/// Template to determine the smallest type and size.
/// Supports up to 16 types.
/// Defines 'value_type' which is the type of the smallest parameter.
/// Defines 'size' which is the size of the smallest parameter.
///\ingroup smallest
//***************************************************************************
template <typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
struct smallest_type
{
private:
// Declaration.
template <bool Boolean, typename TrueType, typename FalseType>
struct choose_type;
// Specialisation for 'true'.
// Defines 'type' as 'TrueType'.
template <typename TrueType, typename FalseType>
struct choose_type<true, TrueType, FalseType>
{
typedef TrueType type;
};
// Specialisation for 'false'.
// Defines 'type' as 'FalseType'.
template <typename TrueType, typename FalseType>
struct choose_type<false, TrueType, FalseType>
{
typedef FalseType type;
};
public:
// Define 'smallest_other' as 'smallest_type' with all but the first parameter.
typedef typename smallest_type<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::type smallest_other;
// Set 'type' to be the smallest of the first parameter and any of the others.
// This is recursive.
typedef typename choose_type<(sizeof(T1) < sizeof(smallest_other)), // Boolean
T1, // TrueType
smallest_other> // FalseType
::type type; // The smallest type of the two.
// The size of the smallest type.
enum
{
size = sizeof(type)
};
};
//***************************************************************************
// Specialisation for one template parameter.
//***************************************************************************
template <typename T1>
struct smallest_type<T1, void, void, void, void, void, void, void,
void, void, void, void, void, void, void, void>
{
typedef T1 type;
enum
{
size = sizeof(type)
};
};

View File

@ -0,0 +1,157 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
//***************************************************************************
// For 16 types.
//***************************************************************************
template <typename T1,
typename T2 = etl::type_id_pair<etl::null_type<0>, -2>,
typename T3 = etl::type_id_pair<etl::null_type<0>, -3>,
typename T4 = etl::type_id_pair<etl::null_type<0>, -4>,
typename T5 = etl::type_id_pair<etl::null_type<0>, -5>,
typename T6 = etl::type_id_pair<etl::null_type<0>, -6>,
typename T7 = etl::type_id_pair<etl::null_type<0>, -7>,
typename T8 = etl::type_id_pair<etl::null_type<0>, -8>,
typename T9 = etl::type_id_pair<etl::null_type<0>, -9>,
typename T10 = etl::type_id_pair<etl::null_type<0>, -10>,
typename T11 = etl::type_id_pair<etl::null_type<0>, -11>,
typename T12 = etl::type_id_pair<etl::null_type<0>, -12>,
typename T13 = etl::type_id_pair<etl::null_type<0>, -13>,
typename T14 = etl::type_id_pair<etl::null_type<0>, -14>,
typename T15 = etl::type_id_pair<etl::null_type<0>, -15>,
typename T16 = etl::type_id_pair<etl::null_type<0>, -16> >
struct type_id_lookup
{
public:
//************************************
template <int Id>
struct type_from_id
{
typedef
typename etl::conditional<Id == T1::Id, typename T1::type,
typename etl::conditional<Id == T2::Id, typename T2::type,
typename etl::conditional<Id == T3::Id, typename T3::type,
typename etl::conditional<Id == T4::Id, typename T4::type,
typename etl::conditional<Id == T5::Id, typename T5::type,
typename etl::conditional<Id == T6::Id, typename T6::type,
typename etl::conditional<Id == T7::Id, typename T7::type,
typename etl::conditional<Id == T8::Id, typename T8::type,
typename etl::conditional<Id == T9::Id, typename T9::type,
typename etl::conditional<Id == T10::Id, typename T10::type,
typename etl::conditional<Id == T11::Id, typename T11::type,
typename etl::conditional<Id == T12::Id, typename T12::type,
typename etl::conditional<Id == T13::Id, typename T13::type,
typename etl::conditional<Id == T14::Id, typename T14::type,
typename etl::conditional<Id == T15::Id, typename T15::type,
typename etl::conditional<Id == T16::Id, typename T16::type,
etl::null_type<0> >::type>::type>::type>::type>
::type>::type>::type>::type>
::type>::type>::type>::type>
::type>::type>::type>::type type;
ETL_STATIC_ASSERT(!(etl::is_same<etl::null_type<0>, type>::value), "Invalid id");
};
//************************************
enum
{
UNKNOWN = UINT_MAX
};
template <typename T>
struct id_from_type
{
enum
{
value =
(unsigned int) etl::is_same<T, typename T1::type>::value ? (unsigned int)T1::Id :
(unsigned int) etl::is_same<T, typename T2::type>::value ? (unsigned int)T2::Id :
(unsigned int) etl::is_same<T, typename T3::type>::value ? (unsigned int)T3::Id :
(unsigned int) etl::is_same<T, typename T4::type>::value ? (unsigned int)T4::Id :
(unsigned int) etl::is_same<T, typename T5::type>::value ? (unsigned int)T5::Id :
(unsigned int) etl::is_same<T, typename T6::type>::value ? (unsigned int)T6::Id :
(unsigned int) etl::is_same<T, typename T7::type>::value ? (unsigned int)T7::Id :
(unsigned int) etl::is_same<T, typename T8::type>::value ? (unsigned int)T8::Id :
(unsigned int) etl::is_same<T, typename T9::type>::value ? (unsigned int)T9::Id :
(unsigned int) etl::is_same<T, typename T10::type>::value ? (unsigned int)T10::Id :
(unsigned int) etl::is_same<T, typename T11::type>::value ? (unsigned int)T11::Id :
(unsigned int) etl::is_same<T, typename T12::type>::value ? (unsigned int)T12::Id :
(unsigned int) etl::is_same<T, typename T13::type>::value ? (unsigned int)T13::Id :
(unsigned int) etl::is_same<T, typename T14::type>::value ? (unsigned int)T14::Id :
(unsigned int) etl::is_same<T, typename T15::type>::value ? (unsigned int)T15::Id :
(unsigned int) etl::is_same<T, typename T16::type>::value ? (unsigned int)T16::Id :
(unsigned int) UNKNOWN
};
ETL_STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type");
};
//************************************
template <typename T>
static unsigned int get_id_from_type(const T&)
{
return get_id_from_type<T>();
}
//************************************
template <typename T>
static unsigned int get_id_from_type()
{
return id_from_type<T>::value;
}
};
//***************************************************************************
// For 16 types.
//***************************************************************************
template <typename T1,
typename T2 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T3 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T4 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T5 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T6 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T7 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T8 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T9 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T10 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T11 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T12 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T13 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T14 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T15 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T16 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> > >
struct type_type_lookup
{
public:
//************************************
template <typename T>
struct type_from_type
{
typedef
typename etl::conditional<etl::is_same<T, typename T1::type1>::value, typename T1::type2,
typename etl::conditional<etl::is_same<T, typename T2::type1>::value, typename T2::type2,
typename etl::conditional<etl::is_same<T, typename T3::type1>::value, typename T3::type2,
typename etl::conditional<etl::is_same<T, typename T4::type1>::value, typename T4::type2,
typename etl::conditional<etl::is_same<T, typename T5::type1>::value, typename T5::type2,
typename etl::conditional<etl::is_same<T, typename T6::type1>::value, typename T6::type2,
typename etl::conditional<etl::is_same<T, typename T7::type1>::value, typename T7::type2,
typename etl::conditional<etl::is_same<T, typename T8::type1>::value, typename T8::type2,
typename etl::conditional<etl::is_same<T, typename T9::type1>::value, typename T9::type2,
typename etl::conditional<etl::is_same<T, typename T10::type1>::value, typename T10::type2,
typename etl::conditional<etl::is_same<T, typename T11::type1>::value, typename T11::type2,
typename etl::conditional<etl::is_same<T, typename T12::type1>::value, typename T12::type2,
typename etl::conditional<etl::is_same<T, typename T13::type1>::value, typename T13::type2,
typename etl::conditional<etl::is_same<T, typename T14::type1>::value, typename T14::type2,
typename etl::conditional<etl::is_same<T, typename T15::type1>::value, typename T15::type2,
typename etl::conditional<etl::is_same<T, typename T16::type1>::value, typename T16::type2,
etl::null_type<0> >::type>::type>::type>::type>::type>::type>::type>::type>
::type>::type>::type>::type>::type>::type>::type>::type type;
ETL_STATIC_ASSERT(!(etl::is_same<etl::null_type<0>, type>::value), "Invalid type");
};
};

View File

@ -0,0 +1,541 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
//***************************************************************************
// For 16 types.
//***************************************************************************
template <typename T0,
typename T1 = void,
typename T2 = void,
typename T3 = void,
typename T4 = void,
typename T5 = void,
typename T6 = void,
typename T7 = void,
typename T8 = void,
typename T9 = void,
typename T10 = void,
typename T11 = void,
typename T12 = void,
typename T13 = void,
typename T14 = void,
typename T15 = void>
struct type_select
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
typename etl::conditional<Id == 7, T7,
typename etl::conditional<Id == 8, T8,
typename etl::conditional<Id == 9, T9,
typename etl::conditional<Id == 10, T10,
typename etl::conditional<Id == 11, T11,
typename etl::conditional<Id == 12, T12,
typename etl::conditional<Id == 13, T13,
typename etl::conditional<Id == 14, T14,
typename etl::conditional<Id == 15, T15,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type>::type>
::type>::type>::type>::type>::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 16, "Invalid Id");
};
};
//***************************************************************************
// For 15 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8,
typename T9,
typename T10,
typename T11,
typename T12,
typename T13,
typename T14>
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
typename etl::conditional<Id == 7, T7,
typename etl::conditional<Id == 8, T8,
typename etl::conditional<Id == 9, T9,
typename etl::conditional<Id == 10, T10,
typename etl::conditional<Id == 11, T11,
typename etl::conditional<Id == 12, T12,
typename etl::conditional<Id == 13, T13,
typename etl::conditional<Id == 14, T14,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type>::type>
::type>::type>::type>::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 15, "Invalid Id");
};
};
//***************************************************************************
// For 14 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8,
typename T9,
typename T10,
typename T11,
typename T12,
typename T13>
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
typename etl::conditional<Id == 7, T7,
typename etl::conditional<Id == 8, T8,
typename etl::conditional<Id == 9, T9,
typename etl::conditional<Id == 10, T10,
typename etl::conditional<Id == 11, T11,
typename etl::conditional<Id == 12, T12,
typename etl::conditional<Id == 13, T13,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type>::type>
::type>::type>::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 14, "Invalid Id");
};
};
//***************************************************************************
// For 13 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8,
typename T9,
typename T10,
typename T11,
typename T12>
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
typename etl::conditional<Id == 7, T7,
typename etl::conditional<Id == 8, T8,
typename etl::conditional<Id == 9, T9,
typename etl::conditional<Id == 10, T10,
typename etl::conditional<Id == 11, T11,
typename etl::conditional<Id == 12, T12,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type>::type>
::type>::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 13, "Invalid Id");
};
};
//***************************************************************************
// For 12 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8,
typename T9,
typename T10,
typename T11>
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
typename etl::conditional<Id == 7, T7,
typename etl::conditional<Id == 8, T8,
typename etl::conditional<Id == 9, T9,
typename etl::conditional<Id == 10, T10,
typename etl::conditional<Id == 11, T11,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type>::type>
::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 12, "Invalid Id");
};
};
//***************************************************************************
// For 11 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8,
typename T9,
typename T10>
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
typename etl::conditional<Id == 7, T7,
typename etl::conditional<Id == 8, T8,
typename etl::conditional<Id == 9, T9,
typename etl::conditional<Id == 10, T10,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type>::type>
::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 11, "Invalid Id");
};
};
//***************************************************************************
// For 10 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8,
typename T9>
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
typename etl::conditional<Id == 7, T7,
typename etl::conditional<Id == 8, T8,
typename etl::conditional<Id == 9, T9,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type>::type>
::type>::type type;
ETL_STATIC_ASSERT(Id < 10, "Invalid Id");
};
};
//***************************************************************************
// For 9 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8>
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
typename etl::conditional<Id == 7, T7,
typename etl::conditional<Id == 8, T8,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type>::type>
::type type;
ETL_STATIC_ASSERT(Id < 9, "Invalid Id");
};
};
//***************************************************************************
// For 8 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
typename etl::conditional<Id == 7, T7,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 8, "Invalid Id");
};
};
//***************************************************************************
// For 7 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
struct type_select<T0, T1, T2, T3, T4, T5, T6>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 7, "Invalid Id");
};
};
//***************************************************************************
// For 6 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
struct type_select<T0, T1, T2, T3, T4, T5>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 6, "Invalid Id");
};
};
//***************************************************************************
// For 5 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4>
struct type_select<T0, T1, T2, T3, T4>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
etl::null_type<0> >
::type>::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 5, "Invalid Id");
};
};
//***************************************************************************
// For 4 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3>
struct type_select<T0, T1, T2, T3>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
etl::null_type<0> >
::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 4, "Invalid Id");
};
};
//***************************************************************************
// For 3 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2>
struct type_select<T0, T1, T2>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
etl::null_type<0> >
::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 3, "Invalid Id");
};
};
//***************************************************************************
// For 2 types.
//***************************************************************************
template <typename T0,
typename T1>
struct type_select<T0, T1>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
etl::null_type<0> >
::type>::type type;
ETL_STATIC_ASSERT(Id < 2, "Invalid Id");
};
};
//***************************************************************************
// For 1 types.
//***************************************************************************
template <typename T0>
struct type_select<T0>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
etl::null_type<0> >
::type type;
ETL_STATIC_ASSERT(Id < 1, "Invalid Id");
};
};

View File

@ -0,0 +1,33 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
//***************************************************************************
/// Template to determine if a type is one of a specified list.
///\ingroup types
template <typename T,
typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
struct is_one_of
{
static const bool value =
etl::is_same<T, T1>::value ||
etl::is_same<T, T2>::value ||
etl::is_same<T, T3>::value ||
etl::is_same<T, T4>::value ||
etl::is_same<T, T5>::value ||
etl::is_same<T, T6>::value ||
etl::is_same<T, T7>::value ||
etl::is_same<T, T8>::value ||
etl::is_same<T, T9>::value ||
etl::is_same<T, T10>::value ||
etl::is_same<T, T11>::value ||
etl::is_same<T, T12>::value ||
etl::is_same<T, T13>::value ||
etl::is_same<T, T14>::value ||
etl::is_same<T, T15>::value ||
etl::is_same<T, T16>::value;
};

View File

@ -0,0 +1,294 @@
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
//***************************************************************************
template <size_t MAX_SIZE_,
typename T1,
typename T2 = void,
typename T3 = void,
typename T4 = void,
typename T5 = void,
typename T6 = void,
typename T7 = void,
typename T8 = void,
typename T9 = void,
typename T10 = void,
typename T11 = void,
typename T12 = void,
typename T13 = void,
typename T14 = void,
typename T15 = void,
typename T16 = void>
class variant_pool
: public etl::generic_pool<etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::size,
etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::alignment,
MAX_SIZE_>
{
public:
typedef etl::generic_pool<etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::size,
etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::alignment,
MAX_SIZE_> base_t;
static const size_t MAX_SIZE = MAX_SIZE_;
//*************************************************************************
/// Default constructor.
//*************************************************************************
variant_pool()
{
}
#if ETL_CPP11_NOT_SUPPORTED || ETL_USING_STLPORT
//*************************************************************************
/// Creates the object. Default constructor.
//*************************************************************************
template <typename T>
T* create()
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>();
}
//*************************************************************************
/// Creates the object. One parameter constructor.
//*************************************************************************
template <typename T, typename TP1>
T* create(const TP1& p1)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(p1);
}
//*************************************************************************
/// Creates the object. Two parameter constructor.
//*************************************************************************
template <typename T, typename TP1, typename TP2>
T* create(const TP1& p1, const TP2& p2)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(p1, p2);
}
//*************************************************************************
/// Creates the object. Three parameter constructor.
//*************************************************************************
template <typename T, typename TP1, typename TP2, typename TP3>
T* create(const TP1& p1, const TP2& p2, const TP3& p3)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(p1, p2, p3);
}
//*************************************************************************
/// Creates the object. Four parameter constructor.
//*************************************************************************
template <typename T, typename TP1, typename TP2, typename TP3, typename TP4>
T* create(const TP1& p1, const TP2& p2, const TP3& p3, const TP4& p4)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(p1, p2, p3, p4);
}
#else
//*************************************************************************
/// Creates the object from a type. Variadic parameter constructor.
//*************************************************************************
template <typename T, typename... Args>
T* create(Args&&... args)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(etl::forward<Args>(args)...);
}
#endif
//*************************************************************************
/// Destroys the object.
//*************************************************************************
template <typename T>
void destroy(const T* const p)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value ||
etl::is_base_of<T, T1>::value ||
etl::is_base_of<T, T2>::value ||
etl::is_base_of<T, T3>::value ||
etl::is_base_of<T, T4>::value ||
etl::is_base_of<T, T5>::value ||
etl::is_base_of<T, T6>::value ||
etl::is_base_of<T, T7>::value ||
etl::is_base_of<T, T8>::value ||
etl::is_base_of<T, T9>::value ||
etl::is_base_of<T, T10>::value ||
etl::is_base_of<T, T11>::value ||
etl::is_base_of<T, T12>::value ||
etl::is_base_of<T, T13>::value ||
etl::is_base_of<T, T14>::value ||
etl::is_base_of<T, T15>::value ||
etl::is_base_of<T, T16>::value), "Invalid type");
base_t::destroy(p);
}
//*************************************************************************
/// Returns the maximum number of items in the variant_pool.
//*************************************************************************
size_t max_size() const
{
return MAX_SIZE;
}
private:
variant_pool(const variant_pool&) ETL_DELETE;
variant_pool& operator =(const variant_pool&) ETL_DELETE;
};
//***************************************************************************
template <typename T1,
typename T2 = void,
typename T3 = void,
typename T4 = void,
typename T5 = void,
typename T6 = void,
typename T7 = void,
typename T8 = void,
typename T9 = void,
typename T10 = void,
typename T11 = void,
typename T12 = void,
typename T13 = void,
typename T14 = void,
typename T15 = void,
typename T16 = void>
class variant_pool_ext
: public etl::generic_pool_ext<etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::size,
etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::alignment>
{
public:
typedef etl::generic_pool_ext<etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::size,
etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::alignment> base_t;
//*************************************************************************
/// Default constructor.
//*************************************************************************
variant_pool_ext(typename base_t::element* buffer, size_t size)
: base_t(buffer, size)
{
}
#if ETL_CPP11_NOT_SUPPORTED || ETL_USING_STLPORT
//*************************************************************************
/// Creates the object. Default constructor.
//*************************************************************************
template <typename T>
T* create()
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>();
}
//*************************************************************************
/// Creates the object. One parameter constructor.
//*************************************************************************
template <typename T, typename TP1>
T* create(const TP1& p1)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(p1);
}
//*************************************************************************
/// Creates the object. Two parameter constructor.
//*************************************************************************
template <typename T, typename TP1, typename TP2>
T* create(const TP1& p1, const TP2& p2)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(p1, p2);
}
//*************************************************************************
/// Creates the object. Three parameter constructor.
//*************************************************************************
template <typename T, typename TP1, typename TP2, typename TP3>
T* create(const TP1& p1, const TP2& p2, const TP3& p3)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(p1, p2, p3);
}
//*************************************************************************
/// Creates the object. Four parameter constructor.
//*************************************************************************
template <typename T, typename TP1, typename TP2, typename TP3, typename TP4>
T* create(const TP1& p1, const TP2& p2, const TP3& p3, const TP4& p4)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(p1, p2, p3, p4);
}
#else
//*************************************************************************
/// Creates the object from a type. Variadic parameter constructor.
//*************************************************************************
template <typename T, typename... Args>
T* create(Args&&... args)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(etl::forward<Args>(args)...);
}
#endif
//*************************************************************************
/// Destroys the object.
//*************************************************************************
template <typename T>
void destroy(const T* const p)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value ||
etl::is_base_of<T, T1>::value ||
etl::is_base_of<T, T2>::value ||
etl::is_base_of<T, T3>::value ||
etl::is_base_of<T, T4>::value ||
etl::is_base_of<T, T5>::value ||
etl::is_base_of<T, T6>::value ||
etl::is_base_of<T, T7>::value ||
etl::is_base_of<T, T8>::value ||
etl::is_base_of<T, T9>::value ||
etl::is_base_of<T, T10>::value ||
etl::is_base_of<T, T11>::value ||
etl::is_base_of<T, T12>::value ||
etl::is_base_of<T, T13>::value ||
etl::is_base_of<T, T14>::value ||
etl::is_base_of<T, T15>::value ||
etl::is_base_of<T, T16>::value), "Invalid type");
base_t::destroy(p);
}
//*************************************************************************
/// Returns the maximum number of items in the variant_pool.
//*************************************************************************
size_t max_size() const
{
return base_t::max_size();
}
private:
variant_pool_ext(const variant_pool_ext&) ETL_DELETE;
variant_pool_ext& operator =(const variant_pool_ext&) ETL_DELETE;
};

View File

@ -28,28 +28,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#if 0
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
#endif
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
//***************************************************************************
// To generate to header file, run this at the command line.
// Note: You will need Python and COG installed.
//
// cog -d -e -osmallest.h -DNTypes=<n> smallest_generator.h
// Where <n> is the number of types to support.
//
// e.g.
// To generate handlers for up to 16 types...
// cog -d -e -osmallest.h -DNTypes=16 smallest_generator.h
//
// See generate.bat
//***************************************************************************
#ifndef ETL_SMALLEST_INCLUDED
#define ETL_SMALLEST_INCLUDED
@ -121,74 +99,7 @@ namespace etl
#endif
#else
//***************************************************************************
/// Template to determine the smallest type and size.
/// Supports up to 16 types.
/// Defines 'value_type' which is the type of the smallest parameter.
/// Defines 'size' which is the size of the smallest parameter.
///\ingroup smallest
//***************************************************************************
template <typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
struct smallest_type
{
private:
// Declaration.
template <bool Boolean, typename TrueType, typename FalseType>
struct choose_type;
// Specialisation for 'true'.
// Defines 'type' as 'TrueType'.
template <typename TrueType, typename FalseType>
struct choose_type<true, TrueType, FalseType>
{
typedef TrueType type;
};
// Specialisation for 'false'.
// Defines 'type' as 'FalseType'.
template <typename TrueType, typename FalseType>
struct choose_type<false, TrueType, FalseType>
{
typedef FalseType type;
};
public:
// Define 'smallest_other' as 'smallest_type' with all but the first parameter.
typedef typename smallest_type<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::type smallest_other;
// Set 'type' to be the smallest of the first parameter and any of the others.
// This is recursive.
typedef typename choose_type<(sizeof(T1) < sizeof(smallest_other)), // Boolean
T1, // TrueType
smallest_other> // FalseType
::type type; // The smallest type of the two.
// The size of the smallest type.
enum
{
size = sizeof(type)
};
};
//***************************************************************************
// Specialisation for one template parameter.
//***************************************************************************
template <typename T1>
struct smallest_type<T1, void, void, void, void, void, void, void,
void, void, void, void, void, void, void, void>
{
typedef T1 type;
enum
{
size = sizeof(type)
};
};
#include "private/smallest_cpp03.h"
#endif
namespace private_smallest

View File

@ -36,15 +36,6 @@ SOFTWARE.
#include "null_type.h"
#include <limits.h>
#if 0
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
#endif
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
namespace etl
{
//***************************************************************************
@ -214,159 +205,7 @@ namespace etl
};
#else
//***************************************************************************
// For 16 types.
//***************************************************************************
template <typename T1,
typename T2 = etl::type_id_pair<etl::null_type<0>, -2>,
typename T3 = etl::type_id_pair<etl::null_type<0>, -3>,
typename T4 = etl::type_id_pair<etl::null_type<0>, -4>,
typename T5 = etl::type_id_pair<etl::null_type<0>, -5>,
typename T6 = etl::type_id_pair<etl::null_type<0>, -6>,
typename T7 = etl::type_id_pair<etl::null_type<0>, -7>,
typename T8 = etl::type_id_pair<etl::null_type<0>, -8>,
typename T9 = etl::type_id_pair<etl::null_type<0>, -9>,
typename T10 = etl::type_id_pair<etl::null_type<0>, -10>,
typename T11 = etl::type_id_pair<etl::null_type<0>, -11>,
typename T12 = etl::type_id_pair<etl::null_type<0>, -12>,
typename T13 = etl::type_id_pair<etl::null_type<0>, -13>,
typename T14 = etl::type_id_pair<etl::null_type<0>, -14>,
typename T15 = etl::type_id_pair<etl::null_type<0>, -15>,
typename T16 = etl::type_id_pair<etl::null_type<0>, -16> >
struct type_id_lookup
{
public:
//************************************
template <int Id>
struct type_from_id
{
typedef
typename etl::conditional<Id == T1::Id, typename T1::type,
typename etl::conditional<Id == T2::Id, typename T2::type,
typename etl::conditional<Id == T3::Id, typename T3::type,
typename etl::conditional<Id == T4::Id, typename T4::type,
typename etl::conditional<Id == T5::Id, typename T5::type,
typename etl::conditional<Id == T6::Id, typename T6::type,
typename etl::conditional<Id == T7::Id, typename T7::type,
typename etl::conditional<Id == T8::Id, typename T8::type,
typename etl::conditional<Id == T9::Id, typename T9::type,
typename etl::conditional<Id == T10::Id, typename T10::type,
typename etl::conditional<Id == T11::Id, typename T11::type,
typename etl::conditional<Id == T12::Id, typename T12::type,
typename etl::conditional<Id == T13::Id, typename T13::type,
typename etl::conditional<Id == T14::Id, typename T14::type,
typename etl::conditional<Id == T15::Id, typename T15::type,
typename etl::conditional<Id == T16::Id, typename T16::type,
etl::null_type<0> >::type>::type>::type>::type>
::type>::type>::type>::type>
::type>::type>::type>::type>
::type>::type>::type>::type type;
ETL_STATIC_ASSERT(!(etl::is_same<etl::null_type<0>, type>::value), "Invalid id");
};
//************************************
enum
{
UNKNOWN = UINT_MAX
};
template <typename T>
struct id_from_type
{
enum
{
value =
(unsigned int) etl::is_same<T, typename T1::type>::value ? (unsigned int)T1::Id :
(unsigned int) etl::is_same<T, typename T2::type>::value ? (unsigned int)T2::Id :
(unsigned int) etl::is_same<T, typename T3::type>::value ? (unsigned int)T3::Id :
(unsigned int) etl::is_same<T, typename T4::type>::value ? (unsigned int)T4::Id :
(unsigned int) etl::is_same<T, typename T5::type>::value ? (unsigned int)T5::Id :
(unsigned int) etl::is_same<T, typename T6::type>::value ? (unsigned int)T6::Id :
(unsigned int) etl::is_same<T, typename T7::type>::value ? (unsigned int)T7::Id :
(unsigned int) etl::is_same<T, typename T8::type>::value ? (unsigned int)T8::Id :
(unsigned int) etl::is_same<T, typename T9::type>::value ? (unsigned int)T9::Id :
(unsigned int) etl::is_same<T, typename T10::type>::value ? (unsigned int)T10::Id :
(unsigned int) etl::is_same<T, typename T11::type>::value ? (unsigned int)T11::Id :
(unsigned int) etl::is_same<T, typename T12::type>::value ? (unsigned int)T12::Id :
(unsigned int) etl::is_same<T, typename T13::type>::value ? (unsigned int)T13::Id :
(unsigned int) etl::is_same<T, typename T14::type>::value ? (unsigned int)T14::Id :
(unsigned int) etl::is_same<T, typename T15::type>::value ? (unsigned int)T15::Id :
(unsigned int) etl::is_same<T, typename T16::type>::value ? (unsigned int)T16::Id :
(unsigned int) UNKNOWN
};
ETL_STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type");
};
//************************************
template <typename T>
static unsigned int get_id_from_type(const T&)
{
return get_id_from_type<T>();
}
//************************************
template <typename T>
static unsigned int get_id_from_type()
{
return id_from_type<T>::value;
}
};
//***************************************************************************
// For 16 types.
//***************************************************************************
template <typename T1,
typename T2 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T3 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T4 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T5 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T6 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T7 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T8 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T9 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T10 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T11 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T12 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T13 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T14 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T15 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
typename T16 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> > >
struct type_type_lookup
{
public:
//************************************
template <typename T>
struct type_from_type
{
typedef
typename etl::conditional<etl::is_same<T, typename T1::type1>::value, typename T1::type2,
typename etl::conditional<etl::is_same<T, typename T2::type1>::value, typename T2::type2,
typename etl::conditional<etl::is_same<T, typename T3::type1>::value, typename T3::type2,
typename etl::conditional<etl::is_same<T, typename T4::type1>::value, typename T4::type2,
typename etl::conditional<etl::is_same<T, typename T5::type1>::value, typename T5::type2,
typename etl::conditional<etl::is_same<T, typename T6::type1>::value, typename T6::type2,
typename etl::conditional<etl::is_same<T, typename T7::type1>::value, typename T7::type2,
typename etl::conditional<etl::is_same<T, typename T8::type1>::value, typename T8::type2,
typename etl::conditional<etl::is_same<T, typename T9::type1>::value, typename T9::type2,
typename etl::conditional<etl::is_same<T, typename T10::type1>::value, typename T10::type2,
typename etl::conditional<etl::is_same<T, typename T11::type1>::value, typename T11::type2,
typename etl::conditional<etl::is_same<T, typename T12::type1>::value, typename T12::type2,
typename etl::conditional<etl::is_same<T, typename T13::type1>::value, typename T13::type2,
typename etl::conditional<etl::is_same<T, typename T14::type1>::value, typename T14::type2,
typename etl::conditional<etl::is_same<T, typename T15::type1>::value, typename T15::type2,
typename etl::conditional<etl::is_same<T, typename T16::type1>::value, typename T16::type2,
etl::null_type<0> >::type>::type>::type>::type>::type>::type>::type>::type>
::type>::type>::type>::type>::type>::type>::type>::type type;
ETL_STATIC_ASSERT(!(etl::is_same<etl::null_type<0>, type>::value), "Invalid type");
};
};
#include "private/type_lookup_cpp03.h"
#endif
}

View File

@ -33,15 +33,6 @@ SOFTWARE.
#include "static_assert.h"
#include "type_traits.h"
#include "null_type.h"
#if 0
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
#endif
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
namespace etl
{
#if ETL_USING_CPP11 && !defined(ETL_TYPE_SELECT_FORCE_CPP03_IMPLEMENTATION)
@ -90,543 +81,7 @@ namespace etl
using type_select_t = typename etl::type_select<TTypes...>:: template select_t<Index>;
#else
//***************************************************************************
// For 16 types.
//***************************************************************************
template <typename T0,
typename T1 = void,
typename T2 = void,
typename T3 = void,
typename T4 = void,
typename T5 = void,
typename T6 = void,
typename T7 = void,
typename T8 = void,
typename T9 = void,
typename T10 = void,
typename T11 = void,
typename T12 = void,
typename T13 = void,
typename T14 = void,
typename T15 = void>
struct type_select
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
typename etl::conditional<Id == 7, T7,
typename etl::conditional<Id == 8, T8,
typename etl::conditional<Id == 9, T9,
typename etl::conditional<Id == 10, T10,
typename etl::conditional<Id == 11, T11,
typename etl::conditional<Id == 12, T12,
typename etl::conditional<Id == 13, T13,
typename etl::conditional<Id == 14, T14,
typename etl::conditional<Id == 15, T15,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type>::type>
::type>::type>::type>::type>::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 16, "Invalid Id");
};
};
//***************************************************************************
// For 15 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8,
typename T9,
typename T10,
typename T11,
typename T12,
typename T13,
typename T14>
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
typename etl::conditional<Id == 7, T7,
typename etl::conditional<Id == 8, T8,
typename etl::conditional<Id == 9, T9,
typename etl::conditional<Id == 10, T10,
typename etl::conditional<Id == 11, T11,
typename etl::conditional<Id == 12, T12,
typename etl::conditional<Id == 13, T13,
typename etl::conditional<Id == 14, T14,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type>::type>
::type>::type>::type>::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 15, "Invalid Id");
};
};
//***************************************************************************
// For 14 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8,
typename T9,
typename T10,
typename T11,
typename T12,
typename T13>
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
typename etl::conditional<Id == 7, T7,
typename etl::conditional<Id == 8, T8,
typename etl::conditional<Id == 9, T9,
typename etl::conditional<Id == 10, T10,
typename etl::conditional<Id == 11, T11,
typename etl::conditional<Id == 12, T12,
typename etl::conditional<Id == 13, T13,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type>::type>
::type>::type>::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 14, "Invalid Id");
};
};
//***************************************************************************
// For 13 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8,
typename T9,
typename T10,
typename T11,
typename T12>
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
typename etl::conditional<Id == 7, T7,
typename etl::conditional<Id == 8, T8,
typename etl::conditional<Id == 9, T9,
typename etl::conditional<Id == 10, T10,
typename etl::conditional<Id == 11, T11,
typename etl::conditional<Id == 12, T12,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type>::type>
::type>::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 13, "Invalid Id");
};
};
//***************************************************************************
// For 12 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8,
typename T9,
typename T10,
typename T11>
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
typename etl::conditional<Id == 7, T7,
typename etl::conditional<Id == 8, T8,
typename etl::conditional<Id == 9, T9,
typename etl::conditional<Id == 10, T10,
typename etl::conditional<Id == 11, T11,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type>::type>
::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 12, "Invalid Id");
};
};
//***************************************************************************
// For 11 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8,
typename T9,
typename T10>
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
typename etl::conditional<Id == 7, T7,
typename etl::conditional<Id == 8, T8,
typename etl::conditional<Id == 9, T9,
typename etl::conditional<Id == 10, T10,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type>::type>
::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 11, "Invalid Id");
};
};
//***************************************************************************
// For 10 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8,
typename T9>
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
typename etl::conditional<Id == 7, T7,
typename etl::conditional<Id == 8, T8,
typename etl::conditional<Id == 9, T9,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type>::type>
::type>::type type;
ETL_STATIC_ASSERT(Id < 10, "Invalid Id");
};
};
//***************************************************************************
// For 9 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8>
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
typename etl::conditional<Id == 7, T7,
typename etl::conditional<Id == 8, T8,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type>::type>
::type type;
ETL_STATIC_ASSERT(Id < 9, "Invalid Id");
};
};
//***************************************************************************
// For 8 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
typename etl::conditional<Id == 7, T7,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 8, "Invalid Id");
};
};
//***************************************************************************
// For 7 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
struct type_select<T0, T1, T2, T3, T4, T5, T6>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
typename etl::conditional<Id == 6, T6,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 7, "Invalid Id");
};
};
//***************************************************************************
// For 6 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
struct type_select<T0, T1, T2, T3, T4, T5>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
typename etl::conditional<Id == 5, T5,
etl::null_type<0> >
::type>::type>::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 6, "Invalid Id");
};
};
//***************************************************************************
// For 5 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3,
typename T4>
struct type_select<T0, T1, T2, T3, T4>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
typename etl::conditional<Id == 4, T4,
etl::null_type<0> >
::type>::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 5, "Invalid Id");
};
};
//***************************************************************************
// For 4 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2,
typename T3>
struct type_select<T0, T1, T2, T3>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
typename etl::conditional<Id == 3, T3,
etl::null_type<0> >
::type>::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 4, "Invalid Id");
};
};
//***************************************************************************
// For 3 types.
//***************************************************************************
template <typename T0,
typename T1,
typename T2>
struct type_select<T0, T1, T2>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
typename etl::conditional<Id == 2, T2,
etl::null_type<0> >
::type>::type>::type type;
ETL_STATIC_ASSERT(Id < 3, "Invalid Id");
};
};
//***************************************************************************
// For 2 types.
//***************************************************************************
template <typename T0,
typename T1>
struct type_select<T0, T1>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
typename etl::conditional<Id == 1, T1,
etl::null_type<0> >
::type>::type type;
ETL_STATIC_ASSERT(Id < 2, "Invalid Id");
};
};
//***************************************************************************
// For 1 types.
//***************************************************************************
template <typename T0>
struct type_select<T0>
{
public:
template <size_t Id>
struct select
{
typedef typename etl::conditional<Id == 0, T0,
etl::null_type<0> >
::type type;
ETL_STATIC_ASSERT(Id < 1, "Invalid Id");
};
};
#include "private/type_select_cpp03.h"
#endif
}

View File

@ -28,28 +28,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#if 0
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
#endif
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
//***************************************************************************
// To generate to header file, run this at the command line.
// Note: You will need Python and COG installed.
//
// cog -d -e -otypes.h -DHandlers=<n> types_generator.h
// Where <n> is the number of types to support.
//
// e.g.
// To generate handlers for up to 16 types...
// cog -d -e -otype_traits.h -DIsOneOf=16 type_traits_generator.h
//
// See generate.bat
//***************************************************************************
#ifndef ETL_TYPE_TRAITS_INCLUDED
#define ETL_TYPE_TRAITS_INCLUDED
@ -1610,34 +1588,7 @@ typedef integral_constant<bool, true> true_type;
{
};
#else
//***************************************************************************
/// Template to determine if a type is one of a specified list.
///\ingroup types
template <typename T,
typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
struct is_one_of
{
static const bool value =
etl::is_same<T, T1>::value ||
etl::is_same<T, T2>::value ||
etl::is_same<T, T3>::value ||
etl::is_same<T, T4>::value ||
etl::is_same<T, T5>::value ||
etl::is_same<T, T6>::value ||
etl::is_same<T, T7>::value ||
etl::is_same<T, T8>::value ||
etl::is_same<T, T9>::value ||
etl::is_same<T, T10>::value ||
etl::is_same<T, T11>::value ||
etl::is_same<T, T12>::value ||
etl::is_same<T, T13>::value ||
etl::is_same<T, T14>::value ||
etl::is_same<T, T15>::value ||
etl::is_same<T, T16>::value;
};
#include "private/type_traits_cpp03.h"
#endif
#if ETL_USING_CPP17

View File

@ -26,28 +26,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#if 0
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
#endif
//***************************************************************************
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//***************************************************************************
//***************************************************************************
// To generate to header file, run this at the command line.
// Note: You will need Python and COG installed.
//
// cog -d -e -ovariant_pool.h -DNTypes=<n> variant_pool_generator.h
// Where <n> is the number of types to support.
//
// e.g.
// To generate handlers for up to 16 types...
// cog -d -e -ovariant_pool.h -DNTypes=16 variant_pool_generator.h
//
// See generate.bat
//***************************************************************************
#ifndef ETL_VARIANT_POOL_INCLUDED
#define ETL_VARIANT_POOL_INCLUDED
@ -175,295 +153,7 @@ namespace etl
variant_pool_ext& operator =(const variant_pool_ext&) ETL_DELETE;
};
#else
//***************************************************************************
template <size_t MAX_SIZE_,
typename T1,
typename T2 = void,
typename T3 = void,
typename T4 = void,
typename T5 = void,
typename T6 = void,
typename T7 = void,
typename T8 = void,
typename T9 = void,
typename T10 = void,
typename T11 = void,
typename T12 = void,
typename T13 = void,
typename T14 = void,
typename T15 = void,
typename T16 = void>
class variant_pool
: public etl::generic_pool<etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::size,
etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::alignment,
MAX_SIZE_>
{
public:
typedef etl::generic_pool<etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::size,
etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::alignment,
MAX_SIZE_> base_t;
static const size_t MAX_SIZE = MAX_SIZE_;
//*************************************************************************
/// Default constructor.
//*************************************************************************
variant_pool()
{
}
#if ETL_CPP11_NOT_SUPPORTED || ETL_USING_STLPORT
//*************************************************************************
/// Creates the object. Default constructor.
//*************************************************************************
template <typename T>
T* create()
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>();
}
//*************************************************************************
/// Creates the object. One parameter constructor.
//*************************************************************************
template <typename T, typename TP1>
T* create(const TP1& p1)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(p1);
}
//*************************************************************************
/// Creates the object. Two parameter constructor.
//*************************************************************************
template <typename T, typename TP1, typename TP2>
T* create(const TP1& p1, const TP2& p2)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(p1, p2);
}
//*************************************************************************
/// Creates the object. Three parameter constructor.
//*************************************************************************
template <typename T, typename TP1, typename TP2, typename TP3>
T* create(const TP1& p1, const TP2& p2, const TP3& p3)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(p1, p2, p3);
}
//*************************************************************************
/// Creates the object. Four parameter constructor.
//*************************************************************************
template <typename T, typename TP1, typename TP2, typename TP3, typename TP4>
T* create(const TP1& p1, const TP2& p2, const TP3& p3, const TP4& p4)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(p1, p2, p3, p4);
}
#else
//*************************************************************************
/// Creates the object from a type. Variadic parameter constructor.
//*************************************************************************
template <typename T, typename... Args>
T* create(Args&&... args)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(etl::forward<Args>(args)...);
}
#endif
//*************************************************************************
/// Destroys the object.
//*************************************************************************
template <typename T>
void destroy(const T* const p)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value ||
etl::is_base_of<T, T1>::value ||
etl::is_base_of<T, T2>::value ||
etl::is_base_of<T, T3>::value ||
etl::is_base_of<T, T4>::value ||
etl::is_base_of<T, T5>::value ||
etl::is_base_of<T, T6>::value ||
etl::is_base_of<T, T7>::value ||
etl::is_base_of<T, T8>::value ||
etl::is_base_of<T, T9>::value ||
etl::is_base_of<T, T10>::value ||
etl::is_base_of<T, T11>::value ||
etl::is_base_of<T, T12>::value ||
etl::is_base_of<T, T13>::value ||
etl::is_base_of<T, T14>::value ||
etl::is_base_of<T, T15>::value ||
etl::is_base_of<T, T16>::value), "Invalid type");
base_t::destroy(p);
}
//*************************************************************************
/// Returns the maximum number of items in the variant_pool.
//*************************************************************************
size_t max_size() const
{
return MAX_SIZE;
}
private:
variant_pool(const variant_pool&) ETL_DELETE;
variant_pool& operator =(const variant_pool&) ETL_DELETE;
};
//***************************************************************************
template <typename T1,
typename T2 = void,
typename T3 = void,
typename T4 = void,
typename T5 = void,
typename T6 = void,
typename T7 = void,
typename T8 = void,
typename T9 = void,
typename T10 = void,
typename T11 = void,
typename T12 = void,
typename T13 = void,
typename T14 = void,
typename T15 = void,
typename T16 = void>
class variant_pool_ext
: public etl::generic_pool_ext<etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::size,
etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::alignment>
{
public:
typedef etl::generic_pool_ext<etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::size,
etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::alignment> base_t;
//*************************************************************************
/// Default constructor.
//*************************************************************************
variant_pool_ext(typename base_t::element* buffer, size_t size)
: base_t(buffer, size)
{
}
#if ETL_CPP11_NOT_SUPPORTED || ETL_USING_STLPORT
//*************************************************************************
/// Creates the object. Default constructor.
//*************************************************************************
template <typename T>
T* create()
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>();
}
//*************************************************************************
/// Creates the object. One parameter constructor.
//*************************************************************************
template <typename T, typename TP1>
T* create(const TP1& p1)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(p1);
}
//*************************************************************************
/// Creates the object. Two parameter constructor.
//*************************************************************************
template <typename T, typename TP1, typename TP2>
T* create(const TP1& p1, const TP2& p2)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(p1, p2);
}
//*************************************************************************
/// Creates the object. Three parameter constructor.
//*************************************************************************
template <typename T, typename TP1, typename TP2, typename TP3>
T* create(const TP1& p1, const TP2& p2, const TP3& p3)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(p1, p2, p3);
}
//*************************************************************************
/// Creates the object. Four parameter constructor.
//*************************************************************************
template <typename T, typename TP1, typename TP2, typename TP3, typename TP4>
T* create(const TP1& p1, const TP2& p2, const TP3& p3, const TP4& p4)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(p1, p2, p3, p4);
}
#else
//*************************************************************************
/// Creates the object from a type. Variadic parameter constructor.
//*************************************************************************
template <typename T, typename... Args>
T* create(Args&&... args)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value), "Unsupported type");
return base_t::template create<T>(etl::forward<Args>(args)...);
}
#endif
//*************************************************************************
/// Destroys the object.
//*************************************************************************
template <typename T>
void destroy(const T* const p)
{
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value ||
etl::is_base_of<T, T1>::value ||
etl::is_base_of<T, T2>::value ||
etl::is_base_of<T, T3>::value ||
etl::is_base_of<T, T4>::value ||
etl::is_base_of<T, T5>::value ||
etl::is_base_of<T, T6>::value ||
etl::is_base_of<T, T7>::value ||
etl::is_base_of<T, T8>::value ||
etl::is_base_of<T, T9>::value ||
etl::is_base_of<T, T10>::value ||
etl::is_base_of<T, T11>::value ||
etl::is_base_of<T, T12>::value ||
etl::is_base_of<T, T13>::value ||
etl::is_base_of<T, T14>::value ||
etl::is_base_of<T, T15>::value ||
etl::is_base_of<T, T16>::value), "Invalid type");
base_t::destroy(p);
}
//*************************************************************************
/// Returns the maximum number of items in the variant_pool.
//*************************************************************************
size_t max_size() const
{
return base_t::max_size();
}
private:
variant_pool_ext(const variant_pool_ext&) ETL_DELETE;
variant_pool_ext& operator =(const variant_pool_ext&) ETL_DELETE;
};
#include "private/variant_pool_cpp03.h"
#endif
}