Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove c surf files
[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 StorageLmm;
17 typedef StorageLmm *StorageLmmPtr;
18
19 class StorageAction;
20 typedef StorageAction *StorageActionPtr;
21
22 class StorageActionLmm;
23 typedef StorageActionLmm *StorageActionLmmPtr;
24
25
26 /*********
27  * Model *
28  *********/
29 class StorageModel : public Model {
30 public:
31   StorageModel();
32   ~StorageModel();
33   StoragePtr createResource(const char* id, const char* model, const char* type_id, const char* content_name);
34   double shareResources(double now);
35   void updateActionsState(double now, double delta);
36
37 };
38
39 /************
40  * Resource *
41  ************/
42
43 class Storage : virtual public Resource {
44 public:
45   Storage(StorageModelPtr model, const char* name, xbt_dict_t properties);
46
47   bool isUsed();
48   void updateState(tmgr_trace_event_t event_type, double value, double date);
49
50   xbt_dict_t p_content; /* char * -> s_surf_file_t */
51
52   virtual StorageActionPtr open(const char* mount, const char* path)=0;
53   virtual StorageActionPtr close(surf_file_t fd)=0;
54   //virtual StorageActionPtr unlink(surf_file_t fd)=0;
55   virtual StorageActionPtr ls(const char *path)=0;
56   //virtual size_t getSize(surf_file_t fd);
57   virtual StorageActionPtr read(void* ptr, size_t size, surf_file_t fd)=0;//FIXME:why we have a useless param ptr ??
58   virtual StorageActionPtr write(const void* ptr, size_t size, surf_file_t fd)=0;//FIXME:why we have a useless param ptr ??
59   xbt_dict_t parseContent(char *filename);
60
61   size_t m_size;
62   size_t m_usedSize;
63   xbt_dynar_t p_writeActions;
64 };
65
66 class StorageLmm : public ResourceLmm, public Storage {
67 public:
68   StorageLmm(StorageModelPtr model, const char* name, xbt_dict_t properties,
69                      lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
70                      char *content_name, size_t size);
71
72   StorageActionPtr open(const char* mount, const char* path);
73   StorageActionPtr close(surf_file_t fd);
74   //StorageActionPtr unlink(surf_file_t fd);
75   StorageActionPtr ls(const char *path);
76   //size_t getSize(surf_file_t fd);
77   StorageActionPtr read(void* ptr, size_t size, surf_file_t fd);//FIXME:why we have a useless param ptr ??
78   StorageActionPtr write(const void* ptr, size_t size, surf_file_t fd);//FIXME:why we have a useless param ptr ??
79
80   lmm_constraint_t p_constraintWrite;    /* Constraint for maximum write bandwidth*/
81   lmm_constraint_t p_constraintRead;     /* Constraint for maximum write bandwidth*/
82 };
83
84 /**********
85  * Action *
86  **********/
87
88 typedef enum {
89   READ=0, WRITE, STAT, OPEN, CLOSE, LS
90 } e_surf_action_storage_type_t;
91
92
93 class StorageAction : virtual public Action {
94 public:
95   StorageAction(){};
96   StorageAction(ModelPtr model, double cost, bool failed, StoragePtr storage, e_surf_action_storage_type_t type)
97    : p_storage(storage), m_type(type) {};
98
99
100
101   e_surf_action_storage_type_t m_type;
102   StoragePtr p_storage;
103   surf_file_t p_file;
104   xbt_dict_t p_lsDict;
105 };
106
107 class StorageActionLmm : public ActionLmm, public StorageAction {
108 public:
109   StorageActionLmm(){};
110   StorageActionLmm(ModelPtr model, double cost, bool failed, StorageLmmPtr storage, e_surf_action_storage_type_t type);
111   void suspend();
112   int unref();
113   void cancel();
114   //FIXME:??void recycle();
115   void resume();
116   bool isSuspended();
117   void setMaxDuration(double duration);
118   void setPriority(double priority);
119
120 };
121
122
123 typedef struct s_storage_type {
124   char *model;
125   char *content;
126   char *type_id;
127   xbt_dict_t properties;
128   size_t size;
129 } s_storage_type_t, *storage_type_t;
130
131 typedef struct s_mount {
132   void *id;
133   char *name;
134 } s_mount_t, *mount_t;
135
136 typedef struct surf_file {
137   char *name;
138   char *storage;
139   size_t size;
140 } s_surf_file_t;
141
142
143 #endif /* STORAGE_HPP_ */