This file is indexed.

/usr/include/ASL/utilities/aslParametersManager.h is in libasl-dev 0.1.6-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
 * Advanced Simulation Library <http://asl.org.il>
 * 
 * Copyright 2015 Avtech Scientific <http://avtechscientific.com>
 *
 *
 * This file is part of Advanced Simulation Library (ASL).
 *
 * ASL is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, version 3 of the License.
 *
 * ASL is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with ASL. If not, see <http://www.gnu.org/licenses/>.
 *
 */


#ifndef ASLPARAMETERSMANAGER_H
#define ASLPARAMETERSMANAGER_H

#include "aslUValue.h"
#include <boost/program_options.hpp>
#include <map>
#include <typeinfo>

namespace asl
{

	class PrefixStore;

	/** This class stores parameter's value and the information
	 needed to extract it from command line and/or parameters file.
	 Important: declare Parameters only after declaring ParametersManager or
	 ApplicationParametersManager instance and before calling 
	 ParametersManager::load() because each Parameter adds itself
	 to the instance automatically!
	\ingroup LDI */
	template <typename T> class Parameter
	{
		public:
			/**
			  \p key_ - option key; is used to specify this parameter through
			  command line and/or parameters file.
			  \p description_ is used in the help output and as comment on
			  parameters file generation.
			  \p units_ - parameter units; is used to complement the option
			  description mentioned above. Might be used for automatic unit
			  conversion in future (to this end it is recommended to use the
			  notation of the Boost::Units library).
			  Since no default value is specified, the parameter is required
			  to be specified in the parameters file or command line.
			*/
			Parameter(const char* key_,
			          const char* description_,
			          const char* units_ = "");
			/**
			  \p defaultValue - default parameter value. Since a default value is
			  specified, the parameter is not required to be specified in the
			  parameters file or command line.
			  \p key_ - option key; is used to specify this parameter through
			  command line and/or parameters file.
			  \p description_ is used in the help output and as comment on
			  parameters file generation.
			  \p units_ - parameter units; is used to complement the option
			  description mentioned above. Might be used for automatic unit
			  conversion in future (to this end it is recommended to use the
			  notation of the Boost::Units library).
			*/
			Parameter(T defaultValue,
			          const char* key_,
			          const char* description_,
			          const char* units_ = "");
			inline const T & v() const;
			inline T & v();
			inline std::shared_ptr<T> p();

		private:
			UValue<T> parameter;
			const std::string key;
			const std::string description;
			const std::string units;
	};


	/** This class automatically accomodates newly created Parameters and then
	 can load them from a parameters file.
	 It has to be declared before declaring all the parameters it will manage!
	 \ingroup Utilities */
	class ParametersManager
	{
		public:
			ParametersManager();
			~ParametersManager();
			/// Enables parameter loader
			void enable();
			/// Adds a Parameter to ParametersManager
			template <typename T> void add(UValue<T> parameter,
			                               const char* key,
			                               const char* description,
			                               const char* units);
			/// Adds a group of parameters with common prefix to ParametersManager
			template <typename T> void add(UValue<std::map<std::string, T>> parameter,
			                               const char* key,
			                               const char* description,
			                               const char* units);
			/// Adds a Parameter with a default value to ParametersManager
			template <typename T> void add(UValue<T> parameter,
			                               T defaultValue,
			                               const char* key,
			                               const char* description,
			                               const char* units);
			/// Adds prefix and the pointer on the respective
			/// Parameter's destinationMap
			template <typename T>
			void addPrefix(const std::string prefix,
			               std::shared_ptr<std::map<std::string, T>> destinationMap);
			/// Loads all previously declared parameters
			/// from parameters file \p paramFile
			void load(std::string paramFile);
			/** Get the parameters file directory (absolute, with ending slash).
			It is convenient to write simulation results output together with
			its respective parameters file into the same directory (whose name
			might reflect the specifics of the parameters used) */
			std::string getDir();

			static ParametersManager * current;

		protected:
			boost::program_options::options_description parametersOptions;
			std::string parametersFileDirectory;
			/// Accomodates prefixes (defined by attached "*" wildcard)
			/// using PrefixStore class
			std::vector<std::shared_ptr<PrefixStore>> prefixes;

			void populateMaps(boost::program_options::variables_map & vm);
			/// Wrties all parameters and their
			/// default values (if available) to the file \p fileName
			void writeParametersFile(const std::string fileName);
			/// Content of the parameters file
			std::string parametersFileStr;
	};


	/** This class inherits ParametersManager class and thus also automatically
	accomodates newly created Parameters and then can load them from
	a parameters file and/or command line. It silently includes two parameters -
	`platform` and `device` that determine the hardware the application will run on.
	It has to be declared before declaring all the parameters it will manage!
	\ingroup Utilities */
	class ApplicationParametersManager: public ParametersManager
	{
		public:
			ApplicationParametersManager(const char* applicationName_,
			                             const char* applicationVersion_);
			
			/** Loads all previously declared parameters from command line
			and/or parameters file (provided through command line) */
			void load(int argc, char* argv[]);

		private:
			UValue<std::string> platform;
			UValue<std::string> device;
			std::string applicationName;
			std::string applicationVersion;
	};


//-------------------------- Implementation --------------------------


	template <typename T> const T & Parameter<T>::v() const
	{
		return parameter.v();
	}


	template <typename T> T & Parameter<T>::v()
	{
		return parameter.v();
	}

	template <typename T> std::shared_ptr<T> Parameter<T>::p()
	{
		return parameter.p;
	}
	
} //namespace asl
#endif // ASLPARAMETERSMANAGER_H