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
dynamic-graph-python
Commits
ed39db7c
Commit
ed39db7c
authored
May 05, 2017
by
Olivier Stasse
Browse files
Implements correctly the list of entities inside the pool.
parent
e2fc6170
Pipeline
#4688
failed with stages
in 47 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/dynamic-graph-py.cc
View file @
ed39db7c
...
...
@@ -59,13 +59,13 @@ namespace dynamicgraph {
namespace
factory
{
extern
PyObject
*
getEntityClassList
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
getEntityMap
(
PyObject
*
self
,
PyObject
*
args
);
}
namespace
signalCaster
{
extern
PyObject
*
getSignalTypeList
(
PyObject
*
self
,
PyObject
*
args
);
}
namespace
pool
{
extern
PyObject
*
writeGraph
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
getEntityList
(
PyObject
*
self
,
PyObject
*
args
);
}
PyObject
*
dgpyError
;
...
...
@@ -216,6 +216,10 @@ static PyMethodDef dynamicGraphMethods[] = {
dynamicgraph
::
python
::
pool
::
writeGraph
,
METH_VARARGS
,
"Write the graph of entities in a filename."
},
{
"get_entity_list"
,
dynamicgraph
::
python
::
pool
::
getEntityList
,
METH_VARARGS
,
"return the list of instanciated entities"
},
{
NULL
,
NULL
,
0
,
NULL
}
/* Sentinel */
};
...
...
src/pool-py.cc
View file @
ed39db7c
...
...
@@ -15,7 +15,8 @@
#include
<Python.h>
#include
<dynamic-graph/pool.h>
#include
<dynamic-graph/entity.h>
#include
<vector>
#include
"exception.hh"
namespace
dynamicgraph
{
...
...
@@ -33,6 +34,43 @@ namespace dynamicgraph {
}
CATCH_ALL_EXCEPTIONS
();
return
Py_BuildValue
(
""
);
}
/**
\brief Get list of entities
*/
PyObject
*
getEntityList
(
PyObject
*
/*self*/
,
PyObject
*
args
)
{
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
std
::
vector
<
std
::
string
>
entityNames
;
try
{
const
PoolStorage
::
Entities
&
listOfEntities
=
dynamicgraph
::
PoolStorage
::
getInstance
()
->
getEntityMap
();
Py_ssize_t
classNumber
=
listOfEntities
.
size
();
// Build a tuple object
PyObject
*
classTuple
=
PyTuple_New
(
classNumber
);
Py_ssize_t
iEntity
=
0
;
for
(
PoolStorage
::
Entities
::
const_iterator
entity_it
=
listOfEntities
.
begin
();
entity_it
!=
listOfEntities
.
end
();
++
entity_it
)
{
const
std
::
string
&
aname
=
entity_it
->
second
->
getName
();
PyObject
*
className
=
Py_BuildValue
(
"s"
,
aname
.
c_str
());
PyTuple_SetItem
(
classTuple
,
iEntity
,
className
);
iEntity
++
;
}
return
Py_BuildValue
(
"O"
,
classTuple
);
}
CATCH_ALL_EXCEPTIONS
();
return
NULL
;
}
}
// python
}
// dynamicgraph
}
// namespace pool
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