Defines the scheduled output interface used by CUDA integrators. More...
#include <Subscriber.h>
Public Member Functions | |
| Subscriber (void) | |
| Constructs an unattached subscriber with no output file. | |
| Subscriber (const std::filesystem::path &filePath) | |
| Constructs a subscriber and opens a text output file. | |
| Subscriber (const std::filesystem::path &filePath, const int reportFrequency) | |
| Constructs a subscriber with an explicit reporting interval. | |
| virtual | ~Subscriber (void) noexcept=default |
| Destroys the stream and releases retained collaborators. | |
| void | setReportFrequency (const int reportFrequency) |
| Sets the number of propagated steps between scheduled updates. | |
| void | setFilePath (const std::filesystem::path &filePath) |
| Sets the logical output-file path without reopening the stream. | |
| void | setCharmmContext (std::shared_ptr< CharmmContext > ctx) |
| Retains the context exposed to subscriber implementations. | |
| void | setIntegrator (std::shared_ptr< CudaIntegrator > integrator) |
| Retains the integrator exposed to subscriber implementations. | |
| int | getReportFrequency (void) const |
| Returns the configured reporting interval. | |
| const std::filesystem::path & | getFilePath (void) const |
| Returns the logical output-file path. | |
| std::filesystem::path & | getFilePath (void) |
| Returns mutable access to the logical output-file path. | |
| virtual void | update (void)=0 |
| Writes one subscriber-specific report. | |
| void | checkPath (const std::filesystem::path &filePath) |
| Checks whether the parent portion of an output path exists. | |
| virtual void | openFile (void) |
| Opens the stored path as a truncating text output stream. | |
| void | addCommentSection (const std::string &commentLines) |
| Appends and flushes one newline-terminated comment section. | |
Protected Attributes | |
| int | m_ReportFrequency |
| Stores the positive, dimensionless reporting interval. | |
| std::filesystem::path | m_FilePath |
| Stores the logical output path owned by the subscriber. | |
| std::fstream | m_FileStream |
| Owns the host file stream used by concrete reporters. | |
| std::shared_ptr< CharmmContext > | m_CharmmContext |
| Retains the context queried by concrete subscriber updates. | |
| std::shared_ptr< CudaIntegrator > | m_Integrator |
| Retains the integrator queried by concrete subscriber updates. | |
Defines the scheduled output interface used by CUDA integrators.
A subscriber owns one host output stream, stores a positive report frequency, and can retain shared ownership of one CharmmContext and one CudaIntegrator. CudaIntegrator::subscribe() attaches those collaborators, retains the subscriber, and snapshots its current report frequency. During propagation, the integrator invokes update synchronously on the calling thread after each matching dynamics step.
The base class is abstract. It is not copyable because it owns a std::fstream, and its user-declared destructor prevents implicit move operations. The class performs no internal locking; callers must serialize stream access, attachment, frequency changes, updates, and destruction.
std::shared_ptr. Call CudaIntegrator::unsubscribe() before releasing the final external owners. | Subscriber::Subscriber | ( | void | ) |
Constructs an unattached subscriber with no output file.
1000, the file path is empty, the stream is closed, and no context or integrator is retained. | Subscriber::Subscriber | ( | const std::filesystem::path & | filePath | ) |
Constructs a subscriber and opens a text output file.
The path is copied, any nonempty parent path is checked with std::filesystem::exists(), and the file is opened with std::ios::out. An existing file is truncated.
| [in] | filePath | File-system path copied by the subscriber. The value must be nonempty; when it has a nonempty parent path, that parent path must exist. |
| ApoCharmmError | With code ApoCharmmErrorCode::InvalidArgument if filePath is empty or its checked parent path does not exist. |
| ApoCharmmError | With code ApoCharmmErrorCode::Runtime if the output file cannot be opened for writing. |
1000 and the text stream is open at filePath. | Subscriber::Subscriber | ( | const std::filesystem::path & | filePath, |
| const int | reportFrequency | ||
| ) |
Constructs a subscriber with an explicit reporting interval.
The frequency is validated before the path is stored or the file is opened. The output is opened as a truncating text stream.
| [in] | filePath | File-system path copied by the subscriber. The value must be nonempty; when it has a nonempty parent path, that parent path must exist. |
| [in] | reportFrequency | Positive, dimensionless number of propagated steps between scheduled updates. |
| ApoCharmmError | With code ApoCharmmErrorCode::InvalidArgument if reportFrequency is not positive, filePath is empty, or its checked parent path does not exist. |
| ApoCharmmError | With code ApoCharmmErrorCode::Runtime if the output file cannot be opened for writing. |
filePath and getReportFrequency() == reportFrequency.
|
virtualdefaultnoexcept |
Destroys the stream and releases retained collaborators.
Destruction is non-throwing. All references returned by getFilePath are invalid after destruction.
| void Subscriber::addCommentSection | ( | const std::string & | commentLines | ) |
Appends and flushes one newline-terminated comment section.
The input is copied. A final newline is appended when the supplied string does not already end with one.
| [in] | commentLines | Nonempty text copied to the current output stream. |
| ApoCharmmError | With code ApoCharmmErrorCode::InvalidArgument if commentLines is empty. |
| ApoCharmmError | With code ApoCharmmErrorCode::NotInitialized if the output stream is not open. |
| ApoCharmmError | With code ApoCharmmErrorCode::Runtime if the write or flush leaves the stream in a failed state. |
| void Subscriber::checkPath | ( | const std::filesystem::path & | filePath | ) |
Checks whether the parent portion of an output path exists.
A path with no parent component returns without a filesystem query. Otherwise, the parent path is checked with std::filesystem::exists(). The current implementation checks existence, not whether the result is a directory.
| [in] | filePath | Path whose parent component is inspected. The path is borrowed for the call and is not retained. |
| ApoCharmmError | With code ApoCharmmErrorCode::InvalidArgument if the parent does not exist or its filesystem status cannot be queried. |
| std::filesystem::path & Subscriber::getFilePath | ( | void | ) |
Returns mutable access to the logical output-file path.
| const std::filesystem::path & Subscriber::getFilePath | ( | void | ) | const |
Returns the logical output-file path.
| int Subscriber::getReportFrequency | ( | void | ) | const |
Returns the configured reporting interval.
|
virtual |
Opens the stored path as a truncating text output stream.
An already-open stream is closed before the new open is attempted. The stream state is cleared, and the stored path is revalidated.
| ApoCharmmError | With code ApoCharmmErrorCode::NotInitialized if the stored file path is empty. |
| ApoCharmmError | With code ApoCharmmErrorCode::InvalidArgument if the checked parent path does not exist. |
| ApoCharmmError | With code ApoCharmmErrorCode::Runtime if the file cannot be opened for writing. |
Reimplemented in DcdSubscriber.
| void Subscriber::setCharmmContext | ( | std::shared_ptr< CharmmContext > | ctx | ) |
Retains the context exposed to subscriber implementations.
| [in] | ctx | Shared context owner to retain. A null shared pointer is accepted and leaves the subscriber unattached. |
| ApoCharmmError | With code ApoCharmmErrorCode::InvalidArgument if a non-null context is already retained. |
| void Subscriber::setFilePath | ( | const std::filesystem::path & | filePath | ) |
Sets the logical output-file path without reopening the stream.
| [in] | filePath | Output path copied by the subscriber. The value must be nonempty; when it contains /, its nonempty parent path must exist. |
| ApoCharmmError | With code ApoCharmmErrorCode::InvalidArgument if filePath is empty or its checked parent path does not exist. |
filePath. The current stream, if any, remains attached to its previous file. | void Subscriber::setIntegrator | ( | std::shared_ptr< CudaIntegrator > | integrator | ) |
Retains the integrator exposed to subscriber implementations.
| [in] | integrator | Shared integrator owner to retain. A null shared pointer is accepted and leaves the subscriber unattached. |
| ApoCharmmError | With code ApoCharmmErrorCode::InvalidArgument if a non-null integrator is already retained. |
| void Subscriber::setReportFrequency | ( | const int | reportFrequency | ) |
Sets the number of propagated steps between scheduled updates.
| [in] | reportFrequency | Positive, dimensionless reporting interval. |
| ApoCharmmError | With code ApoCharmmErrorCode::InvalidArgument if reportFrequency is not positive. |
getReportFrequency() == reportFrequency. A rejected value leaves the previous frequency unchanged.
|
pure virtual |
Writes one subscriber-specific report.
CudaIntegrator invokes this virtual operation synchronously after a propagated step whose local step index is divisible by the frequency cached at subscription. Direct callers are responsible for establishing every state precondition of the concrete subscriber.
Implemented in DcdSubscriber, and RestartSubscriber.
|
protected |
Retains the context queried by concrete subscriber updates.
The pointer can be null. No public operation clears a non-null attachment.
|
protected |
Stores the logical output path owned by the subscriber.
The value can differ from the file currently associated with m_FileStream after a path change that is not followed by openFile.
|
protected |
Owns the host file stream used by concrete reporters.
The stream has no internal synchronization and can represent text or binary output according to the concrete subscriber's open operation.
|
protected |
Retains the integrator queried by concrete subscriber updates.
The pointer can be null. While subscribed, this strong reference and the integrator's strong subscriber reference form an ownership cycle.
|
protected |
Stores the positive, dimensionless reporting interval.
The default is 1000. An integrator copies this value into its parallel scheduling array during subscription.