Commit Graph

46 Commits

Author SHA1 Message Date
Jørgen Kvalsvik
0da5cadc75 RawRecords auto store, strings moved to RawRecord
The accumulated strings are moved into RawRecords, which reduces
execution time (rough measurements indicates 4-8%). To facilitate this,
RawRecords are stored directly in the vector in favour of via
shared_ptrs.
2016-03-22 08:58:48 +01:00
Jørgen Kvalsvik
f0ae5db131 opm-parser adoption of Deck automatic ownership
Since the Deck* family of classes have changed their interfaces to no
longer use shared_ptr, a lot of code broke. This patch fixes all
problems in tests, other signatures and accesses to now use the new Deck
interfaces.
2016-02-18 13:27:24 +01:00
Jørgen Kvalsvik
4b98943665 Replaces unecessary header includes with fwd decls
Every header is self-contained and includes only what it must to
function, relying on users include what they need in source files,
adopting a pay-what-you-use model (in particular for internal
dependencies).
2016-01-26 13:23:22 +01:00
Joakim Hove
1161e1098c Rewritten code generation:
With this commit the generation of built in keywords is completely
changed. The most important changes include:

  1) We have autogenerated a class for each keyword in the new
     ParserKeywords { ... } namespace.

  2) The autogenerated classes derive from ParserKeyword, and the
     default constructor will build of a fully initialized
     ParserKeyword instance, i.e. the keyword used to parse the EQUIL
     keyword can be instantiated as simple as:

         ParserKeywords::EQUIL kw;

  3) The generated keywords have built in static constants for keyword
     and item names, and item default values. That way it should be
     possible for the compiler to catch trivial errors like trying to
     access the keyword "PoRO"; also the the access to default values
     means that properties can be initialized without actually
     insantiating a DeckKeyword.

  4) Two new classes Generator/KeywordLoader and
     Generator/KeywordGenerator have been created, with the help of
     these classes the keyword generation code is significantly
     simplified.
2015-06-08 11:29:18 +02:00
Robert K
05af9e32b7 remove warnings, that is:
sizeType --> p_sizeType since it shadows a member method
trailing ;
comparison of signed and unsigned int
2015-02-13 14:19:24 +01:00
Andreas Lauser
0262b333fd make items which do not have a default un-defaultable
this was a much more common problem than it seemed initially...
2014-12-18 11:43:52 +01:00
Andreas Lauser
ea38a25af4 remove all trailing white space
this is just the result of

```
find -iname "*.[ch]pp" | xargs sed -i "s/ *$//"
find opm/parser/share/keywords -type f |  xargs sed -i "s/ *$//"
```

so if it causes conflicts with other patches, the others should get
priority. The rationale behind this patch is that some people tell
their editor to remove white space which leads to larger than
necessary patches...
2014-12-08 16:34:28 +01:00
Andreas Lauser
eccf3d4551 ParserItem: improve the equallity testing code and remove the defaultSet() method
but we still need the m_defaultSet member because NaN == NaN as well
as NaN != NaN...
2014-09-15 12:29:58 +02:00
Andreas Lauser
b72df6f406 make ParserItems always defaultable
i.e. remove the defaultSet() method and its friends. this is required
to be able to specify defaults in DATA items like grid properties or
saturation tables. e.g.

SGL
10*0.1 10* 10*0.2 /

would not be possible without this. If no meaningful default for an
item is defined, float and double items get NaN, int items get -1 and
string ones get an empty string. The hope is that if these values get
used in the simulation, they will make the result obviously
incorrect. (Whether a data point of an item was defaulted can be
queried using item->defaultApplied(index).)
2014-09-15 12:17:03 +02:00
Joakim Hove
bf35919c6f Default: Changed default handling in ParserItem
This is the first of several large commits changing several aspects of
the handling of defaults. The overall main purpose of these changes is
to protect against using non sensible values in the case the values have
not been sensibly specified in the deck. The changes in this commit
include:

 1. The "default default" values to be used when an item without an
    explicit default are defaulted are removed completely.

 2. If a ParserItem is queried for a default value when no default has
    been assigned it will raise an exception.
2014-09-03 10:37:00 +02:00
Joakim Hove
6c7b613111 Default: Implemented ParserxxxItem::scan() with template 2014-09-03 10:37:00 +02:00
Joakim Hove
8b2981283f Default: Updates to ParserItem::equal()
1. The boolean flag m_defaultSet() is included in the actual
    comparison.

 2. The compare functions is implemented as a functions template.
2014-09-03 10:37:00 +02:00
Arne Morten Kvarving
670e8b692b changed: don't use parameter names that conflicts with member function names
quells warnings (with gcc 4.8)
2014-05-15 14:46:16 +02:00
Joakim Hove
d5bf1726f2 Verified behaviour of defaults (i.e. *) for multivalued items. 2014-04-11 13:42:22 +02:00
Joakim Hove
f59fd25668 Added boolan flag scalar = true to DeckItem.
The purpose of this flag is to keep track of whether a keyword is
supposed to have only one element, i.e. scalar, or several. The
defaultApplied method only makes sense in the case of scalar items, this
method will now throw if it is called on a non-scalar item.
2014-04-11 13:42:22 +02:00
Joakim Hove
084fc24174 Changed parserItem::scan to return modifyable DeckItem - this is required to push dimension later. 2013-12-14 10:11:59 +01:00
Roland Kaufmann
f8c6bfbaf2 Change unintended compile-time polymorphism to dynamic
equals(ParserIntItem&) has a different signature than equals(ParserItem&),
thus the former method does *not* overload the latter. Virtual just means
then only means that you have created a *new* entry in the v-table. If
you call equals through a pointer/reference to the base class ParserItem,
the defined method in the derived class is not called, and we miss out the
test for the equal default value.

Instead, we should take an argument of the base type and use a dynamic
cast to the derived type. If this downcast fails, then they are not equal;
otherwise we have gotten ourselves a pointer to get the properly typed
default value.

We must use pointers instead of references; if we cast to a reference,
a bad_cast exception is thrown if the expression is not in the proper
type hierarchy.
2013-10-23 20:54:56 +02:00
Joakim Hove
0aa416675a ??? 2013-10-16 09:59:32 +02:00
Joakim Hove
2d68ebe94c Merge remote-tracking branch 'upstream/master' into track-default 2013-10-15 14:24:42 +02:00
Joakim Hove
49ac9f4568 ParserIntItem::scan() implemented with (temporary) specialized code 2013-10-14 21:30:17 +02:00
Joakim Hove
d1f0a9f5f7 Moved some tests around 2013-10-14 14:15:44 +02:00
Joakim Hove
d5b6e84f18 Fixed bug with string items with embedded space - using an ugly template specialization hack 2013-10-09 17:04:08 +02:00
Joakim Hove
0afbcfc6e4 sizeType is default set to SINGLE - and optional in Json config 2013-09-18 07:16:09 +02:00
Joakim Hove
3992a32efc Made sizeType : SINGLE default 2013-09-17 22:27:53 +02:00
Joakim Hove
79a59fc629 Added indent parameter to ParserKeyword::inlineNew() to beautify generated cpp source 2013-09-14 22:14:58 +02:00
Joakim Hove
9bc8090c08 Added parserItem method inlineNew() which will create a cpp source representation of self 2013-09-12 23:50:16 +02:00
Joakim Hove
6d0ed41b29 Added property m_defaultSet to track if the default value has been explicitly set 2013-09-12 12:13:32 +02:00
Joakim Hove
5284b4ff89 Added equal() method for the ParserItem classes 2013-09-12 10:58:44 +02:00
Kristian Flikka
0e5593dc9e Removed removed extra layer of scan / scan__ 2013-08-23 15:45:20 +02:00
Kristian Flikka
cdf16c747a Removed the expectedItems concept from the scan functions 2013-08-23 15:39:08 +02:00
Kristian Flikka
64fb9a6cee Removed expectedItems param from readFromRawRecord method in ParserItem 2013-08-23 14:43:17 +02:00
Kristian Flikka
771167c02e Removed ParserXItem's scan with expected elements. Only SINGLE and ALL is now allowed 2013-08-23 14:35:47 +02:00
Joakim Hove
6c582a4b82 Added JsonConfig constructor to ParserIntItem 2013-07-31 16:15:22 +02:00
Kristian Flikka
5fa04e5377 Added/implemented XStringItem for Parser and Deck, with tests. Added integration test for WWCT keyword. Moved DeckItem tests into type-specific files. Removed unused file. 2013-06-20 13:56:11 +02:00
Kristian Flikka
2cce97f115 Split parser function, to make more modular and testable. Moved integrationtests from ParserTests into Integration tests. 2013-06-18 10:28:30 +02:00
Kristian Flikka
7998a84b81 Made the ParserIntItem's scan return DeckItem, and put a virtual scan in ParserItem. The ParserRecord now has a simple, but functioning parse method 2013-05-24 10:09:59 +02:00
Kristian Flikka
7bfe185998 Started working on the flow RawRecord->ParserRecord->DeckRecord. DeckRecord has some containers now. 2013-05-23 12:42:59 +02:00
Joakim Hove
b6c1da8c17 Rewritten scan functionality to the BaseClass and template functions 2013-05-13 16:41:09 +02:00
Joakim Hove
0524ac040f ParserIntItem can handle sizeType == ALL 2013-05-12 21:38:14 +02:00
Joakim Hove
9e1b00ef63 The ParserIntItem::scan() function will push unused values back on the front of the RawRecord. 2013-05-10 13:56:41 +02:00
Joakim Hove
f516cc6833 Added default value to Parser. Rewrote the ParserIntItem::scan() method to use homemade C-sscanf obscurity from h..l 2013-05-09 14:18:36 +02:00
Joakim Hove
c963c7d768 Changed to use only enum for ItemSize. FIXED -> SCALAR with value 1 2013-05-09 12:17:00 +02:00
Kristian Flikka
a874d667db Added some tests 2013-05-08 15:50:20 +02:00
Kristian Flikka
2a331e1a3a ParserIntItem's scan function now supports ITEM_FIXED parsing 2013-05-08 15:29:58 +02:00
Kristian Flikka
2088c3e96d Simple scan implementation in ParserIntItem added. DeckIntItem now support push_back 2013-05-08 14:31:20 +02:00
Kristian Flikka
2d6e6842d6 Changed ParserItem from template based to a base-inheritance based system. Corresponds to and creates DeckItem objects 2013-05-07 21:55:49 +02:00