47Foam::expressions::exprResultGlobals::exprResultGlobals
72 readStream(exprResultGlobals::typeName,
true)
82 for (
auto iter = tbl.cbegin(); iter != tbl.cend(); ++iter)
84 this->set(iter.key(), (*iter)->clone());
103void Foam::expressions::exprResultGlobals::reset()
192 return variables_[
name];
203 for (
const word& scopeName : scopes)
205 const auto tableIter = variables_.cfind(scopeName);
207 if (tableIter.good())
209 const auto resultIter = (*tableIter).cfind(
name);
211 if (resultIter.good())
213 return *(*resultIter);
220 <<
"No scope " << scopeName <<
" for " <<
name <<
nl
221 <<
"Known global scopes: " << variables_.sortedToc() <<
nl;
235 const exprResult& value,
239 Table& tbl = getOrCreateScope(scope);
241 auto iter = tbl.find(
name);
245 tbl.set(
name,
new exprResult(value));
246 iter = tbl.find(
name);
266 Table& tbl = getOrCreateScope(scope);
268 if (overwrite || !tbl.found(
name))
270 tbl.set(
name, std::move(value));
285 word scopeName(scope);
289 if (scopeName.empty())
291 scopeName =
dict.get<
word>(
"globalScope");
294 if (
dict.found(
"resultType"))
323 auto iter = variables_.find(scope);
325 return (iter.good() && iter.val().erase(
name));
A HashTable of pointers to objects of type <T>, with deallocation management of the pointers.
constexpr HashPtrTable() noexcept=default
bool set(const Key &key, T *ptr)
Assign a new entry, overwrites existing.
const_iterator cbegin() const
const_iterator set to the beginning of the HashTable
bool found(const Key &key) const
Same as contains().
label capacity() const noexcept
The size of the underlying table (the number of buckets).
iterator find(const Key &key)
Find and return an iterator set at the hashed entry.
constexpr const_iterator cend() const noexcept
const_iterator to signal the end (for any HashTable)
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & name() const noexcept
Return the object name.
streamFormat format() const noexcept
Get the current stream format.
@ ASCII
"ascii" (normal default)
bool bad() const noexcept
True if stream is corrupted.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
label timeIndex() const noexcept
Return the current time index.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Table()=default
Default construct.
A globally available registry of expression results. These are currently registered on Time (may chan...
const exprResult & get(const word &name, const wordUList &scopes) const
Return a global variable, if it exists, or a exprResult::null.
virtual bool writeData(Ostream &os) const
Write variables.
static exprResultGlobals & New(const objectRegistry &obr)
Static constructor for singleton.
exprResult & addValue(const word &name, const word &scope, const exprResult &value, const bool overwrite=true)
Add named result to specified scope.
virtual bool readData(Istream &os)
Read variables.
Table & getNamespace(const word &name)
Get an existing table for the namespace.
static bool Delete(const objectRegistry &obr)
Static destructor for singleton.
bool removeValue(const word &name, const word &scope)
Remove named result from specified scope.
A polymorphic field/result from evaluating an expression.
static const exprResult null
An empty result.
static autoPtr< exprResult > New(const dictionary &dict)
Return a reference to the selected value driver.
bool reset(bool force=false)
Reset at new timestep according to type.
Registry of regIOobjects.
const Time & time() const noexcept
Return time registry.
bool checkOut(regIOobject *io) const
Remove a regIOobject from registry and free memory if the object is ownedByRegistry....
Type * getObjectPtr(const word &name, const bool recursive=false) const
Return non-const pointer to the object of the given Type, using a const-cast to have it behave like a...
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
A class for handling words, derived from Foam::string.
#define defineTypeName(Type)
Define the typeName.
OBJstream os(runTime.globalPath()/outputName)
#define WarningInFunction
Report a warning using Foam::Warning.
A namespace for expression-related classes/traits etc.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
UList< word > wordUList
UList of word.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
constexpr char nl
The newline '\n' character (0x0a).
#define forAllIters(container, iter)
Iterate across all elements in the container object.