MAK Legion 1.1 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
configuration.h
Go to the documentation of this file.
1 /*********************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************************/
5 
8 
9 #pragma once
10 
11 #include "legionDataStore/export.h"
13 
14 #include <string>
15 #include <map>
16 
17 namespace Legion
18 {
20 
23  class LEGION_DLL Configuration
24  {
25  public:
27  Configuration();
28 
30  Configuration(const std::string& fileName);
31 
33  virtual ~Configuration();
34 
36  virtual Configuration* clone() const;
37 
41  template<typename DATA_TYPE>
42  void registerParameter(const std::string& string);
43 
48  virtual int processArguments(int argc, char** argv);
49 
53  virtual bool processParameters(const std::map<std::string, std::string>& parameterValuePairs);
54 
57  virtual bool hasParameter(const std::string& parameterName) const;
58 
60  virtual bool isParameterSet(const std::string& parameterName) const;
61 
64  virtual bool loadParameters(const std::string& fileName);
65 
68  virtual bool saveParameters(const std::string& filename) const;
69 
71  template<typename DATA_TYPE>
72  void setParameter(const std::string& parameterName, DATA_TYPE parameterValue);
73 
75  template<typename DATA_TYPE>
76  DATA_TYPE parameter(const std::string& parameterName) const;
77 
80  template<typename DATA_TYPE>
81  DATA_TYPE parameterOr(const std::string& parameterName, DATA_TYPE defaultValue) const;
82 
85  virtual void setUnitMultiplier(const std::string& parameterName, float multiplier);
86 
88  virtual float unitMultiplier(const std::string& parameterName) const;
89 
90  virtual std::string helpString() const;
91 
92  ConfigHandle handle() const { return myHandle; }
93 
94  protected:
96 
97  //used by clone
99 
100  };
101 
102  template<typename DATA_TYPE>
103  DATA_TYPE Legion::Configuration::parameterOr(const std::string& parameterName, DATA_TYPE defaultValue) const
104  {
105  if (hasParameter(parameterName))
106  {
107  return parameter<DATA_TYPE>(parameterName);
108  }
109 
110  return defaultValue;
111  }
112 }
UInt64 ConfigHandle
Definition: configuration.h:19
DATA_TYPE parameterOr(const std::string &parameterName, DATA_TYPE defaultValue) const
Get the parameter value with the given name as the expected type Supplied default value is used if pa...
Definition: configuration.h:103
unsigned long long UInt64
Definition: dataTypes.h:46
ConfigHandle handle() const
Definition: configuration.h:92
The configuration object parses the command line and loads a configuration file to provide the user c...
Definition: configuration.h:23
ConfigHandle myHandle
Definition: configuration.h:95

Document ID: Generated on Wed May 26 15:17:05 EDT 2021 from SVN revision 229676
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)