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
3a1616e8
Commit
3a1616e8
authored
3 years ago
by
Wuttke, Joachim
Committed by
Wuttke, Joachim
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
mv rwSessionItem to SessionItem.h
parent
96597fc9
No related branches found
No related tags found
1 merge request
!707
Split serializer
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
GUI/Model/BaseItem/SessionItem.h
+29
-0
29 additions, 0 deletions
GUI/Model/BaseItem/SessionItem.h
GUI/Model/Descriptor/SelectionProperty.h
+0
-1
0 additions, 1 deletion
GUI/Model/Descriptor/SelectionProperty.h
GUI/Model/XML/Serialize.h
+1
-19
1 addition, 19 deletions
GUI/Model/XML/Serialize.h
with
30 additions
and
20 deletions
GUI/Model/BaseItem/SessionItem.h
+
29
−
0
View file @
3a1616e8
...
...
@@ -18,6 +18,7 @@
#include
"Base/Util/Assert.h"
#include
"Fit/Param/RealLimits.h"
#include
"GUI/Model/BaseItem/ModelMapper.h"
// no forward declare, used too often
#include
"GUI/Model/XML/Serialize.h"
#include
"Wrap/WinDllMacros.h"
#include
<QStringList>
#include
<memory>
...
...
@@ -334,6 +335,20 @@ private:
std
::
unique_ptr
<
ModelMapper
>
m_mapper
;
};
// Extends namespace defined in GUI/Model/XML/Serialize.h
namespace
Serialize
{
//! Only for migration
// #bamigration Remove once the SessionItem migration is done
template
<
typename
type
>
void
rwSessionItem
(
Streamer
&
s
,
const
QString
&
tag
,
SessionItem
*
property
);
}
// namespace Serialize
// ************************************************************************************************
// Templates implementation
// ************************************************************************************************
template
<
typename
T
>
T
*
SessionItem
::
item
(
const
QString
&
tag
)
const
{
...
...
@@ -408,4 +423,18 @@ bool SessionItem::hasModelType() const
return
modelType
()
==
T
::
M_TYPE
;
}
template
<
typename
type
>
void
Serialize
::
rwSessionItem
(
Streamer
&
s
,
const
QString
&
tag
,
SessionItem
*
property
)
{
if
(
QXmlStreamWriter
*
w
=
s
.
xmlWriter
())
{
auto
v
=
property
->
value
().
value
<
type
>
();
Serialize
::
rwValue
(
s
,
tag
,
v
);
}
else
if
(
QXmlStreamReader
*
r
=
s
.
xmlReader
())
{
type
v
;
Serialize
::
rwValue
(
s
,
tag
,
v
);
property
->
setValue
(
v
);
}
}
#endif // BORNAGAIN_GUI_MODEL_BASEITEM_SESSIONITEM_H
This diff is collapsed.
Click to expand it.
GUI/Model/Descriptor/SelectionProperty.h
+
0
−
1
View file @
3a1616e8
...
...
@@ -126,7 +126,6 @@ private:
};
// Extends namespace defined in GUI/Model/XML/Serialize.h
namespace
Serialize
{
//! Serializes an item from a catalog.
...
...
This diff is collapsed.
Click to expand it.
GUI/Model/XML/Serialize.h
+
1
−
19
View file @
3a1616e8
...
...
@@ -16,7 +16,7 @@
#define BORNAGAIN_GUI_MODEL_XML_SERIALIZE_H
#include
"GUI/Model/XML/Streamer.h"
#include
"GUI/Model/BaseItem/SessionItem.h"
#include
<memory>
//! Functions to serialize various data types.
//!
...
...
@@ -60,11 +60,6 @@ template <typename ItemClass, typename... ArgsForConstructor>
void
rwOptional
(
Streamer
&
s
,
const
QString
&
tag
,
std
::
unique_ptr
<
ItemClass
>&
up
,
ArgsForConstructor
...
argsForConstructor
);
//! Only for migration
// #bamigration Remove once the SessionItem migration is done
template
<
typename
type
>
void
rwSessionItem
(
Streamer
&
s
,
const
QString
&
tag
,
SessionItem
*
property
);
//! Serializes an optional item of known type that needs an initializer.
//!
//! The initializer will be called after creation and before de-serialization
...
...
@@ -165,19 +160,6 @@ void Serialize::rwOptional(Streamer& s, const QString& tag, std::unique_ptr<Item
}
}
template
<
typename
type
>
void
Serialize
::
rwSessionItem
(
Streamer
&
s
,
const
QString
&
tag
,
SessionItem
*
property
)
{
if
(
QXmlStreamWriter
*
w
=
s
.
xmlWriter
())
{
auto
v
=
property
->
value
().
value
<
type
>
();
Serialize
::
rwValue
(
s
,
tag
,
v
);
}
else
if
(
QXmlStreamReader
*
r
=
s
.
xmlReader
())
{
type
v
;
Serialize
::
rwValue
(
s
,
tag
,
v
);
property
->
setValue
(
v
);
}
}
template
<
typename
ItemClass
>
void
Serialize
::
rwInitializable
(
Streamer
&
s
,
const
QString
&
tag
,
std
::
unique_ptr
<
ItemClass
>&
up
,
const
std
::
function
<
void
(
ItemClass
*
)
>&
initializer
)
...
...
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