Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
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
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
96597fc9
Commit
96597fc9
authored
3 years ago
by
Wuttke, Joachim
Committed by
Wuttke, Joachim
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
mv rwSelected to SelectionProperty.h
parent
f1a0729d
No related branches found
No related tags found
1 merge request
!707
Split serializer
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/Model/Descriptor/SelectionProperty.h
+30
-0
30 additions, 0 deletions
GUI/Model/Descriptor/SelectionProperty.h
GUI/Model/XML/Serialize.h
+1
-21
1 addition, 21 deletions
GUI/Model/XML/Serialize.h
with
31 additions
and
21 deletions
GUI/Model/Descriptor/SelectionProperty.h
+
30
−
0
View file @
96597fc9
...
...
@@ -16,6 +16,7 @@
#define BORNAGAIN_GUI_MODEL_DESCRIPTOR_SELECTIONPROPERTY_H
#include
"GUI/Model/Descriptor/SelectionDescriptor.h"
#include
"GUI/Model/XML/Streamer.h"
// #baMigration docu
template
<
typename
T
>
...
...
@@ -124,5 +125,34 @@ private:
std
::
function
<
void
(
T
,
const
T
)
>
m_initializer
;
};
// Extends namespace defined in GUI/Model/XML/Serialize.h
namespace
Serialize
{
//! Serializes an item from a catalog.
//! Passes optional arguments to the constructor.
template
<
typename
Catalog
,
typename
...
ArgsForCreation
>
void
rwSelected
(
Streamer
&
s
,
SelectionProperty
<
typename
Catalog
::
CatalogedType
*>&
d
,
ArgsForCreation
...
argsForCreation
);
}
// namespace Serialize
// ************************************************************************************************
// Template implementation
// ************************************************************************************************
template
<
typename
Catalog
,
typename
...
ArgsForCreation
>
void
Serialize
::
rwSelected
(
Streamer
&
s
,
SelectionProperty
<
typename
Catalog
::
CatalogedType
*>&
d
,
ArgsForCreation
...
argsForCreation
)
{
if
(
QXmlStreamWriter
*
w
=
s
.
xmlWriter
())
{
typename
Catalog
::
CatalogedType
*
p
=
d
.
get
();
s
.
write
<
Catalog
>
(
d
.
persistentTag
(),
p
);
}
else
if
(
QXmlStreamReader
*
r
=
s
.
xmlReader
())
{
typename
Catalog
::
CatalogedType
*
p
=
nullptr
;
s
.
read
<
Catalog
>
(
d
.
persistentTag
(),
p
,
argsForCreation
...);
d
.
set
(
p
);
}
}
#endif // BORNAGAIN_GUI_MODEL_DESCRIPTOR_SELECTIONPROPERTY_H
This diff is collapsed.
Click to expand it.
GUI/Model/XML/Serialize.h
+
1
−
21
View file @
96597fc9
...
...
@@ -16,7 +16,7 @@
#define BORNAGAIN_GUI_MODEL_XML_SERIALIZE_H
#include
"GUI/Model/XML/Streamer.h"
#include
"GUI/Model/
Descriptor/SelectionProperty
.h"
#include
"GUI/Model/
BaseItem/SessionItem
.h"
//! Functions to serialize various data types.
//!
...
...
@@ -54,12 +54,6 @@ template <typename Catalog, typename... Args>
void
rwCatalogized
(
Streamer
&
s
,
const
QString
&
tag
,
QVector
<
typename
Catalog
::
CatalogedType
*>&
vec
,
Args
...
argsForConstructor
);
//! Serializes an item from a catalog.
//! Passes optional arguments to the constructor.
template
<
typename
Catalog
,
typename
...
ArgsForCreation
>
void
rwSelected
(
Streamer
&
s
,
SelectionProperty
<
typename
Catalog
::
CatalogedType
*>&
d
,
ArgsForCreation
...
argsForCreation
);
//! Serializes an optional item of known type.
//! Passes optional arguments to the constructor.
template
<
typename
ItemClass
,
typename
...
ArgsForConstructor
>
...
...
@@ -149,20 +143,6 @@ void Serialize::rwCatalogized(Streamer& s, const QString& tag,
}
}
template
<
typename
Catalog
,
typename
...
ArgsForCreation
>
void
Serialize
::
rwSelected
(
Streamer
&
s
,
SelectionProperty
<
typename
Catalog
::
CatalogedType
*>&
d
,
ArgsForCreation
...
argsForCreation
)
{
if
(
QXmlStreamWriter
*
w
=
s
.
xmlWriter
())
{
typename
Catalog
::
CatalogedType
*
p
=
d
.
get
();
s
.
write
<
Catalog
>
(
d
.
persistentTag
(),
p
);
}
else
if
(
QXmlStreamReader
*
r
=
s
.
xmlReader
())
{
typename
Catalog
::
CatalogedType
*
p
=
nullptr
;
s
.
read
<
Catalog
>
(
d
.
persistentTag
(),
p
,
argsForCreation
...);
d
.
set
(
p
);
}
}
template
<
typename
ItemClass
,
typename
...
ArgsForConstructor
>
void
Serialize
::
rwOptional
(
Streamer
&
s
,
const
QString
&
tag
,
std
::
unique_ptr
<
ItemClass
>&
up
,
ArgsForConstructor
...
argsForConstructor
)
...
...
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