Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mirrors
SuperElastix
Commits
b47a3a95
Commit
b47a3a95
authored
Feb 14, 2017
by
Floris Berendsen
Browse files
STYLE: uncrustify
parent
e4089f81
Changes
123
Hide whitespace changes
Inline
Side-by-side
Modules/Blueprints/include/selxBlueprint.h
View file @
b47a3a95
...
...
@@ -27,11 +27,10 @@
namespace
selx
{
class
Blueprint
{
public:
typedef
std
::
string
ParameterKeyType
;
typedef
std
::
vector
<
std
::
string
>
ParameterValueType
;
typedef
std
::
map
<
ParameterKeyType
,
ParameterValueType
>
ParameterMapType
;
...
...
@@ -39,18 +38,18 @@ public:
typedef
std
::
vector
<
ComponentNameType
>
ComponentNamesType
;
Blueprint
(
void
);
Blueprint
(
const
Blueprint
&
other
);
// copyable
Blueprint
&
operator
=
(
const
Blueprint
&
other
);
//
Blueprint
(
const
Blueprint
&
other
);
// copyable
Blueprint
&
operator
=
(
const
Blueprint
&
other
);
//
//Blueprint(Blueprint&&);
~
Blueprint
(
void
);
bool
SetComponent
(
ComponentNameType
,
ParameterMapType
parameterMap
);
ParameterMapType
GetComponent
(
ComponentNameType
componentName
)
const
;
bool
DeleteComponent
(
ComponentNameType
componentName
);
bool
ComponentExists
(
ComponentNameType
componentName
)
const
;
// Returns a vector of the all Component names in the graph.
...
...
@@ -67,21 +66,20 @@ public:
//std::unique_ptr<Blueprint> Clone(Blueprint const &other );
// "functional" composition of blueprints is done by adding settings of other to this blueprint. Redefining/overwriting properties is not allowed and returns false.
bool
ComposeWith
(
std
::
unique_ptr
<
Blueprint
>
const
&
other
);
bool
ComposeWith
(
std
::
unique_ptr
<
Blueprint
>
const
&
other
);
// Returns a vector of the Component names at the incoming direction
ComponentNamesType
GetInputNames
(
const
ComponentNameType
name
)
const
;
// Returns a vector of the Component names at the outgoing direction
ComponentNamesType
GetOutputNames
(
const
ComponentNameType
name
)
const
;
void
Write
(
const
std
::
string
filename
);
private:
struct
BlueprintImpl
;
std
::
unique_ptr
<
BlueprintImpl
>
m_Pimple
;
};
}
...
...
Modules/Blueprints/src/selxBlueprint.cxx
View file @
b47a3a95
...
...
@@ -20,30 +20,32 @@
#include
"selxBlueprint.h"
#include
"selxBlueprintImpl.h"
namespace
selx
{
namespace
selx
{
Blueprint
::
Blueprint
(
void
)
:
m_Pimple
(
new
Blueprint
::
BlueprintImpl
)
{}
;
::
Blueprint
(
void
)
:
m_Pimple
(
new
Blueprint
::
BlueprintImpl
)
{}
Blueprint
::
Blueprint
(
const
Blueprint
&
other
)
:
m_Pimple
(
new
BlueprintImpl
(
*
other
.
m_Pimple
)
)
Blueprint
::
Blueprint
(
const
Blueprint
&
other
)
:
m_Pimple
(
new
BlueprintImpl
(
*
other
.
m_Pimple
)
)
{}
Blueprint
&
Blueprint
::
operator
=
(
const
Blueprint
&
other
)
{
if
(
this
!=
&
other
)
{
m_Pimple
.
reset
(
new
BlueprintImpl
(
*
other
.
m_Pimple
));
Blueprint
&
Blueprint
::
operator
=
(
const
Blueprint
&
other
)
{
if
(
this
!=
&
other
)
{
m_Pimple
.
reset
(
new
BlueprintImpl
(
*
other
.
m_Pimple
)
);
}
return
*
this
;
}
//Blueprint
//::Blueprint(Blueprint&&) = default;
Blueprint
::~
Blueprint
(
void
)
=
default
;
bool
Blueprint
::
SetComponent
(
ComponentNameType
name
,
ParameterMapType
parameterMap
)
...
...
@@ -114,18 +116,19 @@ Blueprint
return
this
->
m_Pimple
->
ConnectionExists
(
upstream
,
downstream
);
}
//std::unique_ptr<Blueprint>
//Blueprint
//::Clone(Blueprint const &other)
//{
// return std::make_unique<Blueprint>(other);
// return std::make_unique<Blueprint>(other);
//}
bool
Blueprint
::
ComposeWith
(
std
::
unique_ptr
<
Blueprint
>
const
&
other
)
::
ComposeWith
(
std
::
unique_ptr
<
Blueprint
>
const
&
other
)
{
return
this
->
m_Pimple
->
ComposeWith
(
other
);
return
this
->
m_Pimple
->
ComposeWith
(
other
);
}
...
...
@@ -151,5 +154,4 @@ Blueprint
{
this
->
m_Pimple
->
Write
(
filename
);
}
}
// namespace selx
\ No newline at end of file
}
// namespace selx
Modules/Blueprints/src/selxBlueprintImpl.cxx
View file @
b47a3a95
...
...
@@ -23,15 +23,14 @@
namespace
selx
{
// Declared outside of the class body, so it is a free function
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
Blueprint
::
ParameterMapType
&
val
)
operator
<<
(
std
::
ostream
&
out
,
const
Blueprint
::
ParameterMapType
&
val
)
{
for
(
auto
const
&
mapPair
:
val
)
for
(
auto
const
&
mapPair
:
val
)
{
out
<<
mapPair
.
first
<<
" : [ "
;
for
(
auto
const
&
value
:
mapPair
.
second
)
for
(
auto
const
&
value
:
mapPair
.
second
)
{
out
<<
value
<<
" "
;
}
...
...
@@ -46,11 +45,11 @@ class vertex_label_writer
{
public:
vertex_label_writer
(
NameType
_name
,
ParameterMapType
_parameterMap
)
:
name
(
_name
),
parameterMap
(
_parameterMap
)
{}
vertex_label_writer
(
NameType
_name
,
ParameterMapType
_parameterMap
)
:
name
(
_name
),
parameterMap
(
_parameterMap
)
{}
template
<
class
VertexOrEdge
>
void
operator
()(
std
::
ostream
&
out
,
const
VertexOrEdge
&
v
)
const
void
operator
()(
std
::
ostream
&
out
,
const
VertexOrEdge
&
v
)
const
{
out
<<
"[label=
\"
"
<<
name
[
v
]
<<
"
\n
"
<<
parameterMap
[
v
]
<<
"
\"
]"
;
out
<<
"[label=
\"
"
<<
name
[
v
]
<<
"
\n
"
<<
parameterMap
[
v
]
<<
"
\"
]"
;
}
...
...
@@ -62,9 +61,9 @@ private:
template
<
class
NameType
,
class
ParameterMapType
>
inline
vertex_label_writer
<
NameType
,
ParameterMapType
>
make_vertex_label_writer
(
NameType
n
,
ParameterMapType
p
)
make_vertex_label_writer
(
NameType
n
,
ParameterMapType
p
)
{
return
vertex_label_writer
<
NameType
,
ParameterMapType
>
(
n
,
p
);
return
vertex_label_writer
<
NameType
,
ParameterMapType
>
(
n
,
p
);
}
...
...
@@ -73,11 +72,11 @@ class edge_label_writer
{
public:
edge_label_writer
(
ParameterMapType
_parameterMap
)
:
parameterMap
(
_parameterMap
)
{}
edge_label_writer
(
ParameterMapType
_parameterMap
)
:
parameterMap
(
_parameterMap
)
{}
template
<
class
VertexOrEdge
>
void
operator
()(
std
::
ostream
&
out
,
const
VertexOrEdge
&
v
)
const
void
operator
()(
std
::
ostream
&
out
,
const
VertexOrEdge
&
v
)
const
{
out
<<
"[label=
\"
"
<<
parameterMap
[
v
]
<<
"
\"
]"
;
out
<<
"[label=
\"
"
<<
parameterMap
[
v
]
<<
"
\"
]"
;
}
...
...
@@ -88,9 +87,9 @@ private:
template
<
class
ParameterMapType
>
inline
edge_label_writer
<
ParameterMapType
>
make_edge_label_writer
(
ParameterMapType
p
)
make_edge_label_writer
(
ParameterMapType
p
)
{
return
edge_label_writer
<
ParameterMapType
>
(
p
);
return
edge_label_writer
<
ParameterMapType
>
(
p
);
}
...
...
@@ -109,7 +108,7 @@ Blueprint::BlueprintImpl
}
}
Blueprint
::
ParameterMapType
Blueprint
::
BlueprintImpl
::
GetComponent
(
ComponentNameType
name
)
const
...
...
@@ -134,10 +133,11 @@ Blueprint::BlueprintImpl
this
->
m_Graph
.
remove_vertex
(
name
);
return
true
;
}
return
false
;
}
Blueprint
::
ComponentNamesType
Blueprint
::
BlueprintImpl
::
GetComponentNames
(
void
)
const
...
...
@@ -159,7 +159,7 @@ Blueprint::BlueprintImpl
{
return
false
;
}
if
(
!
this
->
ConnectionExists
(
upstream
,
downstream
)
)
{
boost
::
add_edge_by_label
(
upstream
,
downstream
,
{
parameterMap
},
this
->
m_Graph
);
...
...
@@ -168,7 +168,7 @@ Blueprint::BlueprintImpl
{
this
->
m_Graph
[
this
->
GetConnectionIndex
(
upstream
,
downstream
)
].
parameterMap
=
parameterMap
;
}
return
true
;
}
...
...
@@ -219,44 +219,45 @@ Blueprint::BlueprintImpl
return
boost
::
edge_by_label
(
upstream
,
downstream
,
this
->
m_Graph
).
second
;
}
bool
bool
Blueprint
::
BlueprintImpl
::
ComposeWith
(
std
::
unique_ptr
<
Blueprint
>
const
&
other
)
::
ComposeWith
(
std
::
unique_ptr
<
Blueprint
>
const
&
other
)
{
// Make a backup of the current blueprint status in case composition fails
GraphType
graph_backup
=
GraphType
(
this
->
m_Graph
);
GraphType
graph_backup
=
GraphType
(
this
->
m_Graph
);
// Copy-in all components (Nodes)
for
(
auto
const
&
componentName
:
other
->
GetComponentNames
())
for
(
auto
const
&
componentName
:
other
->
GetComponentNames
()
)
{
// Does other blueprint use component with a name that already exists?
if
(
this
->
ComponentExists
(
componentName
)
)
if
(
this
->
ComponentExists
(
componentName
)
)
{
// Component exists, check if properties can be merged
auto
ownProperties
=
this
->
GetComponent
(
componentName
);
auto
othersProperties
=
other
->
GetComponent
(
componentName
);
auto
ownProperties
=
this
->
GetComponent
(
componentName
);
auto
othersProperties
=
other
->
GetComponent
(
componentName
);
for
(
auto
const
&
othersEntry
:
othersProperties
)
for
(
auto
const
&
othersEntry
:
othersProperties
)
{
// Does other use a property key that already exists in this component?
if
(
ownProperties
.
count
(
othersEntry
.
first
)
)
if
(
ownProperties
.
count
(
othersEntry
.
first
)
)
{
auto
&&
ownValues
=
ownProperties
[
othersEntry
.
first
];
auto
&&
ownValues
=
ownProperties
[
othersEntry
.
first
];
auto
&&
otherValues
=
othersEntry
.
second
;
// Are the property values equal?
if
(
ownValues
.
size
()
!=
otherValues
.
size
())
if
(
ownValues
.
size
()
!=
otherValues
.
size
()
)
{
// No, based on the number of values we see that it is different. Blueprints cannot be Composed
this
->
m_Graph
=
graph_backup
;
return
false
;
}
}
else
{
ParameterValueType
::
const_iterator
ownValue
;
ParameterValueType
::
const_iterator
otherValue
;
for
(
ownValue
=
ownValues
.
begin
(),
otherValue
=
otherValues
.
begin
();
ownValue
!=
ownValues
.
end
();
++
ownValue
,
++
otherValue
)
for
(
ownValue
=
ownValues
.
begin
(),
otherValue
=
otherValues
.
begin
();
ownValue
!=
ownValues
.
end
();
++
ownValue
,
++
otherValue
)
{
if
(
*
otherValue
!=
*
ownValue
)
if
(
*
otherValue
!=
*
ownValue
)
{
// No, at least one value is different. Blueprints cannot be Composed
this
->
m_Graph
=
graph_backup
;
...
...
@@ -268,41 +269,39 @@ Blueprint::BlueprintImpl
else
{
// Property key doesn't exist yet, add entry to this component
auto
ownProperties
=
this
->
GetComponent
(
componentName
);
ownProperties
[
othersEntry
.
first
]
=
othersEntry
.
second
;
this
->
SetComponent
(
componentName
,
ownProperties
);
auto
ownProperties
=
this
->
GetComponent
(
componentName
);
ownProperties
[
othersEntry
.
first
]
=
othersEntry
.
second
;
this
->
SetComponent
(
componentName
,
ownProperties
);
}
}
}
else
{
// Create Component copying properties of other
this
->
SetComponent
(
componentName
,
other
->
GetComponent
(
componentName
)
);
this
->
SetComponent
(
componentName
,
other
->
GetComponent
(
componentName
)
);
}
}
// Copy-in all connections (Edges)
for
(
auto
const
&
componentName
:
other
->
GetComponentNames
())
for
(
auto
const
&
componentName
:
other
->
GetComponentNames
()
)
{
for
(
auto
incomingName
:
other
->
GetInputNames
(
componentName
)
)
for
(
auto
incomingName
:
other
->
GetInputNames
(
componentName
)
)
{
// Does other blueprint have a connection that already exists?
if
(
this
->
ConnectionExists
(
incomingName
,
componentName
)
)
if
(
this
->
ConnectionExists
(
incomingName
,
componentName
)
)
{
// Connection exists, check if properties can be merged
auto
ownProperties
=
this
->
GetConnection
(
incomingName
,
componentName
);
auto
othersProperties
=
other
->
GetConnection
(
incomingName
,
componentName
);
auto
ownProperties
=
this
->
GetConnection
(
incomingName
,
componentName
);
auto
othersProperties
=
other
->
GetConnection
(
incomingName
,
componentName
);
for
(
auto
const
&
othersEntry
:
othersProperties
)
for
(
auto
const
&
othersEntry
:
othersProperties
)
{
// Does other use a property key that already exists in this component?
if
(
ownProperties
.
count
(
othersEntry
.
first
)
)
if
(
ownProperties
.
count
(
othersEntry
.
first
)
)
{
auto
&&
ownValues
=
ownProperties
[
othersEntry
.
first
];
auto
&&
ownValues
=
ownProperties
[
othersEntry
.
first
];
auto
&&
otherValues
=
othersEntry
.
second
;
// Are the property values equal?
if
(
ownValues
.
size
()
!=
otherValues
.
size
())
if
(
ownValues
.
size
()
!=
otherValues
.
size
()
)
{
// No, based on the number of values we see that it is different. Blueprints cannot be Composed
this
->
m_Graph
=
graph_backup
;
...
...
@@ -312,9 +311,9 @@ Blueprint::BlueprintImpl
{
ParameterValueType
::
const_iterator
ownValue
;
ParameterValueType
::
const_iterator
otherValue
;
for
(
ownValue
=
ownValues
.
begin
(),
otherValue
=
otherValues
.
begin
();
ownValue
!=
ownValues
.
end
();
++
ownValue
,
++
otherValue
)
for
(
ownValue
=
ownValues
.
begin
(),
otherValue
=
otherValues
.
begin
();
ownValue
!=
ownValues
.
end
();
++
ownValue
,
++
otherValue
)
{
if
(
*
otherValue
!=
*
ownValue
)
if
(
*
otherValue
!=
*
ownValue
)
{
// No, at least one value is different. Blueprints cannot be Composed
this
->
m_Graph
=
graph_backup
;
...
...
@@ -326,19 +325,18 @@ Blueprint::BlueprintImpl
else
{
// Property key doesn't exist yet, add entry to this component
auto
ownProperties
=
this
->
GetConnection
(
incomingName
,
componentName
);
ownProperties
[
othersEntry
.
first
]
=
othersEntry
.
second
;
this
->
SetConnection
(
incomingName
,
componentName
,
ownProperties
);
auto
ownProperties
=
this
->
GetConnection
(
incomingName
,
componentName
);
ownProperties
[
othersEntry
.
first
]
=
othersEntry
.
second
;
this
->
SetConnection
(
incomingName
,
componentName
,
ownProperties
);
}
}
}
else
{
// Create Component copying properties of other
this
->
SetConnection
(
incomingName
,
componentName
,
other
->
GetConnection
(
incomingName
,
componentName
)
);
this
->
SetConnection
(
incomingName
,
componentName
,
other
->
GetConnection
(
incomingName
,
componentName
)
);
}
}
}
return
true
;
...
...
@@ -397,9 +395,8 @@ Blueprint::BlueprintImpl
{
std
::
ofstream
dotfile
(
filename
.
c_str
()
);
boost
::
write_graphviz
(
dotfile
,
this
->
m_Graph
,
make_vertex_label_writer
(
boost
::
get
(
&
ComponentPropertyType
::
name
,
this
->
m_Graph
),
boost
::
get
(
&
ComponentPropertyType
::
parameterMap
,
this
->
m_Graph
)
),
make_edge_label_writer
(
boost
::
get
(
&
ConnectionPropertyType
::
parameterMap
,
this
->
m_Graph
)
)
);
make_vertex_label_writer
(
boost
::
get
(
&
ComponentPropertyType
::
name
,
this
->
m_Graph
),
boost
::
get
(
&
ComponentPropertyType
::
parameterMap
,
this
->
m_Graph
)
),
make_edge_label_writer
(
boost
::
get
(
&
ConnectionPropertyType
::
parameterMap
,
this
->
m_Graph
)
)
);
}
}
// namespace selx
Modules/Blueprints/src/selxBlueprintImpl.h
View file @
b47a3a95
...
...
@@ -29,15 +29,15 @@
#include
"selxBlueprint.h"
namespace
selx
{
struct
Blueprint
::
BlueprintImpl
{
namespace
selx
{
struct
Blueprint
::
BlueprintImpl
{
// Component parameter map that sits on a node in the graph
// and holds component configuration settings
struct
ComponentPropertyType
{
ComponentPropertyType
(
ComponentNameType
name
=
""
,
ParameterMapType
parameterMap
=
{})
:
name
(
name
),
parameterMap
(
parameterMap
)
{}
ComponentPropertyType
(
ComponentNameType
name
=
""
,
ParameterMapType
parameterMap
=
{}
)
:
name
(
name
),
parameterMap
(
parameterMap
)
{}
ComponentNameType
name
;
ParameterMapType
parameterMap
;
};
...
...
@@ -46,20 +46,20 @@ struct Blueprint::BlueprintImpl {
// and holds component connection configuration settings
struct
ConnectionPropertyType
{
ConnectionPropertyType
(
ParameterMapType
parameterMap
=
{})
:
parameterMap
(
parameterMap
)
{}
ConnectionPropertyType
(
ParameterMapType
parameterMap
=
{}
)
:
parameterMap
(
parameterMap
)
{}
ParameterMapType
parameterMap
;
};
typedef
boost
::
labeled_graph
<
typedef
boost
::
labeled_graph
<
boost
::
adjacency_list
<
boost
::
vecS
,
boost
::
vecS
,
boost
::
bidirectionalS
,
ComponentPropertyType
,
ConnectionPropertyType
boost
::
vecS
,
boost
::
vecS
,
boost
::
bidirectionalS
,
ComponentPropertyType
,
ConnectionPropertyType
>
,
ComponentNameType
>
GraphType
;
typedef
boost
::
graph_traits
<
GraphType
>::
vertex_descriptor
ComponentIndexType
;
typedef
boost
::
graph_traits
<
GraphType
>::
vertex_iterator
ComponentIteratorType
;
typedef
std
::
pair
<
ComponentIteratorType
,
ComponentIteratorType
>
ComponentIteratorPairType
;
...
...
@@ -79,7 +79,7 @@ struct Blueprint::BlueprintImpl {
ParameterMapType
GetComponent
(
ComponentNameType
componentName
)
const
;
bool
DeleteComponent
(
ComponentNameType
componentName
);
bool
ComponentExists
(
ComponentNameType
componentName
)
const
;
// Returns a vector of the all Component names in the graph.
...
...
@@ -93,22 +93,20 @@ struct Blueprint::BlueprintImpl {
bool
ConnectionExists
(
ComponentNameType
upstream
,
ComponentNameType
downstream
)
const
;
bool
ComposeWith
(
std
::
unique_ptr
<
Blueprint
>
const
&
other
);
bool
ComposeWith
(
std
::
unique_ptr
<
Blueprint
>
const
&
other
);
// Returns a vector of the Component names at the incoming direction
ComponentNamesType
GetInputNames
(
const
ComponentNameType
name
)
const
;
// Returns a vector of the Component names at the outgoing direction
ComponentNamesType
GetOutputNames
(
const
ComponentNameType
name
)
const
;
void
Write
(
const
std
::
string
filename
);
ConnectionIndexType
GetConnectionIndex
(
ComponentNameType
upsteam
,
ComponentNameType
downstream
)
const
;
GraphType
m_Graph
;
};
}
// namespace selx
#endif // #ifndef BlueprintImpl_h
\ No newline at end of file
#endif // #ifndef BlueprintImpl_h
Modules/Blueprints/test/selxBlueprintTest.cxx
View file @
b47a3a95
...
...
@@ -32,17 +32,17 @@ public:
virtual
void
SetUp
()
{
parameterMap
[
"NameOfClass"
]
=
ParameterValueType
(
1
,
"TestClassName"
);
anotherParameterMap
[
"NameOfClass"
]
=
ParameterValueType
(
1
,
"AnotherTestClassName"
);
parameterMap
[
"NameOfClass"
]
=
ParameterValueType
(
1
,
"TestClassName"
);
anotherParameterMap
[
"NameOfClass"
]
=
ParameterValueType
(
1
,
"AnotherTestClassName"
);
}
ParameterMapType
parameterMap
;
ParameterMapType
anotherParameterMap
;
};
TEST_F
(
BlueprintTest
,
SetGetDeleteComponent
)
{
std
::
unique_ptr
<
Blueprint
>
blueprint
;
EXPECT_NO_THROW
(
blueprint
=
std
::
unique_ptr
<
Blueprint
>
(
new
Blueprint
()
)
);
...
...
@@ -83,8 +83,8 @@ TEST_F( BlueprintTest, SetGetDeleteConnection )
// Connection should have parameter map
ParameterMapType
parameterMap0
;
EXPECT_NO_THROW
(
parameterMap0
=
blueprint
->
GetConnection
(
"Component0"
,
"Component1"
)
);
EXPECT_EQ
(
parameterMap
[
"NameOfClass"
],
parameterMap0
[
"NameOfClass"
]
);
EXPECT_NO_THROW
(
parameterMap0
=
blueprint
->
GetConnection
(
"Component0"
,
"Component1"
)
);
EXPECT_EQ
(
parameterMap
[
"NameOfClass"
],
parameterMap0
[
"NameOfClass"
]
);
// Another parameter map should transparently added
bool
anotherParameterMapSet
;
...
...
@@ -101,79 +101,75 @@ TEST_F( BlueprintTest, SetGetDeleteConnection )
EXPECT_FALSE
(
blueprint
->
ConnectionExists
(
"Component0"
,
"Component1"
)
);
EXPECT_THROW
(
blueprint
->
GetConnection
(
"Component0"
,
"Component1"
),
std
::
runtime_error
);
}
TEST_F
(
BlueprintTest
,
CopyConstuctor
)
TEST_F
(
BlueprintTest
,
CopyConstuctor
)
{
std
::
unique_ptr
<
Blueprint
>
baseBlueprint
;
EXPECT_NO_THROW
(
baseBlueprint
=
std
::
unique_ptr
<
Blueprint
>
(
new
Blueprint
()
)
);
EXPECT_NO_THROW
(
baseBlueprint
=
std
::
unique_ptr
<
Blueprint
>
(
new
Blueprint
()
)
);
baseBlueprint
->
SetComponent
(
"Component0"
,
{
{
"OperationType"
,
{
"Transform"
}
}
});
baseBlueprint
->
SetComponent
(
"Component0"
,
{
{
"OperationType"
,
{
"Transform"
}
}
}
);
std
::
unique_ptr
<
Blueprint
>
clonedBaseBlueprint
;
EXPECT_NO_THROW
(
clonedBaseBlueprint
=
std
::
make_unique
<
Blueprint
>
(
*
baseBlueprint
.
get
()));
EXPECT_NO_THROW
(
clonedBaseBlueprint
=
std
::
make_unique
<
Blueprint
>
(
*
baseBlueprint
.
get
()
)
);
EXPECT_NO_THROW
(
clonedBaseBlueprint
->
SetComponent
(
"Component1"
,
{
{
"OperationType"
,
{
"Source"
}
},
{
"Dimensionality"
,
{
"3"
}
}
}
)
);
EXPECT_NO_THROW
(
clonedBaseBlueprint
->
SetComponent
(
"Component1"
,
{
{
"OperationType"
,
{
"Source"
}
},
{
"Dimensionality"
,
{
"3"
}
}
}));
Blueprint
::
ParameterMapType
clonedComponent0
;
EXPECT_NO_THROW
(
clonedComponent0
=
clonedBaseBlueprint
->
GetComponent
(
"Component0"
)
);
EXPECT_NO_THROW
(
clonedComponent0
=
clonedBaseBlueprint
->
GetComponent
(
"Component0"
)
);
Blueprint
::
ParameterMapType
component1
;
EXPECT_THROW
(
component1
=
baseBlueprint
->
GetComponent
(
"Component1"
),
std
::
runtime_error
);
EXPECT_THROW
(
component1
=
baseBlueprint
->
GetComponent
(
"Component1"
),
std
::
runtime_error
);
}
TEST_F
(
BlueprintTest
,
Compose
)
TEST_F
(
BlueprintTest
,
Compose
)
{
std
::
unique_ptr
<
Blueprint
>
baseBlueprint
;
EXPECT_NO_THROW
(
baseBlueprint
=
std
::
unique_ptr
<
Blueprint
>
(
new
Blueprint
()));
baseBlueprint
->
SetComponent
(
"Component0"
,
{
{
"OperationType"
,
{
"Transform"
}
}
});
baseBlueprint
->
SetComponent
(
"Component1"
,
{
{
"OperationType"
,
{
"Source"
}
},
{
"Dimensionality"
,
{
"3"
}
}
});
EXPECT_NO_THROW
(
baseBlueprint
=
std
::
unique_ptr
<
Blueprint
>
(
new
Blueprint
()
)
);
baseBlueprint
->
SetComponent
(
"Component0"
,
{
{
"OperationType"
,
{
"Transform"
}
}
}
);
baseBlueprint
->
SetComponent
(
"Component1"
,
{
{
"OperationType"
,
{
"Source"
}
},
{
"Dimensionality"
,
{
"3"
}
}
}
);
// compose-in a new 3rd component Component2
std
::
unique_ptr
<
Blueprint
>
nonConflictingBlueprint0
;
EXPECT_NO_THROW
(
nonConflictingBlueprint0
=
std
::
unique_ptr
<
Blueprint
>
(
new
Blueprint
()
)
);
EXPECT_NO_THROW
(
nonConflictingBlueprint0
=
std
::
unique_ptr
<
Blueprint
>
(
new
Blueprint
()
)
);
nonConflictingBlueprint0
->
SetComponent
(
"Component2"
,
{
{
"OperationType"
,
{
"Sink"
}
}
});
nonConflictingBlueprint0
->
SetComponent
(
"Component2"
,
{
{
"OperationType"
,
{
"Sink"
}
}
}
);
EXPECT_TRUE
(
baseBlueprint
->
ComposeWith
(
nonConflictingBlueprint0
)
);
EXPECT_STREQ
(
"Sink"
,
baseBlueprint
->
GetComponent
(
"Component2"
)[
"OperationType"
][
0
].
c_str
());
EXPECT_TRUE
(
baseBlueprint
->
ComposeWith
(
nonConflictingBlueprint0
)
);
EXPECT_STREQ
(
"Sink"
,
baseBlueprint
->
GetComponent
(
"Component2"
)[
"OperationType"
][
0
].
c_str
()
);
// compose-in additional properties of Component0 and Component1
std
::
unique_ptr
<
Blueprint
>
nonConflictingBlueprint1
;
EXPECT_NO_THROW
(
nonConflictingBlueprint1
=
std
::
unique_ptr
<
Blueprint
>
(
new
Blueprint
()
)
);
EXPECT_NO_THROW
(
nonConflictingBlueprint1
=
std
::
unique_ptr
<
Blueprint
>
(
new
Blueprint
()
)
);
nonConflictingBlueprint1
->
SetComponent
(
"Component0"
,
{
{
"TranformationGroup"
,
{
"Diffeomorphic"
}
},
{
"PixelType"
,
{
"float"
}
}
});
nonConflictingBlueprint1
->
SetComponent
(
"Component1"
,
{
{
"NameOfClass"
,
{
"ImageSourceClass"
}
}
});
nonConflictingBlueprint1
->
SetComponent
(
"Component0"
,
{
{
"TranformationGroup"
,
{
"Diffeomorphic"
}
},
{
"PixelType"
,
{
"float"
}
}
}
);
nonConflictingBlueprint1
->
SetComponent
(
"Component1"
,
{
{
"NameOfClass"
,
{
"ImageSourceClass"
}
}
}
);
EXPECT_TRUE
(
baseBlueprint
->
ComposeWith
(
nonConflictingBlueprint1
)
);
EXPECT_STREQ
(
"Transform"
,
baseBlueprint
->
GetComponent
(
"Component0"
)[
"OperationType"
][
0
].
c_str
());
EXPECT_STREQ
(
"Diffeomorphic"
,
baseBlueprint
->
GetComponent
(
"Component0"
)[
"TranformationGroup"
][
0
].
c_str
());