DeckRecord.hpp
Go to the documentation of this file.
1/*
2 Copyright 2013 Statoil ASA.
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef DECKRECORD_HPP
21#define DECKRECORD_HPP
22
23#include <string>
24#include <vector>
25#include <memory>
26#include <ostream>
27
29
30namespace Opm {
31
32 class DeckRecord {
33 public:
34 typedef std::vector< DeckItem >::const_iterator const_iterator;
35
36 DeckRecord() = default;
37 DeckRecord( std::vector< DeckItem >&& );
38
40
41 size_t size() const;
42 void addItem( DeckItem deckItem );
43
47
48 const DeckItem& getItem( size_t index ) const;
49 const DeckItem& getItem( const std::string& name ) const;
50 const DeckItem& getDataItem() const;
51
52 bool hasItem(const std::string& name) const;
53
54 template <class Item>
56 return getItem( Item::itemName );
57 }
58
59 template <class Item>
60 const DeckItem& getItem() const {
61 return getItem( Item::itemName );
62 }
63
66
67 void write(DeckOutput& writer) const;
68 void write_data(DeckOutput& writer) const;
69 friend std::ostream& operator<<(std::ostream& os, const DeckRecord& record);
70
71 bool equal(const DeckRecord& other, bool cmp_default, bool cmp_numeric) const;
72 bool operator==(const DeckRecord& other) const;
73 bool operator!=(const DeckRecord& other) const;
74
75 template<class Serializer>
76 void serializeOp(Serializer& serializer)
77 {
78 serializer.vector(m_items);
79 }
80
81 private:
82 std::vector< DeckItem > m_items;
83
84 };
85
86}
87#endif /* DECKRECORD_HPP */
88
const char *const name
Definition: cJSON.h:258
int index
Definition: cJSON.h:168
const char *const string
Definition: cJSON.h:170
Definition: DeckItem.hpp:37
Definition: DeckOutput.hpp:29
Definition: DeckRecord.hpp:32
void serializeOp(Serializer &serializer)
Definition: DeckRecord.hpp:76
DeckItem & getItem(const std::string &name)
void write(DeckOutput &writer) const
DeckRecord(std::vector< DeckItem > &&)
bool hasItem(const std::string &name) const
const DeckItem & getItem() const
Definition: DeckRecord.hpp:60
const_iterator begin() const
const DeckItem & getDataItem() const
const DeckItem & getItem(const std::string &name) const
size_t size() const
friend std::ostream & operator<<(std::ostream &os, const DeckRecord &record)
bool operator!=(const DeckRecord &other) const
bool equal(const DeckRecord &other, bool cmp_default, bool cmp_numeric) const
DeckItem & getItem(size_t index)
std::vector< DeckItem >::const_iterator const_iterator
Definition: DeckRecord.hpp:34
void write_data(DeckOutput &writer) const
bool operator==(const DeckRecord &other) const
DeckRecord()=default
void addItem(DeckItem deckItem)
static DeckRecord serializeObject()
const DeckItem & getItem(size_t index) const
DeckItem & getItem()
Definition: DeckRecord.hpp:55
DeckItem & getDataItem()
const_iterator end() const
Definition: Serializer.hpp:38
Definition: A.hpp:4