make Deck constructible from variables
also make it default constructible, add accessors assignment operator and equality operator
This commit is contained in:
@@ -100,6 +100,7 @@ namespace Opm {
|
||||
|
||||
DeckView( const_iterator first, const_iterator last );
|
||||
explicit DeckView( std::pair< const_iterator, const_iterator > );
|
||||
DeckView() = default;
|
||||
void init( const_iterator, const_iterator );
|
||||
|
||||
private:
|
||||
@@ -125,9 +126,15 @@ namespace Opm {
|
||||
Deck();
|
||||
|
||||
Deck( const Deck& );
|
||||
Deck(const std::vector<DeckKeyword>& keywords,
|
||||
const UnitSystem& defUnits,
|
||||
const UnitSystem* activeUnits,
|
||||
const std::string& dataFile,
|
||||
const std::string& inputPath,
|
||||
size_t accessCount);
|
||||
|
||||
//! \brief Deleted assignment operator.
|
||||
Deck& operator=(const Deck& rhs) = delete;
|
||||
Deck& operator=(const Deck& rhs);
|
||||
bool operator==(const Deck& data) const;
|
||||
|
||||
void addKeyword( DeckKeyword&& keyword );
|
||||
void addKeyword( const DeckKeyword& keyword );
|
||||
@@ -149,6 +156,10 @@ namespace Opm {
|
||||
iterator end();
|
||||
void write( DeckOutput& output ) const ;
|
||||
friend std::ostream& operator<<(std::ostream& os, const Deck& deck);
|
||||
|
||||
const std::vector<DeckKeyword>& keywords() const;
|
||||
std::size_t unitSystemAccessCount() const;
|
||||
const std::unique_ptr<UnitSystem>& activeUnitSystem() const;
|
||||
private:
|
||||
Deck(std::vector<DeckKeyword>&& keywordList);
|
||||
|
||||
|
||||
@@ -132,6 +132,24 @@ namespace Opm {
|
||||
Deck( std::vector<DeckKeyword>() )
|
||||
{}
|
||||
|
||||
Deck::Deck(const std::vector<DeckKeyword>& keywords,
|
||||
const UnitSystem& defUnits,
|
||||
const UnitSystem* activeUnit,
|
||||
const std::string& dataFile,
|
||||
const std::string& inputPath,
|
||||
size_t accessCount) :
|
||||
keywordList(keywords),
|
||||
defaultUnits(defUnits),
|
||||
m_dataFile(dataFile),
|
||||
input_path(inputPath),
|
||||
unit_system_access_count(accessCount)
|
||||
{
|
||||
if (activeUnit)
|
||||
activeUnits.reset(new UnitSystem(*activeUnit));
|
||||
this->init(keywordList.begin(), keywordList.end());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
This constructor should be ssen as a technical implemtation detail of the
|
||||
@@ -157,6 +175,7 @@ namespace Opm {
|
||||
this->init(this->keywordList.begin(), this->keywordList.end());
|
||||
if (d.activeUnits)
|
||||
this->activeUnits.reset( new UnitSystem(*d.activeUnits.get()));
|
||||
unit_system_access_count = d.unit_system_access_count;
|
||||
}
|
||||
|
||||
|
||||
@@ -228,6 +247,18 @@ namespace Opm {
|
||||
return this->input_path;
|
||||
}
|
||||
|
||||
const std::unique_ptr<UnitSystem>& Deck::activeUnitSystem() const {
|
||||
return this->activeUnits;
|
||||
}
|
||||
|
||||
const std::vector<DeckKeyword>& Deck::keywords() const {
|
||||
return keywordList;
|
||||
}
|
||||
|
||||
std::size_t Deck::unitSystemAccessCount() const {
|
||||
return unit_system_access_count;
|
||||
}
|
||||
|
||||
std::string Deck::makeDeckPath(const std::string& path) const {
|
||||
if (path.size() > 0 && path[0] == '/')
|
||||
return path;
|
||||
@@ -268,6 +299,34 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
|
||||
Deck& Deck::operator=(const Deck& data) {
|
||||
keywordList = data.keywordList;
|
||||
defaultUnits = data.defaultUnits;
|
||||
m_dataFile = data.m_dataFile;
|
||||
input_path = data.input_path;
|
||||
unit_system_access_count = data.unit_system_access_count;
|
||||
this->init(this->keywordList.begin(), this->keywordList.end());
|
||||
activeUnits.reset();
|
||||
if (data.activeUnits)
|
||||
activeUnits.reset(new UnitSystem(*data.activeUnits));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool Deck::operator==(const Deck& data) const {
|
||||
if ((activeUnitSystem() && !data.activeUnitSystem()) ||
|
||||
(!activeUnitSystem() && data.activeUnitSystem()))
|
||||
return false;
|
||||
|
||||
if (activeUnitSystem() && *activeUnitSystem() != *data.activeUnitSystem())
|
||||
return false;
|
||||
return this->keywords() == data.keywords() &&
|
||||
this->getDefaultUnitSystem() == data.getDefaultUnitSystem() &&
|
||||
this->getDataFile() == data.getDataFile() &&
|
||||
this->getInputPath() == data.getInputPath() &&
|
||||
this->unitSystemAccessCount() == data.unitSystemAccessCount();
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const Deck& deck) {
|
||||
DeckOutput out( os, 10 );
|
||||
deck.write( out );
|
||||
|
||||
Reference in New Issue
Block a user