File: msdatadescription.cpp

package info (click to toggle)
wsclean 3.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,296 kB
  • sloc: cpp: 129,246; python: 22,066; sh: 360; ansic: 230; makefile: 185
file content (59 lines) | stat: -rw-r--r-- 1,858 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "msdatadescription.h"

#include "contiguousms.h"

#include "../main/settings.h"
#include "reorderedmsprovider.h"

#include <aocommon/io/serialostream.h>
#include <aocommon/io/serialistream.h>

#include <cassert>
#include <memory>

using schaapcommon::reordering::StorageManagerType;

namespace wsclean {

std::unique_ptr<MSProvider> MSDataDescription::GetProvider() const {
  if (_isReordered)
    return std::make_unique<ReorderedMsProvider>(_reorderedHandle, _partIndex,
                                                 _polarization, _dataDescId);
  else
    return std::make_unique<ContiguousMS>(
        _filename, _dataColumnName, _modelColumnName, _modelStorageManager,
        _selection, _polarization, _dataDescId, _useMPI);
}

void MSDataDescription::Serialize(aocommon::SerialOStream& stream) const {
  // Serialization is only used with MPI.
  assert(_useMPI);
  stream.Bool(_isReordered)
      .UInt16(_polarization)
      .UInt32(_dataDescId)
      .Object(_selection)
      .String(_filename)
      .String(_dataColumnName)
      .String(_modelColumnName)
      .UInt32(static_cast<unsigned>(_modelStorageManager))
      .Object(_reorderedHandle)
      .UInt64(_partIndex);
}

std::unique_ptr<MSDataDescription> MSDataDescription::Unserialize(
    aocommon::SerialIStream& stream) {
  std::unique_ptr<MSDataDescription> mdd(new MSDataDescription());
  stream.Bool(mdd->_isReordered)
      .UInt16(mdd->_polarization)
      .UInt32(mdd->_dataDescId)
      .Object(mdd->_selection)
      .String(mdd->_filename)
      .String(mdd->_dataColumnName)
      .String(mdd->_modelColumnName);
  mdd->_modelStorageManager = static_cast<StorageManagerType>(stream.UInt32());
  stream.Object(mdd->_reorderedHandle).UInt64(mdd->_partIndex);
  mdd->_useMPI = true;  // Serialization only happens with MPI.
  return mdd;
}

}  // namespace wsclean