Commit d80ce7fc authored by Mark Olesen's avatar Mark Olesen
Browse files

objectRegistry - gets sortedNames() methods

- reduce duplicate code by using some HashTable methods directly
parent a0b3d145
......@@ -93,7 +93,7 @@ Foam::objectRegistry::~objectRegistry()
}
}
for (label i=0; i<nMyObjects; i++)
for (label i=0; i < nMyObjects; i++)
{
checkOut(*myObjects[i]);
}
......@@ -104,15 +104,13 @@ Foam::objectRegistry::~objectRegistry()
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)
{
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 word& name
......@@ -151,8 +158,8 @@ Foam::label Foam::objectRegistry::getEvent() const
if (event_ == labelMax)
{
WarningIn("objectRegistry::getEvent() const")
<< "Event counter has overflowed. Resetting counter on all"
<< " dependent objects." << endl
<< "Event counter has overflowed. "
<< "Resetting counter on all dependent objects." << nl
<< "This might cause extra evaluations." << endl;
// Reset event counter
......@@ -202,7 +209,7 @@ bool Foam::objectRegistry::checkOut(regIOobject& io) const
if (objectRegistry::debug)
{
Pout<< "objectRegistry::checkOut(regIOobject&) : "
<< name() << " : checking out " << io.name()
<< name() << " : checking out " << iter.key()
<< endl;
}
......@@ -211,7 +218,8 @@ bool Foam::objectRegistry::checkOut(regIOobject& io) const
if (objectRegistry::debug)
{
WarningIn("objectRegistry::checkOut(regIOobject&)")
<< name() << " : attempt to checkOut copy of " << io.name()
<< name() << " : attempt to checkOut copy of "
<< iter.key()
<< endl;
}
......@@ -286,8 +294,7 @@ void Foam::objectRegistry::readModifiedObjects()
{
Pout<< "objectRegistry::readModifiedObjects() : "
<< name() << " : Considering reading object "
<< iter()->name()
<< endl;
<< iter.key() << endl;
}
iter()->readIfModified();
......@@ -317,7 +324,7 @@ bool Foam::objectRegistry::writeObject
{
Pout<< "objectRegistry::write() : "
<< name() << " : Considering writing object "
<< iter()->name()
<< iter.key()
<< " with writeOpt " << iter()->writeOpt()
<< " to file " << iter()->objectPath()
<< endl;
......
......@@ -132,9 +132,15 @@ public:
//- Return the list of names of the IOobjects
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;
//- 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
template<class Type>
wordList names() const;
......@@ -142,11 +148,11 @@ public:
//- Lookup and return a const sub-objectRegistry
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>
HashTable<const Type*> lookupClass() const;
//- Is the named Type
//- Is the named Type found?
template<class Type>
bool foundObject(const word& name) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment