Inviwo  0.9.10.1
Inviwo documentation
inviwo::WorkspaceManager Class Reference

#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
 

Detailed Description

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.

Member Function Documentation

◆ clear()

void inviwo::WorkspaceManager::clear ( )

Clear the current workspace. This will invoke all the clear callback that have been added.

◆ createWorkspaceDeserializer()

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.

◆ load() [1/2]

void inviwo::WorkspaceManager::load ( std::istream &  stream,
const std::string &  refPath,
const ExceptionHandler &  exceptionHandler = StandardExceptionHandler() 
)

Load a workspace from a stream

Parameters
streamthe stream to read from.
refPatha 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.
exceptionHandlerA callback for handling errors.

◆ load() [2/2]

void inviwo::WorkspaceManager::load ( const std::string &  path,
const ExceptionHandler &  exceptionHandler = StandardExceptionHandler() 
)

Load a workspace from a file

Parameters
paththe file to read from.
exceptionHandlerA callback for handling errors.

◆ onClear()

WorkspaceManager::ClearHandle inviwo::WorkspaceManager::onClear ( const ClearCallback &  callback)

Callback for clearing the workspace.

◆ onLoad()

WorkspaceManager::DeserializationHandle inviwo::WorkspaceManager::onLoad ( const DeserializationCallback &  callback)

Callback for loading the workspace.

◆ onSave()

WorkspaceManager::SerializationHandle inviwo::WorkspaceManager::onSave ( const SerializationCallback &  callback,
WorkspaceSaveModes  modes = WorkspaceSaveModes{flags::any} 
)

Callback for saving the workspace.

◆ registerFactory()

void inviwo::WorkspaceManager::registerFactory ( FactoryBase factory)

Register a factory that should be used by the workspace loading to create items.

◆ save() [1/2]

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

Parameters
streamthe stream to write to.
refPatha 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.
exceptionHandlerA callback for handling errors.
modeto indicate if we are saving to disk or undo-stack

◆ save() [2/2]

void inviwo::WorkspaceManager::save ( const std::string &  path,
const ExceptionHandler &  exceptionHandler = StandardExceptionHandler(),
WorkspaceSaveMode  mode = WorkspaceSaveMode::Disk 
)

Save the current workspace to a file

Parameters
paththe file to save into.
exceptionHandlerA callback for handling errors.
modeto indicate if we are saving to disk or undo-stack

The documentation for this class was generated from the following files: