Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ControlSystemAdapter-DoocsAdapter
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
ChimeraTK Mirror
ControlSystemAdapter-DoocsAdapter
Commits
9004bbe0
Commit
9004bbe0
authored
7 years ago
by
Martin Killenberg
Browse files
Options
Downloads
Patches
Plain Diff
implemented global import. much copy and paste, needs code cleanup, but tests are passing
parent
117a193e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/VariableMapper.h
+1
-0
1 addition, 0 deletions
include/VariableMapper.h
src/VariableMapper.cc
+37
-0
37 additions, 0 deletions
src/VariableMapper.cc
with
38 additions
and
0 deletions
include/VariableMapper.h
+
1
−
0
View file @
9004bbe0
...
...
@@ -71,6 +71,7 @@ namespace ChimeraTK{
void
processLocation
(
xmlpp
::
Node
const
*
locationNode
);
void
processProperty
(
xmlpp
::
Node
const
*
propertyNode
,
std
::
string
locationName
);
void
processLocationImport
(
xmlpp
::
Node
const
*
importNode
,
std
::
string
locationName
);
void
processGlobalImport
(
xmlpp
::
Node
const
*
importNode
);
std
::
map
<
std
::
string
,
PropertyAttributes
>
_locationDefaults
;
PropertyAttributes
_globalDefaults
;
...
...
This diff is collapsed.
Click to expand it.
src/VariableMapper.cc
+
37
−
0
View file @
9004bbe0
...
...
@@ -3,6 +3,7 @@
#include
<libxml++/libxml++.h>
#include
<iostream>
#include
<regex>
#include
"splitStringAtFirstSlash.h"
namespace
ChimeraTK
{
void
print_indentation
(
unsigned
int
indentation
)
...
...
@@ -180,6 +181,40 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0)
}
}
}
void
VariableMapper
::
processGlobalImport
(
xmlpp
::
Node
const
*
importNode
){
for
(
auto
const
&
node
:
importNode
->
get_children
()){
const
xmlpp
::
TextNode
*
nodeAsText
=
dynamic_cast
<
const
xmlpp
::
TextNode
*>
(
node
);
std
::
string
importSource
=
nodeAsText
->
get_content
();
std
::
cout
<<
"Globaly importing in : "
<<
importSource
<<
std
::
endl
;
// a slash will be added, so we make the source empty for a global import of everything
if
(
importSource
==
"/"
){
importSource
=
""
;
}
for
(
auto
const
&
processVariable
:
_inputVariables
){
if
(
_inputSortedDescriptions
.
find
(
processVariable
)
!=
_inputSortedDescriptions
.
end
()){
std
::
cout
<<
processVariable
<<
" alread in the map. Not importing"
<<
std
::
endl
;
continue
;
}
if
(
processVariable
.
find
(
importSource
+
"/"
)
==
0
){
std
::
cout
<<
"about to import "
<<
processVariable
<<
std
::
endl
;
// This variable is to be imported
auto
nameSource
=
processVariable
.
substr
(
importSource
.
size
()
+
1
);
// add the slash to be removed
auto
locationAndPropertyName
=
splitStringAtFirstSlash
(
nameSource
);
auto
locationName
=
locationAndPropertyName
.
first
;
auto
propertyName
=
locationAndPropertyName
.
second
;
if
(
locationName
.
empty
()
){
throw
std
::
logic_error
(
std
::
string
(
"Invalid XML content in global import of "
)
+
importSource
+
": Cannot create location name from '"
+
nameSource
+
"', one hirarchy level is missing."
);
}
_inputSortedDescriptions
[
processVariable
]
=
PropertyDescription
(
locationName
,
propertyName
);
}
}
}
}
void
VariableMapper
::
prepareOutput
(
std
::
string
xmlFile
,
std
::
set
<
std
::
string
>
inputVariables
){
_inputVariables
=
inputVariables
;
...
...
@@ -207,6 +242,8 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0)
if
(
mainNode
->
get_name
()
==
"location"
){
processLocation
(
mainNode
);
}
else
if
(
mainNode
->
get_name
()
==
"import"
){
processGlobalImport
(
mainNode
);
}
else
{
std
::
cout
<<
"FIXME: Implement main node '"
<<
mainNode
->
get_name
()
<<
"'! Current implementation does nothing"
<<
std
::
endl
;
...
...
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