Initfile.h 19.3 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/******************************************************************************
 *
 * AMDiS - Adaptive multidimensional simulations
 *
 * Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
 * Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
 *
 * Authors: 
 * Simon Vey, Thomas Witkowski, Andreas Naumann, Simon Praetorius, et al.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 *
 * This file is part of AMDiS
 *
 * See also license.opensource.txt in the distribution.
 * 
 ******************************************************************************/
20

Praetorius, Simon's avatar
Praetorius, Simon committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef INITFILE_H
#define INITFILE_H

#include <fstream>
#include <sstream>
#include <string>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stdexcept>
#include <iostream>
#include <typeinfo>
#include "FixVec.h"

36
37
#include "traits/size.hpp"

Praetorius, Simon's avatar
Praetorius, Simon committed
38
#include <boost/lexical_cast.hpp>
39
40
#include <boost/numeric/conversion/cast.hpp> 

41
#include <boost/type_traits.hpp>
Praetorius, Simon's avatar
Praetorius, Simon committed
42

43
44
// a parser for arithmetic expressions
#include "muParser.h"
Praetorius, Simon's avatar
Praetorius, Simon committed
45

46
47
namespace AMDiS {

48
  namespace detail {
49
  
50
51
    // Exceptions
    //_________________________________________________________________________________________
Praetorius, Simon's avatar
Praetorius, Simon committed
52
    
53
    /// Exception for wrong vector size when parsing for concrete vector type
Praetorius, Simon's avatar
Praetorius, Simon committed
54
    struct WrongVectorSize : std::runtime_error {
Praetorius, Simon's avatar
Praetorius, Simon committed
55
      WrongVectorSize(std::string m) : std::runtime_error(m) {}
56
57
    };

58

59
    /// Exception for no delimiter found in vector
Praetorius, Simon's avatar
Praetorius, Simon committed
60
    struct NoDelim : std::runtime_error {
Praetorius, Simon's avatar
Praetorius, Simon committed
61
      NoDelim(std::string m) : std::runtime_error(m) {}
62
63
    };

64

65
    /// Exception for begin and end brackets are different in vector
Praetorius, Simon's avatar
Praetorius, Simon committed
66
    struct WrongVectorFormat : std::runtime_error {
Praetorius, Simon's avatar
Praetorius, Simon committed
67
      WrongVectorFormat(std::string m) : std::runtime_error(m) {}
68
    };
69
    
Praetorius, Simon's avatar
Praetorius, Simon committed
70
    
71
    /// Exception for wrong value format
72
    template<typename T>
73
74
    struct WrongValueFormat : std::runtime_error 
    {  
Praetorius, Simon's avatar
Praetorius, Simon committed
75
76
77
78
79
      static std::string name(bool) { return "bool"; }
      static std::string name(double) { return "double"; }
      static std::string name(float) { return "float"; }
      static std::string name(int) { return "int"; }
      static std::string name(unsigned int) { return "unsigned int"; }
80
81
82
83

      template<typename G>
      static std::string name(G) 
      { 
84
        return std::string(typeid(G).name()); 
85
      }
86

87
      WrongValueFormat(std::string value)
Praetorius, Simon's avatar
Praetorius, Simon committed
88
      : std::runtime_error("cannot convert '" + value + "' into <" + name(T()) + ">")
89
90
      {}
    };
Praetorius, Simon's avatar
Praetorius, Simon committed
91
    
Praetorius, Simon's avatar
Praetorius, Simon committed
92

93
    /// Exception for bad arithmetic expression that can not be evaluated
94
    template<typename T>
95
96
    struct BadArithmeticExpression : std::runtime_error 
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
97
98
99
100
101
      static std::string name(bool) { return "bool"; }
      static std::string name(double) { return "double"; }
      static std::string name(float) { return "float"; }
      static std::string name(int) { return "int"; }
      static std::string name(unsigned int) { return "unsigned int"; }
102

103
104
105
      template<typename G>
      static std::string name(G) 
      { 
106
        return std::string(typeid(G).name());
107
      }
108

109
      BadArithmeticExpression(std::string m, std::string value) 
Praetorius, Simon's avatar
Praetorius, Simon committed
110
111
      : std::runtime_error("cannot evaluate expression '" + value + "' into <" + name(T()) + ">\n"
			   "Parser message: '" + m + "'")
112
113
      {}
    };
Praetorius, Simon's avatar
Praetorius, Simon committed
114
      
115
// _____________________________________________________________________________
116

117
118
    /// return the delimiter or throw an exception if there is no known 
    /// delimiter in value
119
120
121
    inline size_t checkDelim(const std::string& value, const std::string& delims)
    {
      size_t pos(std::string::npos);
Praetorius, Simon's avatar
Praetorius, Simon committed
122
      for (size_t i = 0; i < delims.length(); i++) {
123
124
125
        pos = value.find(delims[i]);
        if (pos != std::string::npos)
          return i;
126
      }
Thomas Witkowski's avatar
Thomas Witkowski committed
127
      //      throw NoDelim("cannot detect the delimiter in " + value);
128
129
130
131
132
133
134
135
136
137
138
139
      return 0; 
    }


