Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
scdaq
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
scouting-demonstrator
scdaq
Commits
f4cde9d0
Commit
f4cde9d0
authored
2 years ago
by
Emilio Meschi
Committed by
Thomas Owen James
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
class to delegate file output file actions
parent
b976d8c5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/OutputFileHandler.h
+57
-0
57 additions, 0 deletions
src/OutputFileHandler.h
with
57 additions
and
0 deletions
src/OutputFileHandler.h
0 → 100644
+
57
−
0
View file @
f4cde9d0
#ifndef OUTPUTFILEHANDLER_H
#define OUTPUTFILEHANDLER_H
#include
<cstdint>
#include
<cstdio>
#include
<string>
class
OutputFileHandler
{
public:
OutputFileHandler
(
const
std
::
string
filename_base_path
,
const
std
::
string
filename_prefix
)
:
filename_base_path_
(
filename_base_path
),
filename_prefix_
(
filename_prefix
),
working_files_basepath_
(
filename_base_path_
+
"/"
+
working_dir_
)
{
create_output_directory_maybe
(
working_files_basepath_
);
}
virtual
~
OutputFileHandler
()
{}
void
open_file
(
uint32_t
index
,
uint32_t
run
);
// Used for fixedNorbits per file option
{
// Create a new file
std
::
string
output_directory
=
my_output_filename_base
+
"/"
+
working_dir
;
create_output_directory
(
output_directory
);
std
::
string
current_filename_a
=
output_directory
+
"/"
+
format_run_file_stem
(
my_output_filename_prefix
,
current_run_number
,
index_
);
std
::
string
filename
=
output_directory
+
"/"
+
format_run_file_stem
(
my_output_filename_prefix
,
control
.
run_number
,
index_
);
LOG
(
INFO
)
<<
"opening file with index "
<<
index_
;
outFile
.
setFile
(
fopen
(
filename
.
c_str
(),
"w"
));
outFile
.
setIndex
(
index_
);
if
(
outFile
.
getFile
()
==
NULL
)
{
std
::
string
err
=
tools
::
strerror
(
"ERROR when creating file '"
+
current_filename_a
+
"'"
);
LOG
(
ERROR
)
<<
err
;
throw
std
::
runtime_error
(
err
);
}
}
private
:
void
create_output_directory_maybe
(
std
::
string
&
output_directory
);
// name of subdir where the files are stored before they are moved to the
// final destination
static
constexpr
std
::
string
working_dir_
{
"in_progress"
};
// name of the journal file. Note: Filename prefix is added making the final
// filename
static
constexpr
std
::
string
journal_file_
{
"index.journal"
};
std
::
string
filename_base_path_
;
std
::
string
filename_prefix_
;
std
::
string
working_files_basepath_
;
uint32_t
current_run_number_
;
FILE
*
current_file_
;
int32_t
current_index_
;
};
#endif
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