mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Added HashPtrTable construct INew from dictionary
This commit is contained in:
@ -72,6 +72,11 @@ class HashPtrTable
|
|||||||
template<class INew>
|
template<class INew>
|
||||||
void read(Istream&, const INew& inewt);
|
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:
|
public:
|
||||||
|
|
||||||
@ -91,6 +96,10 @@ public:
|
|||||||
//- Construct from Istream using default Istream constructor class
|
//- Construct from Istream using default Istream constructor class
|
||||||
HashPtrTable(Istream&);
|
HashPtrTable(Istream&);
|
||||||
|
|
||||||
|
//- Construct from dictionary using default dictionary constructor
|
||||||
|
// class
|
||||||
|
HashPtrTable(const dictionary& dict);
|
||||||
|
|
||||||
//- Construct as copy
|
//- Construct as copy
|
||||||
HashPtrTable(const HashPtrTable<T, Key, Hash>&);
|
HashPtrTable(const HashPtrTable<T, Key, Hash>&);
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,7 @@ License
|
|||||||
#include "Istream.H"
|
#include "Istream.H"
|
||||||
#include "Ostream.H"
|
#include "Ostream.H"
|
||||||
#include "INew.H"
|
#include "INew.H"
|
||||||
|
#include "dictionary.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * 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 * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, class Key, class Hash>
|
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 * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, class Key, class Hash>
|
template<class T, class Key, class Hash>
|
||||||
|
|||||||
Reference in New Issue
Block a user