Added class TableSchema with table metadata.
This commit is contained in:
@@ -114,6 +114,7 @@ EclipseState/Tables/VFPInjTable.cpp
|
||||
EclipseState/Tables/TableManager.cpp
|
||||
EclipseState/Tables/TableContainer.cpp
|
||||
EclipseState/Tables/ColumnSchema.cpp
|
||||
EclipseState/Tables/TableSchema.cpp
|
||||
EclipseState/Tables/TableIndex.cpp
|
||||
#
|
||||
EclipseState/Grid/GridProperty.cpp
|
||||
|
||||
50
opm/parser/eclipse/EclipseState/Tables/TableSchema.cpp
Normal file
50
opm/parser/eclipse/EclipseState/Tables/TableSchema.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
Copyright 2015 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 <utility>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
TableSchema::TableSchema()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TableSchema::addColumn(const ColumnSchema& column) {
|
||||
m_columns.insert( column.name() , column );
|
||||
}
|
||||
|
||||
|
||||
const ColumnSchema&& TableSchema::getColumn( const std::string& name ) const {
|
||||
return std::forward<const ColumnSchema>( m_columns.get( name ) );
|
||||
}
|
||||
|
||||
const ColumnSchema&& TableSchema::getColumn( size_t columnIndex ) const {
|
||||
return std::forward<const ColumnSchema>( m_columns.get( columnIndex) );
|
||||
}
|
||||
|
||||
size_t TableSchema::size() const {
|
||||
return m_columns.size();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
48
opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp
Normal file
48
opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright 2015 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 _TABLE_SCHEMA_HPP_
|
||||
#define _TABLE_SCHEMA_HPP_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Util/OrderedMap.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/ColumnSchema.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
class TableSchema {
|
||||
public:
|
||||
TableSchema();
|
||||
void addColumn(const ColumnSchema& column);
|
||||
const ColumnSchema&& getColumn( const std::string& name ) const;
|
||||
const ColumnSchema&& getColumn( size_t columnIndex ) const;
|
||||
|
||||
/* Number of columns */
|
||||
size_t size() const;
|
||||
private:
|
||||
OrderedMap<ColumnSchema> m_columns;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
foreach(tapp TableManagerTests TabdimsTests TableContainerTests
|
||||
ColumnSchemaTests)
|
||||
ColumnSchemaTests
|
||||
TableSchemaTests)
|
||||
|
||||
opm_add_test(run${tapp} SOURCES ${tapp}.cpp
|
||||
LIBRARIES opmparser ${Boost_LIBRARIES})
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
Copyright (C) 2015 by 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/>.
|
||||
*/
|
||||
|
||||
#define BOOST_TEST_MODULE TableSchemaTests
|
||||
|
||||
#include <opm/common/utility/platform_dependent/disable_warnings.h>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
|
||||
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/ColumnSchema.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/TableEnums.hpp>
|
||||
|
||||
using namespace Opm;
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE( CreateTest ) {
|
||||
TableSchema schema;
|
||||
ColumnSchema col1("Name1" , Table::INCREASING , Table::DEFAULT_NONE);
|
||||
ColumnSchema col2("Name2" , Table::INCREASING , Table::DEFAULT_NONE);
|
||||
BOOST_CHECK_EQUAL( 0 , schema.size( ) );
|
||||
|
||||
schema.addColumn( col1 );
|
||||
BOOST_CHECK_EQUAL( 1 , schema.size( ) );
|
||||
|
||||
schema.addColumn( col2 );
|
||||
BOOST_CHECK_EQUAL( 2 , schema.size( ) );
|
||||
|
||||
BOOST_CHECK_THROW( schema.getColumn( "NO/NOT/THIS/COLUMN" ) , std::invalid_argument );
|
||||
BOOST_CHECK_THROW( schema.getColumn( 5 ) , std::invalid_argument );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user