Flow123d  JS_before_hm-1804-gf2ad740aa
type_base.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_base.cc
15  * @brief
16  */
17 
18 #include <limits>
19 #include <ios>
20 #include <map>
21 #include <vector>
22 #include <string>
23 #include <iomanip>
24 
25 #include "system/system.hh"
26 
27 #include <type_traits>
28 #include <boost/tokenizer.hpp>
29 #include <boost/algorithm/string.hpp>
30 #include <boost/functional/hash.hpp>
31 #include <boost/pointer_cast.hpp>
32 
33 
34 #include "input_type.hh"
35 #include "type_output.hh"
36 #include "type_repository.hh"
37 #include "attribute_lib.hh"
39 
40 #include <stdint.h> // for int64_t
41 #include <boost/algorithm/string.hpp>
42 //
43 
44 #include <boost/functional/hash/hash.hpp> // for hash_com...
45 
46 #include <memory> // for shared_ptr
47 #include <ostream> // for operator<<
48 #include <typeinfo> // for type_info
49 #include <utility> // for make_pair
50 #include "input/json_spirit/json_spirit_error_position.h" // for Error_po...
51 #include "input/json_spirit/json_spirit_reader.h" // for read_or_...
52 #include "input/json_spirit/json_spirit_value.h" // for mValue
53 #include "input/type_base.hh" // for TypeBase
54 #include "input/type_generic.hh" // for ExcGener...
55 #include "system/asserts.hh" // for Assert
56 #include "system/exceptions.hh" // for ExcGener...
57 #include "system/file_path.hh" // for FilePath
58 namespace Input { namespace Type { class Abstract; } }
59 namespace Input { namespace Type { class Record; } }
60 namespace Input { namespace Type { class Selection; } }
61 namespace Input { namespace Type { class Tuple; } }
62 
63 
64 
65 namespace Input {
66 namespace Type {
67 
68 using namespace std;
69 
70 
71 
72 /*******************************************************************
73  * implementation of TypeBase
74  */
75 
76 
77 
79 : attributes_( std::make_shared<attribute_map>() ), root_of_generic_subtree_(false),
80  generic_type_hash_(TypeBase::none_hash) {}
81 
82 
83 
85 : attributes_(other.attributes_), root_of_generic_subtree_(other.root_of_generic_subtree_),
86  generic_type_hash_(other.generic_type_hash_), parameter_map_(other.parameter_map_) {}
87 
88 
89 
91 
92 
93 bool TypeBase::is_valid_identifier(const string& key) {
94  namespace ba = boost::algorithm;
95  return ba::all( key, ba::is_lower() || ba::is_digit() || ba::is_any_of("_") );
96 }
97 
98 
99 string TypeBase::desc() const {
100  stringstream ss;
101  ss << OutputText(this);
102  return ss.str();
103 }
104 
105 
106 
108  // mark unfinished types as deleted
114 
115  // check and remove deleted types
121 }
122 
123 
124 
125  std::string TypeBase::hash_str(TypeHash hash) {
126  stringstream ss;
127  ss << "\"" << std::hex << hash << "\"";
128  return ss.str();
129 }
130 
131 
132 
133 
134 void TypeBase::add_attribute_(std::string name, json_string val) {
135  ASSERT(validate_json(val))(name)(val).error("Invalid JSON format of attribute");
136  (*attributes_)[name] = val;
137 }
138 
139 
141  try {
142  json_spirit::mValue node;
143  json_spirit::read_or_throw( str, node);
144  return true;
145  } catch (json_spirit::Error_position &e ) {
146  return false;
147  }
148 }
149 
150 
152  std::stringstream ss;
153  ss << "{";
154  for (ParameterMap::iterator it=parameter_map.begin(); it!=parameter_map.end(); it++) {
155  if (it != parameter_map.begin()) ss << "," << endl;
156  ss << "\"" << (*it).first << "\" : " << TypeBase::hash_str( (*it).second );
157  }
158  ss << "}";
159  return ss.str();
160 }
161 
163  stringstream ss;
164  ss << "[ ";
165  for (ParameterMap::iterator it=parameter_map.begin(); it!=parameter_map.end(); it++) {
166  if (it != parameter_map.begin()) ss << ", ";
167  ss << "\"" << it->first << "\"";
168  }
169  ss << " ]";
170  return ss.str();
171 }
172 
174  // check if the type is really generic (it may be non-generic even if part of a generic subtree)
175  if (parameter_map.size() > 0)
179 }
180 
181 
182 void TypeBase::copy_attributes(attribute_map other_attributes) {
183  attributes_->clear();
184  for(auto &item : other_attributes) {
185  if (item.first[0] != '_') // not internal attribute
186  attributes_->insert(item);
187  }
188 }
189 
190 
192  return FinishStatus::regular_;
193 }
194 
195 
196 bool TypeBase::is_finished() const {
197  return true;
198 }
199 
200 
201 bool TypeBase::is_closed() const {
202  return true;
203 }
204 
205 
206 string TypeBase::type_name() const {
207  return "TypeBase";
208 }
209 
210 
211 string TypeBase::class_name() const {
212  return "TypeBase";
213 }
214 
215 
217  ASSERT((finish_type != FinishStatus::none_) && (finish_type != FinishStatus::in_perform_)).error();
218  return finish_type;
219 }
220 
221 
222 bool TypeBase::operator==(const TypeBase &other) const {
223  return typeid(*this) == typeid(other);
224 }
225 
226 bool TypeBase::operator!=(const TypeBase & other) const {
227  return ! (*this == other);
228 }
229 
230 
231 
232 
233 
234 
235 
236 
237 
238 
239 std::ostream& operator<<(std::ostream& stream, const TypeBase& type) {
240  return ( stream << OutputText(&type) );
241 }
242 
243 
244 
245 /**********************************************************************************
246  * implementation of Type::Array
247  */
248 
250 {
251  TypeHash seed=0;
252  boost::hash_combine(seed, type_name());
253  boost::hash_combine(seed, data_->lower_bound_);
254  boost::hash_combine(seed, data_->upper_bound_);
255  boost::hash_combine(seed, data_->type_of_values_->content_hash() );
256  return seed;
257 }
258 
259 
261  return data_->finish(finish_type);
262 }
263 
264 
265 
266 Array::ArrayData::ArrayData(unsigned int min_size, unsigned int max_size)
267 : lower_bound_(min_size), upper_bound_(max_size), finish_status(FinishStatus::none_)
268 {}
269 
270 
272 {
273  ASSERT(finish_type != FinishStatus::none_).error();
274  ASSERT(finish_type != FinishStatus::in_perform_).error();
275  ASSERT(finish_status != FinishStatus::in_perform_).error("Recursion in the IST element: array_of_" + type_of_values_->type_name());
276 
278 
279 
281 
282  if (typeid( *(type_of_values_.get()) ) == typeid(Instance)) {
283  type_of_values_->finish(FinishStatus::generic_); // finish Instance object
284  type_of_values_ = type_of_values_->make_instance().first;
285  }
286  if ((finish_type != FinishStatus::generic_) && type_of_values_->is_root_of_generic_subtree())
287  THROW( ExcGenericWithoutInstance() << EI_Object(type_of_values_->type_name()) );
288 
289  type_of_values_->finish(finish_type);
290  ASSERT(type_of_values_->is_finished()).error();
291  if (finish_type == FinishStatus::delete_) type_of_values_.reset();
292  finish_status = finish_type;
293  return (finish_status);
294 }
295 
296 
297 
298 string Array::type_name() const {
299  return "array_of_" + data_->type_of_values_->type_name();
300 }
301 
302 
303 
304 string Array::class_name() const {
305  return "Array";
306 }
307 
308 
309 
310 bool Array::operator==(const TypeBase &other) const {
311  return typeid(*this) == typeid(other) &&
312  (*data_->type_of_values_ == static_cast<const Array *>(&other)->get_sub_type() );
313 }
314 
315 
316 
318  // Create copy of array, we can't set type from parameter vector directly (it's TypeBase that is not allowed)
319  Array arr = this->deep_copy();
320  // Replace parameter stored in type_of_values_
321  MakeInstanceReturnType inst = arr.data_->type_of_values_->make_instance(vec);
322  arr.data_->type_of_values_ = inst.first;
323  ParameterMap parameter_map = inst.second;
324  // Copy attributes
326 
327  // Set parameters as attribute
328  json_string val = this->print_parameter_map_to_json(parameter_map);
329  ASSERT(this->validate_json(val))(val).error("Invalid JSON format of attribute 'parameters'.");
330  arr.parameter_map_ = parameter_map;
331  arr.generic_type_hash_ = this->content_hash();
332 
333  return std::make_pair( std::make_shared<Array>(arr), parameter_map );
334 }
335 
336 
338  Array arr = Array(Integer()); // Type integer will be overwritten
339  arr.data_ = std::make_shared<Array::ArrayData>(*this->data_);
340  arr.data_->finish_status = FinishStatus::none_;
341  return arr;
342 }
343 
344 
345 Array::Array(std::shared_ptr<TypeBase> type, unsigned int min_size, unsigned int max_size)
346 : data_(std::make_shared<ArrayData>(min_size, max_size))
347 {
348  ASSERT_LE(min_size, max_size).error("Wrong limits for size of Input::Type::Array");
349  ASSERT(type->is_closed()).error();
350 
351  data_->type_of_values_ = type;
352 }
353 
354 
355 /// Override @p Type::TypeBase::finish_status.
357  return data_->finish_status; }
358 
359 
360 bool Array::is_finished() const {
361  return (data_->finish_status != FinishStatus::none_) && (data_->finish_status != FinishStatus::in_perform_);
362 }
363 
364 
365 /**********************************************************************************
366  * implementation and explicit instantiation of Array constructor template
367  */
368 
369 template <class ValueType>
370 Array::Array(const ValueType &type, unsigned int min_size, unsigned int max_size)
371 : Array(std::static_pointer_cast<TypeBase>( std::make_shared<ValueType>(type) ), min_size, max_size)
372 {
373  static_assert(std::is_base_of<TypeBase, ValueType >::value, "The type of declared keys has to be a class derived from TypeBase.");
374 }
375 
376 // explicit instantiation
377 
378 #define ARRAY_CONSTRUCT(TYPE) \
379 template Array::Array(const TYPE &type, unsigned int min_size, unsigned int max_size)
380 
381 ARRAY_CONSTRUCT(String);
382 ARRAY_CONSTRUCT(Integer);
383 ARRAY_CONSTRUCT(Double);
384 ARRAY_CONSTRUCT(Bool);
385 ARRAY_CONSTRUCT(FileName);
386 ARRAY_CONSTRUCT(Selection);
387 ARRAY_CONSTRUCT(Array);
388 ARRAY_CONSTRUCT(Record);
389 ARRAY_CONSTRUCT(Tuple);
390 ARRAY_CONSTRUCT(Abstract);
391 ARRAY_CONSTRUCT(Parameter);
392 ARRAY_CONSTRUCT(Instance);
393 
394 
395 /**********************************************************************************
396  * implementation of Type::Scalar ... and descendants.
397  */
398 
399 /**********************************************************************************
400  * implementation of Type::Bool
401  */
402 
403 
405 {
406  TypeHash seed=0;
407  boost::hash_combine(seed, type_name());
408  return seed;
409 }
410 
411 
412 string Bool::type_name() const {
413  return "Bool";
414 }
415 
416 
417 string Bool::class_name() const {
418  return "Bool";
419 }
420 
421 
423  return std::make_pair( std::make_shared<Bool>(*this), ParameterMap() );
424 }
425 
426 /**********************************************************************************
427  * implementation of Type::Integer
428  */
429 
430 Integer::Integer(int lower_bound, int upper_bound)
431 : lower_bound_(lower_bound), upper_bound_(upper_bound)
432 {}
433 
434 
435 
437 {
438  TypeHash seed=0;
439  boost::hash_combine(seed, type_name());
440  boost::hash_combine(seed, lower_bound_);
441  boost::hash_combine(seed, upper_bound_);
442  return seed;
443 }
444 
445 
446 
447 bool Integer::match(std::int64_t value) const {
448  return ( value >=lower_bound_ && value <= upper_bound_);
449 }
450 
451 
452 
453 string Integer::type_name() const {
454  return "Integer";
455 }
456 
457 
458 string Integer::class_name() const {
459  return "Integer";
460 }
461 
462 
464  return std::make_pair( std::make_shared<Integer>(*this), ParameterMap() );
465 }
466 
467 
468 /**********************************************************************************
469  * implementation of Type::Double
470  */
471 
472 
473 Double::Double(double lower_bound, double upper_bound)
474 : lower_bound_(lower_bound), upper_bound_(upper_bound)
475 {}
476 
477 
479 {
480  TypeHash seed=0;
481  boost::hash_combine(seed, type_name());
482  boost::hash_combine(seed, lower_bound_);
483  boost::hash_combine(seed, upper_bound_);
484  return seed;
485 }
486 
487 
488 
489 bool Double::match(double value) const {
490  return ( value >=lower_bound_ && value <= upper_bound_);
491 }
492 
493 
494 
495 string Double::type_name() const {
496  return "Double";
497 }
498 
499 
500 string Double::class_name() const {
501  return "Double";
502 }
503 
504 
506  return std::make_pair( std::make_shared<Double>(*this), ParameterMap() );
507 }
508 
509 
510 /**********************************************************************************
511  * implementation of Type::FileName
512  */
513 
515 
516 
517 
518 FileName::FileName(enum ::FilePath::FileType type)
519 : type_(type)
520 {}
521 
522 
523 
525 {
526  return FileName(::FilePath::input_file);
527 }
528 
529 
530 
532 {
534 }
535 
536 
537 
539 {
540  TypeHash seed=0;
541  boost::hash_combine(seed, type_name());
542  boost::hash_combine(seed, type_);
543  return seed;
544 }
545 
546 
547 
548 
549 
550 string FileName::type_name() const {
551  switch (type_) {
552  case ::FilePath::input_file:
553  return "FileName_input";
554  case ::FilePath::output_file:
555  return "FileName_output";
556  default:
557  return "FileName";
558  }
559 }
560 
561 
562 string FileName::class_name() const {
563  return "FileName";
564 }
565 
566 
567 
568 bool FileName::match(const string &str) const {
569  return (type_ == ::FilePath::input_file) || (str[0] != DIR_DELIMITER); // output files can not be absolute
570 }
571 
572 
573 
575  return std::make_pair( std::make_shared<FileName>(*this), ParameterMap() );
576 }
577 
578 
579 
581  return type_;
582 }
583 
584 
585 
586 
587 bool FileName::operator==(const TypeBase &other) const
588 {
589  return typeid(*this) == typeid(other) &&
590  (type_== static_cast<const FileName *>(&other)->get_file_type() );
591 }
592 
593 
594 /**********************************************************************************
595  * implementation of Type::String
596  */
597 
598 
600 {
601  TypeHash seed=0;
602  boost::hash_combine(seed, type_name());
603  return seed;
604 }
605 
606 
607 
608 string String::type_name() const {
609  return "String";
610 }
611 
612 
613 
614 string String::class_name() const {
615  return "String";
616 }
617 
618 
619 
620 bool String::match(FMT_UNUSED const string &str) const {
621  return true;
622 }
623 
624 
625 
627  return std::make_pair( std::make_shared<String>(*this), ParameterMap() );
628 }
629 
630 
631 
632 } // closing namespace Type
633 } // closing namespace Input
634 
635 
636 
Input::Type::String::type_name
virtual string type_name() const override
Implements Type::TypeBase::type_name.
Definition: type_base.cc:608
Input::Type::Double::make_instance
MakeInstanceReturnType make_instance(std::vector< ParameterPair > vec=std::vector< ParameterPair >()) override
Implements TypeBase::make_instance.
Definition: type_base.cc:505
Input::Type::FileName
Class for declaration of the input data that are file names.
Definition: type_base.hh:612
Input::Type::in_perform_
@ in_perform_
Definition: type_base.hh:76
Armor::vec
ArmaVec< double, N > vec
Definition: armor.hh:885
Input::Type::FinishStatus
FinishStatus
Definition: type_base.hh:74
FilePath::FileType
FileType
Possible types of file.
Definition: file_path.hh:67
Input::Type::FileName::type_
::FilePath::FileType type_
The type of file (input or output).
Definition: type_base.hh:656
Input::Type::TypeBase::copy_attributes
void copy_attributes(attribute_map other_attributes)
Definition: type_base.cc:182
Input::Type::Integer::type_name
string type_name() const override
Implements Type::TypeBase::type_name.
Definition: type_base.cc:453
Input::Type::Integer::upper_bound_
std::int64_t upper_bound_
Maximal value of Integer.
Definition: type_base.hh:522
Input
Abstract linear system class.
Definition: balance.hh:40
Input::Type::String::content_hash
TypeHash content_hash() const override
Implements TypeBase::content_hash.
Definition: type_base.cc:599
Input::Type::TypeBase::is_finished
virtual bool is_finished() const
Definition: type_base.cc:196
ASSERT
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
Definition: asserts.hh:347
Input::Type::FileName::match
bool match(const string &str) const override
Checks relative output paths.
Definition: type_base.cc:568
Input::Type::TypeBase::validate_json
bool validate_json(json_string str) const
Check if str is valid JSON string.
Definition: type_base.cc:140
Input::Type::Integer::class_name
string class_name() const override
Override Type::TypeBase::class_name.
Definition: type_base.cc:458
Input::Type::Array::data_
std::shared_ptr< ArrayData > data_
Handle to the actual array data.
Definition: type_base.hh:429
Input::Type::Integer::content_hash
TypeHash content_hash() const override
Implements TypeBase::content_hash.
Definition: type_base.cc:436
Input::Type::Array::ArrayData::finish
FinishStatus finish(FinishStatus finish_type=FinishStatus::regular_)
Finishes initialization of the ArrayData.
Definition: type_base.cc:271
Input::Type::Array::class_name
string class_name() const override
Override Type::TypeBase::class_name.
Definition: type_base.cc:304
file_path.hh
Input::Type::Array::Array
Array()
Forbids default constructor in order to prevent empty data_.
Input::Type::Integer
Class for declaration of the integral input data.
Definition: type_base.hh:483
asserts.hh
Definitions of ASSERTS.
Input::Type::TypeBase::MakeInstanceReturnType
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:111
Input::Type::TypeBase::add_attribute_
void add_attribute_(std::string name, json_string val)
Add attribute of given name to attribute map.
Definition: type_base.cc:134
Input::Type::TypeBase::finish_status
virtual FinishStatus finish_status() const
Returns true if the type is fully specified and ready for read access.
Definition: type_base.cc:191
Input::TypeRepository::get_instance
static TypeRepository & get_instance()
Return singleton instance of class.
Definition: type_repository.hh:59
Input::Type::Double::type_name
string type_name() const override
Implements Type::TypeBase::type_name.
Definition: type_base.cc:495
value
static constexpr bool value
Definition: json.hpp:87
Input::Type::TypeBase::class_name
virtual string class_name() const
Returns an identification of the class. Useful for output of the documentation.
Definition: type_base.cc:211
Input::Type::Array::finish
FinishStatus finish(FinishStatus finish_type=FinishStatus::regular_) override
Finishes initialization of the Array type because of lazy evaluation of type_of_values.
Definition: type_base.cc:260
Input::Type::none_
@ none_
Definition: type_base.hh:75
Input::Type::delete_
@ delete_
Definition: type_base.hh:79
THROW
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Definition: exceptions.hh:53
Input::Type::Bool::make_instance
MakeInstanceReturnType make_instance(std::vector< ParameterPair > vec=std::vector< ParameterPair >()) override
Implements TypeBase::make_instance.
Definition: type_base.cc:422
std::vector
Definition: doxy_dummy_defs.hh:7
Input::Type::FileName::output
static FileName output()
The factory function for declaring type FileName for input files.
Definition: type_base.cc:531
system.hh
Input::Type::FileName::type_name
string type_name() const override
Implements Type::TypeBase::type_name.
Definition: type_base.cc:550
Input::Type::TypeBase::finish
virtual FinishStatus finish(FinishStatus finish_type=FinishStatus::regular_)
Finish method. Finalize construction of "Lazy types": Record, Selection, Abstract and generic type.
Definition: type_base.cc:216
Input::Type::Double::Double
Double(double lower_bound=-std::numeric_limits< double >::max(), double upper_bound=std::numeric_limits< double >::max())
Constructor.
Definition: type_base.cc:473
type_base.hh
Input::Type::Array::ArrayData::ArrayData
ArrayData(unsigned int min_size, unsigned int max_size)
Constructor.
Definition: type_base.cc:266
json_spirit::Value_impl
Definition: json_spirit_value.h:38
Input::TypeRepository::reset_deleted_types
void reset_deleted_types()
Reset and remove types marked as deleted during finish.
Definition: type_repository.hh:141
exceptions.hh
Input::Type::String::class_name
string class_name() const override
Override Type::TypeBase::class_name.
Definition: type_base.cc:614
Input::Type::Double::upper_bound_
double upper_bound_
Maximal value of Integer.
Definition: type_base.hh:569
Input::Type::TypeBase::parameter_map_
ParameterMap parameter_map_
map of parameters if type is part of generic subtree
Definition: type_base.hh:307
Input::Type::TypeBase::attributes_
std::shared_ptr< attribute_map > attributes_
map of type attributes (e. g. input_type, name etc.)
Definition: type_base.hh:298
Input::Type::TypeBase::TypeBase
TypeBase()
The default constructor.
Definition: type_base.cc:78
Input::Type::Bool::type_name
string type_name() const override
Implements Type::TypeBase::type_name.
Definition: type_base.cc:412
Input::Type::Integer::Integer
Integer(int lower_bound=std::numeric_limits< int >::min(), int upper_bound=std::numeric_limits< int >::max())
Constructor.
Definition: type_base.cc:430
Input::Type::Integer::make_instance
MakeInstanceReturnType make_instance(std::vector< ParameterPair > vec=std::vector< ParameterPair >()) override
Implements TypeBase::make_instance.
Definition: type_base.cc:463
json_spirit.h
attribute_lib.hh
Input::Type::Integer::lower_bound_
std::int64_t lower_bound_
Minimal value of Integer.
Definition: type_base.hh:521
type_generic.hh
Input::Type::TypeBase::is_closed
virtual bool is_closed() const
Returns true if the type is closed.
Definition: type_base.cc:201
Input::Type::Array::is_finished
bool is_finished() const override
Override Type::TypeBase::is_finished.
Definition: type_base.cc:360
Input::Type::FileName::operator==
bool operator==(const TypeBase &other) const override
Comparison of types.
Definition: type_base.cc:587
Input::Type::regular_
@ regular_
Definition: type_base.hh:77
Input::Type::FileName::content_hash
TypeHash content_hash() const override
Implements TypeBase::content_hash.
Definition: type_base.cc:538
json_spirit::read_or_throw
void read_or_throw(const std::string &s, mValue &value)
Definition: json_spirit_reader.cpp:81
Input::Type::Instance
Helper class that stores data of generic types.
Definition: type_generic.hh:89
Input::Type::Bool::class_name
string class_name() const override
Override Type::TypeBase::class_name.
Definition: type_base.cc:417
Input::Type::Integer::match
bool match(std::int64_t value) const
Check valid value of Integer.
Definition: type_base.cc:447
Input::Type::Array::ArrayData
Actual data of the Array.
Definition: type_base.hh:347
Input::Type::Bool::content_hash
TypeHash content_hash() const override
Implements TypeBase::content_hash.
Definition: type_base.cc:404
type_repository.hh
Input::Type::TypeBase::generic_type_hash_
TypeHash generic_type_hash_
hash string of generic type if type is derived, or empty string
Definition: type_base.hh:304
Input::Type::Array::finish_status
FinishStatus finish_status() const override
Override Type::TypeBase::finish_status.
Definition: type_base.cc:356
std::map< std::string, json_string >
Input::Type::Array::type_name
string type_name() const override
Implements Type::TypeBase::type_name.
Definition: type_base.cc:298
Input::Type::FileName::input
static FileName input()
The factory function for declaring type FileName for input files.
Definition: type_base.cc:524
Input::Type::TypeBase::ParameterMap
std::map< std::string, TypeHash > ParameterMap
Defines map of used parameters.
Definition: type_base.hh:109
Input::Type
Definition: balance.hh:41
Input::Type::Array::content_hash
TypeHash content_hash() const override
Implements TypeBase::content_hash.
Definition: type_base.cc:249
Input::Type::String::make_instance
virtual MakeInstanceReturnType make_instance(std::vector< ParameterPair > vec=std::vector< ParameterPair >()) override
Implements TypeBase::make_instance.
Definition: type_base.cc:626
type_output.hh
Input::Type::Array::operator==
bool operator==(const TypeBase &other) const override
Implements Type::TypeBase::operator== Compares also subtypes.
Definition: type_base.cc:310
Input::Type::String::match
virtual bool match(const string &value) const
Definition: type_base.cc:620
input_type.hh
Input::Type::Attribute::root_of_generic_subtree
static string root_of_generic_subtree()
Definition: attribute_lib.hh:45
Input::Type::Double::match
bool match(double value) const
Returns true if the given integer value conforms to the Type::Double bounds.
Definition: type_base.cc:489
Input::Type::TypeBase::is_root_of_generic_subtree
bool is_root_of_generic_subtree() const
Indicates if type is marked with flag root_of_generic_subtree_.
Definition: type_base.hh:232
Input::Type::Array
Class for declaration of inputs sequences.
Definition: type_base.hh:339
Input::Type::generic_
@ generic_
Definition: type_base.hh:78
FilePath::input_file
@ input_file
Definition: file_path.hh:68
Input::Type::FileName::class_name
string class_name() const override
Override Type::TypeBase::class_name.
Definition: type_base.cc:562
Input::Type::TypeBase::type_name
virtual string type_name() const
Returns an identification of the type. Useful for error messages.
Definition: type_base.cc:206
std
Definition: doxy_dummy_defs.hh:5
Input::Type::operator<<
std::ostream & operator<<(std::ostream &stream, const TypeBase &type)
For convenience we provide also redirection operator for output documentation of Input:Type classes.
Definition: type_base.cc:239
Input::Type::Array::get_sub_type
const TypeBase & get_sub_type() const
Getter for the type of array items.
Definition: type_base.hh:397
Input::Type::TypeBase::operator!=
bool operator!=(const TypeBase &other) const
Comparison of types.
Definition: type_base.cc:226
ASSERT_LE
#define ASSERT_LE(a, b)
Definition of comparative assert macro (Less or Equal)
Definition: asserts.hh:304
Input::Type::TypeBase::json_string
std::string json_string
String stored in JSON format.
Definition: type_base.hh:99
json_spirit_error_position.h
json_spirit::Error_position
Definition: json_spirit_error_position.h:21
Input::Type::Attribute::generic_parameters
static string generic_parameters()
Definition: attribute_lib.hh:37
all
@ all
Definition: mixed_mesh_intersections.hh:46
Input::Type::TypeBase::hash_str
std::string hash_str() const
Format the hash of this type.
Definition: type_base.hh:220
Input::Type::TypeBase::delete_unfinished_types
static void delete_unfinished_types()
Finishes and marks all types registered in type repositories and unused in IST.
Definition: type_base.cc:107
json_spirit_value.h
FilePath::output_file
@ output_file
Definition: file_path.hh:69
Input::Type::TypeBase::desc
string desc() const
Returns string with Type extensive documentation.
Definition: type_base.cc:99
Input::Type::OutputText
Class for create text documentation.
Definition: type_output.hh:208
DIR_DELIMITER
#define DIR_DELIMITER
Definition: system.hh:50
Input::Type::Array::make_instance
MakeInstanceReturnType make_instance(std::vector< ParameterPair > vec=std::vector< ParameterPair >()) override
Implements TypeBase::make_instance.
Definition: type_base.cc:317
Input::Type::Double::content_hash
TypeHash content_hash() const override
Implements TypeBase::content_hash.
Definition: type_base.cc:478
Input::Type::TypeBase
Base of classes for declaring structure of the input data.
Definition: type_base.hh:92
Input::Type::Double::lower_bound_
double lower_bound_
Minimal value of Integer.
Definition: type_base.hh:568
Input::Type::FileName::get_file_type
::FilePath::FileType get_file_type() const
Returns type of the file input/output.
Definition: type_base.cc:580
Input::Type::TypeBase::set_generic_attributes
void set_generic_attributes(ParameterMap param_map)
Definition: type_base.cc:173
Input::Type::TypeBase::operator==
virtual bool operator==(const TypeBase &other) const
Comparison of types.
Definition: type_base.cc:222
Input::Type::Double::class_name
string class_name() const override
Override Type::TypeBase::class_name.
Definition: type_base.cc:500
Input::Type::FileName::make_instance
MakeInstanceReturnType make_instance(std::vector< ParameterPair > vec=std::vector< ParameterPair >()) override
Implements TypeBase::make_instance.
Definition: type_base.cc:574
Input::Type::TypeBase::~TypeBase
virtual ~TypeBase()
Destructor.
Definition: type_base.cc:90
fmt::hex
IntFormatSpec< int, TypeSpec< 'x'> > hex(int value)
Input::Type::Array::deep_copy
Array deep_copy() const
Create deep copy of Array.
Definition: type_base.cc:337
Input::Type::TypeBase::print_parameter_map_to_json
json_string print_parameter_map_to_json(ParameterMap parameter_map) const
Create JSON output from parameter_map formatted as value of attribute.
Definition: type_base.cc:151
Input::Type::TypeBase::print_parameter_map_keys_to_json
json_string print_parameter_map_keys_to_json(ParameterMap param_map) const
Definition: type_base.cc:162
Input::Type::TypeBase::TypeHash
std::size_t TypeHash
Type returned by content_hash methods.
Definition: type_base.hh:95
json_spirit_reader.h
Input::Type::TypeBase::is_valid_identifier
static bool is_valid_identifier(const string &key)
Check that a key is valid identifier.
Definition: type_base.cc:93
Input::Type::ARRAY_CONSTRUCT
ARRAY_CONSTRUCT(String)
Input::Type::FileName::FileName
FileName()
Forbids default constructor.
Definition: type_base.cc:514
FMT_UNUSED
#define FMT_UNUSED
Definition: posix.h:75
Input::TypeRepository::finish
void finish(Type::FinishStatus finish_type)
Finish all stored types.
Definition: type_repository.hh:134