36template<
class MatchPredicate>
40 const MatchPredicate& matchName
50 if (matchName(obj->
name()))
62template<
class MatchPredicate1,
class MatchPredicate2>
63Foam::label Foam::objectRegistry::countImpl
66 const MatchPredicate1& matchClass,
67 const MatchPredicate2& matchName
76 if (matchClass(obj->type()) && matchName(obj->
name()))
87template<
class Type,
class MatchPredicate>
88Foam::label Foam::objectRegistry::countTypeImpl
91 const MatchPredicate& matchName
102 (std::is_void<Type>::value || Foam::isA<Type>(*obj))
103 && matchName(obj->
name())
115template<
class MatchPredicate1,
class MatchPredicate2>
119 const MatchPredicate1& matchClass,
120 const MatchPredicate2& matchName,
131 if (matchClass(obj->type()) && matchName(obj->
name()))
133 objNames[count] = obj->
name();
150template<
class Type,
class MatchPredicate>
154 const MatchPredicate& matchName,
167 (std::is_void<Type>::value || Foam::isA<Type>(*obj))
168 && matchName(obj->
name())
171 objNames[count] = obj->
name();
188template<
class Type,
class MatchPredicate>
190Foam::objectRegistry::objectsTypeImpl
193 const MatchPredicate& matchName
196 typedef typename std::remove_cv<Type>::type BaseType;
203 const BaseType* ptr = Foam::isA<BaseType>(*iter.val());
205 if (ptr && matchName(ptr->name()))
207 result.
set(count,
const_cast<BaseType*
>(ptr));
222template<
class MatchPredicate>
226 const MatchPredicate& matchName
229 return classesImpl(*
this, matchName);
233template<
class MatchPredicate>
236 const MatchPredicate& matchClass
243template<
class MatchPredicate1,
class MatchPredicate2>
246 const MatchPredicate1& matchClass,
247 const MatchPredicate2& matchName
250 return countImpl(*
this, matchClass, matchName);
254template<
class Type,
class MatchPredicate>
257 const MatchPredicate& matchName
260 return countTypeImpl<Type>(*
this, matchName);
278 std::is_void<Type>::value
282 ?
bool(Foam::isType<Type>(*obj))
283 :
bool(Foam::isA<Type>(*obj))
321template<
class Type,
class MatchPredicate>
325 const MatchPredicate& matchName
328 return objectsTypeImpl<const Type>(*
this, matchName);
332template<
class Type,
class MatchPredicate>
336 const MatchPredicate& matchName
339 return objectsTypeImpl<const Type>(*
this, matchName);
342template<
class Type,
class MatchPredicate>
346 const MatchPredicate& matchName
349 return objectsTypeImpl<Type>(*
this, matchName);
355template<
class MatchPredicate>
358 const MatchPredicate& matchClass
365template<
class MatchPredicate1,
class MatchPredicate2>
368 const MatchPredicate1& matchClass,
369 const MatchPredicate2& matchName
372 return namesImpl(*
this, matchClass, matchName,
false);
383template<
class Type,
class MatchPredicate>
386 const MatchPredicate& matchName
389 return namesTypeImpl<Type>(*
this, matchName,
false);
393template<
class MatchPredicate>
396 const MatchPredicate& matchClass
403template<
class MatchPredicate1,
class MatchPredicate2>
406 const MatchPredicate1& matchClass,
407 const MatchPredicate2& matchName
410 return namesImpl(*
this, matchClass, matchName,
true);
421template<
class Type,
class MatchPredicate>
424 const MatchPredicate& matchName
427 return namesTypeImpl<Type>(*
this, matchName,
true);
446 ?
bool(Foam::isType<Type>(*obj))
447 :
bool(Foam::isA<Type>(*obj))
450 objectsOfClass.
insert(obj->
name(),
dynamic_cast<const Type*
>(obj));
454 return objectsOfClass;
473 ?
bool(Foam::isType<Type>(*obj))
474 :
bool(Foam::isA<Type>(*obj))
477 objectsOfClass.
insert(obj->
name(),
dynamic_cast<Type*
>(obj));
481 return objectsOfClass;
492 return this->cfindObject<Type>(
name, recursive);
503 return dynamic_cast<const Type*
>(this->cfindIOobject(
name, recursive));
514 return this->cfindObject<Type>(
name, recursive);
525 return const_cast<Type*
>(this->cfindObject<Type>(
name, recursive));
536 return const_cast<Type*
>(this->cfindObject<Type>(
name, recursive));
547 const_iterator iter = cfind(
name);
551 const Type* ptr =
dynamic_cast<const Type*
>(iter());
560 <<
" bad lookup of " <<
name <<
" (objectRegistry "
562 <<
")\n expected a " << Type::typeName
563 <<
", found a " << (*iter)->type() <<
nl
566 else if (recursive && this->parentNotTime())
568 return parent_.lookupObject<Type>(
name, recursive);
573 <<
" failed lookup of " <<
name <<
" (objectRegistry "
575 <<
")\n available objects of type " << Type::typeName
577 << names<Type>() <<
nl
580 return NullObjectRef<Type>();
591 const Type&
ref = this->lookupObject<Type>(
name, recursive);
594 return const_cast<Type&
>(
ref);
A HashTable similar to std::unordered_map.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
label size() const noexcept
The number of elements in table.
IOobjectList lookupClass() const
The list of IOobjects with headerClassName == Type::typeName.
const word & name() const noexcept
Return the object name.
void resize(const label len)
Adjust allocated size of list.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
const T * set(const label i) const
void resize(const label newLen)
Change the size of the list.
Registry of regIOobjects.
UPtrList< const regIOobject > sorted() const
Return sorted list of objects.
bool foundObject(const word &name, const bool recursive=false) const
Is the named Type found?
wordList sortedNames() const
The sorted names of all objects.
HashTable< wordHashSet > classes() const
A summary hash of classes used and their associated object names.
UPtrList< const regIOobject > csorted() const
Return sorted list of objects.
const Type * cfindObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
Type & lookupObjectRef(const word &name, const bool recursive=false) const
wordList names() const
The unsorted names of all objects.
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
const Type & lookupObject(const word &name, const bool recursive=false) const
Type * getObjectPtr(const word &name, const bool recursive=false) const
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 FatalErrorInFunction
Report an error message using Foam::FatalError.
void sort(UList< T > &list)
Sort the list.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
#define forAllIters(container, iter)
Iterate across all elements in the container object.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Extract name (as a word) from an object, typically using its name() method.
Unary and binary predicates that always return true, useful for templating.