atlas
DataInfo.h
1 /*
2  * (C) Copyright 2020 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation
8  * nor does it submit to any jurisdiction.
9  */
10 
11 #pragma once
12 
13 #include <cstdint>
14 #include <string>
15 
16 
17 #include "atlas/io/detail/Checksum.h"
18 #include "atlas/io/detail/Endian.h"
19 
20 namespace atlas {
21 namespace io {
22 
23 class DataInfo {
24 public:
25  int section() const { return section_; }
26  const std::string& compression() const { return compression_; }
27  Endian endian() const { return endian_; }
28 
29  void endian( Endian e ) { endian_ = e; }
30 
31  void compression( const std::string& c ) { compression_ = c; }
32  void size( size_t s ) { uncompressed_size_ = s; }
33  size_t size() const { return uncompressed_size_; }
34  void compressed_size( size_t s ) { compressed_size_ = s; }
35  size_t compressed_size() const { return compressed_size_; }
36  void compressed( bool f ) {
37  if ( f == false ) {
38  compression( "none" );
39  }
40  }
41 
42  bool compressed() const { return compression_ != "none"; }
43 
44  operator bool() const { return section_ > 0; }
45 
46  const Checksum& checksum() const { return checksum_; }
47  void checksum( const std::string& c ) { checksum_ = Checksum( c ); }
48 
49  void section( int s ) { section_ = s; }
50 
51 private:
52  int section_{0};
53  std::string compression_{"none"};
54  Checksum checksum_;
55  Endian endian_{Endian::native};
56  size_t uncompressed_size_{0};
57  size_t compressed_size_{0};
58 };
59 
60 } // namespace io
61 } // namespace atlas
Definition: Checksum.h:19
Definition: DataInfo.h:23
Contains all atlas classes and methods.
Definition: atlas-grids.cc:33