Commit 3f9cc4d6 authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

to merge with new vpz

parent 15c7f4b7
Pipeline #2179 failed with stage
in 49 seconds
......@@ -23,11 +23,13 @@
#include <bits/array.hpp>
#include <bits/unit-test.hpp>
#include <ratio>
#include <string>
namespace vle {
using ID = bits::ID;
using IDs = bits::IDs;
struct Dynamics
{
std::string name;
......@@ -42,7 +44,7 @@ struct View
std::string package;
std::string library;
std::string location;
std::ration timestep;
double timestep;
enum class view_type
{
......@@ -59,7 +61,62 @@ struct View
};
struct Value
{};
{
enum class value_type
{
none,
integer8,
integer32,
integer64,
real32,
real64,
string,
};
Value()
: id(-1)
, type(Value::value_type::none)
{}
ID id; // ID in one of the data_array of the Values structure.
value_type type; // The type of the identifier ID.
};
struct Values
{
bits::data_array<std::int8_t, ID> integer8;
bits::data_array<std::int32_t, ID> integer32;
bits::data_array<std::int64_t, ID> integer64;
bits::data_array<float, ID> real32;
bits::data_array<double, ID> real64;
bits::data_array<std::string, ID> string;
void clear(const Value& value) noexcept
{
switch (value.type) {
case Value::value_type::integer8:
integer8.free(value.id);
break;
case Value::value_type::integer32:
integer32.free(value.id);
break;
case Value::value_type::integer64:
integer64.free(value.id);
break;
case Value::value_type::real32:
real32.free(value.id);
break;
case Value::value_type::real64:
real64.free(value.id);
break;
case Value::value_type::string:
string.free(value.id);
break;
default:
break;
}
}
};
struct Condition
{
......@@ -80,11 +137,11 @@ struct Model
std::string name;
ID dynamics;
ID observables;
data_array<ID> conditions;
data_array<ID> input_slots;
data_array<ID> output_slots;
data_array<ID> models;
data_array<ID> internal_connections;
// bits::data_array<ID> conditions;
// bits::data_array<ID> input_slots;
// bits::data_array<ID> output_slots;
// bits::data_array<ID> models;
// bits::data_array<ID> connections;
enum class model_type
{
......@@ -107,18 +164,18 @@ struct Vpz
std::string author;
std::string version;
data_array<Dynamics> dynamics;
data_array<View> views;
data_array<Conditions> conditions;
data_array<Model> models;
data_array<Connection> connections;
data_array<Class> classes;
data_array<float> value_float;
data_array<double> value_double;
data_array<std::int8_t> value_int8;
data_array<std::int64_t> value_int64;
data_array<std::string> value_string;
bits::data_array<Dynamics, IDs> dynamics;
bits::data_array<View, IDs> views;
bits::data_array<Condition, IDs> conditions;
bits::data_array<Model, IDs> models;
bits::data_array<Connection, IDs> connections;
bits::data_array<Class, IDs> classes;
bits::data_array<float, IDs> value_float;
bits::data_array<double, IDs> value_double;
bits::data_array<std::int8_t, IDs> value_int8;
bits::data_array<std::int64_t, IDs> value_int64;
bits::data_array<std::string, IDs> value_string;
};
} // vle
......@@ -126,6 +183,16 @@ struct Vpz
int
main(int /* argc */, char* /* argv */ [])
{
vle::Vpz vpz;
auto& cond = vpz.conditions.alloc();
cond.name = "condition 1";
float& v1 = vpz.value_float.alloc();
// float& v2 = vpz.value_float.alloc();
v1 = 1.f;
cond.value.id = vpz.value_float.get_id(v1);
cond.value.type = vle::Value::value_type::real32;
return unit_test::report_errors();
}
Markdown is supported
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