Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stack Of Tasks
sot-core
Commits
0c0e089a
Commit
0c0e089a
authored
Sep 29, 2020
by
Joseph Mirabel
Committed by
Guilhem Saurel
Nov 07, 2020
Browse files
[Python] Add constructor of Flags from list or tuple.
parent
c1c85134
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/sot/core/flags.hh
View file @
0c0e089a
...
...
@@ -37,7 +37,7 @@ protected:
public:
Flags
(
const
bool
&
b
=
false
);
Flags
(
const
char
*
flags
);
Flags
(
std
::
vector
<
bool
>
&
&
flags
);
Flags
(
const
std
::
vector
<
bool
>
&
flags
);
void
add
(
const
bool
&
b
);
...
...
src/python-module.cc
View file @
0c0e089a
...
...
@@ -50,7 +50,16 @@ BOOST_PYTHON_MODULE(wrap)
using
dgs
::
Flags
;
bp
::
class_
<
Flags
>
(
"Flags"
,
bp
::
init
<>
())
.
def
(
bp
::
init
<
const
char
*>
())
//TODO .def(bp::init<std::vector<bool>&& >())
.
def
(
"__init__"
,
bp
::
make_constructor
(
+
[](
bp
::
list
bools
)
{
std
::
vector
<
bool
>
flags
(
bp
::
len
(
bools
));
for
(
std
::
size_t
i
=
0
;
i
<
flags
.
size
();
++
i
)
flags
[
i
]
=
bp
::
extract
<
bool
>
(
bools
[
i
]);
return
new
Flags
(
flags
);
}))
.
def
(
"__init__"
,
bp
::
make_constructor
(
+
[](
bp
::
tuple
bools
)
{
std
::
vector
<
bool
>
flags
(
bp
::
len
(
bools
));
for
(
std
::
size_t
i
=
0
;
i
<
flags
.
size
();
++
i
)
flags
[
i
]
=
bp
::
extract
<
bool
>
(
bools
[
i
]);
return
new
Flags
(
flags
);
}))
.
def
(
"add"
,
&
Flags
::
add
)
.
def
(
"set"
,
&
Flags
::
set
)
.
def
(
"unset"
,
&
Flags
::
unset
)
...
...
src/sot/flags.cpp
View file @
0c0e089a
...
...
@@ -47,7 +47,7 @@ Flags::Flags(const char *_flags)
}
}
Flags
::
Flags
(
std
::
vector
<
bool
>
&
&
_flags
)
Flags
::
Flags
(
const
std
::
vector
<
bool
>
&
_flags
)
:
flags
(
_flags
),
outOfRangeFlag
(
false
)
{}
Flags
::
operator
bool
(
void
)
const
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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