Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
9319dc5c159f85442daf1d022936280f84424103
[simgrid.git] / src / surf / storage_interface.hpp
1 #include "surf_interface.hpp"
2
3 #ifndef STORAGE_INTERFACE_HPP_
4 #define STORAGE_INTERFACE_HPP_
5
6 extern xbt_dynar_t mount_list;
7
8 /***********
9  * Classes *
10  ***********/
11
12 class StorageModel;
13 typedef StorageModel *StorageModelPtr;
14
15 class Storage;
16 typedef Storage *StoragePtr;
17
18 class StorageLmm;
19 typedef StorageLmm *StorageLmmPtr;
20
21 class StorageAction;
22 typedef StorageAction *StorageActionPtr;
23
24 class StorageActionLmm;
25 typedef StorageActionLmm *StorageActionLmmPtr;
26
27 /*********
28  * Model *
29  *********/
30 class StorageModel : public Model {
31 public:
32   StorageModel();
33   ~StorageModel();
34   virtual StoragePtr createResource(const char* id, const char* type_id,
35                    const char* content_name, const char* content_type, xbt_dict_t properties)=0;
36
37   xbt_dynar_t p_storageList;
38 };
39
40 /************
41  * Resource *
42  ************/
43
44 class Storage : virtual public Resource {
45 public:
46   Storage(const char* type_id, char *content_name, char *content_type, sg_size_t size);
47   ~Storage();
48
49   bool isUsed();
50   void updateState(tmgr_trace_event_t event_type, double value, double date);
51
52   xbt_dict_t p_content;
53   char* p_contentType;
54   sg_size_t m_size;
55   sg_size_t m_usedSize;
56   char * p_typeId;
57
58   virtual StorageActionPtr open(const char* mount, const char* path)=0;
59   virtual StorageActionPtr close(surf_file_t fd)=0;
60   //virtual StorageActionPtr unlink(surf_file_t fd)=0;
61   virtual StorageActionPtr ls(const char *path)=0;
62   virtual StorageActionPtr read(surf_file_t fd, sg_size_t size)=0;
63   virtual StorageActionPtr write(surf_file_t fd, sg_size_t size)=0;
64   virtual void rename(const char *src, const char *dest)=0;
65
66   virtual xbt_dict_t getContent();
67   virtual sg_size_t getSize();
68
69   xbt_dict_t parseContent(char *filename);
70
71   xbt_dynar_t p_writeActions;
72 };
73
74 class StorageLmm : public ResourceLmm, public Storage {
75 public:
76   StorageLmm(lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
77                      const char* type_id, char *content_name, char *content_type, sg_size_t size);
78
79   lmm_constraint_t p_constraintWrite;    /* Constraint for maximum write bandwidth*/
80   lmm_constraint_t p_constraintRead;     /* Constraint for maximum write bandwidth*/
81 };
82
83 /**********
84  * Action *
85  **********/
86
87 typedef enum {
88   READ=0, WRITE, STAT, OPEN, CLOSE, LS
89 } e_surf_action_storage_type_t;
90
91
92 class StorageAction : virtual public Action {
93 public:
94   StorageAction() : m_type(READ) {};//FIXME:REMOVE
95   StorageAction(StoragePtr storage, e_surf_action_storage_type_t type);
96
97   e_surf_action_storage_type_t m_type;
98   StoragePtr p_storage;
99   surf_file_t p_file;
100   xbt_dict_t p_lsDict;
101 };
102
103 class StorageActionLmm : public ActionLmm, public StorageAction {
104 public:
105   StorageActionLmm() {};//FIXME:REMOVE
106
107   StorageActionLmm(StorageLmmPtr storage, e_surf_action_storage_type_t type);
108 };
109
110 typedef struct s_storage_type {
111   char *model;
112   char *content;
113   char *content_type;
114   char *type_id;
115   xbt_dict_t properties;
116   sg_size_t size;
117 } s_storage_type_t, *storage_type_t;
118
119 typedef struct s_mount {
120   void *storage;
121   char *name;
122 } s_mount_t, *mount_t;
123
124 typedef struct surf_file {
125   char *name;
126   char *mount;
127   sg_size_t size;
128   sg_size_t current_position;
129 } s_surf_file_t;
130
131
132 #endif /* STORAGE_INTERFACE_HPP_ */