3
* @file WrapperData.hxx
4
* @brief This class declares the wrapper data that are exchanged with the platform
6
* (C) Copyright 2005-2007 EDF-EADS-Phimeca
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
* License as published by the Free Software Foundation; either
11
* version 2.1 of the License.
13
* This library is distributed in the hope that it will be useful
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Lesser General Public License for more details.
18
* You should have received a copy of the GNU Lesser General Public
19
* License along with this library; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
* @author: $LastChangedBy: dutka $
23
* @date: $LastChangedDate: 2008-10-29 18:54:45 +0100 (mer 29 oct 2008) $
24
* Id: $Id: WrapperData.hxx 990 2008-10-29 17:54:45Z dutka $
26
#ifndef OPENTURNS_WRAPPERDATA_HXX
27
#define OPENTURNS_WRAPPERDATA_HXX
29
#include <iostream> // for std::ostream
32
#include "Pointer.hxx" // for shared pointer
33
#include "WrapperInterface.h"
34
#include "Collection.hxx"
46
* @struct WrapperSymbolProvided
48
* Stores information about the presence or no of symbols in the wrapper
50
struct WrapperSymbolProvided
53
static const Value NO = WRAPPER_NO;
54
static const Value YES = WRAPPER_YES;
59
* @struct WrapperComputedGradient
61
* Stores information about the computation of gradient for a variable
63
struct WrapperComputedGradient
66
static const Value NO = WRAPPER_NO;
67
static const Value YES = WRAPPER_YES;
72
* @struct WrapperFunctionDescription
74
* WrapperFunctionDescription describes what is the interface af a numerical function
76
struct WrapperFunctionDescription
77
: public Common::Object
80
WrapperSymbolProvided::Value provided_;
82
WrapperFunctionDescription();
83
virtual String str() const;
88
* @struct WrapperDataFileType
90
* Stores the type (input or output) of the file
92
struct WrapperDataFileType
94
typedef unsigned long Value;
95
static const Value IN = WRAPPER_IN;
96
static const Value OUT = WRAPPER_OUT;
100
* @struct WrapperDataFile
102
* This struct holds the name and the path of any file passed as argument to the wrapper
104
struct WrapperDataFile
105
: public Common::Object
107
String id_; ///< The id of the file (any string to distinguish each file from another)
108
String name_; ///< The name of the file (stdin, stdout, log, etc.)
109
FileName path_; ///< The path of the file (/tmp/stdin, /var/log/mylog, etc.)
110
String subst_; ///< The list of variable's ids to be substituted in the file
111
WrapperDataFileType::Value type_; ///< The type of the file (input or output)
114
virtual String str() const;
115
}; /* struct WrapperDataFile */
121
* @struct WrapperDataVariableType
123
* Stores the type (input or output) of the variable
125
struct WrapperDataVariableType {
126
typedef unsigned long Value;
127
static const Value IN = WRAPPER_IN;
128
static const Value OUT = WRAPPER_OUT;
132
* @struct WrapperDataVariable
134
* This struct holds information of any variable passed as argument to the wrapper
136
struct WrapperDataVariable
137
: public Common::Object
139
String id_; ///< The id of the variable (any string to distinguish each variable from another)
140
String comment_; ///< A comment to inform on the variable
141
String unit_; ///< The unit which the variable is expressed in
142
String regexp_; ///< The regular expression used to find the variable location in files
143
String format_; ///< The format in which the variable must be printed in files
144
WrapperDataVariableType::Value type_; ///< The type of the variable (input or output)
145
WrapperComputedGradient::Value gradient_; ///< The gradient of this variable is computed if true
147
WrapperDataVariable();
148
virtual String str() const;
149
}; /* struct WrapperDataVariable */
155
* @struct WrapperState
157
* Stores the mode of invocation of the external code
161
typedef unsigned long Value;
162
static const Value SHARED = WRAPPER_SHAREDSTATE;
163
static const Value SPECIFIC = WRAPPER_SPECIFICSTATE;
168
* @struct WrapperMode
170
* Stores the mode of invocation of the external code
174
typedef unsigned long Value;
175
static const Value STATICLINK = WRAPPER_STATICLINK;
176
static const Value DYNAMICLINK = WRAPPER_DYNAMICLINK;
177
static const Value FORK = WRAPPER_FORK;
182
* @struct WrapperDataTransfer
184
* Stores the mode of transmission for the arguments
186
struct WrapperDataTransfer
188
typedef unsigned long Value;
189
static const Value FILES = WRAPPER_FILES;
190
static const Value PIPE = WRAPPER_PIPE;
191
static const Value ARGUMENTS = WRAPPER_ARGUMENTS;
192
static const Value SOCKET = WRAPPER_SOCKET;
193
static const Value CORBA = WRAPPER_CORBA;
198
* struct WrapperParameter
200
* This structure holds the configuration of the wrapper
202
struct WrapperParameter
203
: public Common::Object
205
WrapperState::Value state_; ///< The sharing mode of internal state
206
WrapperMode::Value mode_; ///< The mode of invocation of the external code
207
WrapperDataTransfer::Value in_; ///< The transmission mode for input arguments
208
WrapperDataTransfer::Value out_; ///< The transmission mode for output arguments
209
String command_; ///< The command that should invoque the external code according to mode
212
virtual String str() const;
213
}; /* struct WrapperParameter */
220
* This class declares the wrapper data that are exchanged with the platform
223
: public Common::Object
227
typedef Type::Collection<WrapperDataFile> FileListType;
228
typedef Type::Collection<WrapperDataVariable> VariableListType;
230
/** Default constructor */
233
/** String converter */
234
virtual String str() const;
236
/** Library path accessor */
237
void setLibraryPath(const FileName & path);
238
FileName getLibraryPath() const;
240
/** Function description accessor */
241
void setFunctionDescription(const WrapperFunctionDescription & funcDescription);
242
WrapperFunctionDescription getFunctionDescription() const;
244
/** Gradient description accessor */
245
void setGradientDescription(const WrapperFunctionDescription & gradDescription);
246
WrapperFunctionDescription getGradientDescription() const;
248
/** Hessian description accessor */
249
void setHessianDescription(const WrapperFunctionDescription & hessDescription);
250
WrapperFunctionDescription getHessianDescription() const;
253
void setFileList(const FileListType & fileList);
254
const FileListType & getFileList() const;
256
/** Conversion method for C interface */
257
struct WrapperFileList * getNewFileListForCInterface() const;
259
/** Frees the memory allocated by getNewFileListForCInterface() method */
260
void freeFileListForCInterface(const struct WrapperFileList * fileList) const;
263
void setVariableList(const VariableListType & variableList);
264
const VariableListType & getVariableList() const;
266
/** Conversion method for C interface */
267
struct WrapperVariableList * getNewVariableListForCInterface() const;
269
/** Frees the memory allocated by getNewVariableListForCInterface() method */
270
void freeVariableListForCInterface(const struct WrapperVariableList * variableList) const;
273
void setParameters(const WrapperParameter & parameters);
274
const WrapperParameter & getParameters() const;
276
/** Conversion method for C interface */
277
struct WrapperConfiguration * getNewParametersForCInterface() const;
279
/** Frees the memory allocated by getNewParametersForCInterface() method */
280
void freeParametersForCInterface(const struct WrapperConfiguration * parameters) const;
286
/** Where the library that hold the function is located */
287
FileName libraryPath_;
289
/** The description of the function to be bound to */
290
WrapperFunctionDescription function_;
292
/** The description of the gradient of the function */
293
WrapperFunctionDescription gradient_;
295
/** The description of the hessian of the function */
296
WrapperFunctionDescription hessian_;
298
/** A shared pointer on the list of files that are exchanged between the platform and the wrapper */
299
Common::Pointer<FileListType> p_fileList_;
301
/** A shared pointer on the list of variables that are exchanged between the platform and the wrapper */
302
Common::Pointer<VariableListType> p_variableList_;
304
/** A shared pointer on the parameters for the wrapper */
305
Common::Pointer<WrapperParameter> p_parameters_;
307
}; /* class WrapperData */
310
} /* namespace Func */
311
} /* namespace Base */
312
} /* namespace OpenTURNS */
314
#endif /* OPENTURNS_WRAPPERDATA_HXX */