dictionary is updated
This commit is contained in:
parent
59c148afa6
commit
5a94fc5688
|
@ -14,4 +14,4 @@ add_subdirectory(phasicFlow)
|
||||||
#add_subdirectory(Geometry)
|
#add_subdirectory(Geometry)
|
||||||
|
|
||||||
|
|
||||||
add_subdirectory(MPIParallelization)
|
#add_subdirectory(MPIParallelization)
|
||||||
|
|
|
@ -27,6 +27,12 @@ streams/streams.cpp
|
||||||
fileSystem/fileSystem.cpp
|
fileSystem/fileSystem.cpp
|
||||||
|
|
||||||
processors/processors.cpp
|
processors/processors.cpp
|
||||||
|
|
||||||
|
dictionary/dictionary.cpp
|
||||||
|
dictionary/entry/iEntry.cpp
|
||||||
|
dictionary/entry/dataEntry.cpp
|
||||||
|
dictionary/twoPartEntry/twoPartEntry.cpp
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(link_libs)
|
set(link_libs)
|
||||||
|
|
|
@ -468,15 +468,6 @@ bool pFlow::dictionary::add
|
||||||
return addPtr(keyword, ptr);
|
return addPtr(keyword, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::dictionary::add
|
|
||||||
(
|
|
||||||
const word& keyword,
|
|
||||||
const int16& v
|
|
||||||
)
|
|
||||||
{
|
|
||||||
uniquePtr<iEntry> ptr = makeUnique<dataEntry>(keyword, *this, token(v));
|
|
||||||
return addPtr(keyword, ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool pFlow::dictionary::add
|
bool pFlow::dictionary::add
|
||||||
(
|
(
|
||||||
|
@ -491,7 +482,7 @@ bool pFlow::dictionary::add
|
||||||
bool pFlow::dictionary::add
|
bool pFlow::dictionary::add
|
||||||
(
|
(
|
||||||
const word& keyword,
|
const word& keyword,
|
||||||
const label& v
|
const uint64& v
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
uniquePtr<iEntry> ptr = makeUnique<dataEntry>(keyword, *this, token(v));
|
uniquePtr<iEntry> ptr = makeUnique<dataEntry>(keyword, *this, token(v));
|
||||||
|
@ -508,6 +499,15 @@ bool pFlow::dictionary::add
|
||||||
return addPtr(keyword, ptr);
|
return addPtr(keyword, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pFlow::dictionary::add
|
||||||
|
(
|
||||||
|
const word& keyword,
|
||||||
|
const uint8& v
|
||||||
|
)
|
||||||
|
{
|
||||||
|
uniquePtr<iEntry> ptr = makeUnique<dataEntry>(keyword, *this, token(v));
|
||||||
|
return addPtr(keyword, ptr);
|
||||||
|
}
|
||||||
|
|
||||||
bool pFlow::dictionary::addDict
|
bool pFlow::dictionary::addDict
|
||||||
(
|
(
|
||||||
|
|
|
@ -34,7 +34,36 @@ Licence:
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dictionary holds a set of data entries or sub-dictionaries that are enclosed
|
||||||
|
* in a curely braces or are in a file.
|
||||||
|
*
|
||||||
|
* data entry format is:
|
||||||
|
* ```
|
||||||
|
* entryName value;
|
||||||
|
* ```
|
||||||
|
* and a dictionary in a file can be:
|
||||||
|
* ```
|
||||||
|
* entryName2 value2;
|
||||||
|
*
|
||||||
|
* entryName3 value3;
|
||||||
|
*
|
||||||
|
* subDict1
|
||||||
|
* {
|
||||||
|
* entryName4 value4;
|
||||||
|
*
|
||||||
|
* ....
|
||||||
|
*
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* subDict2
|
||||||
|
* {
|
||||||
|
* ...
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
*/
|
||||||
class dictionary
|
class dictionary
|
||||||
:
|
:
|
||||||
public iEntry
|
public iEntry
|
||||||
|
@ -43,39 +72,39 @@ protected:
|
||||||
|
|
||||||
//// - Data members
|
//// - Data members
|
||||||
|
|
||||||
// global name of dictionary, separated with dots
|
/// global name of dictionary, separated with dots
|
||||||
word name_;
|
word name_;
|
||||||
|
|
||||||
// all the entries (data and dictionary) of the current dictionary
|
/// all the entries (data and dictionary) of the current dictionary
|
||||||
wordOrderedMapPtr<iEntry> entries_;
|
wordOrderedMapPtr<iEntry> entries_;
|
||||||
|
|
||||||
// entries in order of insertion
|
/// entries in order of insertion
|
||||||
List<iEntry*> orderedEntries_;
|
List<iEntry*> orderedEntries_;
|
||||||
|
|
||||||
// - ref to parrent dictionary
|
/// ref to parrent dictionary
|
||||||
const dictionary& parDict_;
|
const dictionary& parDict_;
|
||||||
|
|
||||||
bool isGlobal_;
|
bool isGlobal_;
|
||||||
|
|
||||||
|
|
||||||
//// - protected methods
|
///// protected methods
|
||||||
|
|
||||||
// - find an entry based on keyword
|
/// find an entry based on keyword
|
||||||
// return nullptr if not found
|
/// return nullptr if not found
|
||||||
iEntry* findEntry(const word& keyword);
|
iEntry* findEntry(const word& keyword);
|
||||||
|
|
||||||
// - find and entry based on keyword
|
/// find and entry based on keyword
|
||||||
// return nullptr if not found
|
/// return nullptr if not found
|
||||||
iEntry* findEntry(const word& keyword)const;
|
iEntry* findEntry(const word& keyword)const;
|
||||||
|
|
||||||
// - reads a dataEntry with keyword from dictionary
|
/// reads a dataEntry with keyword from dictionary
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool readDataEntry( const word& keyword, T& val)const;
|
bool readDataEntry( const word& keyword, T& val)const;
|
||||||
|
|
||||||
// - read dictionary from stream - without keyword
|
/// read dictionary from stream - without keyword
|
||||||
bool readDictionary(iIstream & is);
|
bool readDictionary(iIstream & is);
|
||||||
|
|
||||||
// - write dictionary to stream - with keyword
|
/// write dictionary to stream - with keyword
|
||||||
bool writeDictionary(iOstream& os, bool withBlock = true)const;
|
bool writeDictionary(iOstream& os, bool withBlock = true)const;
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,184 +117,184 @@ public:
|
||||||
|
|
||||||
//// - Constructors
|
//// - Constructors
|
||||||
|
|
||||||
// - cunstructs a null dictionary
|
/// cunstructs a null dictionary
|
||||||
dictionary();
|
dictionary();
|
||||||
|
|
||||||
// - construct an empty dictionary with keyword
|
/// construct an empty dictionary with keyword
|
||||||
dictionary(const word& keyword);
|
dictionary(const word& keyword);
|
||||||
|
|
||||||
// - construct an empty dictionary with keyword and make it global/fileDictionary (if true)
|
/// construct an empty dictionary with keyword and make it global/fileDictionary (if true)
|
||||||
dictionary(const word& keyword, bool global);
|
dictionary(const word& keyword, bool global);
|
||||||
|
|
||||||
// - construct a dictionary with name and read it from file
|
/// construct a dictionary with name and read it from file
|
||||||
dictionary(const word& keyword, const fileSystem& file);
|
dictionary(const word& keyword, const fileSystem& file);
|
||||||
|
|
||||||
// - cunstruct an empty dictionary with keyword and parDict
|
/// cunstruct an empty dictionary with keyword and parDict
|
||||||
dictionary(const word& keyword, const dictionary& parDict);
|
dictionary(const word& keyword, const dictionary& parDict);
|
||||||
|
|
||||||
// - cunstruct a dictionary with keyword and parDict and from stream
|
/// cunstruct a dictionary with keyword and parDict and from stream
|
||||||
dictionary( const word& keyword, const dictionary& parDict, iIstream& is);
|
dictionary( const word& keyword, const dictionary& parDict, iIstream& is);
|
||||||
|
|
||||||
// - copy construct with keyword and new parrent dict
|
/// copy construct with keyword and new parrent dict
|
||||||
// discard the keyword and parDict of dict
|
/// discard the keyword and parDict of dict
|
||||||
dictionary(const word& keyword, const dictionary& parDict, const dictionary& dict);
|
dictionary(const word& keyword, const dictionary& parDict, const dictionary& dict);
|
||||||
|
|
||||||
// - copy construct as default behavior
|
/// copy construct as default behavior
|
||||||
// entries_ are copied smoothly. set parrent dict to nullDict
|
/// entries_ are copied smoothly. set parrent dict to nullDict
|
||||||
dictionary(const dictionary& );
|
dictionary(const dictionary& );
|
||||||
|
|
||||||
|
|
||||||
// - assignment preserve name of this dictionary
|
/// assignment preserve name of this dictionary
|
||||||
// - only entries are transfered with ownership
|
/// only entries are transfered with ownership
|
||||||
dictionary& operator=(const dictionary& rhs);
|
dictionary& operator=(const dictionary& rhs);
|
||||||
|
|
||||||
|
|
||||||
//// - Methods
|
//// - Methods
|
||||||
|
|
||||||
// - pointer to this dictionary
|
/// pointer to this dictionary
|
||||||
virtual dictionary* dictPtr();
|
virtual dictionary* dictPtr();
|
||||||
|
|
||||||
// - pointer to this dictionary
|
/// pointer to this dictionary
|
||||||
virtual const dictionary* dictPtr() const;
|
virtual const dictionary* dictPtr() const;
|
||||||
|
|
||||||
// - if this is a dictionary
|
/// if this is a dictionary
|
||||||
virtual bool isDictionary() const;
|
virtual bool isDictionary() const;
|
||||||
|
|
||||||
// - global name of entry, separated with dots
|
/// global name of entry, separated with dots
|
||||||
virtual word globalName()const;
|
virtual word globalName()const;
|
||||||
|
|
||||||
// - const ref to parrent dictionary
|
/// const ref to parrent dictionary
|
||||||
virtual const dictionary& parrentDict() const;
|
virtual const dictionary& parrentDict() const;
|
||||||
|
|
||||||
// - ref to this dictionary, if it is a dictionary
|
/// ref to this dictionary, if it is a dictionary
|
||||||
virtual dictionary& dict();
|
virtual dictionary& dict();
|
||||||
|
|
||||||
// - const ref to this dictionary, if it is a dictionary
|
/// const ref to this dictionary, if it is a dictionary
|
||||||
virtual const dictionary& dict() const;
|
virtual const dictionary& dict() const;
|
||||||
|
|
||||||
// - if dictionary is file dictionary, return false
|
/// if dictionary is file dictionary, return false
|
||||||
virtual bool isFileDict()const;
|
virtual bool isFileDict()const;
|
||||||
|
|
||||||
// - add a pointer entry (dictionary/dataEntry)
|
/// add a pointer entry (dictionary/dataEntry)
|
||||||
// replaces this entry with existing one
|
// replaces this entry with existing one
|
||||||
bool addPtr(const word& keyword, uniquePtr<iEntry>& etry );
|
bool addPtr(const word& keyword, uniquePtr<iEntry>& etry );
|
||||||
|
|
||||||
// - add a float dataEntry
|
/// add a float dataEntry
|
||||||
bool add(const word& keyword, const float& v);
|
bool add(const word& keyword, const float& v);
|
||||||
|
|
||||||
// - add a double dataEntry
|
/// add a double dataEntry
|
||||||
bool add(const word& keyword, const double& v);
|
bool add(const word& keyword, const double& v);
|
||||||
|
|
||||||
// - add a word dataEntry
|
/// add a word dataEntry
|
||||||
bool add(const word& keyword, const word& v);
|
bool add(const word& keyword, const word& v);
|
||||||
|
|
||||||
// - add a int64 dataEntry
|
/// add a int64 dataEntry
|
||||||
bool add(const word& keyword, const int64& v);
|
bool add(const word& keyword, const int64& v);
|
||||||
|
|
||||||
// - add a int32 dataEntry
|
/// add a int32 dataEntry
|
||||||
bool add(const word& keyword, const int32& v);
|
bool add(const word& keyword, const int32& v);
|
||||||
|
|
||||||
// - add a int16 dataEntry
|
/// add a int8 dataEntry
|
||||||
bool add(const word& keyword, const int16& v);
|
|
||||||
|
|
||||||
// - add a int8 dataEntry
|
|
||||||
bool add(const word& keyword, const int8& v);
|
bool add(const word& keyword, const int8& v);
|
||||||
|
|
||||||
// - add a label dataEntry
|
/// add a uint64 dataEntry
|
||||||
bool add(const word& keyword, const label& v);
|
bool add(const word& keyword, const uint64& v);
|
||||||
|
|
||||||
// - add a uint32 dataEntry
|
/// add a uint32 dataEntry
|
||||||
bool add(const word& keyword, const uint32& v);
|
bool add(const word& keyword, const uint32& v);
|
||||||
|
|
||||||
|
/// add a uint8 dataEntry
|
||||||
|
bool add(const word& keyword, const uint8& v);
|
||||||
|
|
||||||
// add a dictionary with the specifiedd keyword
|
// add a dictionary with the specifiedd keyword
|
||||||
bool addDict(const word& keyword, const dictionary& dict);
|
bool addDict(const word& keyword, const dictionary& dict);
|
||||||
|
|
||||||
// - add a dataEntry of type T
|
/// add a dataEntry of type T
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool add(const word& keyword, const T& v );
|
bool add(const word& keyword, const T& v );
|
||||||
|
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
// - pointer to a subdictionary
|
/// pointer to a subdictionary
|
||||||
// fatalExit if not found
|
/// fatalExit if not found
|
||||||
dictionary* subDictPtr(const word& keyword);
|
dictionary* subDictPtr(const word& keyword);
|
||||||
|
|
||||||
// - ref to a subdictioanry
|
/// ref to a subdictioanry
|
||||||
// fatalExit if not found
|
/// fatalExit if not found
|
||||||
dictionary& subDict(const word& keyword);
|
dictionary& subDict(const word& keyword);
|
||||||
|
|
||||||
// - const ref to a subdictioanry
|
/// const ref to a subdictioanry
|
||||||
// fatalExit if not found
|
/// fatalExit if not found
|
||||||
const dictionary& subDict(const word& keyword) const;
|
const dictionary& subDict(const word& keyword) const;
|
||||||
|
|
||||||
// - pointer to a dataEntry
|
/// pointer to a dataEntry
|
||||||
// fatalExit if not found/not a dataEntry
|
/// fatalExit if not found/not a dataEntry
|
||||||
dataEntry* dataEntryPtr(const word& keyword);
|
dataEntry* dataEntryPtr(const word& keyword);
|
||||||
|
|
||||||
// - ref to a subdictioanry
|
/// ref to a subdictioanry
|
||||||
// fatalExit if not found/not a dataEntry
|
/// fatalExit if not found/not a dataEntry
|
||||||
dataEntry& dataEntryRef(const word& keyword);
|
dataEntry& dataEntryRef(const word& keyword);
|
||||||
|
|
||||||
// - const ref to a subdictioanry
|
/// const ref to a subdictioanry
|
||||||
// fatalExit if not found/not a dataEntry
|
/// fatalExit if not found/not a dataEntry
|
||||||
const dataEntry& dataEntryRef(const word& keyword)const;
|
const dataEntry& dataEntryRef(const word& keyword)const;
|
||||||
|
|
||||||
// - search for a sub-dict with keyword
|
/// search for a sub-dict with keyword
|
||||||
// create a new sub-dict if not found and return a ref to it
|
/// create a new sub-dict if not found and return a ref to it
|
||||||
// fatalExit if fails
|
/// fatalExit if fails
|
||||||
dictionary& subDictOrCreate(const word& keyword);
|
dictionary& subDictOrCreate(const word& keyword);
|
||||||
|
|
||||||
// - get the value of data entry
|
/// get the value of data entry
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T getVal(const word& keyword) const;
|
T getVal(const word& keyword) const;
|
||||||
|
|
||||||
// - get the value of data entry or
|
/// get the value of data entry or
|
||||||
// if not found, set the value to setVal
|
/// if not found, set the value to setVal
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T getValOrSet(const word& keyword, const T& setVal)const;
|
T getValOrSet(const word& keyword, const T& setVal)const;
|
||||||
|
|
||||||
// return number of entris in this dictionary
|
/// return number of entris in this dictionary
|
||||||
size_t numEntries()const;
|
size_t numEntries()const;
|
||||||
|
|
||||||
// return number of non-nullptr dataEntries
|
/// return number of non-nullptr dataEntries
|
||||||
size_t numDataEntries()const;
|
size_t numDataEntries()const;
|
||||||
|
|
||||||
// return number of non-nullptr dictionaries
|
/// return number of non-nullptr dictionaries
|
||||||
size_t numDictionaries()const;
|
size_t numDictionaries()const;
|
||||||
|
|
||||||
// return all keywords (non-nullptr) in this dictionary
|
/// return all keywords (non-nullptr) in this dictionary
|
||||||
wordList allKeywords()const;
|
wordList allKeywords()const;
|
||||||
|
|
||||||
// return a list of all dataEntries (non-nullptr) keywords
|
/// return a list of all dataEntries (non-nullptr) keywords
|
||||||
wordList dataEntryKeywords()const;
|
wordList dataEntryKeywords()const;
|
||||||
|
|
||||||
// return a list of all dictionary (non-null) keywords
|
/// return a list of all dictionary (non-null) keywords
|
||||||
wordList dictionaryKeywords()const;
|
wordList dictionaryKeywords()const;
|
||||||
|
|
||||||
// check if a sub-dictionary exists
|
/// check if a sub-dictionary exists
|
||||||
bool containsDictionay(const word& name)const;
|
bool containsDictionay(const word& name)const;
|
||||||
|
|
||||||
// check if a data entry exist
|
/// check if a data entry exist
|
||||||
bool containsDataEntry(const word& name)const;
|
bool containsDataEntry(const word& name)const;
|
||||||
|
|
||||||
// clone polymorphic object (here dictionary)
|
/// clone polymorphic object (here dictionary)
|
||||||
virtual uniquePtr<iEntry> clone() const;
|
virtual uniquePtr<iEntry> clone() const;
|
||||||
|
|
||||||
virtual iEntry* clonePtr() const;
|
virtual iEntry* clonePtr() const;
|
||||||
|
|
||||||
// - clone the polymorhpic object with parDict as the new parrent dictionary
|
/// clone the polymorhpic object with parDict as the new parrent dictionary
|
||||||
virtual uniquePtr<iEntry> clone(const dictionary& parDict)const;
|
virtual uniquePtr<iEntry> clone(const dictionary& parDict)const;
|
||||||
|
|
||||||
virtual iEntry* clonePtr(const dictionary& parDict) const;
|
virtual iEntry* clonePtr(const dictionary& parDict) const;
|
||||||
|
|
||||||
|
|
||||||
//// IO operations
|
//// - IO operations
|
||||||
|
|
||||||
// - read from stream
|
/// read from stream
|
||||||
virtual bool read(iIstream& is);
|
virtual bool read(iIstream& is);
|
||||||
|
|
||||||
// - write to stream
|
/// write to stream
|
||||||
virtual bool write(iOstream& os) const;
|
virtual bool write(iOstream& os) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -338,7 +367,8 @@ T dictionary::getValOrSet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
} // pFlow
|
||||||
|
|
||||||
|
|
||||||
#endif // __dictionary_hpp__
|
#endif // __dictionary_hpp__
|
||||||
|
|
|
@ -36,7 +36,15 @@ namespace pFlow
|
||||||
|
|
||||||
class dictionary;
|
class dictionary;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data entry to be used in dictionries. Its format is:
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* entryName value;
|
||||||
|
*
|
||||||
|
* entryName2 (list of values);
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
class dataEntry
|
class dataEntry
|
||||||
:
|
:
|
||||||
public iEntry
|
public iEntry
|
||||||
|
@ -46,19 +54,19 @@ protected:
|
||||||
|
|
||||||
//// - data memebers
|
//// - data memebers
|
||||||
|
|
||||||
// - ref to parrent dictionary
|
/// ref to parrent dictionary
|
||||||
const dictionary& parDict_;
|
const dictionary& parDict_;
|
||||||
|
|
||||||
// - list the tokens as input token stream
|
/// list the tokens as input token stream
|
||||||
iTstream tokenStream_;
|
iTstream tokenStream_;
|
||||||
|
|
||||||
|
|
||||||
//// - protected member functions
|
//// - protected member functions
|
||||||
|
|
||||||
// - read dataEntry from stream
|
/// read dataEntry from stream
|
||||||
bool readDataEntry(iIstream& is);
|
bool readDataEntry(iIstream& is);
|
||||||
|
|
||||||
// - write dataEntry to stream
|
/// write dataEntry to stream
|
||||||
bool writeDataEntry(iOstream& os) const;
|
bool writeDataEntry(iOstream& os) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -67,57 +75,57 @@ public:
|
||||||
|
|
||||||
//// - constructors
|
//// - constructors
|
||||||
|
|
||||||
// - construct null dataEntry
|
/// construct null dataEntry
|
||||||
dataEntry();
|
dataEntry();
|
||||||
|
|
||||||
// - construct from keyword and parDict, empty dataEntry
|
/// construct from keyword and parDict, empty dataEntry
|
||||||
dataEntry(const word& keyword, const dictionary& parDict);
|
dataEntry(const word& keyword, const dictionary& parDict);
|
||||||
|
|
||||||
// - construct from keyword, parDict and input token stream
|
/// construct from keyword, parDict and input token stream
|
||||||
dataEntry(const word& keyWord, const dictionary& parDict, const iTstream& is);
|
dataEntry(const word& keyWord, const dictionary& parDict, const iTstream& is);
|
||||||
|
|
||||||
//- construct from keyword, parDict and input stream
|
//- construct from keyword, parDict and input stream
|
||||||
dataEntry(const word& keyWord, const dictionary& parDict, iIstream& is);
|
dataEntry(const word& keyWord, const dictionary& parDict, iIstream& is);
|
||||||
|
|
||||||
// - construct from keyword, parDict and a single token
|
/// construct from keyword, parDict and a single token
|
||||||
dataEntry(const word& keyword, const dictionary& parDict, const token& tok);
|
dataEntry(const word& keyword, const dictionary& parDict, const token& tok);
|
||||||
|
|
||||||
// - construct from keyword, parDict, and data of type T
|
/// construct from keyword, parDict, and data of type T
|
||||||
template<typename T>
|
template<typename T>
|
||||||
dataEntry(const word& keyword, const dictionary& parDict, const T& v);
|
dataEntry(const word& keyword, const dictionary& parDict, const T& v);
|
||||||
|
|
||||||
// - copy construct with new keyword and parDict
|
/// copy construct with new keyword and parDict
|
||||||
dataEntry(const word& keyword, const dictionary& parDict, const dataEntry& entry );
|
dataEntry(const word& keyword, const dictionary& parDict, const dataEntry& entry );
|
||||||
|
|
||||||
// - copy construct
|
/// copy construct
|
||||||
dataEntry(const dataEntry& src )= default;
|
dataEntry(const dataEntry& src )= default;
|
||||||
|
|
||||||
|
|
||||||
//// - Methods
|
//// - Methods
|
||||||
|
|
||||||
// - global name of entry, separated with dots
|
/// global name of entry, separated with dots
|
||||||
virtual word globalName()const;
|
virtual word globalName()const;
|
||||||
|
|
||||||
|
|
||||||
// - access to token stream
|
/// access to token stream
|
||||||
virtual iTstream& stream();
|
virtual iTstream& stream();
|
||||||
|
|
||||||
// - not permited to be called
|
/// not permited to be called
|
||||||
virtual dictionary* dictPtr();
|
virtual dictionary* dictPtr();
|
||||||
|
|
||||||
// - not permited to be called
|
/// not permited to be called
|
||||||
virtual const dictionary* dictPtr() const;
|
virtual const dictionary* dictPtr() const;
|
||||||
|
|
||||||
// - should returen false;
|
/// should returen false;
|
||||||
virtual bool isDictionary()const;
|
virtual bool isDictionary()const;
|
||||||
|
|
||||||
// - const ref to parrent dictionary
|
/// const ref to parrent dictionary
|
||||||
virtual const dictionary& parrentDict() const;
|
virtual const dictionary& parrentDict() const;
|
||||||
|
|
||||||
// - not permited to be called
|
/// not permited to be called
|
||||||
virtual dictionary& dict();
|
virtual dictionary& dict();
|
||||||
|
|
||||||
// - not permited to be called
|
/// not permited to be called
|
||||||
virtual const dictionary& dict() const;
|
virtual const dictionary& dict() const;
|
||||||
|
|
||||||
// clone the object
|
// clone the object
|
||||||
|
@ -132,10 +140,10 @@ public:
|
||||||
|
|
||||||
//// - IO operations
|
//// - IO operations
|
||||||
|
|
||||||
// - read from stream
|
/// read from stream
|
||||||
virtual bool read(iIstream& is);
|
virtual bool read(iIstream& is);
|
||||||
|
|
||||||
// - write to stream
|
/// write to stream
|
||||||
virtual bool write(iOstream& os) const;
|
virtual bool write(iOstream& os) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,6 +35,10 @@ namespace pFlow
|
||||||
|
|
||||||
class dictionary;
|
class dictionary;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface calss for data entry and dictionary
|
||||||
|
*
|
||||||
|
*/
|
||||||
class iEntry
|
class iEntry
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -42,10 +46,10 @@ public:
|
||||||
|
|
||||||
//// - public static methods
|
//// - public static methods
|
||||||
|
|
||||||
// - read a keyword from stream
|
/// read a keyword from stream
|
||||||
static bool readKeyword(iIstream &is, word& keyword, token& tok );
|
static bool readKeyword(iIstream &is, word& keyword, token& tok );
|
||||||
|
|
||||||
// - create an entry (dataEntry or dictionary) from stream
|
/// create an entry (dataEntry or dictionary) from stream
|
||||||
static bool createEntry(dictionary& parDict, iIstream& is, bool hasBlockToken = false);
|
static bool createEntry(dictionary& parDict, iIstream& is, bool hasBlockToken = false);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -57,41 +61,42 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/// Type info
|
||||||
TypeInfo("iEntry");
|
TypeInfo("iEntry");
|
||||||
|
|
||||||
//// - Constructors
|
//// - Constructors
|
||||||
|
|
||||||
// - empty constructor
|
/// empty constructor
|
||||||
iEntry()
|
iEntry()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// - construct with a keyword
|
/// construct with a keyword
|
||||||
iEntry(const word& key)
|
iEntry(const word& key)
|
||||||
{
|
{
|
||||||
// this moved here due to a very strange core dumped error!
|
// this moved here due to a very strange core dumped error!
|
||||||
keyword_ = key;
|
keyword_ = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - destructor
|
/// destructor
|
||||||
virtual ~iEntry()
|
virtual ~iEntry()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
//// - Methods
|
//// - Methods
|
||||||
|
|
||||||
// - return keyword
|
/// return keyword
|
||||||
virtual const word& keyword() const
|
virtual const word& keyword() const
|
||||||
{
|
{
|
||||||
return keyword_;
|
return keyword_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - return keyword
|
/// return keyword
|
||||||
virtual word& keyword()
|
virtual word& keyword()
|
||||||
{
|
{
|
||||||
return keyword_;
|
return keyword_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// name/keyword of entry
|
||||||
virtual word name()const
|
virtual word name()const
|
||||||
{
|
{
|
||||||
return keyword();
|
return keyword();
|
||||||
|
@ -100,49 +105,50 @@ public:
|
||||||
// global name of entry, separated with dots
|
// global name of entry, separated with dots
|
||||||
virtual word globalName()const = 0;
|
virtual word globalName()const = 0;
|
||||||
|
|
||||||
// - pointer to this dictionary
|
/// pointer to this dictionary
|
||||||
virtual dictionary* dictPtr()
|
virtual dictionary* dictPtr()
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - const pointer to this dictionary
|
/// const pointer to this dictionary
|
||||||
virtual const dictionary* dictPtr() const
|
virtual const dictionary* dictPtr() const
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - if this is a dictionary
|
/// if this is a dictionary
|
||||||
virtual bool isDictionary() const
|
virtual bool isDictionary() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - const ref to parrent dictionary
|
/// const ref to parrent dictionary
|
||||||
virtual const dictionary& parrentDict() const = 0;
|
virtual const dictionary& parrentDict() const = 0;
|
||||||
|
|
||||||
// - ref to this dictionary, if it is a dictionary
|
/// ref to this dictionary, if it is a dictionary
|
||||||
virtual dictionary& dict() = 0;
|
virtual dictionary& dict() = 0;
|
||||||
|
|
||||||
// - const ref to this dictionary, if it is a dicrionary
|
/// const ref to this dictionary, if it is a dicrionary
|
||||||
virtual const dictionary& dict() const = 0;
|
virtual const dictionary& dict() const = 0;
|
||||||
|
|
||||||
// clone the object
|
/// clone the object
|
||||||
virtual iEntry* clonePtr() const = 0;
|
virtual iEntry* clonePtr() const = 0;
|
||||||
|
|
||||||
virtual uniquePtr<iEntry> clone() const = 0;
|
virtual uniquePtr<iEntry> clone() const = 0;
|
||||||
|
|
||||||
// clone the object and change its ownership to parDict
|
/// clone the object and change its ownership to parDict
|
||||||
virtual iEntry* clonePtr(const dictionary& parDict) const = 0;
|
virtual iEntry* clonePtr(const dictionary& parDict) const = 0;
|
||||||
|
|
||||||
|
/// clone the object and change its ownership to parDict
|
||||||
virtual uniquePtr<iEntry> clone(const dictionary& parDict)const = 0;
|
virtual uniquePtr<iEntry> clone(const dictionary& parDict)const = 0;
|
||||||
|
|
||||||
//// - IO operatoins
|
//// - IO operatoins
|
||||||
|
|
||||||
// read from stream
|
/// read from stream
|
||||||
virtual bool read(iIstream& is) = 0;
|
virtual bool read(iIstream& is) = 0;
|
||||||
|
|
||||||
// write to stream
|
/// write to stream
|
||||||
virtual bool write(iOstream& os) const =0;
|
virtual bool write(iOstream& os) const =0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -150,11 +156,10 @@ public:
|
||||||
|
|
||||||
iOstream& operator << (iOstream& os, const iEntry& e);
|
iOstream& operator << (iOstream& os, const iEntry& e);
|
||||||
|
|
||||||
|
|
||||||
iIstream& operator >> (iIstream& is, iEntry& e);
|
iIstream& operator >> (iIstream& is, iEntry& e);
|
||||||
|
|
||||||
|
|
||||||
}
|
} // pFlow
|
||||||
|
|
||||||
|
|
||||||
#endif //__iEntry_hpp__
|
#endif //__iEntry_hpp__
|
||||||
|
|
Loading…
Reference in New Issue