|
| 1 | +#include <G3Logging.h> |
| 2 | +#include <G3Timestream.h> |
1 | 3 | #include <serialization.h>
|
2 |
| -#include "G3SuperTimestream.h" |
| 4 | + |
| 5 | +/* |
| 6 | + This is a minimal implementation of the Simons Observatory timestream storage |
| 7 | + class, to enable reading legacy data from disk and convert directly to |
| 8 | + G3TimestreamMap. This class is only visible to the serialization library. |
| 9 | +*/ |
| 10 | + |
| 11 | +class G3SuperTimestream : public G3TimestreamMap { |
| 12 | +private: |
| 13 | + G3SuperTimestream() {}; |
| 14 | + |
| 15 | + friend class cereal::access; |
| 16 | + |
| 17 | + template <class A> void load(A &ar, unsigned v) { |
| 18 | + log_fatal("Library missing FLAC or BZip2 compression"); |
| 19 | + } |
| 20 | + |
| 21 | + template <class A> void save(A &ar, unsigned v) const { |
| 22 | + log_fatal("Convert to G3TimestreamMap to serialize"); |
| 23 | + } |
| 24 | + |
| 25 | + SET_LOGGER("G3SuperTimestream"); |
| 26 | +}; |
| 27 | + |
| 28 | +namespace cereal { |
| 29 | + template <class A> struct specialize<A, G3SuperTimestream, |
| 30 | + cereal::specialization::member_load_save> {}; |
| 31 | + |
| 32 | + // Convert to G3TimestreamMap before handing off to the user |
| 33 | + namespace detail { |
| 34 | + template <> inline std::shared_ptr<void> |
| 35 | + PolymorphicCasters::upcast(std::shared_ptr<G3SuperTimestream> const & dptr, |
| 36 | + std::type_info const & baseInfo) { |
| 37 | + return PolymorphicCasters::upcast( |
| 38 | + std::make_shared<G3TimestreamMap>(*dptr), baseInfo); |
| 39 | + } |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +G3_SERIALIZABLE(G3SuperTimestream, 0); |
| 44 | + |
| 45 | +// Everything below is just the deserialization implementation, largely copied |
| 46 | +// wholesale from the simonsobs/so3g library, and rearranged to handle decompression |
| 47 | +// immediately on load. |
3 | 48 |
|
4 | 49 | #if defined(G3_HAS_FLAC) && defined(BZIP2_FOUND)
|
5 | 50 |
|
@@ -187,7 +232,8 @@ void fill_gaps(struct flac_helper *fh, const std::vector<bool> &gaps, double fil
|
187 | 232 | dest[didx] = (!gaps[didx] && sidx < fh->count) ? src[sidx++] : fillval;
|
188 | 233 | }
|
189 | 234 |
|
190 |
| -template <class A> void G3SuperTimestream::load(A &ar, unsigned v) |
| 235 | +template <> |
| 236 | +void G3SuperTimestream::load(cereal::PortableBinaryInputArchive &ar, unsigned v) |
191 | 237 | {
|
192 | 238 | G3_CHECK_VERSION(v);
|
193 | 239 | using namespace cereal;
|
@@ -406,19 +452,5 @@ template <class A> void G3SuperTimestream::load(A &ar, unsigned v)
|
406 | 452 | } // omp parallel
|
407 | 453 | }
|
408 | 454 |
|
409 |
| -#else |
410 |
| - |
411 |
| -template <class A> void G3SuperTimestream::load(A &ar, unsigned v) |
412 |
| -{ |
413 |
| - log_fatal("Library missing FLAC or BZip2 compression"); |
414 |
| -} |
415 |
| - |
416 | 455 | #endif
|
417 | 456 |
|
418 |
| -// Save directly to a G3TimestreamMap object |
419 |
| -template <class A> void G3SuperTimestream::save(A &ar, unsigned v) const |
420 |
| -{ |
421 |
| - log_fatal("Convert to G3Timestream map to serialize"); |
422 |
| -} |
423 |
| - |
424 |
| -G3_SPLIT_SERIALIZABLE_CODE(G3SuperTimestream); |
|
0 commit comments