FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
knowrob/src/DataSourceHandler.cpp at dev · knowrob/knowrob · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
knowrob
/
knowrob
Public
Notifications
You must be signed in to change notification settings
Fork
112
Star
159
Code
Issues
4
Pull requests
2
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
knowrob
/
src
/
DataSourceHandler.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
44 lines (39 loc) · 1.38 KB
Breadcrumbs
knowrob
/
src
/
DataSourceHandler.cpp
Copy path
File metadata and controls
44 lines (39 loc) · 1.38 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#
include
"
knowrob/DataSourceHandler.h
"
#
include
"
knowrob/integration/python/utils.h
"
using
namespace
knowrob
;
void
DataSourceHandler::addDataHandler
(
const
std::string &format,
const
std::function<
bool
(
const
DataSourcePtr &)> &fn) {
dataSourceHandler_[format] = fn;
}
bool
DataSourceHandler::loadDataSource
(
const
DataSourcePtr &dataSource) {
if
(dataSource->
format
().
empty
()) {
return
loadDataSourceWithUnknownFormat
(dataSource);
}
else
{
auto
it = dataSourceHandler_.
find
(dataSource->
format
());
if
(it != dataSourceHandler_.
end
()) {
return
it->
second
(dataSource);
}
else
{
return
false
;
}
}
}
bool
DataSourceHandler::hasDataHandler
(
const
DataSourcePtr &dataSource)
const
{
return
dataSourceHandler_.
find
(dataSource->
format
()) != dataSourceHandler_.
end
();
}
namespace
knowrob
::py {
template
<>
void
createType<DataSourceHandler>() {
using
namespace
boost
::python
;
class_<DataSourceHandler, std::shared_ptr<DataSourceHandler>>(
"
DataSourceHandler
"
, init<>())
.
def
(
"
addDataHandler
"
, +[]
(DataSourceHandler &x,
const
std::string &format, object &fn) {
//
when KnowRob calls the data handler, it does not hold the GIL
//
so we need to acquire it before calling fn.
x.
addDataHandler
(format, [fn](
const
DataSourcePtr &dataSource) {
gil_lock lock;
return
fn
(dataSource);
});
})
.
def
(
"
loadDataSource
"
, &DataSourceHandler::loadDataSource);
}
}
Back
|
FazBrowse Home
|
New Git URL