Files
opm-common/opm/parser/eclipse/Deck/Section.hpp
Jørgen Kvalsvik 7eb52f1023 Removes DeckKeyword's dependency on ParserKeyword
The completely constructed Deck isn't supposed to have any relationship
with the Parser structures (which are completely stateless in terms of
input data), and ParserKeyword in DeckKeyword was an anomaly. With
recent refactorings this lead to subtle lifetime issues.

This patch breaks this dependency and cleans up DeckKeyword accordingly,
while changing checkDeck to now take the parser as an additional
argument, to look up whether or not some DeckKeyword is in the right
section. This now also means that Parser* objects can be destroyed once
the Deck is created.

The Section::checkSectionTopology has been moved to Parser.cpp. It is a
temporary home for the feature to make the project compile nicely (i.e.
createKeywordList can be compiled as before, without introducing a
circular dependency on itself via Parser.cpp), until some proper cleanup
of the parser code has been done. It never really fully belonged in
Section.cpp anyway, so this is a first step in the direction of some
slight renaming.
2016-02-18 13:27:24 +01:00

96 lines
2.7 KiB
C++

/*
Copyright 2013 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SECTION_HPP
#define SECTION_HPP
#include <string>
#include <opm/parser/eclipse/Deck/Deck.hpp>
namespace Opm {
class UnitSystem;
class Parser;
class Section : public DeckView {
public:
using DeckView::const_iterator;
Section( const Deck& deck, const std::string& startKeyword );
const std::string& name() const;
static bool hasRUNSPEC( const Deck& );
static bool hasGRID( const Deck& );
static bool hasEDIT( const Deck& );
static bool hasPROPS( const Deck& );
static bool hasREGIONS( const Deck& );
static bool hasSOLUTION( const Deck& );
static bool hasSUMMARY( const Deck& );
static bool hasSCHEDULE( const Deck& );
// returns whether the deck has all mandatory sections and if all sections are in
// the right order
static bool checkSectionTopology(const Deck& deck,
const Parser&,
bool ensureKeywordSectionAffiliation = false);
private:
std::string section_name;
};
class RUNSPECSection : public Section {
public:
RUNSPECSection(const Deck& deck) : Section(deck, "RUNSPEC") {}
};
class GRIDSection : public Section {
public:
GRIDSection(const Deck& deck) : Section(deck, "GRID") {}
};
class EDITSection : public Section {
public:
EDITSection(const Deck& deck) : Section(deck, "EDIT") {}
};
class PROPSSection : public Section {
public:
PROPSSection(const Deck& deck) : Section(deck, "PROPS") {}
};
class REGIONSSection : public Section {
public:
REGIONSSection(const Deck& deck) : Section(deck, "REGIONS") {}
};
class SOLUTIONSection : public Section {
public:
SOLUTIONSection(const Deck& deck) : Section(deck, "SOLUTION") {}
};
class SUMMARYSection : public Section {
public:
SUMMARYSection(const Deck& deck) : Section(deck, "SUMMARY") {}
};
}
#endif // SECTION_HPP