Goose Management Model ODdox  1.02
configurator.cpp
Go to the documentation of this file.
1 /*
2 *******************************************************************************************************
3 Copyright (c) 2011, Christopher John Topping, University of Aarhus
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without modification, are permitted provided
7 that the following conditions are met:
8 
9 Redistributions of source code must retain the above copyright notice, this list of conditions and the
10 following disclaimer.
11 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12 the following disclaimer in the documentation and/or other materials provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
15 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
17 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
19 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 ********************************************************************************************************
23 */
24 
25 #define _CRT_SECURE_NO_DEPRECATE
26 
27 #include <stdio.h>
28 #include <iostream>
29 #include <fstream>
30 #include <stdlib.h>
31 #include <string.h>
32 
33 #include "../BatchALMaSS/ALMaSS_Setup.h"
34 #include "configurator.h"
35 #include "maperrormsg.h"
36 
37 #if !(defined __UNIX) & !(defined __BORLANDC__)
38 #include <crtdbg.h>
39 #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
40 #ifdef _DEBUG
41 #define new DEBUG_NEW
42 #endif
43 #endif
44 
45 using namespace std;
46 
47 extern void FloatToDouble(double&, float);
48 
49 class Configurator *g_cfg = NULL;
50 
51 static CfgBool l_cfg_public_warn_on_set("CFG_PUBLIC_WARN_ON_SET",
52  CFG_CUSTOM, true );
53 static CfgBool l_cfg_public_exit_on_set("CFG_PUBLIC_EXIT_ON_SET",
54  CFG_CUSTOM, true );
55 
56 
57 static const char* CfgSecureStrings[] = {
58  "CFG_CUSTOM",
59  "CFG_PUBLIC",
60  "CFG_PRIVATE"
61 };
62 
63 
64 static const char* CfgTypeStrings[] = {
65  "*none*",
66  "int",
67  "double",
68  "bool",
69  "string"
70 };
71 
72 
73 CfgBase::CfgBase( const char* a_key, CfgSecureLevel a_level )
74 {
75  if ( NULL == g_cfg ) {
76  g_cfg = new Configurator;
77  }
78 
79  m_key = a_key;
80  m_level = a_level;
81  m_rangetest = false;
82  g_cfg->Register( this, a_key );
83 }
84 
85 
86 
88 {
89  ;
90 }
91 
92 
93 
94 CfgInt::CfgInt(const char* a_key, CfgSecureLevel a_level, int a_defval) :CfgBase(a_key, a_level)
95 {
96  m_int = a_defval;
97 }
98 
99 CfgInt::CfgInt(const char* a_key, CfgSecureLevel a_level, int a_defval, int a_min, int a_max) :CfgBase(a_key, a_level)
100 {
102  m_min = a_min;
103  m_max = a_max;
104  m_rangetest = true;
105  set(a_defval);
106 }
107 
108 void CfgInt::set(int a_newval) {
109  if (m_rangetest) {
110  if ((a_newval<m_min) || (a_newval>m_max))
111  {
112  g_msg->Warn(WARN_FILE, "CfgInt::set Value out of range: ", a_newval);
113  g_msg->Warn(WARN_FILE, "CfgInt::set Max allowed: ", m_max);
114  g_msg->Warn(WARN_FILE, "CfgInt::set Min allowed: ", m_min);
115  }
116  }
117  m_int = a_newval;
118 }
119 
120 
121 CfgFloat::CfgFloat(const char* a_key, CfgSecureLevel a_level, double a_defval) :CfgBase(a_key, a_level)
122 {
123  m_float = a_defval;
124 }
125 
126 CfgFloat::CfgFloat(const char* a_key, CfgSecureLevel a_level, double a_defval, double a_min, double a_max) : CfgBase(a_key, a_level)
127 {
128  m_min = a_min;
129  m_max = a_max;
130  m_rangetest = true;
131  set(a_defval);
132 }
133 
134 void CfgFloat::set(double a_newval) {
135  if (m_rangetest) {
136  if ((a_newval<m_min) || (a_newval>m_max))
137  {
138  g_msg->Warn("CfgFloat::set Value out of range: ", a_newval);
139  g_msg->Warn("CfgFloat::set Max allowed: ", m_max);
140  g_msg->Warn("CfgFloat::set Min allowed: ", m_min);
141  }
142  }
143  m_float = a_newval;
144 }
145 
146 
147 
148 CfgBool::CfgBool( const char* a_key,
149  CfgSecureLevel a_level,
150  bool a_defval )
151  :CfgBase( a_key, a_level )
152 {
153  m_bool = a_defval;
154 }
155 
156 
157 
158 CfgStr::CfgStr( const char* a_key,
159  CfgSecureLevel a_level,
160  const char* a_defval )
161  :CfgBase( a_key, a_level )
162 {
163  m_string = a_defval;
164 }
165 
166 
167 
169 {
170  m_lineno = 0;
171 }
172 
173 
174 
176 {
177  ;
178 }
179 
180 
181 
182 bool Configurator::Register( CfgBase* a_cfgval, const char* a_key )
183 {
184  string l_key = a_key;
185 
186  if ( CfgI.find( l_key ) != CfgI.end() ) {
187  // Couldn't register, already exists.
188  return false;
189  }
190 
191  unsigned int i = (int) CfgVals.size();
192  CfgI[ l_key ] = i;
193  CfgVals.resize( i+1 );
194  CfgVals[ i ] = a_cfgval;
195 
196  return true;
197 }
198 
199 
200 
201 bool Configurator::ReadSymbols( const char *a_cfgfile ) {
202  ifstream cf_file;
203  char cfgline[ CFG_MAX_LINE_LENGTH ];
204  cf_file.open(a_cfgfile,fstream::in);
205  if ( !cf_file.is_open() ) {
206  g_msg->Warn( WARN_FILE, "Configurator::ReadSymbols() Unable to open file for reading: ", a_cfgfile );
207  exit(1);
208  }
209  while ( !cf_file.eof()) {
210  for (unsigned i=0; i< CFG_MAX_LINE_LENGTH; i++) cfgline[i]=' '; // Done to get rid of the rubbish that otherwise messes up the parse
211  cf_file.getline(cfgline,CFG_MAX_LINE_LENGTH);
212  ParseCfgLine( cfgline );
213  m_lineno++;
214  }
215  cf_file.close();
216  return true;
217 }
218 
219 
220 
221 // Caution, modifies original line, and returns a pointer to a
222 // substring of a_line.
223 char* Configurator::ExtractString( char* a_line )
224 {
225  char lineno[ 20 ];
226 
227  // scan for the first double quote or end of line.
228  while ( *a_line != '"' && *a_line != '\0' ) {
229  a_line++;
230  }
231 
232  // The first char in the string had better contain a '"':
233  if ( *a_line != '"' ) {
234  sprintf( lineno, "%d", m_lineno );
235  g_msg->Warn( WARN_FILE, "Configurator::ExtractString()\n"
236  " String not enclosed in double quotes at "
237  "config line ", lineno );
238  exit(1);
239  }
240 
241  char* endline = ++a_line;
242  bool escaped = false, found = false;
243 
244  while ( *endline != '\0' ) {
245  if ( *endline == '\\' ) {
246  escaped = true;
247  endline++;
248 
249  if ( *endline == '"' &&
250  LastDoubleQuote( endline )) {
251  escaped = false;
252  } else {
253  continue;
254  }
255  }
256  if ( *endline == '"' && !escaped ) {
257  // Found end of string, terminate properly and break the loop.
258  *endline++ = '\0';
259  found = true;
260  break;
261  }
262  escaped = false;
263  endline++;
264  }
265 
266  if ( !found ) {
267  sprintf( lineno, "%d", m_lineno );
268  g_msg->Warn( WARN_FILE, "Configurator::ExtractString() "
269  "No ending double quote after string at "
270  "config line ", lineno );
271  exit(1);
272  }
273 
274 
275  // Check for comment if remainder of line isn't empty.
276  if ( sscanf( endline, "%*s" ) == 1 ) {
277  // Non-empty comment line.
278  if ( sscanf( endline, "%*[#]" ) != 1 ) {
279  // But not initiated by '#'.
280  sprintf( lineno, "%d", m_lineno );
281  g_msg->Warn( WARN_FILE, "Configurator::ExtractString() "
282  "Illegal comment at "
283  "config line ", lineno );
284  exit(1);
285  }
286  }
287 
288  return a_line;
289 }
290 
291 
292 bool Configurator::LastDoubleQuote( char* a_rest_of_line )
293 {
294  a_rest_of_line++;
295 
296  while ( *a_rest_of_line != '\0' && *a_rest_of_line != '#' ) {
297  if ( *a_rest_of_line == '"' ) {
298  return false;
299  }
300  a_rest_of_line++;
301  }
302  return true;
303 }
304 
305 
306 
307 void Configurator::ParseCfgLine( char* a_line )
308 {
309  char l_id [ CFG_MAX_LINE_LENGTH ];
310  char l_type[ CFG_MAX_LINE_LENGTH ];
311  char l_sep [ CFG_MAX_LINE_LENGTH ];
312  char l_val [ CFG_MAX_LINE_LENGTH ];
313  char l_comm[ CFG_MAX_LINE_LENGTH ];
314  char lineno[20];
315 
316  if ( sscanf( a_line, "%[#]", l_id ) == 1 ) {
317  // Comment line.
318  return;
319  }
320 
321  if ( sscanf( a_line, "%s", l_id) == EOF ) {
322  // Empty line consisting only of white spaces.
323  return;
324  }
325 
326  //int l_conv = sscanf( a_line, "%[A-Z_] (%[a-z]) %s", l_id, sizeof(l_id),l_type,sizeof(l_type), l_sep,sizeof(l_sep) );
327 int l_conv = sscanf( a_line, "%[A-Z_] (%[a-z]) %s", l_id, l_type, l_sep );
328 
329  if ( l_conv < 3 ) {
330  // Syntax terror.
331  sprintf( lineno, "%d", m_lineno );
332  g_msg->Warn( WARN_FILE, "Configurator::ParseCfgLine() "
333  "Syntax error at config line ",
334  lineno );
335  exit(1);
336  }
337 
338  if ( strcmp( l_sep, "=" ) != 0 ) {
339  // Missing '=' assignment separator.
340  sprintf( lineno, "%d", m_lineno );
341  g_msg->Warn( WARN_FILE, "Configurator::ParseCfgLine() "
342  "Missing '=' assignment operator at config line ",
343  lineno );
344  exit(1);
345  }
346 
347  if ( CfgI.find( l_id ) == CfgI.end() ) {
348  // Key doesn't exists among the predefined, global configuration
349  // variables. Ignore quietly.
350  return;
351  }
352 
353  if ( strlen( l_type ) == 6 &&
354  strncmp( l_type, "string", 6 ) == 0 ) {
355  // We are not yet ready to do the assignment.
356  // If we really have a string enclosed in non-escaped
357  // double quotes at the end of the line, then we need to
358  // extract it first from our input.
359  SetCfgStr( l_id, ExtractString( a_line ));
360  return;
361  }
362 
363  // Not a string, so extract data value and possible comment.
364  l_conv = sscanf( a_line, "%*[A-Z_] (%*[a-z]) %*s %s %s",
365  l_val, l_comm );
366 
367  if ( l_conv == 2 && l_comm[0] != '#' ) {
368  // Illegal comment at end of line.
369  sprintf( lineno, "%d", m_lineno );
370  g_msg->Warn( WARN_FILE, "Configurator::ParseCfgLine() "
371  "Syntax error at end of config line ",
372  lineno );
373  exit(1);
374  }
375 
376  if ( strlen( l_type ) == 5 &&
377  strncmp( l_type, "float", 5 ) == 0 ) {
378  SetCfgFloat( l_id, l_val );
379  return;
380  }
381 
382  if ( strlen( l_type ) == 4 &&
383  strncmp( l_type, "bool", 4 ) == 0 ) {
384  SetCfgBool( l_id, l_val );
385  return;
386  }
387 
388  if ( strlen( l_type ) == 3 &&
389  strncmp( l_type, "int", 3 ) == 0 ) {
390  SetCfgInt( l_id, l_val );
391  return;
392  }
393 
394  sprintf( lineno, "%d", m_lineno );
395  g_msg->Warn( WARN_FILE, "Configurator::ParseCfgLine() "
396  "Unknown type specifier at config line ",
397  lineno );
398  exit(1);
399 }
400 
401 
402 
403 void Configurator::ShowIdType( unsigned int a_i )
404 {
406  "Type for identifier ",
407  CfgVals[ a_i ]->getkey().c_str() );
408  g_msg->WarnAddInfo( WARN_FILE, " is (",
409  CfgTypeStrings[ CfgVals[ a_i ]->gettype() ] );
410  g_msg->WarnAddInfo( WARN_FILE, ")\n", "" );
411 }
412 
413 
414 
415 bool Configurator::SetCfgGatekeeper( const char* a_method,
416  const char* /* a_key */,
417  CfgSecureLevel a_level )
418 {
419  if ( a_level == CFG_PRIVATE ) {
420  // Attempting to set private config variable. Ignore quietly.
421  return true;
422  }
423 
424  if ( a_level == CFG_PUBLIC &&
426  // Attempting to set public config variable. Warn and
427  // possibly exit if this is configured.
428  char lineno[20];
429  sprintf( lineno, "%d", m_lineno );
430  g_msg->Warn( WARN_FILE, a_method, lineno );
431 
433  exit(1);
434  }
435  return true;
436  }
437  return false;
438 }
439 
440 
441 
442 void Configurator::SetCfgInt( char* a_key, char* a_val )
443 {
444  int l_val;
445  char lineno[20];
446  string l_key = a_key;
447 
448  if ( sscanf( a_val, "%d", &l_val ) != 1 ) {
449  sprintf( lineno, "%d", m_lineno );
450  g_msg->Warn( WARN_FILE, "Configurator::SetCfgInt() "
451  "Not an integer data value at config line",
452  lineno );
453  exit(1);
454  }
455 
456  // Check access security.
457  unsigned int i = CfgI[ l_key ];
458  if ( SetCfgGatekeeper( "Configurator::SetCfgInt() "
459  "Attempting to set public config variable in line",
460  a_key,
461  CfgVals[ i ]->getlevel()
462  )) {
463  return;
464  }
465 
466  if ( CfgVals[ i ]->gettype() != CFG_INT ) {
467  sprintf( lineno, "%d", m_lineno );
468  g_msg->Warn( WARN_FILE, "Configurator::SetCfgInt() "
469  "Non-integer identifier specified at config line",
470  lineno );
471  ShowIdType( i );
472  exit(1);
473  }
474 
475  dynamic_cast<CfgInt*>(CfgVals[ i ])->set( l_val );
476 }
477 
478 
479 void Configurator::SetCfgBool( char* a_key, char* a_val )
480 {
481  char lineno[20];
482  string l_key = a_key;
483  bool l_val = false;
484 
485  if ( strcmp ( a_val, "false" ) == 0 ) {
486  ; // l_val defaults to false.
487  } else if ( strcmp ( a_val, "true" ) == 0 ) {
488  l_val = true;
489  } else {
490  sprintf( lineno, "%d", m_lineno );
491  g_msg->Warn( WARN_FILE, "Configurator::SetCfgBool() "
492  "Not a boolean data value at config line",
493  lineno );
494  exit(1);
495  }
496 
497  // Check access security.
498  unsigned int i = CfgI[ l_key ];
499  if ( SetCfgGatekeeper( "Configurator::SetCfgBool() "
500  "Attempting to set public config variable in line",
501  a_key,
502  CfgVals[ i ]->getlevel()
503  )) {
504  return;
505  }
506 
507  if ( CfgVals[ i ]->gettype() != CFG_BOOL ) {
508  sprintf( lineno, "%d", m_lineno );
509  g_msg->Warn( WARN_FILE, "Configurator::SetCfgBool() "
510  "Non-boolean identifier specified at config line",
511  lineno );
512  ShowIdType( i );
513  exit(1);
514  }
515 
516  dynamic_cast<CfgBool*>(CfgVals[ i ])->set( l_val );
517 }
518 
519 
520 
521 void Configurator::SetCfgFloat( char* a_key, char* a_val )
522 {
523  double l_val;
524  float f;
525  char lineno[20];
526  string l_key = a_key;
527 
528  if ( sscanf( a_val, "%f", &f) != 1 ) {
529  sprintf( lineno, "%d", m_lineno );
530  g_msg->Warn( WARN_FILE, "Configurator::SetCfgFloat() "
531  "Not a floating point data value at config line",
532  lineno );
533  exit(1);
534  }
535  FloatToDouble(l_val,f);
536 
537  // Check access security.
538  unsigned int i = CfgI[ l_key ];
539  if ( SetCfgGatekeeper( "Configurator::SetCfgFloat() "
540  "Attempting to set public config variable in line",
541  a_key,
542  CfgVals[ i ]->getlevel()
543  )) {
544  return;
545  }
546 
547  if ( CfgVals[ i ]->gettype() != CFG_FLOAT ) {
548 sprintf( lineno, "%d", m_lineno );
549  g_msg->Warn( WARN_FILE, "Configurator::SetCfgFloat() "
550  "Non-floating point identifier specified at config line",
551  lineno );
552  ShowIdType( i );
553  exit(1);
554  }
555 
556  dynamic_cast<CfgFloat*>(CfgVals[ i ])->set( l_val );
557 }
558 
559 
560 
561 void Configurator::SetCfgStr( char* a_key, char* a_val )
562 {
563  char lineno[20];
564  string l_key = a_key;
565 
566  // Check access security.
567  unsigned int i = CfgI[ l_key ];
568  if ( SetCfgGatekeeper( "Configurator::SetCfgStr() "
569  "Attempting to set public config variable in line",
570  a_key,
571  CfgVals[ i ]->getlevel()
572  )) {
573  return;
574  }
575 
576  if ( CfgVals[ i ]->gettype() != CFG_STRING ) {
577  sprintf( lineno, "%d", m_lineno );
578  g_msg->Warn( WARN_FILE, "Configurator::SetCfgStr() "
579  "Non-string identifier specified at config line",
580  lineno );
581  ShowIdType( i );
582  exit(1);
583  }
584 
585  dynamic_cast<CfgStr*>(CfgVals[ i ])->set( a_val );
586 }
587 
588 
589 
590 void Configurator::DumpPublicSymbols( const char *a_dumpfile,
591  CfgSecureLevel a_level )
592 {
593  if ( a_level > CFG_PUBLIC ) {
594  a_level = CFG_PUBLIC;
595  }
596  DumpSymbols( a_dumpfile, a_level );
597 }
598 
599 
600 
601 void Configurator::DumpAllSymbolsAndExit( const char *a_dumpfile )
602 {
603  DumpSymbols( a_dumpfile, CFG_PRIVATE );
604  exit(1);
605 }
606 
607 
608 void Configurator::DumpSymbols( const char *a_dumpfile,
609  CfgSecureLevel a_level )
610 {
611  FILE *l_dumpfile;
612  char l_oprefix[ CFG_MAX_LINE_LENGTH ] = {""};
613  char l_nprefix[ CFG_MAX_LINE_LENGTH ];
614  const char* l_id;
615  l_dumpfile=fopen( a_dumpfile, "w" );
616  if (!l_dumpfile) {
617  g_msg->Warn( WARN_FILE, "Configurator::DumpSymbols() "
618  "Unable to open file for writing:",
619  a_dumpfile );
620  exit(1);
621  }
622 
623  typedef map<string,unsigned int>::const_iterator MI;
624 
625  for ( MI ii = CfgI.begin(); ii != CfgI.end(); ii++ ) {
626  unsigned int i = ii->second;
627 
628  // Skip 'secret' variables.
629  if ( CfgVals[ i ]->getlevel() > a_level ) {
630  continue;
631  }
632 
633  // Weird hack to separate different groups of
634  // configuration names.
635  string rubbish=CfgVals[ i ]->getkey();
636  l_id=rubbish.c_str();
637  //l_id = CfgVals[ i ]->getkey().c_str();
638  sscanf( l_id, "%[A-Z]", l_nprefix );
639  if ( strcmp( l_oprefix, l_nprefix ) != 0 ) {
640  fprintf( l_dumpfile, "\n" );
641  strcpy( l_oprefix, l_nprefix );
642  }
643 
644  fprintf( l_dumpfile, "%s (%s) = ",
645  l_id,
646  CfgTypeStrings[ CfgVals[ i ]->gettype() ]
647  );
648 
649  switch( CfgVals[ i ]->gettype() ) {
650  case CFG_INT:
651  {
652  CfgInt* l_p = dynamic_cast<CfgInt*>(CfgVals[ i ]);
653  fprintf( l_dumpfile, "%d", l_p->value() );
654  break;
655  }
656  case CFG_FLOAT:
657  {
658  CfgFloat* l_p = dynamic_cast<CfgFloat*>(CfgVals[ i ]);
659  fprintf( l_dumpfile, "%f", l_p->value() );
660  break;
661  }
662  case CFG_BOOL:
663  {
664  CfgBool* l_p = dynamic_cast<CfgBool*>(CfgVals[ i ]);
665  if ( l_p->value() ) {
666  fprintf( l_dumpfile, "true" );
667  } else {
668  fprintf( l_dumpfile, "false" );
669  }
670  break;
671  }
672  case CFG_STRING:
673  {
674  CfgStr* l_p = dynamic_cast<CfgStr*>(CfgVals[ i ]);
675  fprintf( l_dumpfile, "\"%s\"", l_p->value() );
676  break;
677  }
678  default:
679  {
680  char l_errno[20];
681  sprintf( l_errno, "%d", CfgVals[ i ]->gettype() );
682  g_msg->Warn( WARN_FILE, "Configurator::DumpSymbols() "
683  "Unknown symbol type read:",
684  l_errno );
685  exit(1);
686  }
687  }
688  fprintf( l_dumpfile, " # %s\n",
689  CfgSecureStrings[ CfgVals[ i ]->getlevel() ]
690  );
691  }
692 
693 }
Configurator::CfgI
map< string, unsigned int > CfgI
Definition: configurator.h:164
CfgStr::value
const char * value(void)
Definition: configurator.h:152
CfgStr::CfgStr
CfgStr(const char *a_key, CfgSecureLevel a_level, const char *a_defval)
Definition: configurator.cpp:158
CFG_INT
Definition: configurator.h:53
Configurator::Configurator
Configurator(void)
Definition: configurator.cpp:168
CfgBase::~CfgBase
virtual ~CfgBase(void)
Definition: configurator.cpp:87
CFG_BOOL
Definition: configurator.h:55
CfgFloat::m_min
double m_min
Definition: configurator.h:110
CfgFloat::CfgFloat
CfgFloat(const char *a_key, CfgSecureLevel a_level, double a_defval)
Definition: configurator.cpp:121
MapErrorMsg::WarnAddInfo
void WarnAddInfo(MapErrorState a_level, std::string a_add1, std::string a_add2)
Definition: maperrormsg.cpp:149
CfgStr
String configurator entry class.
Definition: configurator.h:144
Configurator::~Configurator
~Configurator(void)
Definition: configurator.cpp:175
Configurator::SetCfgGatekeeper
bool SetCfgGatekeeper(const char *a_method, const char *a_key, CfgSecureLevel a_level)
Definition: configurator.cpp:415
CFG_STRING
Definition: configurator.h:56
CfgBool::CfgBool
CfgBool(const char *a_key, CfgSecureLevel a_level, bool a_defval)
Definition: configurator.cpp:148
CfgInt::m_max
int m_max
Definition: configurator.h:91
l_cfg_public_exit_on_set
static CfgBool l_cfg_public_exit_on_set("CFG_PUBLIC_EXIT_ON_SET", CFG_CUSTOM, true)
Configurator
A class to provide standard parameter entry facilities.
Definition: configurator.h:161
CFG_PUBLIC
Definition: configurator.h:61
Configurator::ShowIdType
void ShowIdType(unsigned int a_i)
Definition: configurator.cpp:403
CfgFloat::m_max
double m_max
Definition: configurator.h:111
CfgFloat::set
virtual void set(double a_newval)
Definition: configurator.cpp:134
CfgTypeStrings
static const char * CfgTypeStrings[]
Definition: configurator.cpp:64
CfgBase::CfgBase
CfgBase(const char *a_key, CfgSecureLevel a_level)
Definition: configurator.cpp:73
CfgStr::m_string
string m_string
Definition: configurator.h:147
g_cfg
class Configurator * g_cfg
Definition: configurator.cpp:49
Configurator::ReadSymbols
bool ReadSymbols(const char *a_cfgfile)
Definition: configurator.cpp:201
CfgFloat::m_float
double m_float
Definition: configurator.h:109
Configurator::DumpPublicSymbols
void DumpPublicSymbols(const char *a_dumpfile, CfgSecureLevel a_level)
Definition: configurator.cpp:590
CfgBool
Bool configurator entry class.
Definition: configurator.h:127
Configurator::SetCfgBool
void SetCfgBool(char *a_key, char *a_val)
Definition: configurator.cpp:479
CfgSecureStrings
static const char * CfgSecureStrings[]
Definition: configurator.cpp:57
maperrormsg.h
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:59
CfgInt::m_min
int m_min
Definition: configurator.h:92
Configurator::Register
bool Register(CfgBase *a_cfgval, const char *a_key)
Definition: configurator.cpp:182
CFG_MAX_LINE_LENGTH
#define CFG_MAX_LINE_LENGTH
Definition: configurator.h:46
CfgBase::m_rangetest
bool m_rangetest
Definition: configurator.h:73
CFG_FLOAT
Definition: configurator.h:54
Configurator::SetCfgStr
void SetCfgStr(char *a_key, char *a_val)
Definition: configurator.cpp:561
CfgFloat::value
double value(void)
Definition: configurator.h:118
CFG_CUSTOM
Definition: configurator.h:60
FloatToDouble
void FloatToDouble(double &, float)
CfgSecureLevel
CfgSecureLevel
Definition: configurator.h:59
CfgInt::CfgInt
CfgInt(const char *a_key, CfgSecureLevel a_level, int a_defval)
Definition: configurator.cpp:94
Configurator::LastDoubleQuote
bool LastDoubleQuote(char *a_rest_of_line)
Definition: configurator.cpp:292
WARN_FILE
Definition: maperrormsg.h:37
CfgInt
Integer configurator entry class.
Definition: configurator.h:87
l_cfg_public_warn_on_set
static CfgBool l_cfg_public_warn_on_set("CFG_PUBLIC_WARN_ON_SET", CFG_CUSTOM, true)
Configurator::ExtractString
char * ExtractString(char *a_line)
Definition: configurator.cpp:223
g_msg
MapErrorMsg * g_msg
This pointer provides access the to the internal ALMaSS error message system.
Definition: maperrormsg.cpp:41
CfgBase
Base class for a configurator entry.
Definition: configurator.h:69
CfgFloat
Double configurator entry class.
Definition: configurator.h:106
CfgInt::m_int
int m_int
Definition: configurator.h:90
Configurator::SetCfgInt
void SetCfgInt(char *a_key, char *a_val)
Definition: configurator.cpp:442
CFG_PRIVATE
Definition: configurator.h:62
CfgInt::value
int value(void)
Definition: configurator.h:98
Configurator::DumpSymbols
void DumpSymbols(const char *a_dumpfile, CfgSecureLevel a_level)
Definition: configurator.cpp:608
CfgBool::m_bool
bool m_bool
Definition: configurator.h:130
configurator.h
Configurator::CfgVals
vector< CfgBase * > CfgVals
Definition: configurator.h:165
Configurator::ParseCfgLine
void ParseCfgLine(char *a_line)
Definition: configurator.cpp:307
Configurator::SetCfgFloat
void SetCfgFloat(char *a_key, char *a_val)
Definition: configurator.cpp:521
Configurator::m_lineno
unsigned int m_lineno
Definition: configurator.h:168
CfgBool::value
bool value(void)
Definition: configurator.h:135
Configurator::DumpAllSymbolsAndExit
void DumpAllSymbolsAndExit(const char *a_dumpfile)
Definition: configurator.cpp:601
CfgInt::set
virtual void set(int a_newval)
Definition: configurator.cpp:108