Removed RawDeck class
This commit is contained in:
parent
54b8299897
commit
d5705d131e
@ -5,7 +5,6 @@ add_subdirectory(Deck/tests)
|
||||
add_subdirectory(IntegrationTests)
|
||||
|
||||
set( rawdeck_source
|
||||
RawDeck/RawDeck.cpp
|
||||
RawDeck/RawKeyword.cpp
|
||||
RawDeck/RawRecord.cpp )
|
||||
|
||||
|
@ -1,65 +0,0 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include "RawDeck.hpp"
|
||||
#include "RawConsts.hpp"
|
||||
|
||||
namespace Opm {
|
||||
|
||||
RawDeck::RawDeck() {
|
||||
}
|
||||
|
||||
void RawDeck::addKeyword(RawKeywordConstPtr keyword) {
|
||||
m_keywords.push_back(keyword);
|
||||
}
|
||||
|
||||
RawKeywordConstPtr RawDeck::getKeyword(size_t index) const {
|
||||
if (index < m_keywords.size())
|
||||
return m_keywords[index];
|
||||
else
|
||||
throw std::range_error("Index out of range");
|
||||
}
|
||||
|
||||
size_t RawDeck::size() const {
|
||||
return m_keywords.size();
|
||||
}
|
||||
|
||||
|
||||
/// Operator overload to write the content of the RawDeck to an ostream
|
||||
std::ostream& operator<<(std::ostream& os, const RawDeck& deck) {
|
||||
for (size_t i = 0; i < deck.size(); i++) {
|
||||
RawKeywordConstPtr keyword = deck.getKeyword(i);
|
||||
os << keyword->getKeywordName() << " -- Keyword\n";
|
||||
for (size_t i = 0; i < keyword->size(); i++) {
|
||||
RawRecordConstPtr rawRecord = keyword->getRecord(i);
|
||||
for (size_t j = 0; j < rawRecord->size(); j++) {
|
||||
os << rawRecord->getItem(j) << " ";
|
||||
}
|
||||
os << " / -- Data\n";
|
||||
}
|
||||
os << "\n";
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
RawDeck::~RawDeck() {
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
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 RAWDECK_HPP
|
||||
#define RAWDECK_HPP
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <opm/parser/eclipse/RawDeck/RawKeyword.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
/// Class representing the most high level structure, a deck. The RawDeck holds non parsed
|
||||
/// data, in the form of a list of RawKeywords. The order of the keywords is important, as this
|
||||
/// reflects the order they were read in from the eclipse file. The RawDeck forms the basis of the
|
||||
/// semantic parsing that comes after the RawDeck has been created from the eclipse file.
|
||||
|
||||
class RawDeck {
|
||||
public:
|
||||
|
||||
/// Constructor that requires information about the fixed record length keywords.
|
||||
/// All relevant keywords with a fixed number of records
|
||||
/// must be specified through the RawParserKeyword class. This is to be able to know how the records
|
||||
/// of the keyword is structured.
|
||||
|
||||
RawDeck();
|
||||
void addKeyword(RawKeywordConstPtr keyword);
|
||||
RawKeywordConstPtr getKeyword(size_t index) const;
|
||||
size_t size() const;
|
||||
|
||||
// This will move to Parser class when m_rawParserKeywords is moved.
|
||||
bool isKeywordFinished(RawKeywordConstPtr rawKeyword);
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& os, const RawDeck& deck);
|
||||
virtual ~RawDeck();
|
||||
|
||||
private:
|
||||
std::vector<RawKeywordConstPtr> m_keywords;
|
||||
|
||||
void processIncludeKeyword(RawKeywordConstPtr keyword, const boost::filesystem::path& dataFolderPath);
|
||||
static boost::filesystem::path verifyValidInputPath(const std::string& inputPath);
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<RawDeck> RawDeckPtr;
|
||||
typedef boost::shared_ptr<const RawDeck> RawDeckConstPtr;
|
||||
}
|
||||
|
||||
#endif /* RAWDECK_HPP */
|
||||
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#define BOOST_TEST_MODULE RawDeckTests
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <opm/parser/eclipse/RawDeck/RawDeck.hpp>
|
||||
#include <opm/parser/eclipse/RawDeck/RawKeyword.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
using namespace Opm;
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Initialize_NoThrow) {
|
||||
BOOST_CHECK_NO_THROW(RawDeck rawDeck);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(GetNumberOfKeywords_EmptyDeck_RetunsZero) {
|
||||
RawDeckPtr rawDeck(new RawDeck);
|
||||
BOOST_CHECK_EQUAL((unsigned) 0, rawDeck->size());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(GetKeyword_EmptyDeck_ThrowsExeption) {
|
||||
RawDeckPtr rawDeck(new RawDeck);
|
||||
BOOST_CHECK_THROW(rawDeck->getKeyword(0), std::range_error);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(addKeyword_withkeywords_keywordAdded) {
|
||||
RawDeckPtr rawDeck(new RawDeck());
|
||||
|
||||
RawKeywordPtr keyword(new RawKeyword("BJARNE"));
|
||||
rawDeck->addKeyword(keyword);
|
||||
BOOST_CHECK_EQUAL(keyword, rawDeck->getKeyword(0));
|
||||
|
||||
RawKeywordPtr keyword2(new RawKeyword("BJARNE2"));
|
||||
rawDeck->addKeyword(keyword2);
|
||||
BOOST_CHECK_EQUAL(keyword2, rawDeck->getKeyword(1));
|
||||
|
||||
BOOST_CHECK_EQUAL(2U, rawDeck->size());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user