/usr/include/openturns/WrapperData.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 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | // -*- C++ -*-
/**
* @file WrapperData.hxx
* @brief This class declares the wrapper data that are exchanged with the platform
*
* 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_WRAPPERDATA_HXX
#define OPENTURNS_WRAPPERDATA_HXX
#include "OTprivate.hxx"
#include "Object.hxx"
#include "Pointer.hxx" // for shared pointer
#include "WrapperInterface.h"
#include "Collection.hxx"
BEGIN_NAMESPACE_OPENTURNS
/**
* @struct WrapperSymbolProvided
* @brief Stores information about the presence or no of symbols in the wrapper
*/
struct OT_API WrapperSymbolProvided
{
static const WrapperProvided NO; ///< No symbol is provided
static const WrapperProvided YES; ///< The symbol is provided
};
/**
* @struct WrapperComputedGradient
* @brief Stores information about the computation of gradient for a variable
* @internal
* @deprecated
* This class is deprecated and should not be used anymore.
*/
struct OT_API WrapperComputedGradient
{
static const WrapperProvided NO; ///< No need to compute the gradient within the numerical function
static const WrapperProvided YES; ///< We need to compute the gradient within the numerical function
};
/**
* @struct WrapperFunctionDescription
* @brief Describes what is the interface of a numerical function
*/
struct OT_API WrapperFunctionDescription
: public Object
{
String name_; ///< The name of the numerical function
WrapperProvided provided_; ///< Is the symbol present in the wrapper ?
WrapperFunctionDescription();
virtual String __repr__() const;
virtual String __str__(const String & offset = "") const;
};
/**
* @struct WrapperDataFileType
* @brief Stores the type (input or output) of the file
*/
struct OT_API WrapperDataFileType
{
static const WrapperListElementType IN; ///< The file is an input file
static const WrapperListElementType OUT; ///< The file is an output file
};
/**
* @struct WrapperDataFile
* @brief Holds the name and the path of any file passed as argument to the wrapper
*/
struct OT_API WrapperDataFile
: public Object
{
String id_; ///< The id of the file (any string to distinguish each file from another)
String name_; ///< The name of the file (stdin, stdout, log, etc.)
FileName path_; ///< The path of the file (/tmp/stdin, /var/log/mylog, etc.)
String subst_; ///< The list of variable's ids to be substituted in the file
WrapperListElementType type_; ///< The type of the file (input or output)
WrapperDataFile();
Bool operator == (const WrapperDataFile & other) const;
virtual String __repr__() const;
virtual String __str__(const String & offset = "") const;
}; /* struct WrapperDataFile */
/**
* @struct WrapperDataVariableType
* @brief Stores the type (input or output) of the variable
*/
struct OT_API WrapperDataVariableType
{
static const WrapperListElementType IN; ///< The variable is an input variable
static const WrapperListElementType OUT; ///< The variable is an output variable
static const WrapperListElementType INTERNAL; ///< The variable is internal to the platform (not user defined)
};
/**
* @struct WrapperDataVariableLocation
* @brief Stores the line number or the regular expression that locates the variable in the file
*/
struct OT_API WrapperDataVariableLocation
{
static const WrapperLocationType LINE; ///< The location is a line number
static const WrapperLocationType REGEXP; ///< The location is a regular expression
};
/**
* @struct WrapperDataVariable
* @brief Holds information of any variable passed as argument to the wrapper
*/
struct OT_API WrapperDataVariable
: public Object
{
String id_; ///< The id of the variable (any string to distinguish each variable from another)
String comment_; ///< A comment to inform on the variable
String unit_; ///< The unit which the variable is expressed in
String regexp_; ///< The regular expression used to find the variable location in files
String format_; ///< The format in which the variable must be printed in files
WrapperListElementType type_; ///< The type of the variable (input or output)
WrapperProvided gradient_; ///< The gradient of this variable is computed if true (@deprecated)
WrapperLocationType fromType_; ///< The type of the from_ member
String from_; ///< The location where substitution should start
WrapperLocationType toType_; ///< The type of the to_ member
String to_; ///< The location where substitution should stop
WrapperDataVariable();
Bool operator == (const WrapperDataVariable & other) const;
virtual String __repr__() const;
virtual String __str__(const String & offset = "") const;
}; /* struct WrapperDataVariable */
/**
* @struct WrapperState
* @brief Stores the mode of invocation of the external code
*/
struct OT_API WrapperState
{
static const WrapperConfigurationState SHARED; ///< The intenal state is shared amoung function, gradient and hessian
static const WrapperConfigurationState SPECIFIC; ///< Function, gradient and hessian have specific internal state
};
/**
* @struct WrapperMode
* @brief Stores the mode of invocation of the external code
*/
struct OT_API WrapperMode
{
static const WrapperConfigurationMode STATICLINK; ///< The external code is statically linked with the wrapper
static const WrapperConfigurationMode DYNAMICLINK; ///< The external code is dynamically linked with the wrapper
static const WrapperConfigurationMode FORK; ///< the external code is a separate shell command
};
/**
* @struct WrapperDataTransfer
* @brief Stores the mode of transmission for the arguments
*/
struct OT_API WrapperDataTransfer
{
static const WrapperDataTransferMode FILES; ///< The values are transmitted through files
static const WrapperDataTransferMode PIPE; ///< The values are transmitted through a pipe
static const WrapperDataTransferMode ARGUMENTS; ///< The values are transmitted as command line arguments
static const WrapperDataTransferMode SOCKET; ///< The values are transmitted through a socket
static const WrapperDataTransferMode CORBA; ///< The values are transmitted through CORBA
};
/**
* struct WrapperParameter
* @brief Holds the configuration of the wrapper
*/
struct OT_API WrapperParameter
: public Object
{
WrapperConfigurationState state_; ///< The sharing mode of internal state
WrapperConfigurationMode mode_; ///< The mode of invocation of the external code
WrapperDataTransferMode in_; ///< The transmission mode for input arguments
WrapperDataTransferMode out_; ///< The transmission mode for output arguments
String command_; ///< The command that should invoque the external code according to mode
String userPrefix_; ///< The prefix that helps the user to find its compute dir
WrapperParameter();
virtual String __repr__() const;
virtual String __str__(const String & offset = "") const;
}; /* struct WrapperParameter */
/**
* @class WrapperData
* @brief Declares the wrapper data that are exchanged with the platform
*/
class OT_API WrapperData
: public Object
{
CLASSNAME;
public:
typedef struct WrapperExchangedData ExchangedData;
typedef struct WrapperExchangedData * ExchangedDataPointer;
typedef const struct WrapperExchangedData * ConstExchangedDataPointer;
typedef Collection<WrapperDataFile> FileListType;
typedef Collection<WrapperDataVariable> VariableListType;
/** Default constructor */
WrapperData();
/** Constructor from C structure */
WrapperData(const struct WrapperExchangedData * p_exchangedData);
/* String converter */
virtual String __repr__() const;
virtual String __str__(const String & offset = "") const;
/** Library path accessor
* @param path The path of the dynamic library of the wrapper
*/
void setLibraryPath(const FileName & path);
/** Library path accessor
* @return The path of the dynamic library of the wrapper
*/
FileName getLibraryPath() const;
/** Function description accessor
* @param funcDescription The complete description of the numerical function inside the wrapper
*/
void setFunctionDescription(const WrapperFunctionDescription & funcDescription);
/** Function description accessor
* @return The complete description of the numerical function inside the wrapper
*/
WrapperFunctionDescription getFunctionDescription() const;
/** Gradient description accessor
* @param gradDescription The complete description of the numerical function gradient inside the wrapper
*/
void setGradientDescription(const WrapperFunctionDescription & gradDescription);
/** Gradient description accessor
* @return The complete description of the numerical function gradient inside the wrapper
*/
WrapperFunctionDescription getGradientDescription() const;
/** Hessian description accessor
* @param hessDescription The complete description of the numerical function hessian inside the wrapper
*/
void setHessianDescription(const WrapperFunctionDescription & hessDescription);
/** Hessian description accessor
* @return The complete description of the numerical function hessian inside the wrapper
*/
WrapperFunctionDescription getHessianDescription() const;
/** Accessor to file list
* @param fileList The collection of file description for the wrapper
*/
void setFileList(const FileListType & fileList);
/** Accessor to file list
* @return The collection of file description for the wrapper
*/
const FileListType & getFileList() const;
/** Conversion method for C interface
* @return A pointer to a newly allocated C structure that contains the same information as the file list
* @see FreeFileListForCInterface
*/
struct WrapperFileList * getNewFileListForCInterface() const;
/** Frees the memory allocated by getNewFileListForCInterface() method
* @param fileList A pointer to a newly allocated C structure that contains the same information as the file list
* @see getNewFileListForCInterface
*/
static void FreeFileListForCInterface(const struct WrapperFileList * fileList);
/** Accessor to variable list
* @param variableList The collection of variable description for the wrapper
*/
void setVariableList(const VariableListType & variableList);
/** Accessor to variable list
* @return The collection of variable description for the wrapper
*/
const VariableListType & getVariableList() const;
/** Conversion method for C interface
* @return A pointer to a newly allocated C structure that contains the same information as the variable list
* @see FreeVariableListForCInterface
*/
struct WrapperVariableList * getNewVariableListForCInterface() const;
/** Frees the memory allocated by getNewVariableListForCInterface() method
* @param fileList A pointer to a newly allocated C structure that contains the same information as the variable list
* @see getNewVariableListForCInterface
*/
static void FreeVariableListForCInterface(const struct WrapperVariableList * variableList);
/** Accessor to wrapper parameters
* @param parameters The data needed by the wrapper to link to the external code
*/
void setParameters(const WrapperParameter & parameters);
/** Accessor to wrapper parameters
* @return The data needed by the wrapper to link to the external code
*/
const WrapperParameter & getParameters() const;
/** Conversion method for C interface
* @return A pointer to a newly allocated C structure that contains the same information as the wrapper parameters
* @see FreeParametersForCInterface
*/
struct WrapperConfiguration * getNewParametersForCInterface() const;
/** Frees the memory allocated by getNewParametersForCInterface() method
* @param parameters A pointer to a newly allocated C structure that contains the same information as the wrapper parameters
* @see getNewParametersForCInterface
*/
static void FreeParametersForCInterface(const struct WrapperConfiguration * parameters);
/** Builds a newly allocated WrapperExchangedData structure
* @see FreeWrapperExchangedDataForCInterface
*/
struct WrapperExchangedData * getNewWrapperExchangedDataForCInterface() const;
/** Frees the memory allocated by getNewWrapperExchangedDataForCInterface() method
* @param A pointer to a newly allocated WrapperExchangedData structure
* @see getNewWrapperExchangedDataForCInterface
*/
static void FreeWrapperExchangedDataForCInterface(const struct WrapperExchangedData * exchangedData);
/** Check the correctness of the stored data */
Bool isValid() const;
/** Check if variables listed in subst_ are actually defined */
static void CheckSubstitutedVariables(const WrapperDataFile & file, const VariableListType & variableList);
/** Convert void pointer to exchanged data structure pointer */
static ExchangedDataPointer ConvertOpaquePointer( void * ptr);
static ConstExchangedDataPointer ConvertOpaquePointer(const void * ptr);
protected:
private:
/** Where the library that hold the function is located */
FileName libraryPath_;
/** The description of the function to be bound to */
WrapperFunctionDescription function_;
/** The description of the gradient of the function */
WrapperFunctionDescription gradient_;
/** The description of the hessian of the function */
WrapperFunctionDescription hessian_;
/** A shared pointer on the list of files that are exchanged between the platform and the wrapper */
Pointer<FileListType> p_fileList_;
/** A shared pointer on the list of variables that are exchanged between the platform and the wrapper */
Pointer<VariableListType> p_variableList_;
/** A shared pointer on the parameters for the wrapper */
Pointer<WrapperParameter> p_parameters_;
}; /* class WrapperData */
END_NAMESPACE_OPENTURNS
#endif /* OPENTURNS_WRAPPERDATA_HXX */
|