Fuse.Problem
problem.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* Copyright (c) 2017 - Matteo Ragni, University of Trento */
4 /* */
5 /* Permission is hereby granted, free of charge, to any person */
6 /* obtaining a copy of this software and associated documentation */
7 /* files (the "Software"), to deal in the Software without */
8 /* restriction, including without limitation the rights to use, */
9 /* copy, modify, merge, publish, distribute, sublicense, and/or sell */
10 /* copies of the Software, and to permit persons to whom the */
11 /* Software is furnished to do so, subject to the following */
12 /* conditions: */
13 /* */
14 /* The above copyright notice and this permission notice shall be */
15 /* included in all copies or substantial portions of the Software. */
16 /* */
17 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
18 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
19 /* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
20 /* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
21 /* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
22 /* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
23 /* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
24 /* OTHER DEALINGS IN THE SOFTWARE. */
25 /* */
26 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
27 
34 #ifndef _FUSE_PROBLEM_PROBLEM_HH_
35 #define _FUSE_PROBLEM_PROBLEM_HH_
36 
37 #ifndef PROBLEM_PRECISION
38 
45 #define PROBLEM_PRECISION double
46 #endif
47 
48 using namespace std;
49 
50 #include <cmath>
51 #include <cstddef>
52 #include <dlfcn.h>
53 #include <iostream>
54 #include <map>
55 #include <regex>
56 #include <sstream>
57 #include <string>
58 #include <unistd.h>
59 #include <vector>
67 typedef enum FunctionInput {
68  xi = -2,
69  pi
80 typedef enum FunctionOutput {
81  root = -4,
82  info,
83  xo,
84  po,
85  fo
91 #define PROBLEM_E_NOFILE -100
92 
99 typedef void (*Function)(void *, void *, void *);
100 
110 template <class FP> class Problem {
111 
112 private:
113  string dl_file;
114  void *hdl;
116  string x_file;
117  string p_file;
118  string info_file;
119  vector<string> y_file;
120  map<string, int> paths;
122  size_t x_s;
123  size_t p_s
124  size_t f_s;
126  vector<Function> f;
128 public:
129  vector<FP> x;
130  vector<FP> p;
131  vector<FP> y;
133 private:
145  void init();
153  void update();
159  void close();
160 
161 public:
170  Problem(const char *dl)
171  : dl_file(dl), x_file(""), p_file(""), info_file(""), x_s(0), p_s(0),
172  f_s(0) {
173  init();
174  };
180  ~Problem() { close(); };
192  size_t write(FunctionInput type, const char *buf);
208  int read(int type, char *buf, size_t size, size_t offset);
218  int pathid(const char *path);
227  size_t size(FunctionOutput t);
236  size_t filesize(FunctionOutput t, int i = 0);
237 }; /* Problem */
238 
239 #endif /* _FUSE_PROBLEM_PROBLEM_HH_ */
vector< FP > x
Definition: problem.h:129
void(* Function)(void *, void *, void *)
Problem Function pointer definition.
Definition: problem.h:99
The problem container class that abstract the device of filesystem.
Definition: problem.h:110
FunctionInput
Enumeration for the writing filesystem.
Definition: problem.h:67
Definition: problem.h:82
~Problem()
Destroyes the Problem<FP> class.
Definition: problem.h:180
Definition: problem.h:85
Definition: problem.h:83
Definition: problem.h:84
Definition: problem.h:69
Problem(const char *dl)
Initialization, calls init method.
Definition: problem.h:170
FunctionOutput
Enumeration for the reading filesystem.
Definition: problem.h:80
vector< FP > y
Definition: problem.h:131
vector< FP > p
Definition: problem.h:130
Definition: problem.h:81
Definition: problem.h:68