https://mooseframework.inl.gov
Loading...
Searching...
No Matches
InputStream.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12#include <memory>
13#include <istream>
14#include <vector>
15#include <filesystem>
16#include <optional>
17
23{
24public:
25 virtual ~InputStream();
26
33 virtual std::shared_ptr<std::istream> get() const = 0;
34
42 bool inUse() const;
43
47 virtual std::optional<std::filesystem::path> getFilename() const;
48
49protected:
56 void addSharedStream(const std::weak_ptr<std::istream> stream) const;
57
58private:
60 mutable std::vector<std::weak_ptr<std::istream>> _shared_streams;
61};
Helper class that hands out input streams to an underlying, managed stream of arbitrary type.
Definition InputStream.h:23
void addSharedStream(const std::weak_ptr< std::istream > stream) const
Internal method to be called by derived classes to add a shared stream to _shared_streams (so that it...
Definition InputStream.C:21
virtual std::shared_ptr< std::istream > get() const =0
Gets an input stream to the underlying stream.
std::vector< std::weak_ptr< std::istream > > _shared_streams
The streams that have been handed out by get()
Definition InputStream.h:60
bool inUse() const
Whether or not anything is still using this stream.
Definition InputStream.C:35
virtual ~InputStream()
Definition InputStream.C:14
virtual std::optional< std::filesystem::path > getFilename() const
Gets the underlying filename, if any.
Definition InputStream.C:44