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
Guilhem Saurel
dynamic-graph-python
Commits
8cae8bee
Commit
8cae8bee
authored
14 years ago
by
florent
Browse files
Options
Downloads
Patches
Plain Diff
Bind method Entity::getNewStyleCommandMap()
* src/dynamic-graph-py.cc, * src/entity-py.cc.
parent
f7ee5e75
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/dynamic-graph-py.cc
+5
-0
5 additions, 0 deletions
src/dynamic-graph-py.cc
src/entity-py.cc
+30
-0
30 additions, 0 deletions
src/entity-py.cc
with
35 additions
and
0 deletions
src/dynamic-graph-py.cc
+
5
−
0
View file @
8cae8bee
...
...
@@ -28,6 +28,7 @@ namespace dynamicgraph {
extern
PyObject
*
getSignal
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
displaySignals
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
executeCommand
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
listCommands
(
PyObject
*
self
,
PyObject
*
args
);
}
namespace
factory
{
...
...
@@ -121,6 +122,10 @@ static PyMethodDef dynamicGraphMethods[] = {
dynamicgraph
::
python
::
entity
::
executeCommand
,
METH_VARARGS
,
"execute a command"
},
{
"entity_list_commands"
,
dynamicgraph
::
python
::
entity
::
listCommands
,
METH_VARARGS
,
"list the commands of an entity"
},
{
"factory_get_entity_class_list"
,
dynamicgraph
::
python
::
factory
::
getEntityClassList
,
METH_VARARGS
,
...
...
This diff is collapsed.
Click to expand it.
src/entity-py.cc
+
30
−
0
View file @
8cae8bee
...
...
@@ -277,6 +277,36 @@ namespace dynamicgraph {
}
return
NULL
;
}
PyObject
*
listCommands
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
object
=
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
"O"
,
&
object
))
{
return
NULL
;
}
// Retrieve the entity instance
if
(
!
PyCObject_Check
(
object
))
{
PyErr_SetString
(
error
,
"first argument is not an object"
);
return
NULL
;
}
void
*
pointer
=
PyCObject_AsVoidPtr
(
object
);
Entity
*
entity
=
(
Entity
*
)
pointer
;
typedef
std
::
map
<
const
std
::
string
,
command
::
Command
*>
CommandMap
;
CommandMap
map
=
entity
->
getNewStyleCommandMap
();
unsigned
int
nbCommands
=
map
.
size
();
// Create a tuple of same size as the command map
PyObject
*
result
=
PyTuple_New
(
nbCommands
);
unsigned
int
count
=
0
;
for
(
CommandMap
::
iterator
it
=
map
.
begin
();
it
!=
map
.
end
();
it
++
)
{
std
::
string
commandName
=
it
->
first
;
PyObject
*
pyName
=
Py_BuildValue
(
"s"
,
commandName
.
c_str
());
PyTuple_SET_ITEM
(
result
,
count
,
pyName
);
count
++
;
}
return
result
;
}
}
}
}
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