Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Replace surf by surf++ and make it compile
[simgrid.git] / src / surf / storage.hpp
1 #include "surf.hpp"
2
3 #ifndef STORAGE_HPP_
4 #define STORAGE_HPP_
5
6 /***********
7  * Classes *
8  ***********/
9
10 class StorageModel;
11 typedef StorageModel *StorageModelPtr;
12
13 class Storage;
14 typedef Storage *StoragePtr;
15
16 class StorageActionLmm;
17 typedef StorageActionLmm *StorageActionLmmPtr;
18
19 /*********
20  * Model *
21  *********/
22 class StorageModel : Model {
23 public:
24   StorageModel();
25   ~StorageModel();
26   StoragePtr createResource(const char* id, const char* model, const char* type_id, const char* content_name);
27   double shareResources(double now);
28   void updateActionsState(double now, double delta);
29
30   xbt_dict_t parseContent(char *filename, size_t *used_size);
31 };
32
33 /************
34  * Resource *
35  ************/
36
37 class Storage : public ResourceLmm {
38 public:
39   Storage(StorageModelPtr model, const char* name, xbt_dict_t properties);
40
41   bool isUsed();
42   void updateState(tmgr_trace_event_t event_type, double value, double date);
43
44   lmm_constraint_t p_constraintWrite;    /* Constraint for maximum write bandwidth*/
45   lmm_constraint_t p_constraintRead;     /* Constraint for maximum write bandwidth*/
46   xbt_dict_t p_content; /* char * -> s_surf_file_t */
47
48   StorageActionLmmPtr open(const char* mount, const char* path);
49   StorageActionLmmPtr close(surf_file_t fd);
50   StorageActionLmmPtr unlink(surf_file_t fd);
51   StorageActionLmmPtr ls(const char *path);
52   size_t getSize(surf_file_t fd);
53   StorageActionLmmPtr read(void* ptr, size_t size, surf_file_t fd);//FIXME:why we have a useless param ptr ??
54   StorageActionLmmPtr write(const void* ptr, size_t size, surf_file_t fd);//FIXME:why we have a useless param ptr ??
55
56   size_t m_size;
57   size_t m_usedSize;
58   xbt_dynar_t p_writeActions;
59 };
60
61 /**********
62  * Action *
63  **********/
64
65 typedef enum {
66   READ=0, WRITE, STAT, OPEN, CLOSE, LS
67 } e_surf_action_storage_type_t;
68
69 class StorageActionLmm : public ActionLmm {
70 public:
71   StorageActionLmm(){};
72   StorageActionLmm(ModelPtr model, double cost, bool failed, StoragePtr storage, e_surf_action_storage_type_t type);
73
74   int unref();
75   void cancel();
76   //FIXME:??void recycle();
77   void suspend();
78   void resume();
79   bool isSuspended();
80   void setMaxDuration(double duration);
81   void setPriority(double priority);
82
83   e_surf_action_storage_type_t m_type;
84   StoragePtr p_storage;
85   surf_file_t p_file;
86   xbt_dict_t p_lsDict;
87 };
88
89
90 typedef struct s_storage_type {
91   char *model;
92   char *content;
93   char *type_id;
94   xbt_dict_t properties;
95   size_t size;
96 } s_storage_type_t, *storage_type_t;
97
98 typedef struct s_mount {
99   void *id;
100   char *name;
101 } s_mount_t, *mount_t;
102
103 typedef struct surf_file {
104   char *name;
105   char *storage;
106   size_t size;
107 } s_surf_file_t;
108
109
110 #endif /* STORAGE_HPP_ */