atlas
Stream.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 <memory>
15 
16 namespace eckit {
17 class DataHandle;
18 }
19 
20 namespace atlas {
21 namespace io {
22 
23 //---------------------------------------------------------------------------------------------------------------------
24 
31 class Stream {
32 public:
35  Stream() = default;
36 
38  Stream( eckit::DataHandle* );
39 
41  Stream( std::shared_ptr<eckit::DataHandle> );
42 
46  Stream( eckit::DataHandle& );
47 
49  Stream( const Stream& );
50 
52  eckit::DataHandle& datahandle();
53 
55  std::uint64_t seek( std::uint64_t offset );
56 
58  std::uint64_t position();
59 
63  std::uint64_t write( const void* data, size_t length );
64 
68  std::uint64_t read( void* data, size_t length );
69 
71  operator bool() const { return ptr_; }
72 
73 private:
74  std::shared_ptr<eckit::DataHandle> shared_;
75  eckit::DataHandle* ptr_{nullptr};
76 };
77 
78 //---------------------------------------------------------------------------------------------------------------------
79 
80 } // namespace io
81 } // namespace atlas
Handle to a shared eckit::DataHandle.
Definition: Stream.h:31
Definition: Domain.h:19
Contains all atlas classes and methods.
Definition: atlas-grids.cc:33