Files
opm-common/opm/parser/eclipse/Deck/DeckKeyword.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

71 lines
1.8 KiB
C++

/*
* File: DeckKeyword.hpp
* Author: kflik
*
* Created on June 3, 2013, 12:55 PM
*/
#ifndef DECKKEYWORD_HPP
#define DECKKEYWORD_HPP
#include <string>
#include <vector>
#include <memory>
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
namespace Opm {
class ParserKeyword;
class DeckKeyword {
public:
typedef std::vector< DeckRecord >::const_iterator const_iterator;
DeckKeyword(const std::string& keywordName);
DeckKeyword(const std::string& keywordName, bool knownKeyword);
const std::string& name() const;
void setLocation(const std::string& fileName, int lineNumber);
const std::string& getFileName() const;
int getLineNumber() const;
size_t size() const;
void addRecord(DeckRecord&& record);
const DeckRecord& getRecord(size_t index) const;
DeckRecord& getRecord(size_t index);
const DeckRecord& getDataRecord() const;
void setDataKeyword(bool isDataKeyword = true);
bool isKnown() const;
bool isDataKeyword() const;
const std::vector<int>& getIntData() const;
const std::vector<double>& getRawDoubleData() const;
const std::vector<double>& getSIDoubleData() const;
const std::vector<std::string>& getStringData() const;
size_t getDataSize() const;
template <class Keyword>
bool isKeyword() const {
if (Keyword::keywordName == m_keywordName)
return true;
else
return false;
}
const_iterator begin() const;
const_iterator end() const;
private:
std::string m_keywordName;
std::string m_fileName;
int m_lineNumber;
std::vector< DeckRecord > m_recordList;
bool m_knownKeyword;
bool m_isDataKeyword;
};
}
#endif /* DECKKEYWORD_HPP */