Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::WorkspaceManager Class Reference

#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
 
using allocator_type = std::pmr::polymorphic_allocator<std::byte>
 

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 (std::pmr::string &xml, 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::pmr::string &xml, 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(), std::pmr::polymorphic_allocator< std::byte > alloc={}) const
 
std::pair< Deserializer, InviwoSetupInfocreateWorkspaceDeserializerAndInfo (std::istream &stream, const std::filesystem::path &refPath, Logger *logger=LogCentral::getPtr(), std::pmr::polymorphic_allocator< std::byte > alloc={}) const
 
std::pair< Deserializer, InviwoSetupInfocreateWorkspaceDeserializerAndInfo (const std::pmr::string &xml, const std::filesystem::path &refPath, Logger *logger=LogCentral::getPtr(), std::pmr::polymorphic_allocator< std::byte > alloc={}) 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::filesystem::path & refPath,
Logger * logger = LogCentral::getPtr(),
std::pmr::polymorphic_allocator< std::byte > alloc = {} ) const

Create a deserializer for a workspace stream, and apply all needed version updates.

◆ createWorkspaceDeserializerAndInfo() [1/2]

std::pair< Deserializer, InviwoSetupInfo > inviwo::WorkspaceManager::createWorkspaceDeserializerAndInfo ( const std::pmr::string & xml,
const std::filesystem::path & refPath,
Logger * logger = LogCentral::getPtr(),
std::pmr::polymorphic_allocator< std::byte > alloc = {} ) const

Create a deserializer for a workspace string, and apply all needed version updates.

◆ createWorkspaceDeserializerAndInfo() [2/2]

std::pair< Deserializer, InviwoSetupInfo > inviwo::WorkspaceManager::createWorkspaceDeserializerAndInfo ( std::istream & stream,
const std::filesystem::path & refPath,
Logger * logger = LogCentral::getPtr(),
std::pmr::polymorphic_allocator< std::byte > alloc = {} ) const

Create a deserializer for a workspace stream, and apply all needed version updates.

◆ load() [1/3]

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

Load a workspace from a file

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

◆ load() [2/3]

void inviwo::WorkspaceManager::load ( const std::pmr::string & xml,
const std::filesystem::path & refPath,
const ExceptionHandler & exceptionHandler = StandardExceptionHandler(),
WorkspaceSaveMode mode = WorkspaceSaveMode::Disk )

Load a workspace from a string

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

◆ load() [3/3]

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

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

◆ onClear()

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

Callback for clearing the workspace.

◆ onLoad()

DeserializationHandle inviwo::WorkspaceManager::onLoad ( const DeserializationCallback & callback,
WorkspaceSaveModes modes = WorkspaceSaveModes{flags::any} )

Callback for loading the workspace.

◆ onSave()

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/3]

void inviwo::WorkspaceManager::save ( const std::filesystem::path & 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

◆ save() [2/3]

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

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

◆ save() [3/3]

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

Save the current workspace to a stream

Parameters
xmlthe string to write to.
refPatha 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.
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 file: