Commit 7544164d authored by Mark Olesen's avatar Mark Olesen
Browse files

regIOobject, Hasher, IOobject tweak

- regIOobject: don't re-register an unregister object on rename/assignment
- Hasher: split-off HasherInt with uint32_t specializations
- IOobject: writeBanner/writeDivider return Stream for easier chaining.

... also dropped some namespace bracketing while I was at it.
parent 0cfce1a7
......@@ -54,8 +54,7 @@ int main(int argc, char *argv[])
const word listType(is);
Info<< endl;
IOobject::writeDivider(Info);
Info<< listType << endl;
IOobject::writeDivider(Info) << listType << endl;
if (listType == "stringList")
{
......
......@@ -43,8 +43,7 @@ int main(int argc, char *argv[])
List<Tuple2<string, string> > rawList(IFstream("testRegexps")());
Info<< "input list:" << rawList << endl;
IOobject::writeDivider(Info);
Info<< endl;
IOobject::writeDivider(Info) << endl;
List<string> groups;
......
......@@ -86,8 +86,7 @@ int main(int argc, char *argv[])
List<Tuple2<wordRe, string> > rawList(IFstream("testRegexps")());
Info<< "input list:" << rawList << endl;
IOobject::writeDivider(Info);
Info<< endl;
IOobject::writeDivider(Info) << endl;
forAll(rawList, elemI)
{
......
......@@ -26,15 +26,10 @@ License
#include "Callback.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CallbackType>
Callback<CallbackType>::Callback(CallbackRegistry<CallbackType>& cbr)
Foam::Callback<CallbackType>::Callback(CallbackRegistry<CallbackType>& cbr)
:
cbr_(cbr)
{
......@@ -43,7 +38,7 @@ Callback<CallbackType>::Callback(CallbackRegistry<CallbackType>& cbr)
template<class CallbackType>
Callback<CallbackType>::Callback(const Callback<CallbackType>& cb)
Foam::Callback<CallbackType>::Callback(const Callback<CallbackType>& cb)
:
cbr_(cb.cbr_)
{
......@@ -54,7 +49,7 @@ Callback<CallbackType>::Callback(const Callback<CallbackType>& cb)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CallbackType>
Callback<CallbackType>::~Callback()
Foam::Callback<CallbackType>::~Callback()
{
checkOut();
}
......@@ -63,7 +58,7 @@ Callback<CallbackType>::~Callback()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CallbackType>
bool Callback<CallbackType>::checkIn()
bool Foam::Callback<CallbackType>::checkIn()
{
if (!Callback<CallbackType>::link::registered())
{
......@@ -78,7 +73,7 @@ bool Callback<CallbackType>::checkIn()
template<class CallbackType>
bool Callback<CallbackType>::checkOut()
bool Foam::Callback<CallbackType>::checkOut()
{
if (Callback<CallbackType>::link::registered())
{
......@@ -100,8 +95,4 @@ bool Callback<CallbackType>::checkOut()
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
......@@ -30,10 +30,7 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(IOobject, 0);
}
defineTypeNameAndDebug(Foam::IOobject, 0);
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
......
......@@ -353,11 +353,11 @@ public:
//- Write the standard OpenFOAM file/dictionary banner
// Optionally without -*- C++ -*- editor hint (eg, for logs)
template<class Stream>
static inline void writeBanner(Stream& os, bool noHint=false);
static inline Stream& writeBanner(Stream& os, bool noHint=false);
//- Write the standard file section divider
template<class Stream>
static inline void writeDivider(Stream& os);
static inline Stream& writeDivider(Stream& os);
//- Write header
bool writeHeader(Ostream&) const;
......
......@@ -29,7 +29,7 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Stream>
inline void Foam::IOobject::writeBanner(Stream& os, bool noHint)
inline Stream& Foam::IOobject::writeBanner(Stream& os, bool noHint)
{
static bool spacesSet(false);
static char spaces[40];
......@@ -68,14 +68,18 @@ inline void Foam::IOobject::writeBanner(Stream& os, bool noHint)
"| \\\\ / A nd | Web: www.OpenFOAM.org |\n"
"| \\\\/ M anipulation | |\n"
"\\*---------------------------------------------------------------------------*/\n";
return os;
}
template<class Stream>
inline void Foam::IOobject::writeDivider(Stream& os)
inline Stream& Foam::IOobject::writeDivider(Stream& os)
{
os <<
"// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //\n";
return os;
}
......
......@@ -43,8 +43,8 @@ bool Foam::IOobject::writeHeader(Ostream& os) const
return false;
}
writeBanner(os);
os << "FoamFile\n{\n"
writeBanner(os)
<< "FoamFile\n{\n"
<< " version " << os.version() << ";\n"
<< " format " << os.format() << ";\n"
<< " class " << type() << ";\n";
......@@ -58,8 +58,7 @@ bool Foam::IOobject::writeHeader(Ostream& os) const
<< " object " << name() << ";\n"
<< "}" << nl;
writeDivider(os);
os << endl;
writeDivider(os) << endl;
return true;
}
......
......@@ -35,10 +35,8 @@ Description
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(IOdictionary, 0);
}
defineTypeNameAndDebug(Foam::IOdictionary, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......
......@@ -30,10 +30,8 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(IFstream, 0);
}
defineTypeNameAndDebug(Foam::IFstream, 0);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -30,10 +30,7 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(OFstream, 0);
}
defineTypeNameAndDebug(Foam::OFstream, 0);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -28,17 +28,11 @@ Description
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "token.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
bool checkStream(istream& is, const string& fnName)
bool Foam::checkStream(istream& is, const string& fnName)
{
if (!is.good())
{
......@@ -50,7 +44,7 @@ bool checkStream(istream& is, const string& fnName)
}
bool checkStream(ostream& os, const string& fnName)
bool Foam::checkStream(ostream& os, const string& fnName)
{
if (!os.good())
{
......@@ -62,8 +56,4 @@ bool checkStream(ostream& os, const string& fnName)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
......@@ -29,19 +29,13 @@ Description
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "token.H"
#include "int.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Print state of ostream.
void state(ostream& to, const string& s)
void Foam::state(ostream& to, const string& s)
{
state_value osState = state_value(to.rdstate());
......@@ -82,7 +76,7 @@ void state(ostream& to, const string& s)
// Print state of istream.
void state(istream& from, const string& s)
void Foam::state(istream& from, const string& s)
{
state_value isState = state_value(from.rdstate());
......@@ -126,8 +120,4 @@ void state(istream& from, const string& s)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
......@@ -26,15 +26,12 @@ License
#include "objectRegistry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
wordList objectRegistry::names() const
Foam::wordList
Foam::objectRegistry::names() const
{
wordList objectNames(size());
......@@ -54,7 +51,8 @@ wordList objectRegistry::names() const
template<class Type>
HashTable<const Type*> objectRegistry::lookupClass() const
Foam::HashTable<const Type*>
Foam::objectRegistry::lookupClass() const
{
HashTable<const Type*> objectsOfClass(size());
......@@ -75,7 +73,7 @@ HashTable<const Type*> objectRegistry::lookupClass() const
template<class Type>
bool objectRegistry::foundObject(const word& name) const
bool Foam::objectRegistry::foundObject(const word& name) const
{
const_iterator iter = find(name);
......@@ -107,7 +105,7 @@ bool objectRegistry::foundObject(const word& name) const
template<class Type>
const Type& objectRegistry::lookupObject(const word& name) const
const Type& Foam::objectRegistry::lookupObject(const word& name) const
{
const_iterator iter = find(name);
......@@ -154,8 +152,4 @@ const Type& objectRegistry::lookupObject(const word& name) const
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
......@@ -22,9 +22,6 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Constructors & destructor for regIOobject.
\*---------------------------------------------------------------------------*/
#include "regIOobject.H"
......@@ -159,16 +156,16 @@ bool Foam::regIOobject::checkOut()
// Rename object and re-register with objectRegistry under new name
void Foam::regIOobject::rename(const word& newName)
{
// TODO: verify that this works properly with unregistered objects
// I suspect that it incorrectly registers them
// Check out of objectRegistry
checkOut();
IOobject::rename(newName);
// Re-register object with objectRegistry
checkIn();
if (registerObject())
{
// Re-register object with objectRegistry
checkIn();
}
}
......@@ -186,8 +183,11 @@ void Foam::regIOobject::operator=(const IOobject& io)
IOobject::operator=(io);
// Re-register object with objectRegistry
checkIn();
if (registerObject())
{
// Re-register object with objectRegistry
checkIn();
}
}
......
......@@ -34,12 +34,7 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
bool regIOobject::writeObject
bool Foam::regIOobject::writeObject
(
IOstream::streamFormat fmt,
IOstream::versionNumber ver,
......@@ -131,7 +126,7 @@ bool regIOobject::writeObject
}
bool regIOobject::write() const
bool Foam::regIOobject::write() const
{
return writeObject
(
......@@ -141,9 +136,4 @@ bool regIOobject::write() const
);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
......@@ -285,9 +285,9 @@ Foam::argList::argList
// Print the banner once only for parallel runs
if (Pstream::master() && bannerEnabled)
{
IOobject::writeBanner(Info, true);
Info<< "Build : " << Foam::FOAMbuild << nl
<< "Exec : " << argListString.c_str() << nl
IOobject::writeBanner(Info, true)
<< "Build : " << Foam::FOAMbuild << nl
<< "Exec : " << argListString.c_str() << nl
<< "Date : " << dateString.c_str() << nl
<< "Time : " << timeString.c_str() << nl
<< "Host : " << hostName() << nl
......
......@@ -32,14 +32,9 @@ License
#include "OStringStream.H"
#include "Pstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(commSchedule, 0);
}
defineTypeNameAndDebug(Foam::commSchedule, 0);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......
......@@ -35,11 +35,8 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Constructor from components
labelList bandCompression(const labelListList& cellCellAddressing)
Foam::labelList Foam::bandCompression(const labelListList& cellCellAddressing)
{
labelList newOrder(cellCellAddressing.size());
......@@ -106,8 +103,4 @@ labelList bandCompression(const labelListList& cellCellAddressing)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
......@@ -29,10 +29,8 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(lduMesh, 0);
}
defineTypeNameAndDebug(Foam::lduMesh, 0);
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
......
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