#include <nodetemplate.h>
The TemplateArguments class implements a dictionary which stores template arguments for instantiations of NodeTemplates. It implements a two-level dictionary:
Template arguments are usually identified by their relative port path within the node template and the kind of template argument. For a given port there may be several arguments if the port represents several template parameters (for example a TypeTemplateParameter as well as a TemplateParameter).
Public Types | |
enum class | KIND : UChar { NONE , DEDUCED , EXPLICIT , VALUE , TYPE , BUNDLE , VALUEMODE , MASK } |
using | KeyType = Tuple< NodePath, KIND > |
Public Member Functions | |
enum maxon::nodes::TemplateArguments::KIND UChar | MAXON_ENUM_FLAGS_CLASS (KIND) |
TemplateArguments ()=default | |
TemplateArguments (const DataDictionary &defaultArgs) | |
void | Reset () |
template<typename T > | |
Result< void > | SetDefault (const NodePath &path, KIND kind, T &&value) |
template<typename T > | |
Result< void > | SetExplicit (const NodePath &path, KIND kind, T &&value) |
template<typename T > | |
Result< void > | SetDefaultRemoveDeduced (const NodePath &path, KIND kind, T &&value) |
template<typename T > | |
Result< void > | SetNoKindArgument (const InternedId &id, T &&value) |
Result< void > | Remove (const NodePath &path, KIND kind) |
Result< void > | Add (const TemplateArguments &args) |
Opt< const Data & > | Get (const NodePath &path, KIND kind) const |
template<typename T > | |
Opt< const T & > | Get (const NodePath &path, KIND kind) const |
template<typename T > | |
Opt< const T & > | GetValueArgument (const NodePath &path) const |
Opt< const Array< InternedId > & > | GetBundleArgument (const NodePath &path) const |
Opt< const DataType & > | GetTypeArgument (const NodePath &path) const |
Opt< const VALUEMODE & > | GetValueModeArgument (const NodePath &path) const |
Bool | HasDefault (const NodePath &path, KIND kind) const |
Bool | HasDeduced (const NodePath &path, KIND kind) const |
Bool | HasExplicit (const NodePath &path, KIND kind) const |
Bool | Contains (const NodePath &path, KIND kind) const |
template<typename OP > | |
Result< Bool > | GetPathArguments (OP &&receiver) const |
const DataDictionary & | GetArgs () const |
DataDictionary & | GetArgs () |
Bool | IsEmpty () const |
Bool | IsPopulated () const |
MAXON_OPERATOR_STRUCT (TemplateArguments, _args) | |
Static Public Member Functions | |
template<typename... ARGS> | |
static Result< TemplateArguments > | Create (ARGS &&... args) |
Private Member Functions | |
const Data * | GetImpl (const NodePath &path, KIND kind) const |
template<typename PATH , typename T , typename... REST> | |
Result< void > | CreateImpl (const PATH &path, T &&value, REST &&... rest) |
template<typename T > | |
Result< void > | SetImpl (const NodePath &path, T &&value) |
template<typename T > | |
Result< void > | SetImpl (const Char *path, T &&value) |
Static Private Member Functions | |
static Result< void > | CreateImpl () |
static KIND | GetKindFor (const void *, OverloadRank0) |
static KIND | GetKindFor (const DataType *, OverloadRank1) |
static KIND | GetKindFor (const Array< InternedId > *, OverloadRank1) |
Private Attributes | |
DataDictionary | _args |
This enum lists the different kinds of template arguments. Exactly one of VALUE, TYPE, BUNDLE has to be set.
|
default |
{NodePath to port with template argument, argument kind}.
Constructs a @CLASS object with default values.
|
explicit |
Constructs a TemplateArguments object with the given default arguments.
[in] | defaultArgs | The default arguments. |
enum maxon::nodes::TemplateArguments::KIND UChar MAXON_ENUM_FLAGS_CLASS | ( | KIND | ) |
void Reset | ( | ) |
Resets this @CLASS to the state it has right after default construction. This includes freeing all resources held by this @CLASS.
Sets the default value for the template parameter path to value. Deduced or explicit values aren't removed.
[in] | path | The path of the template parameter. |
[in] | kind | The kind of the template parameter. |
[in] | value | The default value for the template parameter. |
Sets the explicit value for the template parameter path to value.
[in] | path | The path of the template parameter. |
[in] | kind | The kind of the template parameter. |
[in] | value | The explicit value for the template parameter. |
Sets the default value for the template parameter path to value, and removes a deduced value if there is one.
[in] | path | The path of the template parameter. |
[in] | kind | The kind of the template parameter. |
[in] | value | The default value for the template parameter. |
Result<void> SetNoKindArgument | ( | const InternedId & | id, |
T && | value | ||
) |
Sets a template parameter with no KIND value. This can be useful when passing TemplateArguments to lower level node implementation.
[in] | id | The identifier of the template parameter (use as key to read this parameter). |
[in] | value | The value for the template parameter. |
Removes any value (default or overridden) for the template parameter path. If there is no such value, nothing happens. kind should not contain any of KIND::MASK or it will not be able to remove all arguments of the given kind (KIND::VALUE, KIND::TYPE or KIND::BUNDLE).
[in] | path | The path of the template parameter. |
[in] | kind | The kind of the template parameter. |
Result<void> Add | ( | const TemplateArguments & | args | ) |
Adds all entries of args on top of this object. So if both TemplateArguments have entries for the same template parameter, the value stored in this object will be overwritten with that of args.
[in] | args | Another TemplateArguments object to add to this object. |
Returns the value for the template parameter identified by the given path.
[in] | path | The path of the template parameter. |
[in] | kind | The kind of the template parameter. |
Returns the value for the template parameter identified by the given path.
[in] | path | The path of the template parameter. |
[in] | kind | The kind of the template parameter. |
Opt<const T&> GetValueArgument | ( | const NodePath & | path | ) | const |
Returns the value for the value template parameter identified by the given path.
[in] | path | The path of the template parameter. |
Opt<const Array<InternedId>&> GetBundleArgument | ( | const NodePath & | path | ) | const |
Returns the value for the bundle template parameter identified by the given path.
[in] | path | The path of the template parameter. |
Returns the value for the type template parameter identified by the given path.
[in] | path | The path of the template parameter. |
Returns the value for the value mode template parameter identified by the given path.
[in] | path | The path of the template parameter. |
Checks if the template parameter identified by path has a default value.
[in] | path | The path of the template parameter. |
[in] | kind | The kind of the template parameter. |
Checks if the template parameter identified by path has a deduced value.
[in] | path | The path of the template parameter. |
[in] | kind | The kind of the template parameter. |
Checks if the template parameter identified by path has an explicit value.
[in] | path | The path of the template parameter. |
[in] | kind | The kind of the template parameter. |
Checks if there is a value for the template parameter identified by path.
[in] | path | The path of the template parameter. |
[in] | kind | The kind of the template parameter. |
Yields all arguments for NodePath-identified parameters to receiver. receiver has to accept (const NodePath&, TemplateArguments::KIND, const Data&) as arguments and return a Result<Bool>, where false as result value stops yielding of further arguments. For parameters which have both a default and a deduced/explicit value only the deduced/explicit value is reported.
[in] | receiver | A callback which receives the arguments. |
const DataDictionary& GetArgs | ( | ) | const |
Returns the underlying DataDictionary used by this TemplateArguments object. The dictionary stores default values as well as overridden values. The keys are usually of type Tuple<NodePath, KIND>, but there may be additional arguments which aren't related to node ports.
DataDictionary& GetArgs | ( | ) |
Returns the underlying DataDictionary used by this TemplateArguments object. The dictionary stores default values as well as overridden values. The keys are usually of type Tuple<NodePath, KIND>, but there may be additional arguments which aren't related to node ports.
|
static |
Bool IsEmpty | ( | ) | const |
Bool IsPopulated | ( | ) | const |
|
staticprivate |
|
private |
|
staticprivate |
|
staticprivate |
|
staticprivate |
MAXON_OPERATOR_STRUCT | ( | TemplateArguments | , |
_args | |||
) |
|
private |