    /// convert string to string
    inline void convert(const std::string valStr, std::string& value) 
    {
      value = trim(valStr);
    }


    /// convert string to intrinsic type
140
141
142
143
144
145
146
147
    template<typename T> inline
    typename boost::enable_if
	     < boost::mpl::and_
	       < boost::is_pod<T>, 
	         boost::mpl::not_< boost::is_enum<T> > >, 
	       void
	     >::type
    convert(const std::string valStr, T& value)
148
149
150
151
152
153
154
    {
      using boost::lexical_cast;
      using boost::numeric_cast;

      mu::Parser parser;
      parser.DefineConst(_T("M_PI"), m_pi);
      parser.DefineConst(_T("M_E"), m_e);
155

Thomas Witkowski's avatar
Thomas Witkowski committed
156
      //      try {
157
158
        parser.SetExpr(valStr);
        value = numeric_cast< T >(parser.Eval());
Thomas Witkowski's avatar
Thomas Witkowski committed
159
160
161
162
163
164
165
/*       } catch (boost::bad_lexical_cast e) { */
/*         throw WrongValueFormat< T >(valStr); */
/*       } catch (boost::bad_numeric_cast e) { */
/*         throw WrongValueFormat< T >(valStr); */
/*       } catch (mu::Parser::exception_type &e) { */
/*         throw BadArithmeticExpression<T>(e.GetMsg(), valStr); */
/*       } */
166
167
168
    }


169
170
171
172
173
174
    template<typename T> inline
    typename boost::enable_if
	     < boost::is_enum<T>, 
	       void
	     >::type
    convert(const std::string valStr, T& value) 
175
    {
176
      int swap = 0;
Thomas Witkowski's avatar
Thomas Witkowski committed
177
      //      try {
178
        swap = boost::lexical_cast<int>(trim(valStr));
Thomas Witkowski's avatar
Thomas Witkowski committed
179
180
181
/*       } catch (boost::bad_lexical_cast e) { */
/*         throw WrongValueFormat< T >(valStr); */
/*       } */
182
183
184
185
      value = static_cast< T >(swap);
    }


186
187
188
189
190
191
192
193
194
195
196
197
    /// convert special enums
    inline void convert(const std::string valStr, Norm& value) 
    {
      std::string swapStr = boost::to_upper_copy(valStr);

      if (swapStr == "NO_NORM")
        value = static_cast< Norm >(NO_NORM);
      else if (swapStr == "H1_NORM")
        value = static_cast< Norm >(H1_NORM);
      else if (swapStr == "L2_NORM")
        value = static_cast< Norm >(L2_NORM);
      else {
Praetorius, Simon's avatar
Praetorius, Simon committed
198
        int swap = 0;
199
200
201
202
203
204
        convert(valStr, swap);
        value = static_cast< Norm >(swap);
      }
    }


Naumann, Andreas's avatar
Naumann, Andreas committed
205
206
207
208
209
210
211
212
213
214
215
216
217
    /// convert value of arbitrary type to string using stringstream and 
    /// operator<< for type
    template<typename T>
    inline void convert(const T value, std::string& valStr) 
    {
      std::stringstream ss;
      ss.precision(6);
      ss << value;
      valStr = ss.str();
    }


    /// convert WorldVector to string
218
219
    // TODO: allgemeine Funktion zum Schreiben von Vektoren implementieren
    //       unter Ausnutzung von Type-Traits
Naumann, Andreas's avatar
Naumann, Andreas committed
220
221
222
    template<typename T>
    inline void convert(const WorldVector<T>& c, std::string& valStr)
    {
223
224
      std::vector<T> temp_vec(size(c));
      for (unsigned i = 0; i < size(temp_vec); i++)
Naumann, Andreas's avatar
Naumann, Andreas committed
225
226
227
228
        temp_vec[i] = c[i];
      convert(temp_vec, valStr);
    }

229
    // forward declarations
Thomas Witkowski's avatar
Thomas Witkowski committed
230
231
232
233
234
235
236
237
238
    template< typename T >
    inline void convert(const std::string valStr, WorldVector<T>& c);

    template<typename T>
    inline void convert(const std::string valStr, std::list<T>& value);

    template<typename T>
    inline void convert(const std::string valStr, std::vector<T>& value);

Naumann, Andreas's avatar
Naumann, Andreas committed
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
    /** parse an container from tag tag. The Container must have the properties:
    * 	- type value_type
    * 	- member function push_back
    */
    template< typename Container >
    inline void getContainer(const std::string val_, Container& c)
    {
      // accepted brackets and delimiters for vector input
      std::string begBrackets= "{[(";
      std::string endBrackets= "}])";
      std::string delims= ";,";

      c.clear();
      std::string val = trim(val_);
      bool hasBrackets = true;
      size_t pos = begBrackets.find(val[0]);
      if (pos == std::string::npos)
        hasBrackets = false;
257
258
259
       if (hasBrackets && val[val.length() - 1] != endBrackets[pos])
        throw WrongVectorFormat("begin and end bracket are different in"
            " value '" + val + "'"); 
Naumann, Andreas's avatar
Naumann, Andreas committed
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
      size_t oldPos = (hasBrackets ? 1 : 0);
      size_t curDelim = 0;
      typedef typename Container::value_type ValueType;
      ValueType swap;
      try {
        curDelim = checkDelim(val, delims);
        pos = val.find(delims[curDelim], oldPos);
        while (pos != std::string::npos) {
          std::string curWord = val.substr(oldPos, pos - oldPos);
          oldPos = pos + 1;
          convert(curWord, swap);
          c.push_back(swap);
          pos = val.find(delims[curDelim], oldPos);
        }
        //last entry
        std::string curWord = val.substr(oldPos, val.length() - (hasBrackets ? 1 : 0) - oldPos);
        convert(curWord, swap);
        c.push_back(swap);
      } catch (NoDelim nd) {
        std::string curWord = val.substr(oldPos, val.length() - (hasBrackets ? 2 : 0));
        curWord = trim(curWord);
        if (curWord.length() > 0) {
          // container with one entry
          convert(curWord, swap);
          c.push_back(swap);
        }
      }
    }

289
290
    // TODO: Verallgemeinerung der convert-method für bel. Vektoren und
    //       hinzunahme der Möglichkeit Matrizen anzugeben
Naumann, Andreas's avatar
Naumann, Andreas committed
291

292
293
294
295
296
297
    /// convert string to WorldVector
    template< typename T >
    inline void convert(const std::string valStr, WorldVector<T>& c) 
    {
      std::vector<T> temp_vec;
      getContainer(valStr, temp_vec);
298
299
       if (static_cast<int>(temp_vec.size()) != c.getSize())
        throw WrongVectorSize("wrong number of entries for WorldVector"); 
300
  
Praetorius, Simon's avatar
Praetorius, Simon committed
301
      for (size_t i = 0; i < temp_vec.size(); i++)
302
        c[i] = temp_vec[i];
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
    }

    /// convert string to std::list using begBrackets, endBrackets and delims
    template<typename T>
    inline void convert(const std::string valStr, std::list<T>& value)
    {
      getContainer(valStr, value);
    }


    /// convert string to std::vector using begBrackets, endBrackets and delims
    template<typename T>
    inline void convert(const std::string valStr, std::vector<T>& value)
    {
      getContainer(valStr, value);
    }


321
  } // end namespace detail
Praetorius, Simon's avatar
Praetorius, Simon committed
322

323
// _____________________________________________________________________________
Praetorius, Simon's avatar
Praetorius, Simon committed
324

325
326
327
328
  /** The entry in an initfile. This helper class was constructed to allow calls 
  *  like val = data.get(tag) for arbitrary types of val. At current stage, only
  *  double and bool is supported
  */
329
330
331
332
333
334
  struct InitEntry {
    ///the value as string
    std::string valStr;

    /// initialize with value as string
    InitEntry(std::string v = "")
335
    : valStr(v) 
336
337
338
339
340
341
342
    {}

    /// cast string to type T
    template<typename T>
    operator T() const 
    { 
      T t; 
343
      detail::convert(valStr, t); 
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
      return t;
    }
  };


  /// output-stream for std::list
  template<typename T>
  std::ostream& operator<<(std::ostream& o, const std::list< T >& l)
  {
    typename std::list< T >::const_iterator it = l.begin();
    o << "[";
    for (unsigned i = 0; it != l.end() && i < l.size(); i++) {
      o << *it << (i < l.size() - 1 ? ", " : "");
      ++it;
    }
    o << "]";
    return o;
  }


  /// output-stream for std::vector
  template<typename T>
  std::ostream& operator<<(std::ostream& o, const std::vector<T>& l)
  {
    typename std::vector<T>::const_iterator it = l.begin();
    o << "[";
    for (unsigned i = 0; it != l.end() && i < l.size(); i++) {
      o << *it << (i < l.size() - 1 ? ", " : "");
      ++it;
    }
    o << "]";
    return o;
  }

378
// _____________________________________________________________________________
379

380
381
382
  /** Basis data container as a map of tag on a value as strings. The container 
  *  throws an exception, if the tag was not found.
  */
383
384
385
386
  struct Initfile : public std::map<std::string, std::string> 
  {
    typedef std::map< std::string, std::string > super;

387
388
    static const int TAG_NOT_FOUND = 1;
    static const int TAG_NOT_FOUND_BREAK = 2;
389

390
    /// Exceptions
Praetorius, Simon's avatar
Praetorius, Simon committed
391
    struct TagNotFound : std::invalid_argument {
392
      TagNotFound(std::string m) 
393
      : std::invalid_argument(m) 
394
395
396
      {}
    };

397
398
399

    struct TagNotFoundBreak : std::invalid_argument {
    // print 'tag not found' and exit
400
      TagNotFoundBreak(std::string m)
401
      : std::invalid_argument(m) 
402
403
      {}
    };
404
405
406
407
408
409


    /** initialize init-file from file with filename in, read data and save it 
    *  to singleton-map
    *  @param in: filename string
    */
410
411
    static void init(std::string in);

412
    static void init(int print, std::string filename, const char *flags = NULL) 
413
    {
414
415
416
        WARNING("Parameters::init(int,std::string,const char*) is depreciated. "
          "Use Parameters::init(std::string) instead!\n");
        init(filename);
417
    }
418
419
420
421
422
423
424
425
426
427


    /** Static get routine for getting parameter-values from init-file 
    *  initialized in init()-method.
    *  Cast the value to the desired type using std::stringstream.
    *  @param tag: The tag to look for
    *  @param value: The result.
    *  @param debugInfo: msgInfo for current parameter. (0..no printing,
    *    1..print missing parameter info, 2..print parameter value) [optional]
    */
428
429
430
431
432
    template<typename T>
    static void get(const std::string tag, T& value, int debugInfo = -1)
    {
      initIntern();
      if (debugInfo == -1)
433
        debugInfo = singlett->getMsgInfo();
434
435
436
437
438
      else {
	int swap(debugInfo);
	debugInfo = singlett->getMsgInfo();
	singlett->msgInfo=swap;
      }
439

440
      std::string valStr;
441
      try {
442
443
444
      int error_code = singlett->checkedGet(tag, valStr);
      if (error_code == 0) {
	valStr = trim(valStr);
445
	detail::convert(valStr, value);
Thomas Witkowski's avatar
Thomas Witkowski committed
446
      } 
447
448
449
450
      } catch(mu::ParserError& e) {
	std::string parser_error = "Could not parse: " + tag;
	throw std::runtime_error(parser_error);
      }
Thomas Witkowski's avatar
Thomas Witkowski committed
451
452
      /*
else if(error_code == TAG_NOT_FOUND_BREAK)
453
	throw TagNotFoundBreak("required tag '" + tag + "' not found");
454
455
456
457
      else if (error_code == TAG_NOT_FOUND) {
	if (debugInfo == 2)
	  std::cout << "there is no tag '" + tag + "'" << std::endl;
      } else
Praetorius, Simon's avatar
Praetorius, Simon committed
458
	throw std::runtime_error("unknown error_code (" + boost::lexical_cast<std::string>(error_code) + ") returned for tag '" + tag + "'");
Thomas Witkowski's avatar
Thomas Witkowski committed
459
460
      */

461
462
463
      if (debugInfo == 2) {
	std::cout << "Parameter '" << tag << "'"
		  << " initialized with: " << value << std::endl;
464
      }
465
      singlett->msgInfo = debugInfo;
466
467
    }

468

469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
    /** Static get routine for getting a parameter-map from init-file 
    *  initialized in init()-method.
    *  Idea: 
    *     line in Initfile: <tag><key>: <value>
    *     is extracted in am map [key]->[value].
    *  @param tag: The tag withch labels the parameter map 
    *  @param debugInfo: msgInfo for current parameter. (0..no printing,
    *    2..print parameter value) [optional]
    */
    static void getParameterMap(const std::string tag, 
				std::map<std::string,std::string> &pm,
				int debugInfo = -1)
    {
	initIntern();
	for (Initfile::iterator it = singlett->begin(); it != singlett->end(); it++){	
	    std::string longTag= (*it).first ;
	    std::string value=(*it).second;
486
487
	    if(longTag.length()>tag.length() && 
	       longTag.compare(0,tag.length(),tag)==0){
488
		if (debugInfo == 2){
489
490
491
		  std::cout <<"tag "<< tag <<"\n";
		  std::cout <<"Extract Parameter map from "<<(*it).first   
			    << " => " <<(*it).second  << std::endl;
492
		}
493

494
		std::string key=trim(longTag.substr(tag.length()));
495

496
		if (debugInfo == 2){
497
498
		  std::cout <<"Parameter map "<< key << " => " 
			    << value << std::endl;
499
500
501
502
503
504
		}
		pm[key]=value;
	    }
	}	    
    }
    
505
506
507
508
    /// return InitEntry object for tag tag
    static InitEntry get(const std::string tag) 
    {
      InitEntry result;
509
510
511
512
513
514
      
      std::string valStr;
      int error_code = singlett->checkedGet(tag, valStr);
      if (error_code == 0) {
	valStr = trim(valStr);
	result = InitEntry(valStr);
Thomas Witkowski's avatar
Thomas Witkowski committed
515
516
517
518
      } 

#if 0
else if(error_code == TAG_NOT_FOUND_BREAK)
519
	throw TagNotFoundBreak("get(): required tag '" + tag + "' not found");
520
      else if (error_code == TAG_NOT_FOUND)
521
	throw TagNotFound("get(): there is no tag '" + tag + "'"); 
Praetorius, Simon's avatar
Praetorius, Simon committed
522
	// exception must be thrown, because an empty object would be return otherwise
523
      else
524
	throw std::runtime_error("get(): unknown error_code returned for tag '" + tag + "'");
Thomas Witkowski's avatar
Thomas Witkowski committed
525
526
#endif

527
528
      return result;
    }
529

530
531
532
533
534
535
536

    /// update map tag->value_old to tag->value in singleton
    template<typename T>
    static void set(const std::string tag, T& value, int debugInfo=  -1) 
    {
      initIntern();
      if (debugInfo == -1)
537
538
        debugInfo = singlett->getMsgInfo();

539
      std::string swap = "";
540
      detail::convert(value, swap);
541
542
543
544
      (*singlett)[trim(tag)] = swap;
      // update msg parameters msgInfo, msgWait, paramInfo
      singlett->getInternalParameters();
      if (debugInfo == 2)
545
546
        std::cout << "Parameter '" << tag << "'"
                  << " set to: " << value << std::endl;
547
    }
548
549


550
551
552
553
554
555
556
    /// add map tag->value to data in singleton
    template< typename T >
    static void add(const std::string tag, T& value, int debugInfo = -1) 
    {
      set(tag, value, debugInfo);
    }

557

558
    /// rescheduling parameter
Praetorius, Simon's avatar
Praetorius, Simon committed
559
    static void readArgv(std::string parameters, int debugInfo = 2);
560

561

562
563
564
    /// Returns specified info level
    static int getMsgInfo() 
    { 
565
      return (singlett != NULL) ? singlett->msgInfo : 0; 
566
567
    }

568

569
570
571
    /// Returns specified wait value
    static int getMsgWait() 
    { 
572
      return (singlett != NULL) ? singlett->msgWait : 0; 
573
    }
574
575


576
577
578
    /// Checks whether parameters are initialized. if not, call init()
    static bool initialized() 
    { 
579
      return (singlett != NULL); 
580
581
    }

582

583
584
585
586
587
    /// return pointer to singleton
    static Initfile *getSingleton() 
    { 
      return singlett; 
    }
588
589


590
591
592
    /// print all data in singleton to std::cout
    static void printParameters();

593

594
595
596
597
598
599
    /// clear data in singleton
    static void clearData()
    {
      initIntern();
      singlett->clear();
    }
600
601


602
603
604
605
606
607
    /// save singlett-data to file with filename fn
    static void save(std::string fn)
    {
      initIntern();
      singlett->write(fn);
    }
Praetorius, Simon's avatar
Praetorius, Simon committed
608
	
609
protected:	
610
    Initfile() 
611
612
613
614
    : msgInfo(0), 
      msgWait(1), 
      paramInfo(1), 
      breakOnMissingTag(0) 
615
    {}
616
617


618
619
    static void initIntern() 
    {
620
      if (singlett == NULL)
Praetorius, Simon's avatar
Praetorius, Simon committed
621
	singlett = new Initfile;
622
    }
Praetorius, Simon's avatar
Praetorius, Simon committed
623

624

625
626
    /// list of processed files
    static std::set< std::string > fn_include_list;
Praetorius, Simon's avatar
Praetorius, Simon committed
627

628

629
630
    /// pointer to the singleton that contains the data
    static Initfile* singlett;
631
632
633
634


    /// return the value of the given tag or throws an exception if the tag 
    /// does not exist
635
    int checkedGet(const std::string& tag, std::string &valStr) const
636
637
638
    {
      super::const_iterator it = find(tag);
      if (it == end()) {
639
        if (breakOnMissingTag == 0 || msgInfo <= 2)
640
	  return TAG_NOT_FOUND;
641
        else
642
	  return TAG_NOT_FOUND_BREAK;
643
      }
644
645
      valStr = it->second;
      return 0;
646
647
    }

648
649
650
651
652
    /// replace variables by its value defined as parameter previousely
    /// variable definition is simple parameter definition
    /// variable evaluation by ${variablename} or $variablename
    /// the last version only for variablenames without whitespaces
    std::string variableReplacement(const std::string& input) const;
653

Praetorius, Simon's avatar
Praetorius, Simon committed
654
655
    std::string variableEvaluation(const std::string& input) const;
    
656
    /** Fill the initfile from an input stream.
657
658
659
660
661
    * @param in: the stream to fill the data from.
    * Current dataformat: tag:value
    * Comment char: percent '%'
    * Include files: #include "filename" or #include <filename>
    */
662
663
664
    void read(std::istream& in);

    /// Fill the initfile from a file with filename fn
665
    void read(std::string fn, bool force = false);
666

667
    /** Write data-map to initfile
668
669
    * @param out: the stream to fill the data in.
    */
670
    void write(std::ostream& out);
Praetorius, Simon's avatar
Praetorius, Simon committed
671

672
673
    /// Write data-map to initfile with filename fn
    void write(std::string fn);
674

675
676
    /// read parameters for msgInfo, msgWait, paramInfo
    void getInternalParameters();
677

678
679
    int msgInfo, msgWait, paramInfo, breakOnMissingTag;	
  };
680
  
681
  typedef Initfile Parameters;
682

683
} // end namespace AMDiS
Praetorius, Simon's avatar
Praetorius, Simon committed
684
#endif