Inviwo
0.9.10.1
Inviwo documentation
|
#include <workspacemanager.h>
Public Types | |
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 |
Public Member Functions | |
WorkspaceManager (InviwoApplication *app) | |
void | clear () |
void | save (std::ostream &stream, const std::string &refPath, const ExceptionHandler &exceptionHandler=StandardExceptionHandler(), WorkspaceSaveMode mode=WorkspaceSaveMode::Disk) |
void | save (const std::string &path, const ExceptionHandler &exceptionHandler=StandardExceptionHandler(), WorkspaceSaveMode mode=WorkspaceSaveMode::Disk) |
void | load (std::istream &stream, const std::string &refPath, const ExceptionHandler &exceptionHandler=StandardExceptionHandler()) |
void | load (const std::string &path, const ExceptionHandler &exceptionHandler=StandardExceptionHandler()) |
ClearHandle | onClear (const ClearCallback &callback) |
SerializationHandle | onSave (const SerializationCallback &callback, WorkspaceSaveModes modes=WorkspaceSaveModes{flags::any}) |
DeserializationHandle | onLoad (const DeserializationCallback &callback) |
void | registerFactory (FactoryBase *factory) |
Deserializer | createWorkspaceDeserializer (std::istream &stream, const std::string &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::string & | refPath, | ||
Logger * | logger = LogCentral::getPtr() |
||
) | const |
Create a deserializer for a workspace stream, and apply all needed version updates.
void inviwo::WorkspaceManager::load | ( | std::istream & | stream, |
const std::string & | refPath, | ||
const ExceptionHandler & | exceptionHandler = StandardExceptionHandler() |
||
) |
Load a workspace from a stream
stream | the stream to read from. |
refPath | a reference that 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. |
void inviwo::WorkspaceManager::load | ( | const std::string & | path, |
const ExceptionHandler & | exceptionHandler = StandardExceptionHandler() |
||
) |
Load a workspace from a file
path | the file to read from. |
exceptionHandler | A callback for handling errors. |
WorkspaceManager::ClearHandle inviwo::WorkspaceManager::onClear | ( | const ClearCallback & | callback | ) |
Callback for clearing the workspace.
WorkspaceManager::DeserializationHandle inviwo::WorkspaceManager::onLoad | ( | const DeserializationCallback & | callback | ) |
Callback for loading the workspace.
WorkspaceManager::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 | ( | std::ostream & | stream, |
const std::string & | 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 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 |
void inviwo::WorkspaceManager::save | ( | const std::string & | 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 |