Skip to content

Commit

Permalink
run code-gen
Browse files Browse the repository at this point in the history
  • Loading branch information
leovsch committed Oct 4, 2024
1 parent e840c55 commit 9983d3c
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,27 @@ struct LineInput {
operator BranchInput const&() const { return reinterpret_cast<BranchInput const&>(*this); }
};

struct AsymLineInput {
ID id{na_IntID}; // ID of the object
ID from_node{na_IntID}; // node IDs to which this branch is connected at both sides
ID to_node{na_IntID}; // node IDs to which this branch is connected at both sides
IntS from_status{na_IntS}; // whether the branch is connected at each side
IntS to_status{na_IntS}; // whether the branch is connected at each side
double c1{nan}; // positive sequence parameters
std::array<std::array<double, 3>, 3> r_matrix{static_cast<std::array<std::array<double, 3>, 3>>(na_IntS)}; // 3 x 3 matrix
std::array<std::array<double, 3>, 3> x_matrix{static_cast<std::array<std::array<double, 3>, 3>>(na_IntS)}; // 3 x 3 matrix
double c0{nan}; // zero sequence parameters
double i_n{nan}; // rated current

// implicit conversions to BaseInput
operator BaseInput&() { return reinterpret_cast<BaseInput&>(*this); }
operator BaseInput const&() const { return reinterpret_cast<BaseInput const&>(*this); }

// implicit conversions to BranchInput
operator BranchInput&() { return reinterpret_cast<BranchInput&>(*this); }
operator BranchInput const&() const { return reinterpret_cast<BranchInput const&>(*this); }
};

struct LinkInput {
ID id{na_IntID}; // ID of the object
ID from_node{na_IntID}; // node IDs to which this branch is connected at both sides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,24 @@ struct get_attributes_list<LineInput> {
};
};

template<>
struct get_attributes_list<AsymLineInput> {
static constexpr std::array<MetaAttribute, 10> value{
// all attributes including base class

meta_data_gen::get_meta_attribute<&AsymLineInput::id>(offsetof(AsymLineInput, id), "id"),
meta_data_gen::get_meta_attribute<&AsymLineInput::from_node>(offsetof(AsymLineInput, from_node), "from_node"),
meta_data_gen::get_meta_attribute<&AsymLineInput::to_node>(offsetof(AsymLineInput, to_node), "to_node"),
meta_data_gen::get_meta_attribute<&AsymLineInput::from_status>(offsetof(AsymLineInput, from_status), "from_status"),
meta_data_gen::get_meta_attribute<&AsymLineInput::to_status>(offsetof(AsymLineInput, to_status), "to_status"),
meta_data_gen::get_meta_attribute<&AsymLineInput::c1>(offsetof(AsymLineInput, c1), "c1"),
meta_data_gen::get_meta_attribute<&AsymLineInput::r_matrix>(offsetof(AsymLineInput, r_matrix), "r_matrix"),
meta_data_gen::get_meta_attribute<&AsymLineInput::x_matrix>(offsetof(AsymLineInput, x_matrix), "x_matrix"),
meta_data_gen::get_meta_attribute<&AsymLineInput::c0>(offsetof(AsymLineInput, c0), "c0"),
meta_data_gen::get_meta_attribute<&AsymLineInput::i_n>(offsetof(AsymLineInput, i_n), "i_n"),
};
};

template<>
struct get_attributes_list<LinkInput> {
static constexpr std::array<MetaAttribute, 5> value{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,25 @@ static_assert(offsetof(LineInput, to_node) == offsetof(BranchInput, to_node));
static_assert(offsetof(LineInput, from_status) == offsetof(BranchInput, from_status));
static_assert(offsetof(LineInput, to_status) == offsetof(BranchInput, to_status));

// static asserts for AsymLineInput
static_assert(std::is_standard_layout_v<AsymLineInput>);
// static asserts for conversion of AsymLineInput to BaseInput
static_assert(std::alignment_of_v<AsymLineInput> >= std::alignment_of_v<BranchInput>);
static_assert(std::same_as<decltype(AsymLineInput::id), decltype(BaseInput::id)>);
static_assert(offsetof(AsymLineInput, id) == offsetof(BaseInput, id));
// static asserts for conversion of AsymLineInput to BranchInput
static_assert(std::alignment_of_v<AsymLineInput> >= std::alignment_of_v<BranchInput>);
static_assert(std::same_as<decltype(AsymLineInput::id), decltype(BranchInput::id)>);
static_assert(std::same_as<decltype(AsymLineInput::from_node), decltype(BranchInput::from_node)>);
static_assert(std::same_as<decltype(AsymLineInput::to_node), decltype(BranchInput::to_node)>);
static_assert(std::same_as<decltype(AsymLineInput::from_status), decltype(BranchInput::from_status)>);
static_assert(std::same_as<decltype(AsymLineInput::to_status), decltype(BranchInput::to_status)>);
static_assert(offsetof(AsymLineInput, id) == offsetof(BranchInput, id));
static_assert(offsetof(AsymLineInput, from_node) == offsetof(BranchInput, from_node));
static_assert(offsetof(AsymLineInput, to_node) == offsetof(BranchInput, to_node));
static_assert(offsetof(AsymLineInput, from_status) == offsetof(BranchInput, from_status));
static_assert(offsetof(AsymLineInput, to_status) == offsetof(BranchInput, to_status));

// static asserts for LinkInput
static_assert(std::is_standard_layout_v<LinkInput>);
// static asserts for conversion of LinkInput to BaseInput
Expand Down

0 comments on commit 9983d3c

Please sign in to comment.