/usr/include/openturns/ResourceMap.hxx is in libopenturns-dev 1.9-5.
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 | // -*- C++ -*-
/**
* @brief ResourceMap defines a resource catalog
*
* Copyright 2005-2017 Airbus-EDF-IMACS-Phimeca
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef OPENTURNS_RESOURCEMAP_HXX
#define OPENTURNS_RESOURCEMAP_HXX
#include <map>
#include "openturns/Log.hxx" // ensures correct static initialization order
#include "openturns/OStream.hxx"
#include "openturns/Pointer.hxx"
#include "openturns/Path.hxx"
#include "openturns/MutexLock.hxx"
BEGIN_NAMESPACE_OPENTURNS
/**
* @class ResourceMap
* @brief Defines a catalog containing all default values used by OpenTURNS
*
* As OpenTURNS uses many default values for its computations, their actual values are
* accessible and editable through this class. Some default values are hardcoded in this class,
* some other are read in an configuration file.
*/
class OT_API ResourceMap
{
public:
#ifndef SWIG
/** GetInstance gives a locked access to the singleton */
static MutexLockSingleton<ResourceMap> GetInstance();
#endif
/** Get a value in the map */
static String Get(String key);
static Bool GetAsBool(String key);
static UnsignedInteger GetAsUnsignedInteger(String key);
static Scalar GetAsScalar(String key);
/** @deprecated */
static Scalar GetAsNumericalScalar(String key);
/** Set a value in the map */
static void Set(String key, String value);
static void SetAsBool(String key, Bool value);
static void SetAsUnsignedInteger(String key, UnsignedInteger value);
static void SetAsScalar(String key, Scalar value);
/** @deprecated */
static void SetAsNumericalScalar(String key, Scalar value);
/** Get the size of the map */
static UnsignedInteger GetSize();
/** Get the list of keys */
static std::vector<String> GetKeys();
/** @copydoc Object::__repr__() const */
String __repr__() const;
protected:
/** Method for retrieving information from the resource map
* @return The list of keys
*/
std::vector<String> getKeys() const;
/** Method for retrieving information from the resource map
* @param key The name under which the value is stored in the ResourceMap
* @return The value written into a string
*/
String get(String key) const;
/** Method for retrieving information from the resource map
* @param key The name under which the value is stored in the ResourceMap
* @return The value if the value is boolean castable, false otherwise
*/
Bool getAsBool(String key) const;
/** Method for retrieving information from the resource map
* @param key The name under which the value is stored in the ResourceMap
* @return The value if the value is integer castable, zero otherwise
*/
UnsignedInteger getAsUnsignedInteger(String key) const;
/** Method for retrieving information from the resource map
* @param key The name under which the value is stored in the ResourceMap
* @return The value if the value is double castable, zero otherwise
*/
Scalar getAsScalar(String key) const;
/** Method for retrieving information from the resource map
* @return The number of constants defined in the ResourceMap
*/
UnsignedInteger getSize() const;
/** Method for setting information into the resource map
* @param key The name under which the value is stored in the ResourceMap
* @param value The value written to a string
*/
void set(String key, String value);
/** Method for setting information into the resource map
* @param key The name under which the value is stored in the ResourceMap
* @param value The value as a boolean
*/
void setAsBool(String key, Bool value);
/** Method for setting information into the resource map
* @param key The name under which the value is stored in the ResourceMap
* @param value The value as an integer
*/
void setAsUnsignedInteger(String key, UnsignedInteger value);
/** Method for setting information into the resource map
* @param key The name under which the value is stored in the ResourceMap
* @param value The value as a double
*/
void setAsScalar(String key, Scalar value);
/** Update the ResourceMap with information from the configuration file */
void readConfigurationFile(const FileName & configurationFile);
/** Find the configuration file in specific path (see Path class for algorithm) */
FileName findConfigurationFile() const;
/** Load the configuration file */
void loadConfigurationFile();
/** Load the configuration defined at installation time */
void loadDefaultConfiguration();
private:
/** Default constructor */
ResourceMap();
/** Default constructor */
ResourceMap(const ResourceMap & other) : map_(other.map_) {}
/** The actual map that stores the key/value pairs */
typedef std::map< String, String > MapType;
MapType map_;
friend struct ResourceMap_init;
}; /* class ResourceMap */
/** This struct initializes all static members of ResourceMap */
struct OT_API ResourceMap_init
{
ResourceMap_init();
~ResourceMap_init();
};
/**
* @fn std::ostream & operator <<(std::ostream & os, const ResourceMap & obj)
* @brief Output stream converter
* @param os A STL output stream resourceMap
* @param obj The resourceMap read by \em os
* @return A reference to \em os
*
* Operator << converts the ResourceMap object to an output stream
* so it is easy to show the content of the resourceMap.
*/
#ifndef SWIG
OT_API std::ostream & operator <<(std::ostream & os, const MutexLockSingleton<ResourceMap> & obj);
OT_API OStream & operator <<(OStream & OS, const MutexLockSingleton<ResourceMap> & obj);
#endif
END_NAMESPACE_OPENTURNS
#endif /* OPENTURNS_RESOURCEMAP_HXX */
|