Commit 9de20a66 authored by Andrew Heather's avatar Andrew Heather
Browse files

ENH: Added HashPtrTable construct INew from dictionary

parent ae2815e7
......@@ -72,6 +72,11 @@ class HashPtrTable
template<class INew>
void read(Istream&, const INew& inewt);
//- Read from dictionary using given dictionary constructor class
template<class INew>
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<T, Key, Hash>&);
......
......@@ -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<T, Key, Hash>::read(Istream& is, const INew& inewt)
}
template<class T, class Key, class Hash>
template<class INew>
void Foam::HashPtrTable<T, Key, Hash>::read
(
const dictionary& dict,
const INew& inewt
)
{
forAllConstIter(dictionary, dict, iter)
{
insert(iter().keyword(), inewt(dict.subDict(iter().keyword())).ptr());
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T, class Key, class Hash>
......@@ -154,6 +170,13 @@ Foam::HashPtrTable<T, Key, Hash>::HashPtrTable(Istream& is)
}
template<class T, class Key, class Hash>
Foam::HashPtrTable<T, Key, Hash>::HashPtrTable(const dictionary& dict)
{
read(dict, INew<T>());
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class T, class Key, class Hash>
......
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