Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dynamic-graph
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
Commits
61911bf3
Commit
61911bf3
authored
14 years ago
by
Thomas Moulard
Browse files
Options
Downloads
Patches
Plain Diff
Enhance import to avoid importing a module twice.
parent
5a0d07d0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/dynamic-graph/fwd.hh
+2
-0
2 additions, 0 deletions
include/dynamic-graph/fwd.hh
include/dynamic-graph/import.h
+21
-1
21 additions, 1 deletion
include/dynamic-graph/import.h
src/dgraph/import.cpp
+11
-15
11 additions, 15 deletions
src/dgraph/import.cpp
with
34 additions
and
16 deletions
include/dynamic-graph/fwd.hh
+
2
−
0
View file @
61911bf3
...
...
@@ -37,6 +37,8 @@ namespace dynamicgraph
template
<
class
Time
>
class
SignalArray
;
class
Interpreter
;
}
// end of namespace dynamicgraph.
#endif //! DYNAMIC_GRAPH_FWD_HH
This diff is collapsed.
Click to expand it.
include/dynamic-graph/import.h
+
21
−
1
View file @
61911bf3
...
...
@@ -23,9 +23,10 @@
# include <boost/filesystem/path.hpp>
# include <dynamic-graph/fwd.hh>
namespace
dynamicgraph
{
class
Interpreter
;
namespace
command
{
namespace
...
...
@@ -36,7 +37,26 @@ namespace dynamicgraph
/// will look for scripts or plug-ins.
typedef
std
::
vector
<
boost
::
filesystem
::
path
>
paths_t
;
/// \brief Import paths list.
///
/// This vector of string is similar to Unix variables such as
/// PATH. It contains all paths that are used to search when
/// importing a script.
///
/// The look-up is made from right to left:
///
/// On Unix:
/// importPaths = A:B:C
/// On Microsoft Windows:
/// importPaths = A;B;C
///
/// When typing "import foo", C will be searched first then B
/// and A. The search stops when the file is found.
extern
paths_t
importPaths
;
/// \brief Already imported paths to avoid multiple inclusion.
extern
paths_t
alreadyImportedPaths
;
}
// end of anonymous namespace.
/// \brief Implement sot interpretor import command.
...
...
This diff is collapsed.
Click to expand it.
src/dgraph/import.cpp
+
11
−
15
View file @
61911bf3
...
...
@@ -68,22 +68,8 @@ namespace dynamicgraph
/// Initialize import paths list (called during static initialization).
paths_t
initializePaths
();
/// \brief Import paths list.
///
/// This vector of string is similar to Unix variables such as
/// PATH. It contains all paths that are used to search when
/// importing a script.
///
/// The look-up is made from right to left:
///
/// On Unix:
/// importPaths = A:B:C
/// On Microsoft Windows:
/// importPaths = A;B;C
///
/// When typing ``import foo'', C will be searched first then B
/// and A. The search stops when the file is found.
paths_t
importPaths
=
initializePaths
();
paths_t
alreadyImportedPaths
;
/// Search for a module.
///
...
...
@@ -268,6 +254,7 @@ namespace dynamicgraph
// Get the absolute path of the module.
boost
::
filesystem
::
path
path
=
searchModule
(
module
);
// Check that the module can be opened.
std
::
ifstream
file
(
path
.
file_string
().
c_str
());
if
(
!
boost
::
filesystem
::
is_regular_file
(
path
)
||
!
file
.
is_open
()
||
!
file
.
good
())
...
...
@@ -296,11 +283,20 @@ namespace dynamicgraph
return
;
}
// If the module has already been imported, do not import it
// again.
if
(
std
::
find
(
alreadyImportedPaths
.
begin
(),
alreadyImportedPaths
.
end
(),
path
)
!=
alreadyImportedPaths
.
end
())
return
;
if
(
path
.
extension
()
!=
SHARED_LIBRARY_EXT
)
importScript
(
interpreter
,
path
,
file
,
os
);
else
importPlugin
(
interpreter
,
path
,
os
);
alreadyImportedPaths
.
push_back
(
path
);
dgDEBUGOUT
(
15
);
}
...
...
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