34#if NDEVR_SUPPORTS_THREADING
35#include <NDEVR/ModelFactory.h>
36#include <NDEVR/Thread.h>
37#include <NDEVR/File.h>
83 void kill(
bool terminate_current);
119 m_exception_handler = exception_handler;
126 m_finished_callback = finished_callback;
158 volatile bool m_is_canceled =
false;
159 volatile bool m_is_accepted =
false;
160 volatile bool m_options_changed =
false;
162 volatile bool m_is_read;
168 mutable std::mutex m_critical_section;
169 std::function<void(
const Exception& e)> m_exception_handler;
170 std::function<void(
bool success)> m_finished_callback;
The equivelent of std::vector but with a bit more control.
void stopThread() override
Stops the thread by killing it and canceling the current operation.
void setExceptionHandler(const std::function< void(const Exception &)> &exception_handler)
Sets a callback to handle exceptions thrown during file operations.
bool readFile(FactoryParameters &file)
Reads a single file using the ModelFactory.
void kill(bool terminate_current)
Kills the thread, optionally terminating the current operation.
void setFiles(const Buffer< FactoryParameters > &files)
Sets the files to be processed and triggers a re-evaluation of the current operation.
ModelFactory * factory() const
Returns the ModelFactory used for file I/O operations.
void deleteReadIDs()
Deletes all design objects that were created during a read operation.
bool writeFile(FactoryParameters &file)
Writes a single file using the ModelFactory, first to a temporary location.
void reset()
Resets the accepted and canceled state so the thread can be reused.
const Buffer< FactoryParameters > & lastRequests() const
Returns the last completed set of factory parameter requests.
void run() override
Main thread loop.
bool isFinished() const
Checks whether the thread has finished processing.
void accept()
Accepts the current operation, allowing temporary files to be committed.
void cancel()
Cancels the current operation, discarding any temporary files or read data.
void requestStopLoad()
Requests cancellation of the current in-progress load/save operation.
bool executeWrite(Buffer< FactoryParameters > &requests)
Executes a write operation for all provided factory parameter requests.
void setFinishedCallback(const std::function< void(bool success)> &finished_callback)
Sets a callback invoked when the thread finishes processing.
bool executeRead(Buffer< FactoryParameters > &requests)
Executes a read operation for all provided factory parameter requests.
bool isAccepted() const
Checks whether the operation has been accepted by the user.
void deleteTempFiles()
Deletes all temporary files created during a write operation.
CachedFactoryIOThread(bool is_read)
Constructs a CachedFactoryIOThread configured for reading or writing.
bool writeTempFiles(ProgressInfo &info)
Moves temporary files to their final destination after a write operation.
A core class where all Design Objects including models, materials, and geometries are stored.
Provides consistent interface to handle errors through the throw expression.
The core logic for importing and exporting files from the model hierarchy.
Used with InfoPipe to signal that the system will be using progress.
Thread()
Constructs a Thread with a default name.
The primary namespace for the NDEVR SDK.
A container of input information that is to be filled with output information by an IOFactory.