2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-06-06 08:42:35 +00:00

fix: compilation with CommonTechset

This commit is contained in:
Jan Laupetin
2026-02-04 21:05:39 +00:00
parent bf9beb1458
commit e749514972
28 changed files with 15 additions and 19 deletions
@@ -0,0 +1,93 @@
#include "StateMapLayout.h"
#include <algorithm>
#include <cassert>
using namespace state_map;
namespace state_map
{
#ifdef _DEBUG
void ValidateStateMapLayout(const StateMapLayout& layout)
{
// Must have at least one state bits field
assert(layout.m_state_bits_count > 0);
for (const auto& var : layout.m_var_layout.m_vars)
{
// Cannot exceed state bits fields
assert(var.m_state_bits_index < layout.m_state_bits_count);
for (auto i = 0u; i < var.m_values.size(); i++)
{
const auto& value = var.m_values[i];
// Zero mask values must be last
assert(value.m_state_bits_mask != 0 || i == var.m_values.size() - 1);
}
}
for (const auto& entry : layout.m_entry_layout.m_entries)
{
// Cannot exceed state bits fields
assert(entry.m_state_bits_index < layout.m_state_bits_count);
// Has to have a mask for passthrough
assert(entry.m_state_bits_mask != 0);
for (auto& resultVar : entry.m_result_vars)
{
const auto correspondingVar = std::ranges::find_if(layout.m_var_layout.m_vars,
[&resultVar](const StateMapLayoutVar& var)
{
return var.m_name == resultVar;
});
// Has to have a corresponding var
assert(correspondingVar != layout.m_var_layout.m_vars.end());
}
}
}
#endif
} // namespace state_map
StateMapLayoutEntry::StateMapLayoutEntry(std::string name, const size_t stateBitsIndex, const size_t stateBitsMask, std::vector<std::string> resultVars)
: m_name(std::move(name)),
m_state_bits_index(stateBitsIndex),
m_state_bits_mask(stateBitsMask),
m_result_vars(std::move(resultVars))
{
}
StateMapLayoutEntries::StateMapLayoutEntries(std::vector<StateMapLayoutEntry> entryList)
: m_entries(std::move(entryList))
{
}
StateMapLayoutVarValue::StateMapLayoutVarValue(std::string name, const size_t stateBitsMask)
: m_name(std::move(name)),
m_state_bits_mask(stateBitsMask)
{
}
StateMapLayoutVar::StateMapLayoutVar(std::string name, const size_t stateBitsIndex, std::vector<StateMapLayoutVarValue> values)
: m_name(std::move(name)),
m_state_bits_index(stateBitsIndex),
m_values(std::move(values))
{
}
StateMapLayoutVars::StateMapLayoutVars(std::vector<StateMapLayoutVar> varList)
: m_vars(std::move(varList))
{
}
StateMapLayout::StateMapLayout(const size_t stateBitsCount, const StateMapLayoutEntries& entryLayout, const StateMapLayoutVars& varLayout)
: m_state_bits_count(stateBitsCount),
m_entry_layout(entryLayout),
m_var_layout(varLayout)
{
#ifdef _DEBUG
ValidateStateMapLayout(*this);
#endif
}
@@ -0,0 +1,63 @@
#pragma once
#include <cstddef>
#include <string>
#include <vector>
namespace state_map
{
class StateMapLayoutEntry
{
public:
StateMapLayoutEntry(std::string name, size_t stateBitsIndex, size_t stateBitsMask, std::vector<std::string> resultVars);
std::string m_name;
size_t m_state_bits_index;
size_t m_state_bits_mask;
std::vector<std::string> m_result_vars;
};
class StateMapLayoutEntries
{
public:
explicit StateMapLayoutEntries(std::vector<StateMapLayoutEntry> entryList);
std::vector<StateMapLayoutEntry> m_entries;
};
class StateMapLayoutVarValue
{
public:
StateMapLayoutVarValue(std::string name, size_t stateBitsMask);
std::string m_name;
size_t m_state_bits_mask;
};
class StateMapLayoutVar
{
public:
StateMapLayoutVar(std::string name, size_t stateBitsIndex, std::vector<StateMapLayoutVarValue> values);
std::string m_name;
size_t m_state_bits_index;
std::vector<StateMapLayoutVarValue> m_values;
};
class StateMapLayoutVars
{
public:
explicit StateMapLayoutVars(std::vector<StateMapLayoutVar> varList);
std::vector<StateMapLayoutVar> m_vars;
};
class StateMapLayout
{
public:
StateMapLayout(size_t stateBitsCount, const StateMapLayoutEntries& entryLayout, const StateMapLayoutVars& varLayout);
size_t m_state_bits_count;
const StateMapLayoutEntries& m_entry_layout;
const StateMapLayoutVars& m_var_layout;
};
} // namespace state_map