31 #include <type_traits>
36 template<
class MatchPredicate>
40 const MatchPredicate& matchName
50 if (matchName(obj->
name()))
62 template<
class MatchPredicate1,
class MatchPredicate2>
63 Foam::label Foam::objectRegistry::countImpl
66 const MatchPredicate1& matchClass,
67 const MatchPredicate2& matchName
76 if (matchClass(obj->type()) && matchName(obj->
name()))
87 template<
class Type,
class MatchPredicate>
88 Foam::label Foam::objectRegistry::countTypeImpl
91 const MatchPredicate& matchName
102 (std::is_void<Type>::value || isA<Type>(*obj))
103 && matchName(obj->
name())
115 template<
class MatchPredicate1,
class MatchPredicate2>
119 const MatchPredicate1& matchClass,
120 const MatchPredicate2& matchName,
131 if (matchClass(obj->type()) && matchName(obj->
name()))
138 objNames.resize(
count);
150 template<
class Type,
class MatchPredicate>
154 const MatchPredicate& matchName,
167 (std::is_void<Type>::value || isA<Type>(*obj))
168 && matchName(obj->
name())
176 objNames.resize(
count);
189 template<
class MatchPredicate>
193 const MatchPredicate& matchName
196 return classesImpl(*
this, matchName);
200 template<
class MatchPredicate>
203 const MatchPredicate& matchClass
210 template<
class MatchPredicate1,
class MatchPredicate2>
213 const MatchPredicate1& matchClass,
214 const MatchPredicate2& matchName
217 return countImpl(*
this, matchClass, matchName);
221 template<
class Type,
class MatchPredicate>
224 const MatchPredicate& matchName
227 return countTypeImpl<Type>(*
this, matchName);
245 std::is_void<Type>::value
246 || (strict ? isType<Type>(*obj) :
bool(isA<Type>(*obj)))
257 template<
class MatchPredicate>
260 const MatchPredicate& matchClass
267 template<
class MatchPredicate1,
class MatchPredicate2>
270 const MatchPredicate1& matchClass,
271 const MatchPredicate2& matchName
274 return namesImpl(*
this, matchClass, matchName,
false);
285 template<
class Type,
class MatchPredicate>
288 const MatchPredicate& matchName
291 return namesTypeImpl<Type>(*
this, matchName,
false);
295 template<
class MatchPredicate>
298 const MatchPredicate& matchClass
305 template<
class MatchPredicate1,
class MatchPredicate2>
308 const MatchPredicate1& matchClass,
309 const MatchPredicate2& matchName
312 return namesImpl(*
this, matchClass, matchName,
true);
323 template<
class Type,
class MatchPredicate>
326 const MatchPredicate& matchName
329 return namesTypeImpl<Type>(*
this, matchName,
true);
345 if (strict ? isType<Type>(*obj) :
bool(isA<Type>(*obj)))
347 objectsOfClass.
insert(obj->
name(),
dynamic_cast<const Type*
>(obj));
351 return objectsOfClass;
367 if (strict ? isType<Type>(*obj) :
bool(isA<Type>(*obj)))
369 objectsOfClass.
insert(obj->
name(),
dynamic_cast<Type*
>(obj));
373 return objectsOfClass;
384 return this->cfindObject<Type>(
name, recursive);
395 return dynamic_cast<const Type*
>(this->cfindIOobject(
name, recursive));
406 return this->cfindObject<Type>(
name, recursive);
417 return const_cast<Type*
>(this->cfindObject<Type>(
name, recursive));
428 return const_cast<Type*
>(this->cfindObject<Type>(
name, recursive));
439 const_iterator iter = cfind(
name);
443 const Type* ptr =
dynamic_cast<const Type*
>(iter());
452 <<
" lookup of " <<
name <<
" from objectRegistry "
454 <<
" successful\n but it is not a " << Type::typeName
455 <<
", it is a " << (*iter)->type()
458 else if (recursive && this->parentNotTime())
460 return parent_.lookupObject<Type>(
name, recursive);
465 <<
" request for " << Type::typeName
466 <<
" " <<
name <<
" from objectRegistry " << this->
name()
467 <<
" failed\n available objects of type " << Type::typeName
472 return NullObjectRef<Type>();
483 const Type&
ref = this->lookupObject<Type>(
name, recursive);
486 return const_cast<Type&
>(
ref);