Skip to content

Commit

Permalink
2.3.1
Browse files Browse the repository at this point in the history
* fixed `FullControlT<>::updatePlan()`
* renamed `Status` to `TaskStatus`
  • Loading branch information
andrew-gresyk authored Sep 22, 2023
1 parent f7a3eab commit d4a0666
Show file tree
Hide file tree
Showing 22 changed files with 1,066 additions and 964 deletions.
8 changes: 8 additions & 0 deletions development/hfsm2/detail/containers/bit_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class BitArrayT final {
static constexpr Index CAPACITY = NCapacity;
static constexpr Index UNIT_COUNT = contain(CAPACITY, 8);

using BitArray = BitArrayT<CAPACITY>;

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

class Bits {
Expand Down Expand Up @@ -91,6 +93,8 @@ class BitArrayT final {
public:
HFSM2_CONSTEXPR(14) BitArrayT() noexcept { clear(); }

HFSM2_CONSTEXPR(14) void set() noexcept;

HFSM2_CONSTEXPR(14) void clear() noexcept;

template <Short NIndex>
Expand All @@ -113,6 +117,10 @@ class BitArrayT final {
template <typename TIndex>
HFSM2_CONSTEXPR(14) void clear(const TIndex index) noexcept;

HFSM2_CONSTEXPR(14) bool operator & (const BitArray& other) const noexcept;

HFSM2_CONSTEXPR(14) void operator &= (const BitArray& other) noexcept;

template <Short NUnit, Short NWidth>
HFSM2_CONSTEXPR(14) Bits bits() noexcept;

Expand Down
33 changes: 33 additions & 0 deletions development/hfsm2/detail/containers/bit_array.inl
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@ BitArrayT<NCapacity>::CBits::get(const Index index) const noexcept {
////////////////////////////////////////////////////////////////////////////////
// COMMON

template <unsigned NCapacity>
HFSM2_CONSTEXPR(14)
void
BitArrayT<NCapacity>::set() noexcept {
for (uint8_t& unit : _storage)
unit = UINT8_MAX;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

template <unsigned NCapacity>
HFSM2_CONSTEXPR(14)
void
Expand Down Expand Up @@ -303,6 +313,29 @@ BitArrayT<NCapacity>::clear(const TIndex index) noexcept {

//------------------------------------------------------------------------------

template <unsigned NCapacity>
HFSM2_CONSTEXPR(14)
bool
BitArrayT<NCapacity>::operator & (const BitArray& other) const noexcept {
for (Index i = 0; i < UNIT_COUNT; ++i)
if ((_storage[i] & other._storage[i]) == 0)
return false;

return true;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

template <unsigned NCapacity>
HFSM2_CONSTEXPR(14)
void
BitArrayT<NCapacity>::operator &= (const BitArray& other) noexcept {
for (Index i = 0; i < UNIT_COUNT; ++i)
_storage[i] &= other._storage[i];
}

//------------------------------------------------------------------------------

template <unsigned NCapacity>
template <Short NUnit, Short NWidth>
HFSM2_CONSTEXPR(14)
Expand Down
4 changes: 3 additions & 1 deletion development/hfsm2/detail/containers/task_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace detail {
#pragma pack(push, 1)

struct TaskBase {
static_assert(sizeof(Long) == sizeof(StateID), "");

HFSM2_CONSTEXPR(11) TaskBase() noexcept {}

HFSM2_CONSTEXPR(11) TaskBase(const StateID origin_,
Expand All @@ -18,7 +20,7 @@ struct TaskBase {
, type{type_}
{}

static_assert(sizeof(Long) == sizeof(StateID), "");
HFSM2_CONSTEXPR(11) bool cyclic() const noexcept { return origin == destination; }

union {
StateID origin = INVALID_STATE_ID;
Expand Down
5 changes: 1 addition & 4 deletions development/hfsm2/detail/root.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,15 +770,12 @@ class RV_ <G_<NFeatureTag, TContext, Manual HFSM2_IF_UTILITY_THEORY(, TRank,
HFSM2_IF_UTILITY_THEORY(using typename Base::RNG);

#if HFSM2_SERIALIZATION_AVAILABLE()
using typename Base::PlanControl;
using typename Base::TransitionSets;

using typename Base::Args;
using typename Base::WriteStream;
using typename Base::ReadStream;
#endif

#if HFSM2_TRANSITION_HISTORY_AVAILABLE()
#if HFSM2_SERIALIZATION_AVAILABLE() || HFSM2_TRANSITION_HISTORY_AVAILABLE()
using typename Base::PlanControl;
using typename Base::TransitionSets;
#endif
Expand Down
18 changes: 9 additions & 9 deletions development/hfsm2/detail/root/control.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ class PlanControlT

StateID _regionStateId = 0;
Long _regionSize = StateList::SIZE;
Status _status;
TaskStatus _taskStatus;
};

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -665,7 +665,7 @@ class FullControlBaseT
#if HFSM2_PLANS_AVAILABLE()

template <typename TState>
HFSM2_CONSTEXPR(14) Status buildPlanStatus() noexcept;
HFSM2_CONSTEXPR(14) TaskStatus buildPlanStatus() noexcept;

#endif

Expand Down Expand Up @@ -814,7 +814,7 @@ class FullControlBaseT

using PlanControl::_regionStateId;
using PlanControl::_regionSize;
using PlanControl::_status;
using PlanControl::_taskStatus;

bool _locked = false;
};
Expand Down Expand Up @@ -904,8 +904,8 @@ class FullControlT<ArgsT<TContext
#if HFSM2_PLANS_AVAILABLE()

template <typename TState>
HFSM2_CONSTEXPR(14) Status updatePlan(TState& headState,
const Status subStatus) noexcept;
HFSM2_CONSTEXPR(14) TaskStatus updatePlan(TState& headState,
const TaskStatus subStatus) noexcept;

#endif

Expand Down Expand Up @@ -1048,7 +1048,7 @@ class FullControlT<ArgsT<TContext

using FullControlBase::_regionStateId;
using FullControlBase::_regionSize;
using FullControlBase::_status;
using FullControlBase::_taskStatus;

using FullControlBase::_locked;
};
Expand Down Expand Up @@ -1129,8 +1129,8 @@ class FullControlT<ArgsT<TContext
#if HFSM2_PLANS_AVAILABLE()

template <typename TState>
HFSM2_CONSTEXPR(14) Status updatePlan(TState& headState,
const Status subStatus) noexcept;
HFSM2_CONSTEXPR(14) TaskStatus updatePlan(TState& headState,
const TaskStatus subStatus) noexcept;

#endif

Expand All @@ -1144,7 +1144,7 @@ class FullControlT<ArgsT<TContext
using FullControlBase::_core;
using FullControlBase::_regionId;

using FullControlBase::_status;
using FullControlBase::_taskStatus;
};

////////////////////////////////////////////////////////////////////////////////
Expand Down
Loading

0 comments on commit d4a0666

Please sign in to comment.