/usr/include/openturns/ResourceMap.hxx is in libopenturns-dev 1.5-7build2.
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 | // -*- C++ -*-
/**
* @file ResourceMap.hxx
* @brief ResourceMap defines a resource catalog
*
* Copyright 2005-2015 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/>.
*
* @author schueller
* @date 2012-02-17 19:35:43 +0100 (Fri, 17 Feb 2012)
*/
#ifndef OPENTURNS_RESOURCEMAP_HXX
#define OPENTURNS_RESOURCEMAP_HXX
#include <map>
#include "OStream.hxx"
#include "Pointer.hxx"
#include "Path.hxx"
#include "MutexLock.hxx"
BEGIN_NAMESPACE_OPENTURNS
/** Forward declaration */
class ResourceMap;
class OT_API ResourceMapInstance
{
ResourceMap & rm_;
MutexLock lock_;
public:
ResourceMapInstance( ResourceMap & rm ) throw();
ResourceMapInstance( const ResourceMapInstance & other );
/** @copydoc Object::__repr__() const */
String __repr__() const;
#ifndef SWIG
ResourceMap & lock() throw();
const ResourceMap & lock() const throw();
#endif
}; // end class ResourceMapInstance
/**
* @class ResourceMap
* @brief Defines a catalog containing all default values used by Open TURNS
*
* As Open TURNS 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:
/** Since ResourceMap is a singleton, GetInstance gives access to the object */
static ResourceMapInstance GetInstance();
private:
static void Release();
static void Initialize();
public:
/** Get a value in the map */
static String Get(String key);
static Bool GetAsBool(String key);
static UnsignedInteger GetAsUnsignedInteger(String key);
static NumericalScalar 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 SetAsNumericalScalar(String key, NumericalScalar value);
/** @copydoc Object::__repr__() const */
String __repr__() const;
protected:
/** 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
*/
NumericalScalar getAsNumericalScalar(String key) 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 setAsNumericalScalar(String key, NumericalScalar 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();
};
static ResourceMap_init __ResourceMap_initializer;
/**
* @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.
*/
OT_API std::ostream & operator <<(std::ostream & os, const ResourceMapInstance & obj);
#ifndef SWIG
OT_API OStream & operator <<(OStream & OS, const ResourceMapInstance & obj);
#endif
END_NAMESPACE_OPENTURNS
#endif /* OPENTURNS_RESOURCEMAP_HXX */
|