9 #include "includes/kratos_parameters.h"
10 #include "containers/model.h"
11 #include "includes/smart_pointers.h"
17 #ifdef KRATOS_SMP_CXX11
108 void Push(const Model& rModel);
166 #ifdef KRATOS_SMP_OPENMP
169 #elif defined(KRATOS_SMP_CXX11)
170 using ID = std::thread::thread_id;
178 {
return Left.mID == Right.mID;}
181 {
return Left.mID != Right.mID;}
184 {
return rStream << threadID.mID;}
189 void Erase(
const std::set<const_iterator>& rLines);
192 static bool IsValidEntry(
const value_type& rEntry);
195 [[nodiscard]] std::shared_ptr<iterator::FileAccess> Open(std::ios::openmode OpenMode = std::ios::in)
const;
197 std::filesystem::path mJournalPath;
199 std::pair<Extractor,ThreadID> mExtractor;
201 mutable std::weak_ptr<iterator::FileAccess> mpFileAccess;
266 using Extractor = std::function<Parameters(
const Model&)>;
275 Journal(
const std::filesystem::path& rJournalPath);
278 Journal(
const std::filesystem::path& rJournalPath,
303 void Push(const Model& rModel);
A read-only iterator over the items of a delimited file.
Definition: FileContentIterator.hpp:129
std::string value_type
Definition: FileContentIterator.hpp:133
A wrapper class for identifying threads.
Definition: Journal.hpp:164
friend std::ostream & operator<<(std::ostream &rStream, ThreadID threadID)
Definition: Journal.hpp:183
friend bool operator==(ThreadID Left, ThreadID Right)
Definition: Journal.hpp:177
friend bool operator!=(ThreadID Left, ThreadID Right)
Definition: Journal.hpp:180
A class for keeping administrational text data throughout an analysis.
Definition: Journal.hpp:42
std::function< value_type(const Model &)> Extractor
Definition: Journal.hpp:52
void SetExtractor(Extractor &&rExtractor)
Set the extractor handling the conversion from Model to a string.
JournalBase(JournalBase &&rOther)=delete
The move constructor is deleted because it's ambiguous what should happen to the associated file.
bool IsOpen() const noexcept
Check whether the associated file is opened by this object.
const_iterator begin() const
Create an iterator to the first line of the associated file.
iterator::value_type value_type
Definition: Journal.hpp:48
JournalBase(const JournalBase &rOther)
Copy constructor.
JournalBase(const std::filesystem::path &rJournalPath)
Construct a registry given an associated file path and a no-op extractor.
FileStringIterator iterator
Definition: Journal.hpp:44
KRATOS_CLASS_POINTER_DEFINITION(JournalBase)
size_type size() const
Count the number of lines in the file (including the last empty one).
JournalBase()
Construct the object with an empty file name (invalid).
JournalBase & operator=(const JournalBase &rOther)
Copy assignment operator.
const std::filesystem::path & GetFilePath() const noexcept
Get the path to the associated file.
void Push(const Model &rModel)
Call the extractor and append the results to the associated file.
JournalBase & operator=(JournalBase &&rOther)=delete
The move assignment operator is deleted because it's ambiguous what should happen to the associated f...
void Clear()
Delete the associated file.
JournalBase(const std::filesystem::path &rJournalPath, const Extractor &rExtractor)
Construct a registry given an associated file path and extractor.
const_iterator end() const
Create an iterator to the last (empty) line of the associated file.
void Erase(const_iterator itEntry)
Erase an entry from the associated file.
void EraseIf(const std::function< bool(const value_type &)> &rPredicate)
Erase all lines from the associated file matching the input predicate.
std::size_t size_type
Definition: Journal.hpp:50
An iterator wrapping JournalBase::iterator but with Parameters as value_type.
Definition: Journal.hpp:216
void pointer
Definition: Journal.hpp:226
iterator(const iterator &rOther)=default
Parameters value_type
Definition: Journal.hpp:222
std::forward_iterator_tag iterator_category
Definition: Journal.hpp:220
iterator & operator=(const iterator &rOther)=default
friend bool operator!=(const iterator &rLeft, const iterator &rRight)
friend bool operator==(const iterator &rLeft, const iterator &rRight)
void reference
Definition: Journal.hpp:228
JournalBase::iterator GetBase() const
Definition: Journal.hpp:247
iterator(iterator &&rOther)=default
value_type operator*() const
std::ptrdiff_t difference_type
Definition: Journal.hpp:224
iterator & operator=(iterator &&rOther)=default
A class for keeping administrational text data throughout an analysis.
Definition: Journal.hpp:212
Journal & operator=(const Journal &rOther)=default
Copy assignment operator.
void SetExtractor(Extractor &&rExtractor)
Set the extractor handling the conversion from Model to a string.
std::function< Parameters(const Model &)> Extractor
Definition: Journal.hpp:266
bool IsOpen() const noexcept
Check whether the associated file is opened by this object.
const_iterator begin() const
Create an iterator to the first line of the associated file.
Journal(const std::filesystem::path &rJournalPath, const Extractor &rExtractor)
Construct a registry given an associated file path and extractor.
iterator::value_type value_type
Definition: Journal.hpp:262
Journal()
Construct the object with an empty file name (invalid).
KRATOS_CLASS_POINTER_DEFINITION(Journal)
size_type size() const
Count the number of lines in the file (including the last empty one).
const std::filesystem::path & GetFilePath() const noexcept
Get the path to the associated file.
void Push(const Model &rModel)
Call the extractor and append the results to the associated file.
void Clear()
JournalBase::Clear()
Journal & operator=(Journal &&rOther)=delete
The move assignment operator is deleted because it's ambiguous what should happen to the associated f...
Journal(const std::filesystem::path &rJournalPath)
Construct a registry given an associated file path and a no-op extractor.
Journal(Journal &&rOther)=delete
The move constructor is deleted because it's ambiguous what should happen to the associated file.
Journal(const Journal &rOther)=default
Copy constructor.
const_iterator end() const
Create an iterator to the last (empty) line of the associated file.
void Erase(const_iterator itEntry)
Erase an entry from the associated file.
void EraseIf(const std::function< bool(const value_type &)> &rPredicate)
Erase all lines from the associated file matching the input predicate.
std::size_t size_type
Definition: Journal.hpp:264
Definition: AddIOToPython.hpp:12
Definition: CheckpointID.hpp:68