Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gauthier Quesnel
bits
Commits
207d6285
Commit
207d6285
authored
Apr 07, 2019
by
Gauthier Quesnel
Browse files
next15
parent
41017a06
Pipeline
#2315
failed with stage
in 1 minute and 7 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
include/bits/allocator.hpp
View file @
207d6285
...
...
@@ -8,6 +8,7 @@
#include <memory>
#include <cstdint>
#include <cstdlib>
namespace
bits
{
...
...
@@ -33,6 +34,11 @@ public:
return
malloc
(
n
);
}
void
*
allocate
(
size_t
n
,
size_t
alignment
)
{
return
aligned_alloc
(
alignment
,
n
);
}
void
deallocate
(
void
*
p
,
size_t
/*n*/
)
{
free
(
p
);
...
...
include/bits/data-array.hpp
View file @
207d6285
...
...
@@ -138,7 +138,15 @@ make_next_key<IDs>(unsigned key) noexcept
template
<
typename
T
,
typename
Identifier
>
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
value_type
=
T
;
struct
item
{
...
...
@@ -201,8 +209,8 @@ struct data_array
item
*
items
=
nullptr
;
// items vector.
int
max_size
=
0
;
// total size
int
max_used
=
0
;
// highest index ever alloced
int
capacity
=
0
;
// num alloced items
int
max_used
=
0
;
// highest index ever alloc
at
ed
int
capacity
=
0
;
// num alloc
at
ed items
unsigned
int
next_key
=
1
;
// [1..2^16] (don't let == 0)
int
free_head
=
-
1
;
// index of first free entry
};
...
...
test/vpz.cpp
View file @
207d6285
...
...
@@ -38,14 +38,14 @@ using ID = bits::ID;
struct
ID2
{
ID2
()
=
default
;
constexpr
ID2
()
noexcept
=
default
;
ID2
(
ID
id
)
constexpr
ID2
(
ID
id
)
noexcept
:
id1
(
id
)
,
id2
(
id
)
{}
ID2
(
ID
id1_
,
ID
id2_
)
constexpr
ID2
(
ID
id1_
,
ID
id2_
)
noexcept
:
id1
(
id1_
)
,
id2
(
id2_
)
{}
...
...
@@ -304,9 +304,6 @@ struct Class
std
::
string
name
;
};
struct
State
{};
struct
SimDynamics
{
// 1) classical hierarchy model? => no
...
...
@@ -316,7 +313,6 @@ struct SimDynamics
// std::function<void(State)> output;
// 3) Each library gives a DataArray<T> of atomic model.
// dynamics_id gives the correct library
//
unsigned
dynamics_id
;
ID
model_id
;
...
...
@@ -384,7 +380,9 @@ struct data_array_wrapper
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
)
{
...
...
@@ -493,22 +491,6 @@ struct Vpz
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
)
{
fprintf
(
&
f
,
" <dynamics>
\n
"
);
...
...
@@ -606,6 +588,34 @@ struct Vpz
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
)
{
fprintf
(
&
f
,
...
...
@@ -613,23 +623,22 @@ struct Vpz
"<!DOCTYPE vle_project PUBLIC
\"
-//VLE TEAM//DTD Strict // EN
\"
"
"
\"
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
,
"<vle_project version=
\"
%s
\"
date=
\"
%s
\"
author=
\"
%s
\"
>
\n
"
,
version
.
c_str
(),
date
.
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
"
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment