![]() |
NDEVR
API Documentation
|
A thread designed to read and write files using the FactoryIO interface. More...
Public Member Functions | |
| CachedFactoryIOThread (bool is_read) | |
| Constructs a CachedFactoryIOThread configured for reading or writing. | |
| 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 | deleteReadIDs () |
| Deletes all design objects that were created during a read operation. | |
| void | deleteTempFiles () |
| Deletes all temporary files created during a write operation. | |
| bool | executeRead (Buffer< FactoryParameters > &requests) |
| Executes a read operation for all provided factory parameter requests. | |
| bool | executeWrite (Buffer< FactoryParameters > &requests) |
| Executes a write operation for all provided factory parameter requests. | |
| ModelFactory * | factory () const |
| Returns the ModelFactory used for file I/O operations. | |
| bool | isAccepted () const |
| Checks whether the operation has been accepted by the user. | |
| bool | isFinished () const |
| Checks whether the thread has finished processing. | |
| void | kill (bool terminate_current) |
| Kills the thread, optionally terminating the current operation. | |
| const Buffer< FactoryParameters > & | lastRequests () const |
| Returns the last completed set of factory parameter requests. | |
| bool | readFile (FactoryParameters &file) |
| Reads a single file using the ModelFactory. | |
| void | requestStopLoad () |
| Requests cancellation of the current in-progress load/save operation. | |
| void | reset () |
| Resets the accepted and canceled state so the thread can be reused. | |
| void | run () override |
| Main thread loop. | |
| void | setExceptionHandler (const std::function< void(const Exception &)> &exception_handler) |
| Sets a callback to handle exceptions thrown during file operations. | |
| void | setFiles (const Buffer< FactoryParameters > &files) |
| Sets the files to be processed and triggers a re-evaluation of the current operation. | |
| void | setFinishedCallback (const std::function< void(bool success)> &finished_callback) |
| Sets a callback invoked when the thread finishes processing. | |
| void | stopThread () override |
| Stops the thread by killing it and canceling the current operation. | |
| bool | writeFile (FactoryParameters &file) |
| Writes a single file using the ModelFactory, first to a temporary location. | |
| bool | writeTempFiles (ProgressInfo &info) |
| Moves temporary files to their final destination after a write operation. | |
| Public Member Functions inherited from Thread | |
| Thread () | |
| Constructs a Thread with a default name. | |
| Thread (const StringView &name) | |
| Constructs a Thread with the specified name. | |
| virtual | ~Thread () |
| Destroys the Thread and cleans up resources. | |
| void | detach () |
| Detaches the thread, allowing it to run independently. | |
| void | forceStop () |
| Forces the running flag to false without waiting for the thread to finish. | |
| bool | isPrimaryThread () const |
| Checks whether this thread is the primary thread. | |
| bool | isRunning () const |
| Checks whether the thread is currently running. | |
| void | join () |
| Blocks the calling thread until this thread finishes execution. | |
| virtual void | requestStopThread () |
| Requests the thread to stop without blocking. | |
| void | setIsPrimaryThread (bool is_primary_thread) |
| Sets whether this thread should be treated as the primary thread. | |
| void | setThreadName (const StringView &name) |
| Sets the name of this thread. | |
| virtual bool | shouldExitThread () const |
| Checks whether the thread has been requested to exit. | |
| void | start () |
| Starts the thread execution. | |
| const String & | threadName () const |
| Gets the name assigned to this thread. | |
Additional Inherited Members | |
| Static Public Member Functions inherited from Thread | |
| static Thread & | CurrentThread () |
| Gets a reference to the Thread object for the calling thread. | |
| static String | CurrentThreadName () |
| Gets the name of the current thread. | |
| static void | ServiceVirtualThreads () |
| Services any virtual threads that require periodic execution. | |
| static void | SetCurrentThreadName (const StringView &name) |
| Sets the name of the current thread. | |
| static void | StopAllThreads () |
| Stops all tracked threads. | |
| Protected Member Functions inherited from Thread | |
| const std::thread & | self () |
| Gets a const reference to the underlying std::thread. | |
| Protected Attributes inherited from Thread | |
| volatile bool | m_is_running = false |
| Whether the thread is currently running. | |
| volatile bool | m_is_single_run = true |
| Whether the thread should execute only once before stopping. | |
A thread designed to read and write files using the FactoryIO interface.
Thread will perform all actions on a temp file, then move the file when accept() is called.
For write operations, files are first written to a temporary location. When accept() is called, the temporary files are moved to their final destination. This allows the user to confirm or cancel the operation before committing changes to disk. For read operations, the thread reads files into the DesignObjectLookup, and deleteReadIDs() cleans up if the operation is canceled.
Definition at line 52 of file CachedFactoryIOThread.h.
| CachedFactoryIOThread::CachedFactoryIOThread | ( | bool | is_read | ) |
Constructs a CachedFactoryIOThread configured for reading or writing.
| [in] | is_read | Whether this thread is used for reading (true) or writing (false). |
| void CachedFactoryIOThread::accept | ( | ) |
Accepts the current operation, allowing temporary files to be committed.
For write operations, this triggers moving temp files to their final destinations.
| void CachedFactoryIOThread::deleteReadIDs | ( | ) |
Deletes all design objects that were created during a read operation.
Used to roll back a read when the operation is canceled.
| bool CachedFactoryIOThread::executeRead | ( | Buffer< FactoryParameters > & | requests | ) |
Executes a read operation for all provided factory parameter requests.
| [in] | requests | The list of FactoryParameters describing files to read. |
| bool CachedFactoryIOThread::executeWrite | ( | Buffer< FactoryParameters > & | requests | ) |
Executes a write operation for all provided factory parameter requests.
| [in] | requests | The list of FactoryParameters describing files to write. |
|
inline |
Returns the ModelFactory used for file I/O operations.
Definition at line 156 of file CachedFactoryIOThread.h.
|
inline |
Checks whether the operation has been accepted by the user.
Definition at line 141 of file CachedFactoryIOThread.h.
| bool CachedFactoryIOThread::isFinished | ( | ) | const |
Checks whether the thread has finished processing.
| void CachedFactoryIOThread::kill | ( | bool | terminate_current | ) |
Kills the thread, optionally terminating the current operation.
| [in] | terminate_current | Whether to cancel the current operation before stopping. |
|
inline |
Returns the last completed set of factory parameter requests.
Definition at line 110 of file CachedFactoryIOThread.h.
| bool CachedFactoryIOThread::readFile | ( | FactoryParameters & | file | ) |
Reads a single file using the ModelFactory.
| [in] | file | The FactoryParameters describing the file to read. |
| void CachedFactoryIOThread::requestStopLoad | ( | ) |
Requests cancellation of the current in-progress load/save operation.
Sets the cancel flag on all current FactoryParameters so the operation can exit gracefully.
|
overridevirtual |
Main thread loop.
Waits for file requests and processes them until accepted or canceled.
Handles read and write operations, exception handling, progress reporting, and notifies the finished callback upon completion.
Reimplemented from Thread.
|
inline |
Sets a callback to handle exceptions thrown during file operations.
| [in] | exception_handler | A function called with the Exception when an error occurs. |
Definition at line 117 of file CachedFactoryIOThread.h.
| void CachedFactoryIOThread::setFiles | ( | const Buffer< FactoryParameters > & | files | ) |
Sets the files to be processed and triggers a re-evaluation of the current operation.
Any in-progress operation is canceled before the new file list is applied.
| [in] | files | The list of FactoryParameters describing the files to process. |
|
inline |
Sets a callback invoked when the thread finishes processing.
| [in] | finished_callback | A function called with true on success, false on failure. |
Definition at line 124 of file CachedFactoryIOThread.h.
| bool CachedFactoryIOThread::writeFile | ( | FactoryParameters & | file | ) |
Writes a single file using the ModelFactory, first to a temporary location.
| [in] | file | The FactoryParameters describing the file to write. |
| bool CachedFactoryIOThread::writeTempFiles | ( | ProgressInfo & | info | ) |
Moves temporary files to their final destination after a write operation.
| [in] | info | ProgressInfo to report move progress and errors. |