diff --git a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H index 29896fc836..fe6e6157f6 100644 --- a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H +++ b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H @@ -72,6 +72,11 @@ class HashPtrTable template void read(Istream&, const INew& inewt); + //- Read from dictionary using given dictionary constructor class + template + void read(const dictionary& dict, const INew& inewt); + + public: @@ -91,6 +96,10 @@ public: //- Construct from Istream using default Istream constructor class HashPtrTable(Istream&); + //- Construct from dictionary using default dictionary constructor + // class + HashPtrTable(const dictionary& dict); + //- Construct as copy HashPtrTable(const HashPtrTable&); diff --git a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTableIO.C b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTableIO.C index 1930e117b3..0300fc72b5 100644 --- a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTableIO.C +++ b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTableIO.C @@ -27,6 +27,7 @@ License #include "Istream.H" #include "Ostream.H" #include "INew.H" +#include "dictionary.H" // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // @@ -137,6 +138,21 @@ void Foam::HashPtrTable::read(Istream& is, const INew& inewt) } +template +template +void Foam::HashPtrTable::read +( + const dictionary& dict, + const INew& inewt +) +{ + forAllConstIter(dictionary, dict, iter) + { + insert(iter().keyword(), inewt(dict.subDict(iter().keyword())).ptr()); + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template @@ -154,6 +170,13 @@ Foam::HashPtrTable::HashPtrTable(Istream& is) } +template +Foam::HashPtrTable::HashPtrTable(const dictionary& dict) +{ + read(dict, INew()); +} + + // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // template