Flow123d  release_2.2.0-914-gf1a3a4f
type_record.cc
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file type_record.cc
15  * @brief
16  */
17 
18 #include "input_type.hh"
19 #include "type_repository.hh"
22 #include "attribute_lib.hh"
23 
24 #include <boost/typeof/typeof.hpp>
25 #include <boost/algorithm/string.hpp>
26 #include <boost/functional/hash.hpp>
27 
28 namespace Input {
29 namespace Type {
30 
31 using namespace std;
32 
33 
34 /*******************************************************************
35  * implementation of Default
36  */
37 
39 : value_("OPTIONAL"), type_(no_default_optional_type), storage_(NULL)
40 {}
41 
42 Default::Default(const std::string & value)
44 {
45  boost::algorithm::trim(value_);
46 }
47 
48 
49 
50 Default::Default(enum DefaultType type, const std::string & value)
51 : value_(value), type_(type), storage_(NULL)
52 {}
53 
55 { TypeBase::TypeHash seed = 0;
56  boost::hash_combine(seed, "Default");
57  boost::hash_combine(seed, type_);
58  boost::hash_combine(seed, value_);
59  return seed;
60 }
61 
62 
63 bool Default::check_validity(std::shared_ptr<TypeBase> type) const
64 {
65  if ( storage_ ) return true;
66  if ( !has_value_at_declaration() ) return false;
67 
68  type->finish();
69 
70  try {
71  istringstream is("[\n" + value_ + "\n]");
73  reader.read_stream(is, Array(type), FileFormat::format_JSON);
74  storage_ = reader.get_storage()->get_item(0);
75  return true;
76  } catch ( Input::ReaderInternalBase::ExcNotJSONFormat &e ) {
77  THROW( ExcWrongDefaultJSON() << EI_DefaultStr( value_ ) << EI_TypeName(type->type_name())
78  << make_nested_ei(e) );
79  } catch ( Input::ReaderInternalBase::ExcInputError &e ) {
80  THROW( ExcWrongDefault() << EI_DefaultStr( value_ ) << EI_TypeName(type->type_name())
81  << make_nested_ei(e) );
82  }
83 }
84 
85 
86 Input::StorageBase *Default::get_storage(std::shared_ptr<TypeBase> type) const
87 {
88  if ( !storage_ ) this->check_validity(type);
89  return storage_;
90 }
91 
92 
93 
94 /**********************************************************************************
95  * implementation of Type::Record
96  */
97 
98 
100 : data_( std::make_shared<RecordData> ("EmptyRecord","") )
101 {
102  close();
103  finish();
104 }
105 
106 
107 
108 Record::Record(const Record & other)
109 : TypeBase( other ), data_(other.data_)
110 {}
111 
112 
113 
114 Record::Record(const string & type_name_in, const string & description)
115 : data_( std::make_shared<RecordData>(type_name_in, description) )
116 {
117  data_->declare_key("TYPE", std::make_shared<String>(), Default( "\""+type_name()+"\"" ),
118  "Sub-record Selection.", TypeBase::attribute_map());
119 }
120 
121 
123 {
124  TypeHash seed=0;
125  boost::hash_combine(seed, "Record");
126  data_->content_hash(seed);
127  return seed;
128 }
129 
130 
131 
132 Record &Record::allow_auto_conversion(const string &from_key) {
133  ASSERT(data_->auto_conversion_key_idx == -1)(from_key).error("auto conversion key is already set");
134  data_->auto_conversion_key_idx = 0;
135  data_->auto_conversion_key=from_key;
136 
137  return *this;
138 }
139 
140 
141 
143 
144  ASSERT( origin.is_closed() ).error();
145 
146  std::vector<Key>::iterator it = data_->keys.begin();
147  if (data_->keys.size() && it->key_ == "TYPE") it++; // skip TYPE key if exists
148 
149  int n_inserted = 0;
150  for(KeyIter pit=origin.data_->keys.begin(); pit != origin.data_->keys.end(); ++pit) {
151  Key tmp_key=*pit; // make temporary copy of the key
152  KeyHash key_h = key_hash(tmp_key.key_);
153 
154  tmp_key.derived = true;
155 
156  // we have to copy TYPE also since there should be place in storage for it
157  // however we change its Default to name of actual Record
158  if (tmp_key.key_=="TYPE")
159  tmp_key.default_=Default( "\""+type_name()+"\"" );
160 
161  // check for duplicate keys, override keys of the parent record by the child record
162  RecordData::key_to_index_const_iter kit = data_->key_to_index.find(key_h);
163  if (kit != data_->key_to_index.end()) {
164  // in actual record exists a key with same name as in parent record
165  // use values form the child record
166  Key *k = &(data_->keys[kit->second+n_inserted]); // indices in key_to_index are not yet updated
167 
168  tmp_key.key_ = k->key_;
169  tmp_key.description_ = k->description_;
170  tmp_key.type_ = k->type_;
171  tmp_key.default_ = k->default_;
172  tmp_key.derived = false;
173  k->key_ = ""; // mark original key for deletion
174  }
175 
176  data_->key_to_index[key_h] = tmp_key.key_index;
177 
178  it = data_->keys.insert(it, tmp_key)+1;
179  n_inserted++;
180  }
181  // delete duplicate keys and update key indices
182  for (unsigned int i=0; i<data_->keys.size(); i++) {
183  if (data_->keys[i].key_.compare("") == 0) {
184  data_->keys.erase( data_->keys.begin()+i);
185  i--;
186  } else {
187  data_->keys[i].key_index = i;
188  data_->key_to_index[key_hash( data_->keys[i].key_)] = i;
189  }
190  }
191 }
192 
193 
194 
196  ASSERT( parent.is_closed() )(parent.type_name()).error();
197  ASSERT( data_->keys.size() > 0 && data_->keys[0].key_ == "TYPE" )(this->type_name())
198  .error("Derived record must have defined TYPE key!");
199 
200  // check if parent exists in parent_vec_ vector
201  TypeHash hash = parent.content_hash();
202  for (auto &parent : data_->parent_vec_) {
203  if ( parent->content_hash() == hash ) {
204  return *this;
205  }
206  }
207 
208  // add Abstract to vector of parents
209  data_->parent_vec_.push_back( std::make_shared<Abstract>(parent) );
210 
211  return *this;
212 }
213 
214 
216  ASSERT( other.is_closed() )(other.type_name()).error();
217 
218  Record tmp(other);
219  make_copy_keys(tmp);
220 
221  return *this;
222 }
223 
224 
226  return data_->finish_status_;
227 }
228 
229 
230 bool Record::is_finished() const {
231  return (data_->finish_status_ != FinishStatus::none_) && (data_->finish_status_ != FinishStatus::in_perform_);
232 }
233 
234 
235 bool Record::is_closed() const {
236  return data_->closed_;
237 }
238 
239 
240 
241 
243 {
244  ASSERT(finish_type != FinishStatus::none_).error();
245  ASSERT(finish_type != FinishStatus::in_perform_).error();
246  ASSERT(data_->finish_status_ != FinishStatus::in_perform_)(this->type_name())(this->type_name()).error("Recursion in the IST element of type Record.");
247 
248  if (this->is_finished()) return data_->finish_status_;
249 
250  ASSERT(data_->closed_)(this->type_name()).error();
251 
252  data_->finish_status_ = FinishStatus::in_perform_;
253  for (vector<Key>::iterator it=data_->keys.begin(); it!=data_->keys.end(); it++)
254  {
255 
256  if (it->key_ != "TYPE") {
257  if (typeid( *(it->type_.get()) ) == typeid(Instance)) {
258  it->type_->finish(FinishStatus::generic_); // finish Instance object
259  it->type_ = it->type_->make_instance().first;
260  }
261  if ((finish_type != FinishStatus::generic_) && it->type_->is_root_of_generic_subtree())
262  THROW( ExcGenericWithoutInstance()
263  << EI_Object(it->type_->type_name())
264  << EI_TypeName(this->type_name()));
265  it->type_->finish(finish_type);
266  ASSERT(it->type_->is_finished()).error();
267  if (finish_type == FinishStatus::delete_) it->type_.reset();
268  }
269 
270  if (finish_type == FinishStatus::regular_) {
271  try {
272  it->default_.check_validity(it->type_);
273  } catch (ExcWrongDefaultJSON & e) {
274  e << EI_KeyName(it->key_);
275  throw;
276  } catch (ExcWrongDefault & e) {
277  e << EI_KeyName(it->key_);
278  throw;
279  }
280  }
281 
282  }
283 
284  // Check default values of autoconvertible records
285  if (data_->auto_conversion_key_idx != -1 ) {
286  data_->auto_conversion_key_idx=key_index(data_->auto_conversion_key);
287 
288  // check that all other obligatory keys have default values
289  for(KeyIter it=data_->keys.begin(); it != data_->keys.end(); ++it) {
290  const string &other_key = it->key_;
291  ASSERT(!it->default_.is_obligatory() || (int)(it->key_index) == data_->auto_conversion_key_idx)
292  (data_->auto_conversion_key_iter()->key_)(other_key)
293  .error("Finishing auto convertible Record from given key, but other obligatory key has no default value.");
294  }
295  }
296 
297  data_->finish_status_ = finish_type;
298  return (data_->finish_status_);
299 }
300 
301 
302 
304  data_->closed_=true;
306  for (auto &parent : data_->parent_vec_) {
307  parent->add_child(rec);
308  }
309 
310  return rec;
311 }
312 
313 
314 
315 string Record::type_name() const {
316  return data_->type_name_;
317 }
318 
319 
320 
321 string Record::class_name() const {
322  return "Record";
323 }
324 
325 
326 
327 bool Record::operator==(const TypeBase &other) const
328 { return typeid(*this) == typeid(other) &&
329  (type_name() == static_cast<const Record *>(&other)->type_name() );
330 }
331 
332 
334  finished_check();
335  return data_->auto_conversion_key_iter();
336 }
337 
338 
339 /*Record &Record::declare_type_key() {
340  ASSERT(data_->keys.size() == 0).error("Declaration of TYPE key must be carried as the first.");
341  data_->declare_key("TYPE", std::make_shared<String>(), Default::obligatory(),
342  "Sub-record selection.", TypeBase::attribute_map());
343  return *this;
344 }*/
345 
346 /*Record &Record::has_obligatory_type_key() {
347  ASSERT(! data_->parent_vec_.size()).error("Record with obligatory TYPE key can't be derived");
348  declare_type_key();
349  return *this;
350 }*/
351 
353  this->add_attribute_(key, value);
354  return *this;
355 }
356 
357 
359  Record rec = this->deep_copy();
360  ParameterMap parameter_map;
361  this->set_instance_data(rec, parameter_map, vec);
362 
363  return std::make_pair( std::make_shared<Record>(rec.close()), parameter_map );
364 }
365 
366 
368  // Replace keys of type Parameter
369  for (std::vector<Key>::iterator key_it=rec.data_->keys.begin(); key_it!=rec.data_->keys.end(); key_it++) {
370  if ( key_it->key_ != "TYPE" ) { // TYPE key isn't substituted
371  MakeInstanceReturnType inst = key_it->type_->make_instance(vec);
372  key_it->type_ = inst.first;
373  ParameterMap other_map = inst.second;
374  parameter_map.insert(other_map.begin(), other_map.end());
375  }
376  }
377  // Set attributes
378  rec.parameter_map_ = parameter_map;
379  rec.generic_type_hash_ = this->content_hash();
380 
381  this->set_generic_attributes(parameter_map);
382 }
383 
384 
386  Record rec = Record();
387  rec.data_ = std::make_shared<Record::RecordData>(*this->data_);
388  rec.data_->closed_ = false;
389  rec.data_->finish_status_ = FinishStatus::none_;
392  rec.parameter_map_ = this->parameter_map_;
393  return rec;
394 }
395 
396 
397 /*const Record &Record::add_parent(Abstract &parent) const {
398  ASSERT( parent.is_closed() )(parent.type_name()).error();
399 
400  // check if parent exists in parent_vec_ vector
401  TypeHash hash = parent.content_hash();
402  for (auto &parent : data_->parent_vec_) {
403  if ( parent->content_hash() == hash ) {
404  return *this;
405  }
406  }
407 
408  data_->parent_vec_.push_back( std::make_shared<Abstract>(parent) );
409 
410  // finish inheritance
411  ASSERT( data_->keys.size() > 0 && data_->keys[0].key_ == "TYPE" )(this->type_name())
412  .error("Derived record must have defined TYPE key!");
413  data_->keys[0].default_ = Default( "\""+type_name()+"\"" );
414 
415  return *this;
416 }*/
417 
418 
421  return *this;
422 }
423 
424 
425 
426 /**********************************************************************************
427  * implementation of Type::Record::RecordData
428  */
429 
430 Record::RecordData::RecordData(const string & type_name_in, const string & description)
431 :description_(description),
432  type_name_(type_name_in),
433  finish_status_(FinishStatus::none_),
434  closed_(false),
435  derived_(false),
436  auto_conversion_key_idx(-1) // auto conversion turned off
437 {
438 
439 }
440 
441 
443  if (auto_conversion_key_idx >= 0) return keys.begin() + auto_conversion_key_idx;
444  else return keys.end();
445 }
446 
447 
448 
449 void Record::RecordData::declare_key(const string &key,
450  std::shared_ptr<TypeBase> type,
451  const Default &default_value,
452  const string &description,
453  TypeBase::attribute_map key_attributes)
454 {
455  ASSERT(!closed_)(key)(this->type_name_).error();
456  // validity test of default value
457 
458  ASSERT( finish_status_ == FinishStatus::none_ )(key)(type_name_).error("Declaration of key in finished Record");
459  ASSERT( key=="TYPE" || TypeBase::is_valid_identifier(key) )(key)(type_name_).error("Invalid key identifier in declaration of Record");
460 
461  KeyHash key_h = key_hash(key);
463  if ( it == key_to_index.end() ) {
464  key_to_index.insert( std::make_pair(key_h, keys.size()) );
465  Key tmp_key = { (unsigned int)keys.size(), key, description, type, default_value, false, key_attributes };
466  keys.push_back(tmp_key);
467  } else {
468  ASSERT( keys[it->second].derived )(key)(type_name_).error("Re-declaration of the key in Record");
469  Key tmp_key = { it->second, key, description, type, default_value, false};
470  keys[ it->second ] = tmp_key;
471  }
472 
473 }
474 
476  boost::hash_combine(seed, type_name_);
477  boost::hash_combine(seed, description_);
478  boost::hash_combine(seed, auto_conversion_key);
479  for( const Key &key : keys) {
480  if (key.key_ != "TYPE") {
481  boost::hash_combine(seed, key.key_);
482  boost::hash_combine(seed, key.description_);
483  boost::hash_combine(seed, key.type_->content_hash() );
484  boost::hash_combine(seed, key.default_.content_hash() );
485  }
486  }
487 }
488 
489 
490 Record &Record::declare_key(const string &key, std::shared_ptr<TypeBase> type,
491  const Default &default_value, const string &description,
492  TypeBase::attribute_map key_attributes)
493 {
494  data_->declare_key(key, type, default_value, description, key_attributes);
495  return *this;
496 }
497 
498 
499 template <class KeyType>
500 Record &Record::declare_key(const string &key, const KeyType &type,
501  const Default &default_value, const string &description,
502  TypeBase::attribute_map key_attributes)
503 // this accept only lvalues - we assume that these are not local variables
504 {
505  // ASSERT MESSAGE: The type of declared keys has to be a class derived from TypeBase.
506  BOOST_STATIC_ASSERT( (boost::is_base_of<TypeBase, KeyType>::value) );
507  std::shared_ptr<TypeBase> type_copy = std::make_shared<KeyType>(type);
508  return declare_key(key, type_copy, default_value, description, key_attributes);
509 }
510 
511 
512 
513 template <class KeyType>
514 Record &Record::declare_key(const string &key, const KeyType &type,
515  const string &description,
516  TypeBase::attribute_map key_attributes)
517 {
518  return declare_key(key,type, Default::optional(), description, key_attributes);
519 }
520 
521 
522 
523 // explicit instantiation of template methods
524 
525 #define RECORD_DECLARE_KEY(TYPE) \
526 template Record & Record::declare_key<TYPE>(const string &key, const TYPE &type, const Default &default_value, const string &description, TypeBase::attribute_map key_attributes); \
527 template Record & Record::declare_key<TYPE>(const string &key, const TYPE &type, const string &description, TypeBase::attribute_map key_attributes)
528 
529 
530 RECORD_DECLARE_KEY(String);
531 RECORD_DECLARE_KEY(Integer);
532 RECORD_DECLARE_KEY(Double);
533 RECORD_DECLARE_KEY(Bool);
534 RECORD_DECLARE_KEY(FileName);
535 RECORD_DECLARE_KEY(Selection);
539 RECORD_DECLARE_KEY(AdHocAbstract);
540 RECORD_DECLARE_KEY(Parameter);
541 RECORD_DECLARE_KEY(Instance);
542 RECORD_DECLARE_KEY(Tuple);
543 
544 
545 
546 
547 } // closing namespace Type
548 } // closing namespace Input
549 
550 
std::shared_ptr< T > add_type(const T &type)
Add type to TypeRepository if doesn&#39;t exist there or get existing type with same TypeHash.
void read_stream(istream &in, const Type::TypeBase &root_type, FileFormat format)
This method actually reads the given stream in.
static bool is_valid_identifier(const string &key)
Check that a key is valid identifier.
Definition: type_base.cc:94
Base of classes for declaring structure of the input data.
Definition: type_base.hh:99
void make_copy_keys(Record &origin)
Auxiliary method that actually makes the copy of keys.
Definition: type_record.cc:142
void set_generic_attributes(ParameterMap param_map)
Definition: type_base.cc:174
virtual bool is_closed() const override
Returns true if data_ is closed.
Base class for nodes of a data storage tree.
Definition: storage.hh:68
void declare_key(const string &key, std::shared_ptr< TypeBase > type, const Default &default_value, const string &description, TypeBase::attribute_map key_attributes)
Declares a key and stores its type.
Definition: type_record.cc:449
void copy_attributes(attribute_map other_attributes)
Definition: type_base.cc:183
std::vector< struct Key >::const_iterator KeyIter
Public typedef of constant iterator into array of keys.
Definition: type_record.hh:216
virtual StorageBase * get_item(const unsigned int index) const
Definition: storage.cc:66
void content_hash(TypeBase::TypeHash &seed) const
Count hash of RecordData.
Definition: type_record.cc:475
bool root_of_generic_subtree_
flag is true if type should be root of generic subtree
Definition: type_base.hh:307
string type_name() const override
Implements Type::TypeBase::type_name.
Definition: type_record.cc:315
Reader for (slightly) modified input files.
Class Input::Type::Default specifies default value of keys of a Input::Type::Record.
Definition: type_record.hh:61
std::pair< std::shared_ptr< TypeBase >, ParameterMap > MakeInstanceReturnType
Return type of make_instance methods, contains instance of generic type and map of used parameters...
Definition: type_base.hh:117
Abstract linear system class.
Definition: equation.hh:37
DefaultType
Possible types of default values.
Definition: type_record.hh:67
std::map< KeyHash, unsigned int >::const_iterator key_to_index_const_iter
Container-like access to the database of valid keys.
Definition: type_record.hh:491
FinishStatus finish_status_
Record is finished when it is correctly derived (optional) and have correct shared pointers to types ...
Definition: type_record.hh:505
unsigned int key_index(const string &key) const
Interface to mapping key -> index in record.
Definition: type_record.hh:538
Helper class that stores data of generic types.
Definition: type_generic.hh:89
virtual TypeHash content_hash() const override
Implements TypeBase::content_hash.
Definition: type_record.cc:122
static KeyHash key_hash(const string &str)
Hash function.
Definition: type_base.hh:267
std::shared_ptr< TypeBase > type_
Type of the key.
Definition: type_record.hh:205
unsigned int key_index
Position inside the record.
Definition: type_record.hh:202
Record::KeyIter auto_conversion_key_iter() const
Returns iterator to auto-conversion key.
Definition: type_record.cc:442
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
Definition: asserts.hh:346
TypeBase::TypeHash content_hash() const
Hash of the Default specification, counted of type_ and value_.
Definition: type_record.cc:54
Input::StorageBase * storage_
Storage of default value read by reader.
Definition: type_record.hh:161
std::shared_ptr< attribute_map > attributes_
map of type attributes (e. g. input_type, name etc.)
Definition: type_base.hh:304
void add_attribute_(std::string name, json_string val)
Add attribute of given name to attribute map.
Definition: type_base.cc:135
StorageBase * get_storage()
Getter for root of the storage tree.
Record & close() const
Close the Record for further declarations of keys.
Definition: type_record.cc:303
Class for declaration of inputs sequences.
Definition: type_base.hh:345
static constexpr bool value
Definition: json.hpp:87
static TypeRepository & get_instance()
Return singleton instance of class.
string description_
Key description in context of particular Record type.
Definition: type_record.hh:204
ParameterMap parameter_map_
map of parameters if type is part of generic subtree
Definition: type_base.hh:313
Default()
Forbids default constructor.
Definition: type_record.cc:38
string KeyHash
The type of hash values used in associative array that translates key names to indices in Record and ...
Definition: type_base.hh:264
virtual Record & derive_from(Abstract &parent)
Method to derive new Record from an AbstractRecord parent.
Definition: type_record.cc:195
static Default optional()
The factory function to make an empty default value which is optional.
Definition: type_record.hh:124
Record()
Default constructor. Empty handle.
Definition: type_record.cc:99
virtual Record & allow_auto_conversion(const string &from_key)
Allows shorter input of the Record providing only value of the from_key given as the parameter...
Definition: type_record.cc:132
Record & add_attribute(std::string key, TypeBase::json_string value)
Add TYPE key as obligatory.
Definition: type_record.cc:352
bool operator==(const TypeBase &other) const override
Class comparison and Record type name comparision.
Definition: type_record.cc:327
bool closed_
If record is closed, we do not allow any further declare_key calls.
Definition: type_record.hh:508
Input::StorageBase * get_storage(std::shared_ptr< TypeBase > type) const
Return storage_, if storage_ is NULL, call check_validity method.
Definition: type_record.cc:86
virtual Record & root_of_generic_subtree()
Definition: type_record.cc:419
enum DefaultType type_
Type of the Default.
Definition: type_record.hh:160
const string description_
Description of the whole record type.
Definition: type_record.hh:497
string key_
Key identifier.
Definition: type_record.hh:203
TypeHash content_hash() const override
Implements TypeBase::content_hash.
Record & declare_key(const string &key, std::shared_ptr< TypeBase > type, const Default &default_value, const string &description, TypeBase::attribute_map key_attributes=TypeBase::attribute_map())
Declares a new key of the Record.
Definition: type_record.cc:490
friend class Abstract
Definition: type_record.hh:184
Class for declaration of polymorphic Record.
Record deep_copy() const
Create deep copy of Record (copy all data stored in shared pointers etc.)
Definition: type_record.cc:385
RECORD_DECLARE_KEY(String)
Internal data class.
Definition: type_record.hh:463
Structure for description of one key in record.
Definition: type_record.hh:201
bool has_value_at_declaration() const
Returns true if the default value is or will be available when someone tries to read the value...
Definition: type_record.hh:132
Record & copy_keys(const Record &other)
Copy keys from other record.
Definition: type_record.cc:215
void finished_check() const
Assertion for finished Type::Record.
Definition: type_record.hh:428
virtual string class_name() const override
Override Type::TypeBase::class_name.
Definition: type_record.cc:321
TypeHash generic_type_hash_
hash string of generic type if type is derived, or empty string
Definition: type_base.hh:310
FinishStatus finish(FinishStatus finish_type=FinishStatus::regular_) override
Finish declaration of the Record type.
Definition: type_record.cc:242
string value_
Stored value.
Definition: type_record.hh:159
RecordData(const string &type_name_in, const string &description)
Constructor.
Definition: type_record.cc:430
std::string auto_conversion_key
Name of key to use for auto conversion.
Definition: type_record.hh:522
int auto_conversion_key_idx
Index of auto convertible key.
Definition: type_record.hh:519
friend class Array
Definition: type_base.hh:315
std::string json_string
String stored in JSON format.
Definition: type_base.hh:105
bool is_closed() const override
Returns true if data_ is closed.
Definition: type_record.cc:235
Record type proxy class.
Definition: type_record.hh:182
bool check_validity(std::shared_ptr< TypeBase > type) const
Check validity of value_ using the JSON reader if default type is default_at_declaration.
Definition: type_record.cc:63
const string & value() const
Returns stored value. Possibly empty string.
Definition: type_record.hh:145
Default default_
Default, type and possibly value itself.
Definition: type_record.hh:206
std::vector< struct Key > keys
Keys in order as they where declared.
Definition: type_record.hh:494
std::shared_ptr< RecordData > data_
Data handle.
Definition: type_record.hh:527
virtual MakeInstanceReturnType make_instance(std::vector< ParameterPair > vec=std::vector< ParameterPair >()) override
Implements TypeBase::make_instance.
Definition: type_record.cc:358
EI_Nested make_nested_ei(Exc &e)
Definition: exceptions.hh:272
Default value given at declaration time.
Definition: type_record.hh:68
void set_instance_data(Record &rec, ParameterMap &parameter_map, std::vector< ParameterPair > vec)
Declares a TYPE key of the Record.
Definition: type_record.cc:367
std::size_t TypeHash
Type returned by content_hash methods.
Definition: type_base.hh:102
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Definition: exceptions.hh:53
std::map< KeyHash, unsigned int > key_to_index
Database of valid keys.
Definition: type_record.hh:489
const string type_name_
Name of the whole record type.
Definition: type_record.hh:499
bool is_finished() const override
Implements TypeBase::is_finished.
Definition: type_record.cc:230
KeyIter auto_conversion_key_iter() const
Returns iterator to auto-conversion key.
Definition: type_record.cc:333
FinishStatus finish_status() const override
Implements TypeBase::finish_status.
Definition: type_record.cc:225
virtual string type_name() const override
Implements Type::TypeBase::type_name.