34template<
class ObjectType>
44template<
class ObjectType>
50 return obr().cfindObject<ObjectType>(fieldName);
54template<
class ObjectType>
60 return obr().findObject<ObjectType>(fieldName);
64template<
class ObjectType>
71 return obr().getObjectPtr<ObjectType>(fieldName);
75template<
class ObjectType>
81 return obr().getObjectPtr<ObjectType>(fieldName);
85template<
class ObjectType>
91 return obr().lookupObject<ObjectType>(fieldName);
95template<
class ObjectType>
101 return obr().lookupObjectRef<ObjectType>(fieldName);
105template<
class ObjectType>
113 if (cacheable && fieldName == tfield().
name())
116 <<
"Cannot store cache-able field with the name used in the cache."
118 <<
" Either choose a different name or cache the field"
119 <<
" and use the 'writeObjects' functionObject."
125 ObjectType* fieldptr;
130 && (fieldptr = getObjectPtr<ObjectType>(fieldName)) !=
nullptr
136 if (fieldptr != &tfield())
138 (*fieldptr) = tfield;
147 if (fieldName.size() && fieldName != tfield().
name())
149 tfield.
ref().rename(fieldName);
153 fieldName = tfield().name();
163template<
class ObjectType>
166 const word& fieldName,
171 ObjectType* fieldptr;
175 && (fieldptr = obr.
getObjectPtr<ObjectType>(fieldName)) !=
nullptr
178 (*fieldptr) = tfield;
182 if (fieldName.size() && fieldName != tfield().
name())
184 tfield.
ref().rename(fieldName);
const ObjectType & lookupObject(const word &fieldName) const
Lookup and return object (eg, a field) from the (sub) objectRegistry.
const ObjectType * cfindObject(const word &fieldName) const
Return const pointer to the object (eg, a field) in the (sub) objectRegistry.
bool foundObject(const word &fieldName) const
Find object (eg, a field) in the (sub) objectRegistry.
ObjectType * getObjectPtr(const word &fieldName) const
Return non-const pointer to the object of the given Type, using a const-cast to have it behave like a...
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
bool store(word &fieldName, const tmp< ObjectType > &tfield, bool cacheable=false)
Store the field in the (sub) objectRegistry under the given name.
const ObjectType * findObject(const word &fieldName) const
Return const pointer to the object (eg, a field) in the (sub) objectRegistry.
bool storeInDb(const word &fieldName, const tmp< ObjectType > &tfield, const objectRegistry &obr)
Store the field in an optional objectRegistry under the given name.
ObjectType & lookupObjectRef(const word &fieldName) const
Lookup and return object (eg, a field) from the (sub) objectRegistry.
Registry of regIOobjects.
bool foundObject(const word &name, const bool recursive=false) const
Contains the named Type?
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...
bool store()
Register object with its registry and transfer ownership to the registry.
A class for managing temporary objects.
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
A class for handling words, derived from Foam::string.
#define WarningInFunction
Report a warning using Foam::Warning.
Ostream & endl(Ostream &os)
Add newline and flush stream.
constexpr char nl
The newline '\n' character (0x0a).