Inviwo 0.9.12-pre
Inviwo documentation
|
#include <workspacemanager.h>
Public Types | |
using | ExceptionHandler = std::function<void(ExceptionContext)> |
using | ClearCallback = typename ClearDispatcher::Callback |
using | ClearHandle = typename ClearDispatcher::Handle |
using | SerializationCallback = std::function<void(Serializer&)> |
using | SerializationHandle = typename SerializationDispatcher::Handle |
using | DeserializationCallback = std::function<void(Deserializer&)> |
using | DeserializationHandle = typename DeserializationDispatcher::Handle |
using | ModifiedChangedCallback = typename ModifiedChangedDispatcher::Callback |
using | ModifiedChangedHandle = typename ModifiedChangedDispatcher::Handle |
using | ModifiedCallback = typename ModifiedDispatcher::Callback |
using | ModifiedHandle = typename ModifiedDispatcher::Handle |
Public Member Functions | |
WorkspaceManager (InviwoApplication *app) | |
void | clear () |
void | save (std::ostream &stream, const std::filesystem::path &refPath, const ExceptionHandler &exceptionHandler=StandardExceptionHandler(), WorkspaceSaveMode mode=WorkspaceSaveMode::Disk) |
void | save (const std::filesystem::path &path, const ExceptionHandler &exceptionHandler=StandardExceptionHandler(), WorkspaceSaveMode mode=WorkspaceSaveMode::Disk) |
void | load (std::istream &stream, const std::filesystem::path &refPath, const ExceptionHandler &exceptionHandler=StandardExceptionHandler(), WorkspaceSaveMode mode=WorkspaceSaveMode::Disk) |
void | load (const std::filesystem::path &path, const ExceptionHandler &exceptionHandler=StandardExceptionHandler(), WorkspaceSaveMode mode=WorkspaceSaveMode::Disk) |
ClearHandle | onClear (const ClearCallback &callback) |
SerializationHandle | onSave (const SerializationCallback &callback, WorkspaceSaveModes modes=WorkspaceSaveModes{flags::any}) |
DeserializationHandle | onLoad (const DeserializationCallback &callback, WorkspaceSaveModes modes=WorkspaceSaveModes{flags::any}) |
void | setModified () |
bool | isModified () const |
ModifiedChangedHandle | onModifiedChanged (const ModifiedChangedCallback &callback) |
ModifiedHandle | onModified (const ModifiedCallback &callback) |
void | registerFactory (FactoryBase *factory) |
Deserializer | createWorkspaceDeserializer (std::istream &stream, const std::filesystem::path &refPath, Logger *logger=LogCentral::getPtr()) const |
The WorkspaceManager is responsible for clearing, loading, and saving a workspace. Different items such as the processor network can register callbacks for clearing, loading, or saving a workspace. Other object can also register callbacks. It also responsible for keeping a list of factories to use while deserializing. Other module can register factories that should be used while deserializing. The user interface should use the Workspace Manager to clear, load, and save workspaces. instead of calling the Processor Network directly. The workspace manager is owned by the InviwoApplication.
void inviwo::WorkspaceManager::clear | ( | ) |
Clear the current workspace. This will invoke all the clear callback that have been added.
Deserializer inviwo::WorkspaceManager::createWorkspaceDeserializer | ( | std::istream & | stream, |
const std::filesystem::path & | refPath, | ||
Logger * | logger = LogCentral::getPtr() ) const |
Create a deserializer for a workspace stream, and apply all needed version updates.
void inviwo::WorkspaceManager::load | ( | const std::filesystem::path & | path, |
const ExceptionHandler & | exceptionHandler = StandardExceptionHandler(), | ||
WorkspaceSaveMode | mode = WorkspaceSaveMode::Disk ) |
Load a workspace from a file
path | the file to read from. |
exceptionHandler | A callback for handling errors. |
void inviwo::WorkspaceManager::load | ( | std::istream & | stream, |
const std::filesystem::path & | refPath, | ||
const ExceptionHandler & | exceptionHandler = StandardExceptionHandler(), | ||
WorkspaceSaveMode | mode = WorkspaceSaveMode::Disk ) |
Load a workspace from a stream
stream | the stream to read from. |
refPath | a reference that can be use by the deserializer to calculate relative paths. The same refPath should be given when loading. Most often this should be the path to the saved file. |
exceptionHandler | A callback for handling errors. |
ClearHandle inviwo::WorkspaceManager::onClear | ( | const ClearCallback & | callback | ) |
Callback for clearing the workspace.
DeserializationHandle inviwo::WorkspaceManager::onLoad | ( | const DeserializationCallback & | callback, |
WorkspaceSaveModes | modes = WorkspaceSaveModes{flags::any} ) |
Callback for loading the workspace.
SerializationHandle inviwo::WorkspaceManager::onSave | ( | const SerializationCallback & | callback, |
WorkspaceSaveModes | modes = WorkspaceSaveModes{flags::any} ) |
Callback for saving the workspace.
void inviwo::WorkspaceManager::registerFactory | ( | FactoryBase * | factory | ) |
Register a factory that should be used by the workspace loading to create items.
void inviwo::WorkspaceManager::save | ( | const std::filesystem::path & | path, |
const ExceptionHandler & | exceptionHandler = StandardExceptionHandler(), | ||
WorkspaceSaveMode | mode = WorkspaceSaveMode::Disk ) |
Save the current workspace to a file
path | the file to save into. |
exceptionHandler | A callback for handling errors. |
mode | to indicate if we are saving to disk or undo-stack |
void inviwo::WorkspaceManager::save | ( | std::ostream & | stream, |
const std::filesystem::path & | refPath, | ||
const ExceptionHandler & | exceptionHandler = StandardExceptionHandler(), | ||
WorkspaceSaveMode | mode = WorkspaceSaveMode::Disk ) |
Save the current workspace to a stream
stream | the stream to write to. |
refPath | a reference that can be use by the serializer to store relative paths. The same refPath should be given when loading. Most often this should be the path to the saved file. |
exceptionHandler | A callback for handling errors. |
mode | to indicate if we are saving to disk or undo-stack |