Commit 207d6285 authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

next15

parent 41017a06
Pipeline #2315 failed with stage
in 1 minute and 7 seconds
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <memory> #include <memory>
#include <cstdint> #include <cstdint>
#include <cstdlib>
namespace bits { namespace bits {
...@@ -33,6 +34,11 @@ public: ...@@ -33,6 +34,11 @@ public:
return malloc(n); return malloc(n);
} }
void* allocate(size_t n, size_t alignment)
{
return aligned_alloc(alignment, n);
}
void deallocate(void* p, size_t /*n*/) void deallocate(void* p, size_t /*n*/)
{ {
free(p); free(p);
......
...@@ -138,7 +138,15 @@ make_next_key<IDs>(unsigned key) noexcept ...@@ -138,7 +138,15 @@ make_next_key<IDs>(unsigned key) noexcept
template<typename T, typename Identifier> template<typename T, typename Identifier>
struct data_array struct data_array
{ {
static_assert(std::is_default_constructible<T>::value,
"data_array needs a default constructor");
static_assert(std::is_nothrow_default_constructible<T>::value,
"data_array needs a nothrow default constructor");
static_assert(std::is_nothrow_destructible<T>::value,
"data_array needs a nothrow destructor");
using identifier_type = Identifier; using identifier_type = Identifier;
using value_type = T;
struct item struct item
{ {
...@@ -201,8 +209,8 @@ struct data_array ...@@ -201,8 +209,8 @@ struct data_array
item* items = nullptr; // items vector. item* items = nullptr; // items vector.
int max_size = 0; // total size int max_size = 0; // total size
int max_used = 0; // highest index ever alloced int max_used = 0; // highest index ever allocated
int capacity = 0; // num alloced items int capacity = 0; // num allocated items
unsigned int next_key = 1; // [1..2^16] (don't let == 0) unsigned int next_key = 1; // [1..2^16] (don't let == 0)
int free_head = -1; // index of first free entry int free_head = -1; // index of first free entry
}; };
......
...@@ -38,14 +38,14 @@ using ID = bits::ID; ...@@ -38,14 +38,14 @@ using ID = bits::ID;
struct ID2 struct ID2
{ {
ID2() = default; constexpr ID2() noexcept = default;
ID2(ID id) constexpr ID2(ID id) noexcept
: id1(id) : id1(id)
, id2(id) , id2(id)
{} {}
ID2(ID id1_, ID id2_) constexpr ID2(ID id1_, ID id2_) noexcept
: id1(id1_) : id1(id1_)
, id2(id2_) , id2(id2_)
{} {}
...@@ -304,9 +304,6 @@ struct Class ...@@ -304,9 +304,6 @@ struct Class
std::string name; std::string name;
}; };
struct State
{};
struct SimDynamics struct SimDynamics
{ {
// 1) classical hierarchy model? => no // 1) classical hierarchy model? => no
...@@ -316,7 +313,6 @@ struct SimDynamics ...@@ -316,7 +313,6 @@ struct SimDynamics
// std::function<void(State)> output; // std::function<void(State)> output;
// 3) Each library gives a DataArray<T> of atomic model. // 3) Each library gives a DataArray<T> of atomic model.
// dynamics_id gives the correct library // dynamics_id gives the correct library
//
unsigned dynamics_id; unsigned dynamics_id;
ID model_id; ID model_id;
...@@ -384,7 +380,9 @@ struct data_array_wrapper ...@@ -384,7 +380,9 @@ struct data_array_wrapper
struct AllDynamics struct AllDynamics
{ {
std::vector<data_array_wrapper> all_dynamics; std::vector<data_array_wrapper>
all_dynamics; // Initialized with the size of the
// DataArray<Dynamics>::size attribute.
ID alloc(unsigned dynamics_id) ID alloc(unsigned dynamics_id)
{ {
...@@ -493,22 +491,6 @@ struct Vpz ...@@ -493,22 +491,6 @@ struct Vpz
vec3_32.init(object_capacity); vec3_32.init(object_capacity);
} }
// void write(FILE& f, Condition& cond)
// {
// fprintf(&f, " <condition name=\"%s\">\n", cond.name.c_str());
// // for (int i = cond->port_list.head; i != -1;
// // i = condition_port_list[i].next) {
// // auto* port =
// condition_ports->try_to_get(condition_list[i].id);
// // if (port) {
// // }
// // }
// fprintf(&f, " </conditions>\n");
// }
void write_dynamics(FILE& f) void write_dynamics(FILE& f)
{ {
fprintf(&f, " <dynamics>\n"); fprintf(&f, " <dynamics>\n");
...@@ -606,6 +588,34 @@ struct Vpz ...@@ -606,6 +588,34 @@ struct Vpz
fprintf(&f, " </views>\n"); fprintf(&f, " </views>\n");
} }
void write_model(FILE& f, Model& model)
{
fprintf(&f, " <structures>\n");
int space = 2;
if (model.type == Model::model_type::atomic) {
if (model.input_slot_number == 0 && model.output_slot_number == 0) {
fprintf(
&f, " <model name=\"%s\" type=\"atomic\" />\n", model.name);
} else {
fprintf(
&f, " <model name=\"%s\" type=\"atomic\">\n", model.name);
if (model.input_slot_number) {
fprintf(&f, "<in>\n");
fprintf(&f, "</in>\n");
}
if (model.output_slot_number) {
fprintf(&f, "<out>\n");
fprintf(&f, "</out>\n");
}
fprintf(&f, " </model>\n");
}
} else {
}
fprintf(&f, " </structures>\n");
}
void write(FILE& f) void write(FILE& f)
{ {
fprintf(&f, fprintf(&f,
...@@ -613,23 +623,22 @@ struct Vpz ...@@ -613,23 +623,22 @@ struct Vpz
"<!DOCTYPE vle_project PUBLIC \"-//VLE TEAM//DTD Strict // EN\"" "<!DOCTYPE vle_project PUBLIC \"-//VLE TEAM//DTD Strict // EN\""
"\"https://www.vle-project.org/vle-1.1.0.dtd\">\n"); "\"https://www.vle-project.org/vle-1.1.0.dtd\">\n");
{
write_dynamics(f);
fprintf(&f, " <experiment name=\"%s\">\n", name.c_str());
write_conditions(f);
write_views(f);
fprintf(&f, " </experiment>\n");
}
fprintf(&f, fprintf(&f,
"<vle_project version=\"%s\" date=\"%s\" author=\"%s\">\n", "<vle_project version=\"%s\" date=\"%s\" author=\"%s\">\n",
version.c_str(), version.c_str(),
date.c_str(), date.c_str(),
author.c_str()); author.c_str());
// write_model(f, );
write_dynamics(f);
fprintf(&f, " <experiment name=\"%s\">\n", name.c_str());
write_conditions(f);
write_views(f);
fprintf(&f, " </experiment>\n");
fprintf(&f, "</vle_project>\n"); fprintf(&f, "</vle_project>\n");
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment