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
117a193e
Commit
117a193e
authored
7 years ago
by
Martin Killenberg
Browse files
Options
Downloads
Patches
Plain Diff
importing locations works
parent
5fd4308f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/VariableMapper.h
+2
-0
2 additions, 0 deletions
include/VariableMapper.h
src/VariableMapper.cc
+26
-4
26 additions, 4 deletions
src/VariableMapper.cc
tests/src/testVariableMapper.cpp
+18
-16
18 additions, 16 deletions
tests/src/testVariableMapper.cpp
with
46 additions
and
20 deletions
include/VariableMapper.h
+
2
−
0
View file @
117a193e
...
...
@@ -66,6 +66,8 @@ namespace ChimeraTK{
protected
:
VariableMapper
()
=
default
;
std
::
set
<
std
::
string
>
_inputVariables
;
void
processLocation
(
xmlpp
::
Node
const
*
locationNode
);
void
processProperty
(
xmlpp
::
Node
const
*
propertyNode
,
std
::
string
locationName
);
void
processLocationImport
(
xmlpp
::
Node
const
*
importNode
,
std
::
string
locationName
);
...
...
This diff is collapsed.
Click to expand it.
src/VariableMapper.cc
+
26
−
4
View file @
117a193e
...
...
@@ -2,6 +2,7 @@
#include
<libxml++/libxml++.h>
#include
<iostream>
#include
<regex>
namespace
ChimeraTK
{
void
print_indentation
(
unsigned
int
indentation
)
...
...
@@ -156,12 +157,33 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0)
void
VariableMapper
::
processLocationImport
(
xmlpp
::
Node
const
*
importNode
,
std
::
string
locationName
){
for
(
auto
const
&
node
:
importNode
->
get_children
()){
const
xmlpp
::
TextNode
*
nodeAsText
=
dynamic_cast
<
const
xmlpp
::
TextNode
*>
(
node
);
std
::
cout
<<
"Importing location: "
<<
nodeAsText
->
get_content
()
<<
std
::
endl
;
// loop source tree, cut beginning, replace / with _ and add a property
std
::
string
importSource
=
nodeAsText
->
get_content
();
std
::
cout
<<
"Importing in location '"
<<
locationName
<<
"': "
<<
importSource
<<
std
::
endl
;
// loop source tree, cut beginning, replace / with _ and add a property
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
){
// processVariable starts with wanted source
std
::
cout
<<
"importing "
<<
processVariable
<<
" from "
<<
importSource
<<
" into "
<<
locationName
<<
std
::
endl
;
auto
propertyNameSource
=
processVariable
.
substr
(
importSource
.
size
()
+
1
);
// add the slash to be removed
std
::
cout
<<
"propertyNameSource "
<<
propertyNameSource
<<
std
::
endl
;
auto
propertyName
=
std
::
regex_replace
(
propertyNameSource
,
std
::
regex
(
"/"
),
"."
);
std
::
cout
<<
"new property name is "
<<
propertyName
<<
std
::
endl
;
_inputSortedDescriptions
[
processVariable
]
=
PropertyDescription
(
locationName
,
propertyName
);
}
}
}
}
void
VariableMapper
::
prepareOutput
(
std
::
string
xmlFile
,
std
::
set
<
std
::
string
>
inputVariables
){
_inputVariables
=
inputVariables
;
xmlpp
::
DomParser
parser
;
// parser.set_validate();
parser
.
set_substitute_entities
();
//We just want the text to be resolved/unescaped automatically.
...
...
@@ -175,8 +197,8 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0)
//Walk the tree:
const
xmlpp
::
Node
*
rootNode
=
parser
.
get_document
()
->
get_root_node
();
//deleted by DomParser.
std
::
cout
<<
"****************************
\n
Predefined printout in "
<<
xmlFile
<<
":
\n
"
<<
std
::
endl
;
print_node
(
rootNode
);
//
std::cout << "****************************\nPredefined printout in "<< xmlFile<<":\n" << std::endl;
//
print_node(rootNode);
std
::
cout
<<
"
\n
My interpretation for "
<<
xmlFile
<<
"
\n
==================================="
<<
std
::
endl
;
...
...
This diff is collapsed.
Click to expand it.
tests/src/testVariableMapper.cpp
+
18
−
16
View file @
117a193e
...
...
@@ -64,9 +64,11 @@ std::set< std::string > generateInputVariables(){
template
<
typename
Map
>
bool
mapCompare
(
Map
const
&
lhs
,
Map
const
&
rhs
)
{
// No predicate needed because there is operator== for pairs already.
std
::
cout
<<
"lhs.size() "
<<
lhs
.
size
()
<<
", rhs.size() "
<<
rhs
.
size
()
<<
std
::
endl
;
return
lhs
.
size
()
==
rhs
.
size
()
&&
std
::
equal
(
lhs
.
begin
(),
lhs
.
end
(),
rhs
.
begin
());
if
(
lhs
.
size
()
!=
rhs
.
size
()
){
std
::
cout
<<
"Map size comparison failed: lhs.size() "
<<
lhs
.
size
()
<<
", rhs.size() "
<<
rhs
.
size
()
<<
std
::
endl
;
return
false
;
}
return
std
::
equal
(
lhs
.
begin
(),
lhs
.
end
(),
rhs
.
begin
());
}
void
testXmlParsing
(
std
::
string
xmlFile
,
std
::
map
<
std
::
string
,
VariableMapper
::
PropertyDescription
>
propertyMap
){
...
...
@@ -82,27 +84,27 @@ BOOST_AUTO_TEST_CASE( testRename ){
}
BOOST_AUTO_TEST_CASE
(
testImportLocation
){
testXmlParsing
(
"variableTreeXml/importLocation.xml"
,
{
{
"/A/a/di"
,
{
"B"
,
"a
_
di"
}},
{
"/A/a/do"
,
{
"B"
,
"a
_
do"
}},
testXmlParsing
(
"variableTreeXml/importLocation.xml"
,
{
{
"/A/a/di"
,
{
"B"
,
"a
.
di"
}},
{
"/A/a/do"
,
{
"B"
,
"a
.
do"
}},
{
"/A/b"
,
{
"B"
,
"b"
}}
});
}
BOOST_AUTO_TEST_CASE
(
testImportAll
){
testXmlParsing
(
"variableTreeXml/importAll.xml"
,
{
{
"/A/a/di"
,
{
"A"
,
"a
_
di"
}},
{
"/A/a/do"
,
{
"A"
,
"a
_
do"
}},
testXmlParsing
(
"variableTreeXml/importAll.xml"
,
{
{
"/A/a/di"
,
{
"A"
,
"a
.
di"
}},
{
"/A/a/do"
,
{
"A"
,
"a
.
do"
}},
{
"/A/b"
,
{
"A"
,
"b"
}},
{
"/B/a/dr"
,
{
"B"
,
"a
_
dr"
}},
{
"/B/c/de"
,
{
"B"
,
"c
_
de"
}},
{
"/B/c/gne"
,
{
"B"
,
"c
_
gne"
}},
{
"/C/a/da"
,
{
"C"
,
"a
_
da"
}},
{
"/C/b/ge"
,
{
"C"
,
"b
_
ge"
}},
{
"/C/c/be"
,
{
"C"
,
"c
_
be"
}},
{
"/C/c/de"
,
{
"C"
,
"c
_
de"
}},
{
"/B/a/dr"
,
{
"B"
,
"a
.
dr"
}},
{
"/B/c/de"
,
{
"B"
,
"c
.
de"
}},
{
"/B/c/gne"
,
{
"B"
,
"c
.
gne"
}},
{
"/C/a/da"
,
{
"C"
,
"a
.
da"
}},
{
"/C/b/ge"
,
{
"C"
,
"b
.
ge"
}},
{
"/C/c/be"
,
{
"C"
,
"c
.
be"
}},
{
"/C/c/de"
,
{
"C"
,
"c
.
de"
}},
{
"/DIRECT/DOUBLE"
,
{
"DIRECT"
,
"DOUBLE"
}},
{
"/DIRECT/DOUBLE"
,
{
"DIRECT"
,
"DOUBLE_ARRAY"
}},
{
"/DIRECT/DOUBLE
_ARRAY
"
,
{
"DIRECT"
,
"DOUBLE_ARRAY"
}},
{
"/DIRECT/INT"
,
{
"DIRECT"
,
"INT"
}},
{
"/DIRECT/INT"
,
{
"DIRECT"
,
"INT_ARRAY"
}}
{
"/DIRECT/INT
_ARRAY
"
,
{
"DIRECT"
,
"INT_ARRAY"
}}
});
}
...
...
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