Flow123d  last_with_con_2.0.0-663-gd0e2296
type_base.hh
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.hh
15  * @brief
16  */
17 
18 #ifndef TYPE_BASE_HH_
19 #define TYPE_BASE_HH_
20 
21 #include <limits>
22 #include <ios>
23 #include <set>
24 #include <map>
25 #include <vector>
26 #include <string>
27 #include <iomanip>
28 
29 #include <boost/type_traits.hpp>
30 #include <boost/tokenizer.hpp>
31 #include <boost/algorithm/string.hpp>
32 
33 #include "system/global_defs.h"
34 #include "system/system.hh"
35 #include "system/exceptions.hh"
36 #include "system/file_path.hh"
37 
38 
39 
40 
41 namespace Input {
42 
43 namespace Type {
44 
45 
46 
47 using namespace std;
48 
49 /**
50  * Declaration of common exceptions and error info types.
51  */
52 TYPEDEF_ERR_INFO( EI_KeyName, const string );
53 
54 TYPEDEF_ERR_INFO( EI_DefaultStr, const string);
55 TYPEDEF_ERR_INFO( EI_TypeName, const string);
56 TYPEDEF_ERR_INFO( EI_Desc, const string);
57 DECLARE_EXCEPTION( ExcWrongDefaultJSON, << "Consistency Error: Not valid JSON of Default value "
58  << EI_DefaultStr::qval << " of type " << EI_TypeName::qval << ";\n"
59  << "During declaration of the key: " << EI_KeyName::qval );
60 DECLARE_EXCEPTION( ExcWrongDefault, << "Consistency Error: " << EI_Desc::val << "Default value "
61  << EI_DefaultStr::qval << " do not match type: " << EI_TypeName::qval << ";\n"
62  << "During declaration of the key: " << EI_KeyName::qval );
63 DECLARE_EXCEPTION( ExcUnknownDescendant, << "Unknown descendant of TypeBase class, name: " << EI_TypeName::qval );
64 
65 
66 
67 
68 /**
69  * FinishStatus manages finish of elements in IST.
70  *
71  * Specifies:
72  * - finish status of IST elements
73  * - type of executing finish
74  */
76  none_, //< unfinished element / this type can't be used as type of finish
77  in_perform_, //< finish of element performs (used in recursion check) / this type can't be used as type of finish
78  regular_, //< finished element of IST / finish of IST executed recursively from root element
79  generic_, //< finished element in generic subtree / finish of generic subtree (executed from Instance object)
80  delete_ //< finished element marked as deleted (that doesn't appear in IST) / finish of unused elements (that can be removed)
81 };
82 
83 
84 /**
85  * @brief Base of classes for declaring structure of the input data.
86  *
87  * Provides methods and class members common to all types. Namely, the type name, finished status (nontrivial only
88  * for types with complex initialization - Record, AbstractRecosd, Selection), attributes, data of generic types
89  * and output of the documentation.
90  *
91  * @ingroup input_types
92  */
93 class TypeBase {
94 public:
95  /// Type returned by content_hash methods.
96  typedef std::size_t TypeHash;
97 
98  /// String stored in JSON format.
99  typedef std::string json_string;
100  /// Defines map of Input::Type attributes.
102 
103  /// Defines pairs of (name, Input::Type), that are used for replace of parameters in generic types.
104  typedef std::pair< std::string, std::shared_ptr<TypeBase> > ParameterPair;
105  /// Define vector of parameters passed to the overloaded make_instance method.
107 
108  /// Defines map of used parameters
110  /// Return type of make_instance methods, contains instance of generic type and map of used parameters
111  typedef std::pair< std::shared_ptr<TypeBase>, ParameterMap > MakeInstanceReturnType;
112 
113 
114  /**
115  * @brief Returns true if the type is fully specified and ready for read access.
116  *
117  * For Record and Array types this say nothing about child types referenced in particular type object.
118  * In particular for Record and Selection, it returns true after @p finish() method is called.
119  */
120  virtual FinishStatus finish_status() const
121  {return FinishStatus::regular_;}
122 
123  virtual bool is_finished() const
124  {return true;}
125 
126  /**
127  * @brief Returns true if the type is closed.
128  */
129  virtual bool is_closed() const
130  {return true;}
131 
132  /// Returns an identification of the type. Useful for error messages.
133  virtual string type_name() const { return "TypeBase"; }
134  /// Returns an identification of the class. Useful for output of the documentation.
135  virtual string class_name() const { return "TypeBase"; }
136 
137  /**
138  * @brief Returns string with Type extensive documentation.
139  *
140  * We need this to pass Type description at throw points since the Type object can be deallocated during stack
141  * unrolling so it is not good idea to pass pointer. Maybe we can pass smart pointers. Actually this method is
142  * used in various exceptions in json_to_storage.
143  *
144  * TODO: Some old note on this topic:
145  * !!! how to pass instance of descendant of TypeBase through EI -
146  * - can not pass it directly since TypeBase is not copyconstructable
147  * - can not use shared_ptr for same reason
148  * - can not use C pointers since the referred object can be temporary
149  * solutions:
150  * - consistently move TypeBase to Pimpl design
151  * - provide virtual function make_copy, that returns valid shared_ptr
152  *
153  */
154  string desc() const;
155 
156 
157 
158  /**
159  * @brief Comparison of types.
160  *
161  * It compares kind of type (Integer, Double, String, Record, ..), for complex types it also compares names.
162  * For arrays compare subtypes.
163  */
164  virtual bool operator==(const TypeBase &other) const
165  { return typeid(*this) == typeid(other); }
166 
167  /// Comparison of types.
168  bool operator!=(const TypeBase & other) const
169  { return ! (*this == other); }
170 
171  /// Destructor
172  virtual ~TypeBase();
173 
174 
175 
176  /**
177  * @brief Finishes and marks all types registered in type repositories and unused in IST.
178  *
179  * Steps of this method:
180  * 1) finishes all types unused in IST, marks them as deleted (FinishStatus::deleted_)
181  * 2) iterates these deleted types once more, checks shared pointers link to Record keys, descendants of Abstract etc.
182  * - if count == 1, it's OK, method resets shared pointer
183  * - in other cases throws error
184  */
185  static void delete_unfinished_types();
186 
187 
188  /**
189  * @brief Finish method. Finalize construction of "Lazy types": Record, Selection, Abstract and generic type.
190  *
191  * These input types are typically defined by means of static generating methods, whose allows initialization
192  * any of other input types. Since e.g. a Record can link to other input types through its keys at the
193  * initialization phase. But some setting (e.g. add descendants to Abstract) can't be done in initialization
194  * phase. Therefore, the remaining part of initialization can be done later, in finalization phase, typically
195  * from main(), by calling the method finish().
196  *
197  * Method allows finish in different cases that is managed by @p finish_type:
198  *
199  * - base finish of IST requires FinishStatus::regular_ and typically finish of root type is called in this case
200  * - finish of generic types can be different of other Input::Types (e. g. for Record) and needs set @p finish_type
201  * to FinishStatus::generic_
202  * - input types unused in IST can be finished with parameter FinishStatus::delete_. These types can be then safely
203  * deleted from \p Input::TypeRepository (see also \p delete_unfinished_types)
204  *
205  */
207  {
208  ASSERT((finish_type != FinishStatus::none_) && (finish_type != FinishStatus::in_perform_)).error();
209  return finish_type;
210  };
211 
212  /**
213  * @brief Hash of the type specification.
214  *
215  * Provides unique id computed from its content (definition) so that same types have same hash.
216  *
217  * Hash is counted using type, name and other class members specific for descendants.
218  */
219  virtual TypeHash content_hash() const =0;
220 
221  /**
222  * @brief Format given hash for output.
223  *
224  * Use hex format and double quotas.
225  */
226  static std::string hash_str(TypeHash hash);
227 
228  /// Format the hash of this type.
229  inline std::string hash_str() const {
230  return hash_str(content_hash());
231  }
232 
233  /**
234  * Create instance of generic type.
235  *
236  * Replace parameters in input tree by type stored in @p vec.
237  */
238  virtual MakeInstanceReturnType make_instance(ParameterVector vec = ParameterVector()) =0;
239 
240  /// Indicates if type is marked with flag @p root_of_generic_subtree_
242  return root_of_generic_subtree_;
243  }
244 
245 protected:
246 
247  /// The default constructor.
248  TypeBase();
249 
250  /// Copy constructor.
251  TypeBase(const TypeBase& other);
252 
253  /**
254  * @brief Add attribute of given @p name to attribute map.
255  *
256  * Parameter @p val must contain valid JSON string.
257  */
258  void add_attribute_(std::string name, json_string val);
259 
260 
261 
262  /**
263  * @brief The type of hash values used in associative array that translates key names to indices in Record and Selection.
264  *
265  * For simplicity, we currently use whole strings as "hash".
266  */
267  typedef string KeyHash;
268 
269  /// Hash function.
270  inline static KeyHash key_hash(const string &str) {
271  return (str);
272  }
273 
274  /**
275  * @brief Check that a @p key is valid identifier.
276  *
277  * I.e. consists only of valid characters, that are lower-case letters, digits and underscore,
278  * we allow identifiers starting with a digit, but it is discouraged since it slows down parsing of the input file.
279  */
280  static bool is_valid_identifier(const string& key);
281 
282  /// Check if @p str is valid JSON string
283  bool validate_json(json_string str) const;
284 
285  /// Create JSON output from @p parameter_map formatted as value of attribute.
286  json_string print_parameter_map_to_json(ParameterMap parameter_map) const;
287 
288  /**
289  * JSON format of the vector of parameter names. Used for generic composed types.
290  * TODO: use ParameterVector instead of ParameterMap and merge this method with the previous one.
291  */
292  json_string print_parameter_map_keys_to_json(ParameterMap param_map) const;
293 
294  /**
295  * Extract and set attributes from the ParameterMap containing parameters of the subtree.
296  * Used in implementations of the make_instance method.
297  */
298  void set_generic_attributes(ParameterMap param_map);
299 
300  /**
301  * Copy attributes to the instance of the generic type. Remove all internal attributes starting with '_'.
302  */
303  void copy_attributes(attribute_map other_attributes);
304 
305 
306  /// map of type attributes (e. g. input_type, name etc.)
307  std::shared_ptr<attribute_map> attributes_;
308 
309  /// flag is true if type should be root of generic subtree
311 
312  /// hash string of generic type if type is derived, or empty string
314 
315  /// map of parameters if type is part of generic subtree
316  ParameterMap parameter_map_;
317 
318  friend class Array;
319  friend class Record;
320  friend class OutputBase;
321 };
322 
323 /**
324  * @brief For convenience we provide also redirection operator for output documentation of Input:Type classes.
325  */
326 std::ostream& operator<<(std::ostream& stream, const TypeBase& type);
327 
328 
329 class Record;
330 class Selection;
331 
332 
333 /**
334  * @brief Class for declaration of inputs sequences.
335  *
336  * The type is fully specified after its constructor is called. All elements of the Array has same type, however you
337  * can use elements of Abstract.
338  *
339  * If you not disallow Array size 1, the input reader will try to convert any other type
340  * on input into array with one element, e.g.
341  @code
342  int_array=1 # is equivalent to
343  int_array=[ 1 ]
344  @endcode
345  *
346  * @ingroup input_types
347  */
348 class Array : public TypeBase {
349  friend class OutputBase;
350 
351 protected:
352 
353  /**
354  * @brief Actual data of the Array.
355  */
356  class ArrayData {
357  public:
358 
359  /// Constructor
360  ArrayData(unsigned int min_size, unsigned int max_size)
361  : lower_bound_(min_size), upper_bound_(max_size), finish_status(FinishStatus::none_)
362  {}
363  /// Finishes initialization of the ArrayData.
364  FinishStatus finish(FinishStatus finish_type = FinishStatus::regular_);
365  /// Type of Array
366  std::shared_ptr<TypeBase> type_of_values_;
367  /// Minimal size of Array
368  unsigned int lower_bound_;
369  /// Maximal size of Array
370  unsigned int upper_bound_;
371  /// Flag specified if Array is finished
373 
374  };
375 
376 public:
377  /**
378  * @brief Constructor with a @p type of array items given as pure reference.
379  *
380  * In this case \p type has to by descendant of \p TypeBase different from 'complex' types
381  * @p Record and @p Selection. You can also specify minimum and maximum size of the array.
382  */
383  template <class ValueType>
384  Array(const ValueType &type, unsigned int min_size=0, unsigned int max_size=std::numeric_limits<unsigned int>::max() );
385 
386  /**
387  * @brief Constructor with a shared pointer @p type of array.
388  */
389  Array(std::shared_ptr<TypeBase> type, unsigned int min_size=0, unsigned int max_size=std::numeric_limits<unsigned int>::max() );
390 
391  /**
392  * @brief Implements @p TypeBase::content_hash.
393  *
394  * Hash is calculated by type name, bounds, hash of stored type and hash of attributes.
395  */
396  TypeHash content_hash() const override;
397 
398  /// Finishes initialization of the Array type because of lazy evaluation of type_of_values.
399  FinishStatus finish(FinishStatus finish_type = FinishStatus::regular_) override;
400 
401  /// Override @p Type::TypeBase::finish_status.
402  FinishStatus finish_status() const override {
403  return data_->finish_status; }
404 
405  /// Override @p Type::TypeBase::is_finished.
406  bool is_finished() const override {
407  return (data_->finish_status != FinishStatus::none_) && (data_->finish_status != FinishStatus::in_perform_); }
408 
409  /// Getter for the type of array items.
410  inline const TypeBase &get_sub_type() const {
411  return *data_->type_of_values_; }
412 
413  /// Checks size of particular array.
414  inline bool match_size(unsigned int size) const {
415  return size >=data_->lower_bound_ && size<=data_->upper_bound_; }
416 
417  /**
418  * @brief Implements @p Type::TypeBase::type_name.
419  *
420  * Name has form \p array_of_'subtype_name'.
421  */
422  string type_name() const override;
423  /// Override @p Type::TypeBase::class_name.
424  string class_name() const override { return "Array"; }
425 
426  /// @brief Implements @p Type::TypeBase::operator== Compares also subtypes.
427  bool operator==(const TypeBase &other) const override;
428 
429  /// Implements @p TypeBase::make_instance.
431 
432  /**
433  * @brief Create deep copy of Array.
434  *
435  * Copy all data stored in shared pointers etc.
436  */
437  Array deep_copy() const;
438 
439 protected:
440 
441  /// Handle to the actual array data.
442  std::shared_ptr<ArrayData> data_;
443 private:
444  /// Forbids default constructor in order to prevent empty data_.
445  Array();
446 };
447 
448 
449 
450 /**
451  * @brief Base of all scalar types.
452  *
453  * @ingroup input_types
454  */
455 class Scalar : public TypeBase {};
456 
457 
458 /**
459  * @brief Class for declaration of the input of type Bool.
460  *
461  * String names of boolean values are \p 'true' and \p 'false'.
462  *
463  * @ingroup input_types
464  */
465 class Bool : public Scalar {
466 public:
467  /// Constructor.
469  {}
470 
471  /// Implements @p TypeBase::content_hash.
472  TypeHash content_hash() const override;
473 
474 
475  /**
476  * @brief Implements @p Type::TypeBase::type_name.
477  *
478  * Name has form \p Bool.
479  */
480  string type_name() const override;
481  /// Override @p Type::TypeBase::class_name.
482  string class_name() const override { return "Bool"; }
483 
484  /// Implements @p TypeBase::make_instance.
486 };
487 
488 
489 /**
490  * @brief Class for declaration of the integral input data.
491  *
492  * The data are stored in an \p signed \p int variable. You can specify bounds for the valid input data.
493  *
494  * @ingroup input_types
495  */
496 class Integer : public Scalar {
497  friend class OutputBase;
498 
499 public:
500  /**
501  * @brief Constructor.
502  *
503  * You can also specify minimum and maximum value.
504  */
505  Integer(int lower_bound=std::numeric_limits<int>::min(), int upper_bound=std::numeric_limits<int>::max())
506  : lower_bound_(lower_bound), upper_bound_(upper_bound)
507  {}
508 
509  /**
510  * @brief Implements @p TypeBase::content_hash.
511  *
512  * Hash is calculated by type name and bounds.
513  */
514  TypeHash content_hash() const override;
515 
516  /**
517  * @brief Check valid value of Integer.
518  *
519  * Returns true if the given integer value conforms to the Type::Integer bounds.
520  */
521  bool match(std::int64_t value) const;
522 
523  /**
524  * @brief Implements @p Type::TypeBase::type_name.
525  *
526  * Name has form \p Integer.
527  */
528  string type_name() const override;
529  /// Override @p Type::TypeBase::class_name.
530  string class_name() const override { return "Integer"; }
531 
532  /// Implements @p TypeBase::make_instance.
534 private:
535 
536  std::int64_t lower_bound_; ///< Minimal value of Integer.
537  std::int64_t upper_bound_; ///< Maximal value of Integer.
538 
539 };
540 
541 
542 /**
543  * @brief Class for declaration of the input data that are floating point numbers.
544  *
545  * The data are stored in an \p double variable. You can specify bounds for the valid input data.
546  *
547  * @ingroup input_types
548  */
549 class Double : public Scalar {
550  friend class OutputBase;
551 
552 public:
553  /**
554  * @brief Constructor.
555  *
556  * You can also specify minimum and maximum value.
557  */
558  Double(double lower_bound= -std::numeric_limits<double>::max(), double upper_bound=std::numeric_limits<double>::max())
559  : lower_bound_(lower_bound), upper_bound_(upper_bound)
560  {}
561 
562  /**
563  * @brief Implements @p TypeBase::content_hash.
564  *
565  * Hash is calculated by type name and bounds.
566  */
567  TypeHash content_hash() const override;
568 
569  /// Returns true if the given integer value conforms to the Type::Double bounds.
570  bool match(double value) const;
571 
572  /**
573  * @brief Implements @p Type::TypeBase::type_name.
574  *
575  * Name has form \p Double.
576  */
577  string type_name() const override;
578  /// Override @p Type::TypeBase::class_name.
579  string class_name() const override { return "Double"; }
580 
581  /// Implements @p TypeBase::make_instance.
583 private:
584 
585  double lower_bound_; ///< Minimal value of Integer.
586  double upper_bound_; ///< Maximal value of Integer.
587 
588 };
589 
590 
591 
592 /**
593  * @brief Class for declaration of the input data that are in string format.
594  *
595  * Just for consistency, but is essentially same as Scalar.
596  *
597  * @ingroup input_types
598  */
599 class String : public Scalar {
600 public:
601  /**
602  * @brief Implements @p Type::TypeBase::type_name.
603  *
604  * Name has form \p String.
605  */
606  virtual string type_name() const override;
607  /// Override @p Type::TypeBase::class_name.
608  string class_name() const override { return "String"; }
609 
610  /// Implements @p TypeBase::content_hash.
611  TypeHash content_hash() const override;
612 
613  /// Particular descendants can check validity of the string.
614  virtual bool match(const string &value) const;
615 
616  /// Implements @p TypeBase::make_instance.
617  virtual MakeInstanceReturnType make_instance(std::vector<ParameterPair> vec = std::vector<ParameterPair>()) override;
618 };
619 
620 
621 /**
622  * @brief Class for declaration of the input data that are file names.
623  *
624  * We strictly distinguish filenames for input and output files.
625  *
626  * @ingroup input_types
627  */
628 class FileName : public String {
629 public:
630 
631  /// Implements @p TypeBase::content_hash.
632  TypeHash content_hash() const override;
633 
634  /**
635  * @brief The factory function for declaring type FileName for input files.
636  */
637  static FileName input()
638  { return FileName(::FilePath::input_file); }
639 
640  /**
641  * @brief The factory function for declaring type FileName for input files.
642  */
643  static FileName output()
644  { return FileName(::FilePath::output_file); }
645 
646  /**
647  * @brief Implements @p Type::TypeBase::type_name.
648  *
649  * Name has form \p FileName_input or \p FileName_output
650  */
651  string type_name() const override;
652  /// Override @p Type::TypeBase::class_name.
653  string class_name() const override { return "FileName"; }
654 
655  /// Comparison of types.
656  bool operator==(const TypeBase &other) const override;
657 
658  /// Checks relative output paths.
659  bool match(const string &str) const override;
660 
661 
662  /**
663  * @brief Returns type of the file input/output.
664  */
666  return type_;
667  }
668 
669  /// Implements @p TypeBase::make_instance.
671 
672 
673 
674 private:
675  /// The type of file (input or output).
677 
678  /// Forbids default constructor.
679  FileName();
680 
681  /// Forbids direct construction.
682  FileName(enum ::FilePath::FileType type)
683  : type_(type)
684  {}
685 
686 };
687 
688 } // closing namespace Type
689 } // closing namespace Input
690 
691 
692 
693 
694 
695 #endif /* TYPE_BASE_HH_ */
Bool()
Constructor.
Definition: type_base.hh:468
std::int64_t lower_bound_
Minimal value of Integer.
Definition: type_base.hh:536
Base of classes for declaring structure of the input data.
Definition: type_base.hh:93
bool is_root_of_generic_subtree()
Indicates if type is marked with flag root_of_generic_subtree_.
Definition: type_base.hh:241
virtual bool is_closed() const
Returns true if the type is closed.
Definition: type_base.hh:129
virtual bool operator==(const TypeBase &other) const
Comparison of types.
Definition: type_base.hh:164
FinishStatus finish_status
Flag specified if Array is finished.
Definition: type_base.hh:372
std::string hash_str() const
Format the hash of this type.
Definition: type_base.hh:229
bool root_of_generic_subtree_
flag is true if type should be root of generic subtree
Definition: type_base.hh:310
virtual string class_name() const
Returns an identification of the class. Useful for output of the documentation.
Definition: type_base.hh:135
TYPEDEF_ERR_INFO(EI_KeyName, const string)
Class for declaration of the input of type Bool.
Definition: type_base.hh:465
FileType
Possible types of file.
Definition: file_path.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:111
virtual bool is_finished() const
Definition: type_base.hh:123
unsigned int upper_bound_
Maximal size of Array.
Definition: type_base.hh:370
::FilePath::FileType type_
The type of file (input or output).
Definition: type_base.hh:676
Base abstract class for output description of the Input::Type tree.
Definition: type_output.hh:58
Double(double lower_bound=-std::numeric_limits< double >::max(), double upper_bound=std::numeric_limits< double >::max())
Constructor.
Definition: type_base.hh:558
virtual FinishStatus finish(FinishStatus finish_type=FinishStatus::regular_)
Finish method. Finalize construction of "Lazy types": Record, Selection, Abstract and generic type...
Definition: type_base.hh:206
Base of all scalar types.
Definition: type_base.hh:455
static KeyHash key_hash(const string &str)
Hash function.
Definition: type_base.hh:270
virtual string type_name() const
Returns an identification of the type. Useful for error messages.
Definition: type_base.hh:133
Class for declaration of the input data that are file names.
Definition: type_base.hh:628
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
Definition: asserts.hh:347
string class_name() const override
Override Type::TypeBase::class_name.
Definition: type_base.hh:608
std::shared_ptr< attribute_map > attributes_
map of type attributes (e. g. input_type, name etc.)
Definition: type_base.hh:307
Class for declaration of the integral input data.
Definition: type_base.hh:496
ArrayData(unsigned int min_size, unsigned int max_size)
Constructor.
Definition: type_base.hh:360
Class for declaration of inputs sequences.
Definition: type_base.hh:348
double upper_bound_
Maximal value of Integer.
Definition: type_base.hh:586
static constexpr bool value
Definition: json.hpp:87
ParameterMap parameter_map_
map of parameters if type is part of generic subtree
Definition: type_base.hh:316
string KeyHash
The type of hash values used in associative array that translates key names to indices in Record and ...
Definition: type_base.hh:267
std::shared_ptr< ArrayData > data_
Handle to the actual array data.
Definition: type_base.hh:442
bool operator==(const Null &, const Null &)
Global macros to enhance readability and debugging, general constants.
Class for declaration of the input data that are floating point numbers.
Definition: type_base.hh:549
static FileName input()
The factory function for declaring type FileName for input files.
Definition: type_base.hh:637
std::map< std::string, TypeHash > ParameterMap
Defines map of used parameters.
Definition: type_base.hh:109
std::int64_t upper_bound_
Maximal value of Integer.
Definition: type_base.hh:537
std::map< std::string, json_string > attribute_map
Defines map of Input::Type attributes.
Definition: type_base.hh:101
bool match_size(unsigned int size) const
Checks size of particular array.
Definition: type_base.hh:414
std::pair< std::string, std::shared_ptr< TypeBase > > ParameterPair
Defines pairs of (name, Input::Type), that are used for replace of parameters in generic types...
Definition: type_base.hh:104
bool operator!=(const TypeBase &other) const
Comparison of types.
Definition: type_base.hh:168
string class_name() const override
Override Type::TypeBase::class_name.
Definition: type_base.hh:653
virtual FinishStatus finish_status() const
Returns true if the type is fully specified and ready for read access.
Definition: type_base.hh:120
TypeHash generic_type_hash_
hash string of generic type if type is derived, or empty string
Definition: type_base.hh:313
::FilePath::FileType get_file_type() const
Returns type of the file input/output.
Definition: type_base.hh:665
static FileName output()
The factory function for declaring type FileName for input files.
Definition: type_base.hh:643
bool is_finished() const override
Override Type::TypeBase::is_finished.
Definition: type_base.hh:406
std::shared_ptr< TypeBase > type_of_values_
Type of Array.
Definition: type_base.hh:366
Actual data of the Array.
Definition: type_base.hh:356
const TypeBase & get_sub_type() const
Getter for the type of array items.
Definition: type_base.hh:410
DECLARE_EXCEPTION(ExcWrongDefaultJSON,<< "Consistency Error: Not valid JSON of Default value "<< EI_DefaultStr::qval<< " of type "<< EI_TypeName::qval<< ";\n"<< "During declaration of the key: "<< EI_KeyName::qval)
double lower_bound_
Minimal value of Integer.
Definition: type_base.hh:585
std::string json_string
String stored in JSON format.
Definition: type_base.hh:99
string class_name() const override
Override Type::TypeBase::class_name.
Definition: type_base.hh:530
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:173
string class_name() const override
Override Type::TypeBase::class_name.
Definition: type_base.hh:579
Record type proxy class.
Definition: type_record.hh:171
Integer(int lower_bound=std::numeric_limits< int >::min(), int upper_bound=std::numeric_limits< int >::max())
Constructor.
Definition: type_base.hh:505
unsigned int lower_bound_
Minimal size of Array.
Definition: type_base.hh:368
string class_name() const override
Override Type::TypeBase::class_name.
Definition: type_base.hh:424
Class for declaration of the input data that are in string format.
Definition: type_base.hh:599
std::size_t TypeHash
Type returned by content_hash methods.
Definition: type_base.hh:96
std::vector< ParameterPair > ParameterVector
Define vector of parameters passed to the overloaded make_instance method.
Definition: type_base.hh:106
FinishStatus finish_status() const override
Override Type::TypeBase::finish_status.
Definition: type_base.hh:402
Template for classes storing finite set of named values.
FileName(enum::FilePath::FileType type)
Forbids direct construction.
Definition: type_base.hh:682
string class_name() const override
Override Type::TypeBase::class_name.
Definition: type_base.hh:482