mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
objectRegistry - gets sortedNames() methods
- reduce duplicate code by using some HashTable methods directly
This commit is contained in:
@ -93,7 +93,7 @@ Foam::objectRegistry::~objectRegistry()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (label i=0; i<nMyObjects; i++)
|
for (label i=0; i < nMyObjects; i++)
|
||||||
{
|
{
|
||||||
checkOut(*myObjects[i]);
|
checkOut(*myObjects[i]);
|
||||||
}
|
}
|
||||||
@ -104,15 +104,13 @@ Foam::objectRegistry::~objectRegistry()
|
|||||||
|
|
||||||
Foam::wordList Foam::objectRegistry::names() const
|
Foam::wordList Foam::objectRegistry::names() const
|
||||||
{
|
{
|
||||||
wordList objectNames(size());
|
return HashTable<regIOobject*>::toc();
|
||||||
|
}
|
||||||
|
|
||||||
label count=0;
|
|
||||||
for (const_iterator iter = cbegin(); iter != cend(); ++iter)
|
|
||||||
{
|
|
||||||
objectNames[count++] = iter()->name();
|
|
||||||
}
|
|
||||||
|
|
||||||
return objectNames;
|
Foam::wordList Foam::objectRegistry::sortedNames() const
|
||||||
|
{
|
||||||
|
return HashTable<regIOobject*>::sortedToc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -125,7 +123,7 @@ Foam::wordList Foam::objectRegistry::names(const word& ClassName) const
|
|||||||
{
|
{
|
||||||
if (iter()->type() == ClassName)
|
if (iter()->type() == ClassName)
|
||||||
{
|
{
|
||||||
objectNames[count++] = iter()->name();
|
objectNames[count++] = iter.key();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,6 +133,15 @@ Foam::wordList Foam::objectRegistry::names(const word& ClassName) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::wordList Foam::objectRegistry::sortedNames(const word& ClassName) const
|
||||||
|
{
|
||||||
|
wordList sortedLst = names(ClassName);
|
||||||
|
sort(sortedLst);
|
||||||
|
|
||||||
|
return sortedLst;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const Foam::objectRegistry& Foam::objectRegistry::subRegistry
|
const Foam::objectRegistry& Foam::objectRegistry::subRegistry
|
||||||
(
|
(
|
||||||
const word& name
|
const word& name
|
||||||
@ -151,8 +158,8 @@ Foam::label Foam::objectRegistry::getEvent() const
|
|||||||
if (event_ == labelMax)
|
if (event_ == labelMax)
|
||||||
{
|
{
|
||||||
WarningIn("objectRegistry::getEvent() const")
|
WarningIn("objectRegistry::getEvent() const")
|
||||||
<< "Event counter has overflowed. Resetting counter on all"
|
<< "Event counter has overflowed. "
|
||||||
<< " dependent objects." << endl
|
<< "Resetting counter on all dependent objects." << nl
|
||||||
<< "This might cause extra evaluations." << endl;
|
<< "This might cause extra evaluations." << endl;
|
||||||
|
|
||||||
// Reset event counter
|
// Reset event counter
|
||||||
@ -202,7 +209,7 @@ bool Foam::objectRegistry::checkOut(regIOobject& io) const
|
|||||||
if (objectRegistry::debug)
|
if (objectRegistry::debug)
|
||||||
{
|
{
|
||||||
Pout<< "objectRegistry::checkOut(regIOobject&) : "
|
Pout<< "objectRegistry::checkOut(regIOobject&) : "
|
||||||
<< name() << " : checking out " << io.name()
|
<< name() << " : checking out " << iter.key()
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +218,8 @@ bool Foam::objectRegistry::checkOut(regIOobject& io) const
|
|||||||
if (objectRegistry::debug)
|
if (objectRegistry::debug)
|
||||||
{
|
{
|
||||||
WarningIn("objectRegistry::checkOut(regIOobject&)")
|
WarningIn("objectRegistry::checkOut(regIOobject&)")
|
||||||
<< name() << " : attempt to checkOut copy of " << io.name()
|
<< name() << " : attempt to checkOut copy of "
|
||||||
|
<< iter.key()
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,8 +294,7 @@ void Foam::objectRegistry::readModifiedObjects()
|
|||||||
{
|
{
|
||||||
Pout<< "objectRegistry::readModifiedObjects() : "
|
Pout<< "objectRegistry::readModifiedObjects() : "
|
||||||
<< name() << " : Considering reading object "
|
<< name() << " : Considering reading object "
|
||||||
<< iter()->name()
|
<< iter.key() << endl;
|
||||||
<< endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
iter()->readIfModified();
|
iter()->readIfModified();
|
||||||
@ -317,7 +324,7 @@ bool Foam::objectRegistry::writeObject
|
|||||||
{
|
{
|
||||||
Pout<< "objectRegistry::write() : "
|
Pout<< "objectRegistry::write() : "
|
||||||
<< name() << " : Considering writing object "
|
<< name() << " : Considering writing object "
|
||||||
<< iter()->name()
|
<< iter.key()
|
||||||
<< " with writeOpt " << iter()->writeOpt()
|
<< " with writeOpt " << iter()->writeOpt()
|
||||||
<< " to file " << iter()->objectPath()
|
<< " to file " << iter()->objectPath()
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|||||||
@ -132,9 +132,15 @@ public:
|
|||||||
//- Return the list of names of the IOobjects
|
//- Return the list of names of the IOobjects
|
||||||
wordList names() const;
|
wordList names() const;
|
||||||
|
|
||||||
//- Return the list of names of the IOobjects of given class name
|
//- Return the sorted list of names of the IOobjects
|
||||||
|
wordList sortedNames() const;
|
||||||
|
|
||||||
|
//- Return the list of names of IOobjects of given class name
|
||||||
wordList names(const word& className) const;
|
wordList names(const word& className) const;
|
||||||
|
|
||||||
|
//- Return the sorted list of names of IOobjects of given class name
|
||||||
|
wordList sortedNames(const word& className) const;
|
||||||
|
|
||||||
//- Return the list of names of the IOobjects of given type
|
//- Return the list of names of the IOobjects of given type
|
||||||
template<class Type>
|
template<class Type>
|
||||||
wordList names() const;
|
wordList names() const;
|
||||||
@ -142,11 +148,11 @@ public:
|
|||||||
//- Lookup and return a const sub-objectRegistry
|
//- Lookup and return a const sub-objectRegistry
|
||||||
const objectRegistry& subRegistry(const word& name) const;
|
const objectRegistry& subRegistry(const word& name) const;
|
||||||
|
|
||||||
//- Lookup and return all the object of the given Type
|
//- Lookup and return all objects of the given Type
|
||||||
template<class Type>
|
template<class Type>
|
||||||
HashTable<const Type*> lookupClass() const;
|
HashTable<const Type*> lookupClass() const;
|
||||||
|
|
||||||
//- Is the named Type
|
//- Is the named Type found?
|
||||||
template<class Type>
|
template<class Type>
|
||||||
bool foundObject(const word& name) const;
|
bool foundObject(const word& name) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user