Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dynamic-graph-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stack Of Tasks
dynamic-graph-python
Commits
95b27447
Commit
95b27447
authored
4 years ago
by
Joseph Mirabel
Browse files
Options
Downloads
Patches
Plain Diff
Add entity constructor with no argument.
parent
e1bc9742
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/dynamic-graph/python/module.hh
+18
-8
18 additions, 8 deletions
include/dynamic-graph/python/module.hh
with
18 additions
and
8 deletions
include/dynamic-graph/python/module.hh
+
18
−
8
View file @
95b27447
...
...
@@ -13,6 +13,22 @@ namespace python {
constexpr
int
AddSignals
=
1
;
constexpr
int
AddCommands
=
2
;
namespace
internal
{
template
<
typename
T
,
int
Options
=
AddCommands
|
AddSignals
>
bp
::
object
makeEntity1
(
const
char
*
name
)
{
Entity
*
ent
=
entity
::
create
(
T
::
CLASS_NAME
.
c_str
(),
name
);
assert
(
dynamic_cast
<
T
*>
(
ent
)
!=
NULL
);
bp
::
object
obj
(
bp
::
ptr
(
static_cast
<
T
*>
(
ent
)));
if
(
Options
&
AddCommands
)
entity
::
addCommands
(
obj
);
if
(
Options
&
AddSignals
)
entity
::
addSignals
(
obj
);
return
obj
;
}
template
<
typename
T
,
int
Options
=
AddCommands
|
AddSignals
>
bp
::
object
makeEntity2
()
{
return
makeEntity1
<
T
,
Options
>
(
""
);
}
}
/// \tparam Options by default, all the signals and commands are added as
/// attribute to the Python object. This behaviour works fine for
/// entities that have static commands and signals.
...
...
@@ -48,14 +64,8 @@ inline auto exposeEntity ()
})
;
*/
bp
::
def
(
T
::
CLASS_NAME
.
c_str
(),
+
[](
const
char
*
name
)
->
bp
::
object
{
Entity
*
ent
=
entity
::
create
(
T
::
CLASS_NAME
.
c_str
(),
name
);
assert
(
dynamic_cast
<
T
*>
(
ent
)
!=
NULL
);
bp
::
object
obj
(
bp
::
ptr
(
static_cast
<
T
*>
(
ent
)));
if
(
Options
&
AddCommands
)
entity
::
addCommands
(
obj
);
if
(
Options
&
AddSignals
)
entity
::
addSignals
(
obj
);
return
obj
;
});
bp
::
def
(
T
::
CLASS_NAME
.
c_str
(),
&
internal
::
makeEntity1
<
T
,
Options
>
);
bp
::
def
(
T
::
CLASS_NAME
.
c_str
(),
&
internal
::
makeEntity2
<
T
,
Options
>
);
return
obj
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment