Bifrost SDK
Bifrost SDK documentation
WatchpointLayout.h
Go to the documentation of this file.
1//-
2// ================================================================================================
3// Copyright 2025 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_WATCHPOINT_LAYOUT_H
17#define BIFROSTGRAPH_EXECUTOR_WATCHPOINT_LAYOUT_H
18
19#include <BifrostGraph/Executor/internal/ExecutorExport.h>
20
23
24#include <Amino/Core/TypeId.h>
25
26namespace Amino {
27class Any;
28class String;
29class Type;
30} // namespace Amino
31
32namespace BifrostGraph {
33namespace Executor {
34
35class Workspace;
36class WatchpointLayout;
37class WatchpointLayoutFactory;
38class WatchpointLayoutPath;
39
40namespace Private {
41class WorkspaceImpl;
42}
43
46
49class BIFROSTGRAPH_EXECUTOR_SHARED_DECL WatchpointLayoutPtr {
50public:
53
58
64
70
76
82
84 explicit inline operator bool() const noexcept { return m_layout != nullptr; }
85
88 inline bool operator==(WatchpointLayoutPtr const& other) const noexcept {
89 return m_layout == other.m_layout;
90 }
91
94 inline bool operator!=(WatchpointLayoutPtr const& other) const noexcept {
95 return m_layout != other.m_layout;
96 }
97
100 inline operator WatchpointLayout const*() const noexcept { return m_layout; } // NOLINT
101
104 inline WatchpointLayout const* operator->() const noexcept { return m_layout; }
105
108 inline WatchpointLayout* operator->() noexcept { return m_layout; }
109
112 inline WatchpointLayout* get() const noexcept { return m_layout; }
113
117 template <typename T>
118 inline bool isA() const noexcept {
119 return dynamic_cast<T*>(m_layout) != nullptr;
120 }
121
125 template <typename T>
126 inline T& getAs() const noexcept {
127 return *static_cast<T*>(m_layout);
128 }
129
130private:
131#ifndef DOXYGEN
132 WatchpointLayout* m_layout = nullptr;
133#endif
134};
135
138
140class BIFROSTGRAPH_EXECUTOR_SHARED_DECL WatchpointLayout {
141public:
147 Amino::TypeId const& typeId);
148
153 static WatchpointLayoutPtr create(Amino::Type const& type, Amino::TypeId const& typeId);
154
157
159 Amino::TypeId const& getTypeId() const;
160
162 Amino::Type const& getType() const;
163
166
170
171protected:
173 WatchpointLayout(Amino::Type const& type, Amino::TypeId const& typeId);
174
175private:
177 WatchpointLayout(WatchpointLayout const&) = delete;
178
179private:
180 friend WatchpointLayoutPtr;
183 virtual void deleteThis();
184
185private:
186 class Impl;
187 Impl* m_impl;
188
190 std::size_t m_useCount = 0u;
191};
192
195
197class BIFROSTGRAPH_EXECUTOR_SHARED_DECL WatchpointLayoutComposite : public WatchpointLayout {
198public:
205 Amino::TypeId const& typeId,
206 bool placeHolder = false);
207
213 static WatchpointLayoutPtr create(Amino::Type const& type,
214 Amino::TypeId const& typeId,
215 bool placeHolder = false);
216
219
223
228
237 Amino::Any const& value,
238 Amino::String& out_value) const;
239
240protected:
242 WatchpointLayoutComposite(Amino::Type const& type,
243 Amino::TypeId const& typeId,
244 bool placeHolder);
245
246private:
249
250public:
252 class BIFROSTGRAPH_EXECUTOR_SHARED_DECL Iterator {
254 class Impl;
255
256 public:
257 explicit Iterator(Impl* impl);
259
263
266 bool operator==(const Iterator& other) const;
267
270 bool operator!=(const Iterator& other) const;
271
272 class BIFROSTGRAPH_EXECUTOR_SHARED_DECL SubLayout {
273 public:
274 Amino::String const& name() const;
276 };
277
279 SubLayout const& operator*() const;
280
281 private:
282 Impl* m_impl;
283 };
284
287 bool placeHolder() const;
288
290 bool empty() const;
291
293 std::size_t size() const;
294
297
299 Iterator end() const;
300
306
310 WatchpointLayoutPtr const get(Amino::String const& name) const;
311
312private:
313 class Impl;
314 Impl* m_impl;
315};
316
319
321class BIFROSTGRAPH_EXECUTOR_SHARED_DECL WatchpointLayoutArray : public WatchpointLayout {
322public:
328 Amino::Any const& value);
329
336 Amino::Type const& type,
337 Amino::Any const& value);
338
341
344
346 Amino::Type const& getElementType() const;
347
350
354
360 bool getIndices(Watchpoint::Filters const& filters,
361 Watchpoint::Sorter const& sorter,
362 Watchpoint::Indices& out_indices) const;
363
364protected:
367 Amino::Type const& type,
368 Amino::Any const& value);
369
370private:
373
374public:
376 std::size_t size() const;
377
381 WatchpointLayoutPtr layout(std::size_t index) const;
382
383private:
384 class Impl;
385 Impl* m_impl;
386};
387
390
392class BIFROSTGRAPH_EXECUTOR_SHARED_DECL WatchpointLayoutFactory {
393private:
398 WatchpointLayoutFactory() noexcept;
399
402 explicit WatchpointLayoutFactory(Uninitialized uninitialized) noexcept;
403
406 void setWorkspace(Workspace const& workspace) noexcept;
407
410 friend class BifrostGraph::Executor::Private::WorkspaceImpl;
411
412public:
417
420
422 bool isValid() const noexcept;
423
425 Workspace const& getWorkspace() const;
426
430 Amino::Type getType(Amino::String const& typeName) const;
431
438
442 bool exists(Amino::TypeId const& typeId) const;
443
447 WatchpointLayoutPtr get(Amino::TypeId const& typeId) const;
448
452 WatchpointLayoutPtr get(Amino::Any const& any) const;
453
458 WatchpointLayoutPtr get(Amino::Type const& type, Amino::Any const& any) const;
459
466 bool getValue(Amino::Any const& any,
468 Amino::String& out_value) const;
469
470private:
471 class Impl;
472 Impl* m_impl;
473};
474
476class BIFROSTGRAPH_EXECUTOR_SHARED_DECL WatchpointLayoutPath {
477public:
481 explicit WatchpointLayoutPath(Amino::String const& path);
485
488
494
496 bool empty() const;
497
500 void push_front(Amino::String const& element);
501
504 void push_front(std::size_t index);
505
507 Amino::String const& front() const;
509 bool frontIsIndex() const;
511 std::size_t frontAsIndex() const;
512
516
519 void push_back(Amino::String const& element);
520
523 void push_back(std::size_t index);
524
526 Amino::String const& back() const;
528 bool backIsIndex() const;
530 std::size_t backAsIndex() const;
531
535
536private:
537#ifndef DOXYGEN
538 class Impl;
539 Impl* m_impl;
540#endif
541};
542
543} // namespace Executor
544} // namespace BifrostGraph
545
546#endif // BIFROSTGRAPH_EXECUTOR_WATCHPOINT_LAYOUT_H
Type identifier for types.
BifrostGraph Executor Watchpoint.
bool exists(Amino::StringView path, Amino::String *errorMessage=nullptr)
Verify if a path exists.
Uninitialized
Tag for explicitly specifying that a constructor should not initialize any data members,...
Definition: Types.h:59
Definition: HostData.h:33
Generic value class that allows for storage of a value of any type.
Definition: Any.h:180
The string class used by Amino.
Definition: String.h:46
Type identifier for a type.
Definition: TypeId.h:45
Structure that holds the sorting settings for getIndices.
Definition: Watchpoint.h:364
A smart pointer on WatchpointLayout objects allowing them to be easily shared and managed.
bool operator==(WatchpointLayoutPtr const &other) const noexcept
Comparison.
WatchpointLayoutPtr & operator=(WatchpointLayoutPtr &&)
Assignment operators.
~WatchpointLayoutPtr()
Destructor If the pointer owns a layout object, its 'use count' is decremented by one....
WatchpointLayout const * operator->() const noexcept
Indirection.
bool isA() const noexcept
Check whether or not the pointed layout of type T.
WatchpointLayoutPtr()
Construct an empty pointer.
WatchpointLayoutPtr(WatchpointLayoutPtr const &other)
Copy constructor Construct a smart pointer on the same layout object as other and sharing ownership.
WatchpointLayout * get() const noexcept
Accessor.
T & getAs() const noexcept
Get the pointed layout casted as type T.
WatchpointLayoutPtr(WatchpointLayoutPtr &&other)
Move constructor Construct a smart pointer on the same layout object as other and taking ownership.
WatchpointLayout * operator->() noexcept
Indirection.
WatchpointLayoutPtr(WatchpointLayout *layout)
Construct a smart pointer that owns the layout object pointed by layout,.
bool operator!=(WatchpointLayoutPtr const &other) const noexcept
Comparison.
WatchpointLayoutPtr & operator=(WatchpointLayoutPtr const &)
Assignment operators.
Amino::Type const & getType() const
Get the type the layout is based on.
static WatchpointLayoutPtr create(WatchpointLayoutFactory const &factory, Amino::TypeId const &typeId)
Create a new WatchpointLayout.
Amino::String const & getTypeName() const
Get the fully qualified type name the layout is based on.
WatchpointLayout(Amino::Type const &type, Amino::TypeId const &typeId)
Internal constructor.
static WatchpointLayoutPtr create(Amino::Type const &type, Amino::TypeId const &typeId)
Create a new WatchpointLayout.
virtual void deleteThis()
Function used by the smart pointer to destroy the instance.
Amino::String const & getTypeKind() const
Get the layout's kind name.
Amino::TypeId const & getTypeId() const
Get the typeId the layout is based on.
A composite layout, that contains sub layouts.
bool empty() const
Return whether or not the composite has no sub layouts.
bool hasFlattenedRepresentation() const
Check whether or not the composite has a flattened string representation.
static WatchpointLayoutPtr create(WatchpointLayoutFactory const &factory, Amino::TypeId const &typeId, bool placeHolder=false)
Create a new WatchpointLayoutComposite.
bool flattenedRepresentation(WatchpointLayoutFactory const &factory, Amino::Any const &value, Amino::String &out_value) const
Get the flattened string representation of the value based on the composite's custom layout.
static WatchpointLayoutPtr create(Amino::Type const &type, Amino::TypeId const &typeId, bool placeHolder=false)
Create a new WatchpointLayoutComposite.
WatchpointLayoutPtr const get(Amino::String const &name) const
Get the sub layout of given name.
Iterator begin() const
Return an iterator on the first sub layout.
WatchpointLayoutComposite(Amino::Type const &type, Amino::TypeId const &typeId, bool placeHolder)
Internal constructor.
bool placeHolder() const
Return whether or not this is a place holder for a custom layout.
Iterator end() const
Return an iterator past the last sub layout.
std::size_t size() const
Return the number of sub layouts.
Amino::String const & flattenedRepresentation() const
Get the template of the flattened string representation for the composite.
WatchpointLayoutPtr add(Amino::String const &name, WatchpointLayoutPtr const &layout)
Add a sub layout.
SubLayout const & operator*() const
Get the layout pointed by current iterator.
bool operator!=(const Iterator &other) const
Comparison.
Iterator & operator++()
Advance to the next iterator.
bool operator==(const Iterator &other) const
Comparison.
Amino::String const & getElementTypeKind() const
Get the kind name of the element layout's.
WatchpointLayoutArray(WatchpointLayoutFactory const &factory, Amino::Type const &type, Amino::Any const &value)
Internal constructor.
bool getIndices(Watchpoint::Filters const &filters, Watchpoint::Sorter const &sorter, Watchpoint::Indices &out_indices) const
Helper to return the indices of the array for given filters and sorter settings.
std::size_t size() const
Return the number of elements.
Amino::Type const & getElementType() const
Get the element type of the layout array type.
Amino::TypeId const & getElementTypeId() const
Get the element typeId of the layout array type.
static WatchpointLayoutPtr create(WatchpointLayoutFactory const &factory, Amino::Type const &type, Amino::Any const &value)
Create a new WatchpointLayoutArray for value value.
Amino::String const & getElementTypeName() const
Get the fully qualified element type name of the layout array type.
WatchpointLayoutPtr layout(std::size_t index) const
Get the layout of the element at given index.
static WatchpointLayoutPtr create(WatchpointLayoutFactory const &factory, Amino::Any const &value)
Create a new WatchpointLayoutArray for value value.
Layout factory to build layouts for types and/or values.
static WatchpointLayoutFactory & getInvalid() noexcept
Get a statically allocated factory that is uninitialized and invalid. Any operation on this instance ...
WatchpointLayoutPath & operator=(WatchpointLayoutPath const &)
Assignment operators.
void push_back(Amino::String const &element)
Append an element.
WatchpointLayoutPath & pop_front()
Remove fist element.
bool frontIsIndex() const
Check if first item of path is an array index.
std::size_t frontAsIndex() const
Get the first element of the path as an array index.
void push_back(std::size_t index)
Append an array index.
Amino::String const & back() const
Get the last element of the path.
WatchpointLayoutPath & pop_back()
Remove last element.
WatchpointLayoutPath(WatchpointLayoutPath const &)
Constructors.
Amino::String const & front() const
Get the first element of the path.
void push_front(Amino::String const &element)
Prepend an element.
WatchpointLayoutPath & operator=(WatchpointLayoutPath &&)
Constructors.
WatchpointLayoutPath(Amino::String const &path)
Constructors.
std::size_t backAsIndex() const
Get the last element of the path as an array index.
WatchpointLayoutPath(WatchpointLayoutPath &&)
Constructors.
bool backIsIndex() const
Check if last item of path is an array index.
void push_front(std::size_t index)
Prepend an array index.
The Workspace is the central element of the BifrostGraph Executor.
Definition: Workspace.h:69
BifrostGraph Executor common types.