Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
NexusCPP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software Control System
Libraries
NexusCPP
Commits
2c466926
Commit
2c466926
authored
Jan 17, 2023
by
Stephane Poirier
Browse files
Options
Downloads
Patches
Plain Diff
[DataStreamer] New option 'throw_if_file_exists'
parent
888b410a
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/nexuscpp/nxbuffer.h
+23
-0
23 additions, 0 deletions
include/nexuscpp/nxbuffer.h
src/nxbuffer.cpp
+12
-1
12 additions, 1 deletion
src/nxbuffer.cpp
test/datastreamer/src/main.cpp
+3
-2
3 additions, 2 deletions
test/datastreamer/src/main.cpp
with
38 additions
and
3 deletions
include/nexuscpp/nxbuffer.h
+
23
−
0
View file @
2c466926
...
...
@@ -91,6 +91,25 @@ private:
std::vector<std::size_t> dims_;
};
*/
//=============================================================================
/// OverwriteError
///
/// This class may be used by the DataStreamer in case of
/// a buffer file already exists before the acquisition start
//=============================================================================
class
NEXUSCPP_DECL
OverwriteError
:
public
NexusException
{
public:
OverwriteError
()
:
NexusException
()
{}
OverwriteError
(
const
char
*
pcszDesc
,
const
char
*
pcszOrigin
)
:
NexusException
(
pcszDesc
,
pcszOrigin
)
{}
OverwriteError
(
const
std
::
string
&
desc
,
const
char
*
pcszOrigin
)
:
NexusException
(
desc
.
c_str
(),
pcszOrigin
)
{}
};
//==============================================================================
/// DataItemCategory
///==============================================================================
...
...
@@ -203,6 +222,9 @@ public:
/// Messages logging handler
IMessageHandler
*
message_handler_p
;
/// Throw an exception if destination buffer file already exists ?
bool
throw_if_file_exists
;
// ----------------
// error management
// ----------------
...
...
@@ -227,6 +249,7 @@ public:
exception_handler_p
=
0
;
max_attempts
=
10
;
retry_delay
=
250
;
throw_if_file_exists
=
false
;
}
}
Config
;
...
...
This diff is collapsed.
Click to expand it.
src/nxbuffer.cpp
+
12
−
1
View file @
2c466926
...
...
@@ -1240,7 +1240,18 @@ void DataStreamer::PrivOpenNewbuffer()
std
::
string
sFileName
;
{
yat
::
AutoMutex
<>
_lock
(
s_indexLock
);
sFileName
=
GenerateBufferName
(
m_cfg
.
buffer_name
,
s_mapFileIndex
[
m_cfg
.
buffer_name
],
m_cfg
.
data_source
);
sFileName
=
GenerateBufferName
(
m_cfg
.
buffer_name
,
s_mapFileIndex
[
m_cfg
.
buffer_name
],
m_cfg
.
data_source
);
yat
::
FileName
fn
(
m_cfg
.
target_path
,
sFileName
);
if
(
fn
.
file_access
()
)
{
yat
::
Format
msg
(
"Buffer file {} already exists!"
);
msg
.
arg
(
fn
);
if
(
m_cfg
.
throw_if_file_exists
)
throw
OverwriteError
(
msg
,
"DataStreamer::PrivOpenNewbuffer"
);
else
if
(
m_cfg
.
message_handler_p
)
m_cfg
.
message_handler_p
->
OnNexusMessage
(
yat
::
LOG_WARNING
,
msg
);
}
s_mapFileIndex
[
m_cfg
.
buffer_name
]
+=
1
;
}
...
...
This diff is collapsed.
Click to expand it.
test/datastreamer/src/main.cpp
+
3
−
2
View file @
2c466926
...
...
@@ -102,8 +102,6 @@ public:
{
YAT_LOG_EXCEPTION
(
e
);
m_error_flag
=
true
;
//YAT_LOG_ERROR("Kill process!");
//exit(0);
}
virtual
void
OnNexusMessage
(
yat
::
ELogLevel
lvl
,
const
yat
::
String
&
msg
)
{
...
...
@@ -585,6 +583,9 @@ void Simu::run_acq(NexusDataStreamerFinalizerPtr finalizer_ptr)
cfg
.
exception_handler_p
=
this
;
cfg
.
message_handler_p
=
this
;
OUT_LN
(
"compress level: "
<<
m_config
.
compress_level
);
// cfg.throw_if_file_exists = true;
nx
::
DataStreamer
*
streamer_p
=
new
nx
::
DataStreamer
(
cfg
);
stream_map
[
stream
.
name
]
=
streamer_p
;
...
...
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