|
29 | 29 | #include "openPMD/Iteration.hpp" |
30 | 30 | #include "openPMD/IterationEncoding.hpp" |
31 | 31 | #include "openPMD/Streaming.hpp" |
| 32 | +#include "openPMD/WriteIterations.hpp" |
32 | 33 | #include "openPMD/auxiliary/Option.hpp" |
33 | 34 | #include "openPMD/auxiliary/Variant.hpp" |
34 | 35 | #include "openPMD/backend/Attributable.hpp" |
|
52 | 53 | namespace openPMD |
53 | 54 | { |
54 | 55 | class ReadIterations; |
55 | | -class WriteIterations; |
56 | 56 | class Series; |
57 | 57 | class SeriesImpl; |
58 | 58 |
|
@@ -84,27 +84,21 @@ class SeriesData : public AttributableData |
84 | 84 | Container< Iteration, uint64_t > iterations{}; |
85 | 85 |
|
86 | 86 | OPENPMD_private : |
| 87 | + auxiliary::Option< WriteIterations > m_writeIterations; |
| 88 | + std::string m_name; |
| 89 | + std::string m_filenamePrefix; |
| 90 | + std::string m_filenamePostfix; |
| 91 | + int m_filenamePadding; |
| 92 | + IterationEncoding m_iterationEncoding{}; |
| 93 | + Format m_format; |
87 | 94 | /** |
88 | 95 | * Whether a step is currently active for this iteration. |
89 | 96 | * Used for group-based iteration layout, see SeriesData.hpp for |
90 | 97 | * iteration-based layout. |
91 | 98 | * Access via stepStatus() method to automatically select the correct |
92 | 99 | * one among both flags. |
93 | 100 | */ |
94 | | - std::shared_ptr< StepStatus > |
95 | | - m_stepStatus = std::make_shared< StepStatus >( StepStatus::NoStep ); |
96 | | - |
97 | | - std::shared_ptr< IterationEncoding > m_iterationEncoding{ |
98 | | - std::make_shared< IterationEncoding >() }; |
99 | | - std::shared_ptr< std::string > m_name; |
100 | | - std::shared_ptr< Format > m_format; |
101 | | - |
102 | | - std::shared_ptr< std::string > m_filenamePrefix; |
103 | | - std::shared_ptr< std::string > m_filenamePostfix; |
104 | | - std::shared_ptr< int > m_filenamePadding; |
105 | | - |
106 | | - std::shared_ptr< auxiliary::Option< WriteIterations > > m_writeIterations = |
107 | | - std::make_shared< auxiliary::Option< WriteIterations > >(); |
| 101 | + StepStatus m_stepStatus = StepStatus::NoStep; |
108 | 102 | }; // SeriesData |
109 | 103 |
|
110 | 104 | class SeriesInternal; |
@@ -467,135 +461,8 @@ class Series : public SeriesImpl |
467 | 461 | */ |
468 | 462 | WriteIterations writeIterations(); |
469 | 463 | }; |
470 | | - |
471 | | -/** |
472 | | - * @brief Subclass of Iteration that knows its own index withing the containing |
473 | | - * Series. |
474 | | - */ |
475 | | -class IndexedIteration : public Iteration |
476 | | -{ |
477 | | - friend class SeriesIterator; |
478 | | - |
479 | | -public: |
480 | | - using iterations_t = decltype( internal::SeriesData::iterations ); |
481 | | - using index_t = iterations_t::key_type; |
482 | | - index_t const iterationIndex; |
483 | | - |
484 | | -private: |
485 | | - template< typename Iteration_t > |
486 | | - IndexedIteration( Iteration_t && it, index_t index ) |
487 | | - : Iteration( std::forward< Iteration_t >( it ) ) |
488 | | - , iterationIndex( index ) |
489 | | - { |
490 | | - } |
491 | | -}; |
492 | | - |
493 | | -class SeriesIterator |
494 | | -{ |
495 | | - using iteration_index_t = IndexedIteration::index_t; |
496 | | - |
497 | | - using maybe_series_t = auxiliary::Option< Series >; |
498 | | - |
499 | | - maybe_series_t m_series; |
500 | | - iteration_index_t m_currentIteration = 0; |
501 | | - |
502 | | - //! construct the end() iterator |
503 | | - SeriesIterator(); |
504 | | - |
505 | | -public: |
506 | | - SeriesIterator( Series ); |
507 | | - |
508 | | - SeriesIterator & operator++(); |
509 | | - |
510 | | - IndexedIteration |
511 | | - operator*(); |
512 | | - |
513 | | - bool |
514 | | - operator==( SeriesIterator const & other ) const; |
515 | | - |
516 | | - bool |
517 | | - operator!=( SeriesIterator const & other ) const; |
518 | | - |
519 | | - static SeriesIterator |
520 | | - end(); |
521 | | -}; |
522 | | - |
523 | | -/** |
524 | | - * @brief Reading side of the streaming API. |
525 | | - * |
526 | | - * Create instance via Series::readIterations(). |
527 | | - * For use in a C++11-style foreach loop over iterations. |
528 | | - * Designed to allow reading any kind of Series, streaming and non- |
529 | | - * streaming alike. |
530 | | - * Calling Iteration::close() manually before opening the next iteration is |
531 | | - * encouraged and will implicitly flush all deferred IO actions. |
532 | | - * Otherwise, Iteration::close() will be implicitly called upon |
533 | | - * SeriesIterator::operator++(), i.e. upon going to the next iteration in |
534 | | - * the foreach loop. |
535 | | - * Since this is designed for streaming mode, reopening an iteration is |
536 | | - * not possible once it has been closed. |
537 | | - * |
538 | | - */ |
539 | | -class ReadIterations |
540 | | -{ |
541 | | - friend class Series; |
542 | | - |
543 | | -private: |
544 | | - using iterations_t = decltype( internal::SeriesData::iterations ); |
545 | | - using iterator_t = SeriesIterator; |
546 | | - |
547 | | - Series m_series; |
548 | | - |
549 | | - ReadIterations( Series ); |
550 | | - |
551 | | -public: |
552 | | - iterator_t begin(); |
553 | | - |
554 | | - iterator_t |
555 | | - end(); |
556 | | -}; |
557 | | - |
558 | | -/** Writing side of the streaming API. |
559 | | - * |
560 | | - * Create instance via Series::writeIterations(). |
561 | | - * For use via WriteIterations::operator[](). |
562 | | - * Designed to allow reading any kind of Series, streaming and non- |
563 | | - * streaming alike. Calling Iteration::close() manually before opening |
564 | | - * the next iteration is encouraged and will implicitly flush all |
565 | | - * deferred IO actions. Otherwise, Iteration::close() will be implicitly |
566 | | - * called upon SeriesIterator::operator++(), i.e. upon going to the next |
567 | | - * iteration in the foreach loop. |
568 | | - * |
569 | | - * Since this is designed for streaming mode, reopening an iteration is |
570 | | - * not possible once it has been closed. |
571 | | - * |
572 | | - */ |
573 | | -class WriteIterations : private Container< Iteration, uint64_t > |
574 | | -{ |
575 | | - friend class Series; |
576 | | - |
577 | | -private: |
578 | | - using iterations_t = Container< Iteration, uint64_t >; |
579 | | - struct SharedResources |
580 | | - { |
581 | | - iterations_t iterations; |
582 | | - auxiliary::Option< uint64_t > currentlyOpen; |
583 | | - |
584 | | - SharedResources( iterations_t ); |
585 | | - ~SharedResources(); |
586 | | - }; |
587 | | - |
588 | | - using key_type = typename iterations_t::key_type; |
589 | | - using value_type = typename iterations_t::key_type; |
590 | | - WriteIterations( iterations_t ); |
591 | | - explicit WriteIterations() = default; |
592 | | - //! Index of the last opened iteration |
593 | | - std::shared_ptr< SharedResources > shared; |
594 | | - |
595 | | -public: |
596 | | - mapped_type & |
597 | | - operator[]( key_type const & key ) override; |
598 | | - mapped_type & |
599 | | - operator[]( key_type && key ) override; |
600 | | -}; |
601 | 464 | } // namespace openPMD |
| 465 | + |
| 466 | +// Make sure that this one is always included if Series.hpp is included, |
| 467 | +// otherwise SeriesImpl::readIterations() cannot be used |
| 468 | +#include "openPMD/ReadIterations.hpp" |
0 commit comments