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
e6639bae
Commit
e6639bae
authored
1 year ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
IOFactory: disambiguate fct names
parent
e290a8d3
No related branches found
No related tags found
1 merge request
!1579
save axis in rad (#504)
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Device/IO/IOFactory.cpp
+18
-17
18 additions, 17 deletions
Device/IO/IOFactory.cpp
Device/IO/IOFactory.h
+4
-4
4 additions, 4 deletions
Device/IO/IOFactory.h
with
22 additions
and
21 deletions
Device/IO/IOFactory.cpp
+
18
−
17
View file @
e6639bae
...
@@ -50,23 +50,23 @@ Datafield* IOFactory::readDatafield(const std::string& file_name, LoaderSelector
...
@@ -50,23 +50,23 @@ Datafield* IOFactory::readDatafield(const std::string& file_name, LoaderSelector
Datafield
*
result
=
nullptr
;
Datafield
*
result
=
nullptr
;
if
(
readAs
(
bornagain
))
if
(
readAs
(
bornagain
))
result
=
readDatafiel
d
(
file_name
,
result
=
functional_rea
d
(
file_name
,
[](
std
::
istream
&
s
)
{
return
ReadWriteINT
().
readDatafield
(
s
);
});
[](
std
::
istream
&
s
)
{
return
ReadWriteINT
().
readDatafield
(
s
);
});
else
if
(
readAs
(
nicos
))
else
if
(
readAs
(
nicos
))
result
=
readDatafiel
d
(
file_name
,
[](
std
::
istream
&
s
)
{
return
IO
::
readNicosData
(
s
);
});
result
=
functional_rea
d
(
file_name
,
[](
std
::
istream
&
s
)
{
return
IO
::
readNicosData
(
s
);
});
#ifdef BA_TIFF_SUPPORT
#ifdef BA_TIFF_SUPPORT
else
if
(
readAs
(
tiff
))
else
if
(
readAs
(
tiff
))
result
=
readDatafiel
d
(
file_name
,
result
=
functional_rea
d
(
file_name
,
[](
std
::
istream
&
s
)
{
return
ReadWriteTiff
().
readDatafield
(
s
);
});
[](
std
::
istream
&
s
)
{
return
ReadWriteTiff
().
readDatafield
(
s
);
});
#endif
#endif
else
else
// Try to read ASCII by default. Binary maps to ASCII.
// Try to read ASCII by default. Binary maps to ASCII.
// If the file is not actually a matrix of numbers,
// If the file is not actually a matrix of numbers,
// the error will be thrown during the reading.
// the error will be thrown during the reading.
result
=
readDatafiel
d
(
result
=
functional_rea
d
(
file_name
,
[](
std
::
istream
&
s
)
{
return
ReadWriteNumpyTXT
().
readDatafield
(
s
);
});
file_name
,
[](
std
::
istream
&
s
)
{
return
ReadWriteNumpyTXT
().
readDatafield
(
s
);
});
ASSERT
(
result
);
ASSERT
(
result
);
...
@@ -75,26 +75,27 @@ Datafield* IOFactory::readDatafield(const std::string& file_name, LoaderSelector
...
@@ -75,26 +75,27 @@ Datafield* IOFactory::readDatafield(const std::string& file_name, LoaderSelector
Datafield
*
IOFactory
::
readReflectometryData
(
const
std
::
string
&
file_name
)
Datafield
*
IOFactory
::
readReflectometryData
(
const
std
::
string
&
file_name
)
{
{
return
readDatafiel
d
(
file_name
,
return
functional_rea
d
(
file_name
,
[](
std
::
istream
&
s
)
{
return
ReadReflectometry
().
readDatafield
(
s
);
});
[](
std
::
istream
&
s
)
{
return
ReadReflectometry
().
readDatafield
(
s
);
});
}
}
void
IOFactory
::
writeDatafield
(
const
Datafield
&
data
,
const
std
::
string
&
file_name
)
void
IOFactory
::
writeDatafield
(
const
Datafield
&
data
,
const
std
::
string
&
file_name
)
{
{
if
(
DataUtils
::
Format
::
isIntFile
(
file_name
))
if
(
DataUtils
::
Format
::
isIntFile
(
file_name
))
writeDatafield
(
file_name
,
[
&
](
std
::
ostream
&
s
)
{
ReadWriteINT
().
writeDatafield
(
data
,
s
);
});
functional_write
(
file_name
,
[
&
](
std
::
ostream
&
s
)
{
ReadWriteINT
().
writeDatafield
(
data
,
s
);
});
#ifdef BA_TIFF_SUPPORT
#ifdef BA_TIFF_SUPPORT
else
if
(
DataUtils
::
Format
::
isTiffFile
(
file_name
))
else
if
(
DataUtils
::
Format
::
isTiffFile
(
file_name
))
writeDatafield
(
file_name
,
functional_write
(
file_name
,
[
&
](
std
::
ostream
&
s
)
{
ReadWriteTiff
().
writeDatafield
(
data
,
s
);
});
[
&
](
std
::
ostream
&
s
)
{
ReadWriteTiff
().
writeDatafield
(
data
,
s
);
});
#endif
#endif
else
else
writeDatafield
(
file_name
,
functional_write
(
file_name
,
[
&
](
std
::
ostream
&
s
)
{
ReadWriteNumpyTXT
().
writeDatafield
(
data
,
s
);
});
[
&
](
std
::
ostream
&
s
)
{
ReadWriteNumpyTXT
().
writeDatafield
(
data
,
s
);
});
}
}
void
IOFactory
::
writeDatafield
(
const
std
::
string
&
file_name
,
void
IOFactory
::
functional_write
(
const
std
::
string
&
file_name
,
std
::
function
<
void
(
std
::
ostream
&
)
>
writeData
)
std
::
function
<
void
(
std
::
ostream
&
)
>
writeData
)
{
{
using
namespace
DataUtils
::
Format
;
using
namespace
DataUtils
::
Format
;
...
@@ -149,8 +150,8 @@ void IOFactory::writeSimulationResult(const SimulationResult& result, const std:
...
@@ -149,8 +150,8 @@ void IOFactory::writeSimulationResult(const SimulationResult& result, const std:
writeDatafield
(
result
.
data_field
(),
file_name
);
writeDatafield
(
result
.
data_field
(),
file_name
);
}
}
Datafield
*
IOFactory
::
readDatafiel
d
(
const
std
::
string
&
file_name
,
Datafield
*
IOFactory
::
functional_rea
d
(
const
std
::
string
&
file_name
,
std
::
function
<
Datafield
*
(
std
::
istream
&
)
>
readData
)
std
::
function
<
Datafield
*
(
std
::
istream
&
)
>
readData
)
{
{
if
(
!
BaseUtils
::
Filesystem
::
IsFileExists
(
file_name
))
if
(
!
BaseUtils
::
Filesystem
::
IsFileExists
(
file_name
))
throw
std
::
runtime_error
(
"File does not exist: "
+
file_name
);
throw
std
::
runtime_error
(
"File does not exist: "
+
file_name
);
...
...
This diff is collapsed.
Click to expand it.
Device/IO/IOFactory.h
+
4
−
4
View file @
e6639bae
...
@@ -63,11 +63,11 @@ public:
...
@@ -63,11 +63,11 @@ public:
static
void
writeSimulationResult
(
const
SimulationResult
&
result
,
const
std
::
string
&
file_name
);
static
void
writeSimulationResult
(
const
SimulationResult
&
result
,
const
std
::
string
&
file_name
);
private
:
private
:
static
Datafield
*
readDatafiel
d
(
const
std
::
string
&
file_name
,
static
Datafield
*
functional_rea
d
(
const
std
::
string
&
file_name
,
std
::
function
<
Datafield
*
(
std
::
istream
&
)
>
readData
);
std
::
function
<
Datafield
*
(
std
::
istream
&
)
>
readData
);
static
void
writeDatafield
(
const
std
::
string
&
file_name
,
static
void
functional_write
(
const
std
::
string
&
file_name
,
std
::
function
<
void
(
std
::
ostream
&
)
>
writeData
);
std
::
function
<
void
(
std
::
ostream
&
)
>
writeData
);
static
bool
fileTypeMatchesLoaderSelector
(
const
std
::
string
&
fileName
,
LoaderSelector
selector
);
static
bool
fileTypeMatchesLoaderSelector
(
const
std
::
string
&
fileName
,
LoaderSelector
selector
);
};
};
...
...
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