#include <GraphScope.h>
Inherits std::enable_shared_from_this< GraphScope >.
Public Member Functions | |
bool | isEmpty () const |
const GsvFlattenedSet & | allVars () const |
fdk::StringSet | varNames () const |
Get the list of all vars in this scope including the inherited ones. | |
bool | hasVar (const std::string &varname) const |
Returns true if the named var is in the scope, either locally or inherited. | |
bool | hasLocalVar (const std::string &varname) const |
Returns true if the named var is a local var in the scope. | |
std::optional< std::string > | valueOf (const std::string &varname) const |
Returns a GSV value from the named var (<setname>.<varname>). | |
std::optional< std::string > | valueOf (const std::string &set, const std::string &key) const |
const GraphScopeId & | id () const |
const fdk::Hash & | hash () const |
Returns the hash of all of its data, including parents. | |
const fdk::Hash & | localHash () const |
Returns the hash of the local vars in this scope. | |
GraphScopePtr | parent () const |
Returns the parent of the GraphScope. | |
GsvSets | localGsvSets () const |
Returns the local override GsvSets held by the GraphScope. | |
const GraphScopePtr | build (const GsvSets &gsvSets) |
const GsvFlattenedAllDataSet & | data () const |
int | evaluate (const std::string &expression, std::string &expanded) const |
GraphScopePtr | ptr () |
Returns a shared pointer to the GraphScope. | |
Friends | |
class | GraphScopeRepository |
class | GraphScopeImpl |
std::ostream & | operator<< (std::ostream &os, const GraphScope &scope) |
For debugging only, do not use for serialization. | |
A GraphScope is an immutable object that holds GsvSets. A Gsv is a Graph Scope Variable that is defined by a Node and set to a GraphScope during the Op tree generation. GSVs can be used in expressions, for example, a GSV named 'dir' used in a Read node file path like "/Volume/%dir" and can be resolved to different values depending on the GraphScope used in the context. A GraphScope can have a parent scope, which allows for the GraphScope to be extended and overriden. A GraphScope can be directly constructed via a GraphScopeRepository, or indirectly via an existing GraphScope that will call the GraphScopeRepository under the hood. The access to a GraphScope should be done via a GraphScopePtr returned either by a GraphScopeRepository::build() or GraphScope::build() function. If a GraphScopePtr is empty, the scope should be considered nonexisting.
const GsvFlattenedSet & GraphScope::allVars | ( | ) | const |
Get the flattened set of all vars with expanded names. Vars in custom GvsSets have names expanded to '<setname>.<varname>'.
std::optional< std::string > GraphScope::valueOf | ( | const std::string & | set, |
const std::string & | key | ||
) | const |
Returns a GSV value from a GsvSet in this scope. set is the name of the GsvSet to be searched for key. key is the GSV name to be searched. Returns an optional string with the GSV value, if found, or std::nullopt otherwise.
const GraphScopeId & GraphScope::id | ( | ) | const |
Returns the unique ID for this scope which will change if any of its local or inherited vars change in name or value.
const GraphScopePtr GraphScope::build | ( | const GsvSets & | gsvSets | ) |
Returns a GsvSet with the given GsvSets and parented by the callee GsvSet. data is the GsvSets to be held by the GraphScope.
References ptr().
const GsvFlattenedAllDataSet & GraphScope::data | ( | ) | const |
Returns all the GSV data used to create this scope in a flattened fashion. The key in this map is in the form <gsv-set-name>.<variable-name>. The value for each key is a vector with all the values the variable had during the scope construction. The order of the values is the reverse order of construction (most recent overrides comes first).
int GraphScope::evaluate | ( | const std::string & | expression, |
std::string & | expanded | ||
) | const |
Find and replaces Graph Scope Variables by their values on a given string. The variable begin is marked by an '' character optionally followed by '{'. A variable name is defined as an uninterrupted sequence of valid characters (i.e. the set [a-zA-Z0-9_]) until a character that is not valid is found. In the case '{' is part of the variable being marker, '}' must be the terminating character. Once a variable name is identified, the variable value is retrieved and the variable name along its preceding '', and '{}' if present, are replaced by its value.
Recursive expressions are permited and expressions with infinite recursion are ignored. For example, with two variables 'shot' and 'seq' with values 'shotValue' and 'this_is_%{shot}' respectively, the evaluated value of 'seq' would be 'this_is_shotValue'.
Some variable names are ignored so they wont clash with existing features. They are: v, V and d.
It returns flag to indicate what happened during the expansion. See eGsvUnchanged, eGsvExpanded, eGsvUndefined and eGsvInfiniteRecursion.
©2025 The Foundry Visionmongers, Ltd. All Rights Reserved. |