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

IOobjectList - gets sortedNames() method

- could also be the default

- reduce duplicate code by using some HashTable methods directly
parent 4d10d061
......@@ -58,7 +58,7 @@ Foam::IOobjectList::IOobjectList
}
}
// Create list file names in directory
// Create a list of file names in this directory
fileNameList ObjectNames =
readDir(db.path(newInstance, db.dbDir()/local), fileName::FILE);
......@@ -130,8 +130,8 @@ Foam::IOobject* Foam::IOobjectList::lookup(const word& name) const
{
if (IOobject::debug)
{
Info<< "IOobjectList::lookup : found " << name
<< endl;
Info<< "IOobjectList::lookup : found "
<< name << endl;
}
return const_cast<IOobject*>(*iter);
......@@ -140,8 +140,8 @@ Foam::IOobject* Foam::IOobjectList::lookup(const word& name) const
{
if (IOobject::debug)
{
Info<< "IOobjectList::lookup : could not find " << name
<< endl;
Info<< "IOobjectList::lookup : could not find "
<< name << endl;
}
return NULL;
......@@ -151,7 +151,7 @@ Foam::IOobject* Foam::IOobjectList::lookup(const word& name) const
Foam::IOobjectList Foam::IOobjectList::lookupClass(const word& ClassName) const
{
IOobjectList IOobjectsOfClass(size());
IOobjectList objectsOfClass(size());
for
(
......@@ -165,34 +165,26 @@ Foam::IOobjectList Foam::IOobjectList::lookupClass(const word& ClassName) const
if (IOobject::debug)
{
Info<< "IOobjectList::lookupClass : found "
<< iter()->name()
<< endl;
<< iter.key() << endl;
}
IOobjectsOfClass.insert(iter()->name(), new IOobject(*iter()));
objectsOfClass.insert(iter.key(), new IOobject(*iter()));
}
}
return IOobjectsOfClass;
return objectsOfClass;
}
Foam::wordList Foam::IOobjectList::names() const
{
wordList objectNames(size());
return HashPtrTable<IOobject>::toc();
}
label count = 0;
for
(
HashPtrTable<IOobject>::const_iterator iter = begin();
iter != end();
++iter
)
{
objectNames[count++] = iter()->name();
}
return objectNames;
Foam::wordList Foam::IOobjectList::sortedNames() const
{
return HashPtrTable<IOobject>::sortedToc();
}
......@@ -210,7 +202,7 @@ Foam::wordList Foam::IOobjectList::names(const word& ClassName) const
{
if (iter()->headerClassName() == ClassName)
{
objectNames[count++] = iter()->name();
objectNames[count++] = iter.key();
}
}
......@@ -220,4 +212,13 @@ Foam::wordList Foam::IOobjectList::names(const word& ClassName) const
}
Foam::wordList Foam::IOobjectList::sortedNames(const word& ClassName) const
{
wordList sortedLst = names(ClassName);
sort(sortedLst);
return sortedLst;
}
// ************************************************************************* //
......@@ -84,23 +84,29 @@ public:
// Member functions
//- Add an IOobject to list
//- Add an IOobject to the list
bool add(IOobject&);
//- Remove an IOobject from list
//- Remove an IOobject from the list
bool remove(IOobject&);
//- Lookup a given name and return IOobject ptr if found else NULL
IOobject* lookup(const word& name) const;
//- Return the list for all IOobjects of given class
//- Return the list for all IOobjects of a given class
IOobjectList lookupClass(const word& className) const;
//- Return the list of names of the IOobjects
wordList names() const;
//- Return the sorted list of names of the IOobjects
wordList sortedNames() const;
//- Return the list of names of the IOobjects of given class
wordList names(const word& className) const;
//- Return the sorted list of names of the IOobjects of given class
wordList sortedNames(const word& className) const;
};
......
Supports Markdown
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