Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
dtd update for new cluster routing options
[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 Storage;
19 typedef Storage *StoragePtr;
20
21 class StorageAction;
22 typedef StorageAction *StorageActionPtr;
23
24 class StorageAction;
25 typedef StorageAction *StorageActionPtr;
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 : public Resource {
45 public:
46   Storage(ModelPtr model, const char *name, xbt_dict_t props,
47                   const char* type_id, char *content_name, char *content_type, sg_size_t size);
48   Storage(ModelPtr model, const char *name, xbt_dict_t props,
49                   lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
50                   const char* type_id, char *content_name, char *content_type, sg_size_t size);
51   ~Storage();
52
53   bool isUsed();
54   void updateState(tmgr_trace_event_t event_type, double value, double date);
55
56   xbt_dict_t p_content;
57   char* p_contentType;
58   sg_size_t m_size;
59   sg_size_t m_usedSize;
60   char * p_typeId;
61
62   virtual StorageActionPtr open(const char* mount, const char* path)=0;
63   virtual StorageActionPtr close(surf_file_t fd)=0;
64   //virtual StorageActionPtr unlink(surf_file_t fd)=0;
65   virtual StorageActionPtr ls(const char *path)=0;
66   virtual StorageActionPtr read(surf_file_t fd, sg_size_t size)=0;
67   virtual StorageActionPtr write(surf_file_t fd, sg_size_t size)=0;
68   virtual void rename(const char *src, const char *dest)=0;
69
70   virtual xbt_dict_t getContent();
71   virtual sg_size_t getSize();
72
73   xbt_dict_t parseContent(char *filename);
74
75   xbt_dynar_t p_writeActions;
76
77   lmm_constraint_t p_constraintWrite;    /* Constraint for maximum write bandwidth*/
78   lmm_constraint_t p_constraintRead;     /* Constraint for maximum write bandwidth*/
79 };
80
81 /**********
82  * Action *
83  **********/
84
85 typedef enum {
86   READ=0, WRITE, STAT, OPEN, CLOSE, LS
87 } e_surf_action_storage_type_t;
88
89
90 class StorageAction : public Action {
91 public:
92   StorageAction() : m_type(READ) {};//FIXME:REMOVE
93   StorageAction(ModelPtr model, double cost, bool failed,
94                         StoragePtr storage, e_surf_action_storage_type_t type);
95   StorageAction(ModelPtr model, double cost, bool failed, lmm_variable_t var,
96                         StoragePtr storage, e_surf_action_storage_type_t type);
97
98   e_surf_action_storage_type_t m_type;
99   StoragePtr p_storage;
100   surf_file_t p_file;
101   xbt_dict_t p_lsDict;
102 };
103
104 typedef struct s_storage_type {
105   char *model;
106   char *content;
107   char *content_type;
108   char *type_id;
109   xbt_dict_t properties;
110   sg_size_t size;
111 } s_storage_type_t, *storage_type_t;
112
113 typedef struct s_mount {
114   void *storage;
115   char *name;
116 } s_mount_t, *mount_t;
117
118 typedef struct surf_file {
119   char *name;
120   char *mount;
121   sg_size_t size;
122   sg_size_t current_position;
123 } s_surf_file_t;
124
125
126 #endif /* STORAGE_INTERFACE_HPP_ */