Commit d73ae169 authored by mattijs's avatar mattijs
Browse files

ENH: debug: register multiple variables with same name

parent 339844e1
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -28,7 +28,9 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T>
Foam::Dictionary<T>::Dictionary()
Foam::Dictionary<T>::Dictionary(const label size)
:
DictionaryBase<IDLList<T>, T>(size)
{}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -61,8 +61,8 @@ public:
// Constructors
//- Null constructor
Dictionary();
//- Construct given initial table size
Dictionary(const label size = 128);
//- Copy construct
Dictionary(const Dictionary&);
......
......@@ -55,22 +55,30 @@ void Foam::Time::readDict()
{
const word& name = iter().keyword();
simpleRegIOobject* objPtr = objects.lookupPtr(name);
simpleObjectRegistryEntry* objPtr = objects.lookupPtr(name);
if (objPtr)
{
Info<< " " << iter() << endl;
const List<simpleRegIOobject*>& objects = *objPtr;
if (iter().isDict())
{
OStringStream os(IOstream::ASCII);
os << iter().dict();
IStringStream is(os.str());
objPtr->readData(is);
forAll(objects, i)
{
OStringStream os(IOstream::ASCII);
os << iter().dict();
IStringStream is(os.str());
objects[i]->readData(is);
}
}
else
{
objPtr->readData(iter().stream());
forAll(objects, i)
{
objects[i]->readData(iter().stream());
}
}
}
}
......@@ -91,22 +99,30 @@ void Foam::Time::readDict()
{
const word& name = iter().keyword();
simpleRegIOobject* objPtr = objects.lookupPtr(name);
simpleObjectRegistryEntry* objPtr = objects.lookupPtr(name);
if (objPtr)
{
Info<< " " << iter() << endl;
const List<simpleRegIOobject*>& objects = *objPtr;
if (iter().isDict())
{
OStringStream os(IOstream::ASCII);
os << iter().dict();
IStringStream is(os.str());
objPtr->readData(is);
forAll(objects, i)
{
OStringStream os(IOstream::ASCII);
os << iter().dict();
IStringStream is(os.str());
objects[i]->readData(is);
}
}
else
{
objPtr->readData(iter().stream());
forAll(objects, i)
{
objects[i]->readData(iter().stream());
}
}
}
}
......@@ -133,11 +149,16 @@ void Foam::Time::readDict()
forAllConstIter(simpleObjectRegistry, objects, iter)
{
iter()->readData(dummyIs);
const List<simpleRegIOobject*>& objects = *iter;
forAll(objects, i)
{
objects[i]->readData(dummyIs);
Info<< " ";
iter()->writeData(Info);
Info<< endl;
Info<< " ";
objects[i]->writeData(Info);
Info<< endl;
}
}
}
......@@ -262,16 +283,21 @@ void Foam::Time::readDict()
simpleObjectRegistry& objects = debug::dimensionSetObjects();
simpleRegIOobject* objPtr = objects.lookupPtr("DimensionSets");
simpleObjectRegistryEntry* objPtr = objects.lookupPtr("DimensionSets");
if (objPtr)
{
Info<< controlDict_.subDict("DimensionSets") << endl;
OStringStream os(IOstream::ASCII);
os << dict;
IStringStream is(os.str());
objPtr->readData(is);
const List<simpleRegIOobject*>& objects = *objPtr;
forAll(objects, i)
{
OStringStream os(IOstream::ASCII);
os << dict;
IStringStream is(os.str());
objects[i]->readData(is);
}
}
}
......
......@@ -183,24 +183,42 @@ int Foam::debug::optimisationSwitch(const char* name, const int defaultValue)
void Foam::debug::addDebugObject(const char* name, simpleRegIOobject* obj)
{
debugObjects().append(name, obj);
simpleObjectRegistryEntry* ptr = debugObjects().lookupPtr(name);
if (ptr)
{
//std::cerr<< "debug::addDebugObject : Duplicate entry " << name
// << " in runtime selection table"
// << std::endl;
//error::safePrintStack(std::cerr);
ptr->append(obj);
}
else
{
debugObjects().append
(
name,
new simpleObjectRegistryEntry
(
List<simpleRegIOobject*>(1, obj)
)
);
}
}
void Foam::debug::addInfoObject(const char* name, simpleRegIOobject* obj)
{
infoObjects().append(name, obj);
simpleObjectRegistryEntry* ptr = infoObjects().lookupPtr(name);
if (ptr)
{
ptr->append(obj);
}
else
{
//std::cerr<< "debug::addInfoObject : Duplicate entry " << name
// << " in runtime selection table"
// << std::endl;
//error::safePrintStack(std::cerr);
infoObjects().append
(
name,
new simpleObjectRegistryEntry
(
List<simpleRegIOobject*>(1, obj)
)
);
}
}
......@@ -211,12 +229,21 @@ void Foam::debug::addOptimisationObject
simpleRegIOobject* obj
)
{
optimisationObjects().append(name, obj);
simpleObjectRegistryEntry* ptr = optimisationObjects().lookupPtr(name);
if (ptr)
{
//std::cerr<< "debug::addOptimisationObject : Duplicate entry " << name
// << " in runtime selection table"
// << std::endl;
//error::safePrintStack(std::cerr);
ptr->append(obj);
}
else
{
optimisationObjects().append
(
name,
new simpleObjectRegistryEntry
(
List<simpleRegIOobject*>(1, obj)
)
);
}
}
......@@ -227,12 +254,21 @@ void Foam::debug::addDimensionSetObject
simpleRegIOobject* obj
)
{
dimensionSetObjects().append(name, obj);
simpleObjectRegistryEntry* ptr = dimensionSetObjects().lookupPtr(name);
if (ptr)
{
//std::cerr<< "debug::addDimensionSetObject : Duplicate entry " << name
// << " in runtime selection table"
// << std::endl;
//error::safePrintStack(std::cerr);
ptr->append(obj);
}
else
{
dimensionSetObjects().append
(
name,
new simpleObjectRegistryEntry
(
List<simpleRegIOobject*>(1, obj)
)
);
}
}
......@@ -243,13 +279,24 @@ void Foam::debug::addDimensionedConstantObject
simpleRegIOobject* obj
)
{
dimensionedConstantObjects().append(name, obj);
simpleObjectRegistryEntry* ptr = dimensionedConstantObjects().lookupPtr
(
name
);
if (ptr)
{
ptr->append(obj);
}
else
{
//std::cerr<< "debug::addDimensionedConstantObject : Duplicate entry "
// << name
// << " in runtime selection table"
// << std::endl;
//error::safePrintStack(std::cerr);
dimensionedConstantObjects().append
(
name,
new simpleObjectRegistryEntry
(
List<simpleRegIOobject*>(1, obj)
)
);
}
}
......
......@@ -34,7 +34,8 @@ SourceFiles
#ifndef simpleObjectRegistry_H
#define simpleObjectRegistry_H
#include "UPtrDictionary.H"
//#include "UPtrDictionary.H"
#include "Dictionary.H"
#include "simpleRegIOobject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -43,12 +44,30 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class simpleObjectRegistry Declaration
Class simpleObjectRegistryEntry Declaration
\*---------------------------------------------------------------------------*/
class simpleObjectRegistryEntry
:
public Dictionary<simpleObjectRegistryEntry>::link,
public List<simpleRegIOobject*>
{
public:
simpleObjectRegistryEntry(const List<simpleRegIOobject*>& data)
:
List<simpleRegIOobject*>(data)
{}
};
/*---------------------------------------------------------------------------*\
Class simpleObjectRegistry Declaration
\*---------------------------------------------------------------------------*/
class simpleObjectRegistry
:
public UPtrDictionary<simpleRegIOobject>
public Dictionary<simpleObjectRegistryEntry>
{
public:
......@@ -57,7 +76,7 @@ public:
//- Construct given initial table size
simpleObjectRegistry(const label nIoObjects = 128)
:
UPtrDictionary<simpleRegIOobject>(nIoObjects)
Dictionary<simpleObjectRegistryEntry>(nIoObjects)
{}
};
......
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