Skip to content

Commit 346bc75

Browse files
committed
Add closeFile operation to JSON backend
1 parent 1b248d5 commit 346bc75

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

include/openPMD/IO/JSON/JSONIOHandlerImpl.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ namespace openPMD
184184
Parameter< Operation::OPEN_FILE > const &
185185
) override;
186186

187+
void closeFile(
188+
Writable *,
189+
Parameter< Operation::CLOSE_FILE > const &
190+
) override;
191+
187192
void openPath(
188193
Writable *,
189194
Parameter< Operation::OPEN_PATH > const &

src/IO/JSON/JSONIOHandlerImpl.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,21 @@ namespace openPMD
306306
}
307307

308308

309+
void JSONIOHandlerImpl::closeFile(
310+
Writable * writable,
311+
Parameter< Operation::CLOSE_FILE > const &
312+
)
313+
{
314+
auto fileIterator = m_files.find( writable );
315+
if ( fileIterator != m_files.end( ) )
316+
{
317+
putJsonContents( fileIterator->second );
318+
fileIterator->second.invalidate( );
319+
m_files.erase( fileIterator );
320+
}
321+
}
322+
323+
309324
void JSONIOHandlerImpl::openPath(
310325
Writable * writable,
311326
Parameter< Operation::OPEN_PATH > const & parameters

test/SerialIOTest.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ close_iteration_test( std::string file_ending )
144144

145145
TEST_CASE( "close_iteration_test", "[serial]" )
146146
{
147+
#if openPMD_HAVE_ADIOS2
147148
close_iteration_test( "bp" );
149+
#endif
150+
close_iteration_test( "json" );
148151
}
149152

150153
inline void

0 commit comments

Comments
 (0)