# PhasicFlow: src/phasicFlow/dictionary/entry/dataEntry.hpp Source File

dataEntry.hpp
Go to the documentation of this file.
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
// based on OpenFOAM dictionary, with some modifications/simplifications
// to be tailored to our needs
#ifndef __dataEntry_hpp__
#define __dataEntry_hpp__
#include "iEntry.hpp"
#include "iTstream.hpp"
#include "oTstream.hpp"
namespace pFlow
{
class dictionary;
class dataEntry
:
public iEntry
{
protected:
// - ref to parrent dictionary
const dictionary& parDict_;
// - list the tokens as input token stream
iTstream tokenStream_;
// - read dataEntry from stream
bool readDataEntry(iIstream& is);
// - write dataEntry to stream
bool writeDataEntry(iOstream& os) const;
public:
static dataEntry nullDataEntry;
// - construct null dataEntry
dataEntry();
// - construct from keyword and parDict, empty dataEntry
dataEntry(const word& keyword, const dictionary& parDict);
// - construct from keyword, parDict and input token stream
dataEntry(const word& keyWord, const dictionary& parDict, const iTstream& is);
//- construct from keyword, parDict and input stream
dataEntry(const word& keyWord, const dictionary& parDict, iIstream& is);
// - construct from keyword, parDict and a single token
dataEntry(const word& keyword, const dictionary& parDict, const token& tok);
// - construct from keyword, parDict, and data of type T
template<typename T>
dataEntry(const word& keyword, const dictionary& parDict, const T& v);
// - copy construct with new keyword and parDict
dataEntry(const word& keyword, const dictionary& parDict, const dataEntry& entry );
// - copy construct
dataEntry(const dataEntry& src )= default;
// - global name of entry, separated with dots
virtual word globalName()const;
// - access to token stream
virtual iTstream& stream();
// - not permited to be called
virtual dictionary* dictPtr();
// - not permited to be called
virtual const dictionary* dictPtr() const;
// - should returen false;
virtual bool isDictionary()const;
// - const ref to parrent dictionary
virtual const dictionary& parrentDict() const;
// - not permited to be called
virtual dictionary& dict();
// - not permited to be called
virtual const dictionary& dict() const;
// clone the object
virtual iEntry* clonePtr() const;
virtual uniquePtr<iEntry> clone() const;
// clone the object and change its ownership to parDict
virtual iEntry* clonePtr(const dictionary& parDict) const;
virtual uniquePtr<iEntry> clone(const dictionary& parDict)const;
// - read from stream
virtual bool read(iIstream& is);
// - write to stream
virtual bool write(iOstream& os) const;
};
template<typename T>
dataEntry::dataEntry(const word& keyword, const dictionary& parDict, const T& v)
:
dataEntry(keyword, parDict)
{
oTstream os("oTStream for " + globalName());
os<< v << endStatementToken();
tokenStream_ = std::move(os.tokens());
}
} // pFlow
#endif //__dataEntry_hpp__
pFlow::oTstream
Definition: oTstream.hpp:23
pFlow::dataEntry::readDataEntry
bool readDataEntry(iIstream &is)
Definition: dataEntry.cpp:35
iTstream.hpp
pFlow::token
Definition: token.hpp:42
pFlow::dataEntry::stream
virtual iTstream & stream()
Definition: dataEntry.cpp:261
pFlow::endStatementToken
token endStatementToken()
Definition: token.hpp:504
pFlow::dataEntry::parrentDict
virtual const dictionary & parrentDict() const
Definition: dataEntry.cpp:297
pFlow::dataEntry::globalName
virtual word globalName() const
Definition: dataEntry.cpp:291
pFlow::dataEntry::writeDataEntry
bool writeDataEntry(iOstream &os) const
Definition: dataEntry.cpp:98
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
oTstream.hpp
pFlow::iEntry::keyword
virtual const word & keyword() const
Definition: iEntry.hpp:84
pFlow::oTstream::tokens
const tokenList & tokens() const
Definition: oTstream.cpp:32
pFlow
Definition: demComponent.hpp:28
pFlow::dataEntry::parDict_
const dictionary & parDict_
Definition: dataEntry.hpp:50
pFlow::dataEntry::dataEntry
dataEntry()
Definition: dataEntry.cpp:159
pFlow::dataEntry
Definition: dataEntry.hpp:40
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::dataEntry::tokenStream_
iTstream tokenStream_
Definition: dataEntry.hpp:53
pFlow::dataEntry::dictPtr
virtual dictionary * dictPtr()
Definition: dataEntry.cpp:269
iEntry.hpp
pFlow::dataEntry::nullDataEntry
static dataEntry nullDataEntry
Definition: dataEntry.hpp:66
pFlow::dataEntry::isDictionary
virtual bool isDictionary() const
Definition: dataEntry.cpp:286
pFlow::iTstream
Definition: iTstream.hpp:21
pFlow::dataEntry::read
virtual bool read(iIstream &is)
Definition: dataEntry.cpp:345
pFlow::uniquePtr
Definition: uniquePtr.hpp:44
pFlow::dataEntry::clone
virtual uniquePtr< iEntry > clone() const
Definition: dataEntry.cpp:321
pFlow::iEntry
Definition: iEntry.hpp:38
pFlow::dataEntry::clonePtr
virtual iEntry * clonePtr() const
Definition: dataEntry.cpp:327
pFlow::dataEntry::dict
virtual dictionary & dict()
Definition: dataEntry.cpp:303
pFlow::dataEntry::write
virtual bool write(iOstream &os) const
Definition: dataEntry.cpp:366
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::dictionary
Definition: dictionary.hpp:38