Bifrost SDK
Bifrost SDK documentation
Workspace.h
Go to the documentation of this file.
1//-
2// ================================================================================================
3// Copyright 2024 Autodesk, Inc. All rights reserved.
4//
5// Use of this software is subject to the terms of the Autodesk license agreement provided
6// at the time of installation or download, or which otherwise accompanies this software in
7// either electronic or hard copy form.
8// ================================================================================================
9//+
10
15
16#ifndef BIFROSTGRAPH_EXECUTOR_WORKSPACE_H
17#define BIFROSTGRAPH_EXECUTOR_WORKSPACE_H
18
19#include <BifrostGraph/Executor/internal/ExecutorExport.h>
20#include <BifrostGraph/Executor/internal/PropagateConstPtr.h>
21
27
28#include <Amino/Core/String.h>
29
30#include <utility>
31
32//-------------------------------------------------------------------------------------------------
33// Forward declarations
34//-------------------------------------------------------------------------------------------------
35
36namespace Amino {
37class TypeId;
38} // namespace Amino
39
40namespace BifrostGraph {
41namespace Executor {
42
43class Library;
44class Watchpoint;
45class WatchpointLayoutFactory;
46
47namespace Private {
48class IGraphContainerOwner;
49class IRestrictedWorkspaceServices;
50class WorkspaceImpl;
51} // namespace Private
52
56//-------------------------------------------------------------------------------------------------
57// CLASS Workspace
58//-------------------------------------------------------------------------------------------------
69class BIFROSTGRAPH_EXECUTOR_SHARED_DECL Workspace {
70protected:
71 //---------------------------------------------------------------------------------------------
72 // Initialization
73 //---------------------------------------------------------------------------------------------
74
89 explicit Workspace(const Amino::String& name) noexcept;
90
98 explicit Workspace(Uninitialized uninitialized) noexcept;
99
102
103public:
105 virtual ~Workspace() noexcept;
106
117 virtual bool isValid() const noexcept;
118
122 static Workspace& getInvalid() noexcept;
123
124 //---------------------------------------------------------------------------------------------
125 // Library
126 //---------------------------------------------------------------------------------------------
127
136 const Library& getLibrary() const noexcept;
137 Library& getLibrary() noexcept;
139
140 //---------------------------------------------------------------------------------------------
141 // Configuration Files
142 //---------------------------------------------------------------------------------------------
143
160 bool loadConfigFiles(const StringArray& configFiles,
161 const StringArray& disabledPacks = StringArray()) noexcept;
162
163 //---------------------------------------------------------------------------------------------
164 // Resources Services
165 //---------------------------------------------------------------------------------------------
166
175 bool registerTypeTranslationsPlugins(TypeTranslation::PluginHostData* hostData) const noexcept;
176
185 bool unregisterTypeTranslationsPlugins(
186 TypeTranslation::PluginHostData* hostData) const noexcept;
187
188 //---------------------------------------------------------------------------------------------
189 // GraphContainer Management
190 //---------------------------------------------------------------------------------------------
191
206 template <typename Functor>
207 GraphContainer& addGraphContainerT(Functor&& func) noexcept {
208 if (isValid()) {
209 // Make a new GraphContainer (potentially a class derived from GraphContainer).
211 try {
212 owner = std::forward<Functor&&>(func)(getGraphContainerOwnerServices());
213 } catch (...) {
214 }
215 // Validate then add the new GraphContainer.
216 // Upon failure, validateAndAddGraphContainer will destroy the GraphContainer (if any).
217 GraphContainer* container = validateAndAddGraphContainer(std::move(owner));
218 if (container) {
219 return *container;
220 }
221 }
222 // Upon any failure, return an invalid GraphContainer:
224 }
225
233 template <typename T>
234 using DeleterFunc = void (*)(T* p);
235
242 GraphContainer& addGraphContainer(DeleterFunc<GraphContainer> deleter) noexcept;
244
251 bool deleteGraphContainer(GraphContainer& graphContainer) noexcept;
252
258 const Watchpoint* getWatchpoint(const Amino::TypeId& typeId) const noexcept;
259
263 WatchpointLayoutFactory const& getWatchpointLayoutFactory() const noexcept;
264 WatchpointLayoutFactory& getWatchpointLayoutFactory() noexcept;
266
267protected:
274 void reportMessage(MessageCategory category, const Amino::String& message) const noexcept;
275
276private:
294 virtual void onReportedMessage(MessageSource source,
295 MessageCategory category,
296 const Amino::String& message) const noexcept;
297
306 Private::IGraphContainerOwner& getGraphContainerOwnerServices() noexcept;
307
325 GraphContainer* validateAndAddGraphContainer(Owner<GraphContainer>&& owner) noexcept;
326
327public:
328 //---------------------------------------------------------------------------------------------
329 // IRestrictedWorkspaceServices
330 //---------------------------------------------------------------------------------------------
331
341 const Private::IRestrictedWorkspaceServices& getRestrictedServices() const noexcept;
342 Private::IRestrictedWorkspaceServices& getRestrictedServices() noexcept;
344
345private:
348 Workspace(const Workspace&) = delete;
349 Workspace(Workspace&&) = delete;
350 Workspace& operator=(const Workspace&) = delete;
351 Workspace& operator=(Workspace&&) = delete;
353
354private:
355 friend class Private::WorkspaceImpl;
356 Internal::PropagateConstPtr<Private::WorkspaceImpl, Internal::Owned::kYes> m_impl;
357 static Workspace s_invalid;
358};
360} // namespace Executor
361} // namespace BifrostGraph
362
363#endif // BIFROSTGRAPH_EXECUTOR_WORKSPACE_H
String class.
Provide factory functions for Executor core classes.
BifrostGraph Executor GraphContainer.
BifrostGraph Executor Owner helper class.
BifrostGraph Executor TypeTranslation.
MessageSource
The source object of a reported message.
Definition: Types.h:42
Uninitialized
Tag for explicitly specifying that a constructor should not initialize any data members,...
Definition: Types.h:59
MessageCategory
The category of a reported message.
Definition: Types.h:33
Definition: HostData.h:33
Define a Amino array of elements of type T.
Definition: Array.h:105
The string class used by Amino.
Definition: String.h:46
The GraphContainer class that loads a graph to be executed and manages the Jobs that execute this gra...
static GraphContainer & getInvalid() noexcept
Get a statically allocated GraphContainer that is uninitialized, invalid and not owned by any Workspa...
A Library of types and node definitions that can be used by Bifrost.
Definition: Library.h:53
The Owner<T> class template represents ownership of an object pointer. It indicates that the pointed ...
Definition: Owner.h:38
BifrostGraph Executor TypeTranslation.
BifrostGraph Executor Watchpoint.
Definition: Watchpoint.h:68
Layout factory to build layouts for types and/or values.
The Workspace is the central element of the BifrostGraph Executor.
Definition: Workspace.h:69
void(*)(T *p) DeleterFunc
The signature for the custom pointer deleter of a pointee p.
Definition: Workspace.h:234
Workspace(Uninitialized uninitialized) noexcept
Constructor that leaves the Workspace in an uninitialized state.
GraphContainer & addGraphContainer() noexcept
Aliases for adding an instance of a GraphContainer base class, using an optional custom deleter funct...
Workspace(const Amino::String &name) noexcept
Construct a Workspace. The Workspace is initialized with a newly created BifrostGraph::Executor::Libr...
virtual ~Workspace() noexcept
Destructor.
EXECUTOR_DECLARE_MAKE_OWNER_FRIENDSHIP()
Allow the makeOwner<> factory functions to access the constructors of this class.
BifrostGraph Executor common types.