void sg_platf_new_storage(sg_platf_storage_cbarg_t storage)
{
xbt_assert(!xbt_lib_get_or_null(storage_lib, storage->id,ROUTING_STORAGE_LEVEL),
- "Reading a storage, processing unit \"%s\" already exists", storage->id);
+ "Refusing to add a second storage named \"%s\"", storage->id);
- // Verification of an existing type_id
-#ifndef NDEBUG
- void* storage_type = xbt_lib_get_or_null(storage_type_lib, storage->type_id,ROUTING_STORAGE_TYPE_LEVEL);
-#endif
- xbt_assert(storage_type,"Reading a storage, type id \"%s\" does not exists", storage->type_id);
+ void* stype = xbt_lib_get_or_null(storage_type_lib, storage->type_id,ROUTING_STORAGE_TYPE_LEVEL);
+ xbt_assert(stype,"No storage type '%s'", storage->type_id);
XBT_DEBUG("ROUTING Create a storage name '%s' with type_id '%s' and content '%s'",
storage->id,
ROUTING_STORAGE_LEVEL,
(void *) xbt_strdup(storage->type_id));
- void* stype = xbt_lib_get_or_null(storage_type_lib,
- storage->type_id,
- ROUTING_STORAGE_TYPE_LEVEL);
- if(!stype) xbt_die("No storage type '%s'",storage->type_id);
-
- // if storage content is not specified use the content of storage_type if exist
+ // if storage content is not specified use the content of storage_type if any
if(!strcmp(storage->content,"") && strcmp(((storage_type_t) stype)->content,"")){
storage->content = ((storage_type_t) stype)->content;
storage->content_type = ((storage_type_t) stype)->content_type;
************/
Storage::Storage(Model *model, const char *name, xbt_dict_t props,
- const char* type_id, char *content_name, char *content_type,
+ const char* type_id, const char *content_name, const char *content_type,
sg_size_t size)
: Resource(model, name)
, PropertyHolder(props)
- , p_contentType(content_type)
+ , p_contentType(xbt_strdup(content_type))
, m_size(size), m_usedSize(0)
, p_typeId(xbt_strdup(type_id))
, p_writeActions(xbt_dynar_new(sizeof(Action*),NULL))
Storage::Storage(Model *model, const char *name, xbt_dict_t props,
lmm_system_t maxminSystem, double bread, double bwrite,
- double bconnection, const char* type_id, char *content_name,
- char *content_type, sg_size_t size, char *attach)
- : Resource(model, name, lmm_constraint_new(maxminSystem, this, bconnection))
- , PropertyHolder(props)
- , p_contentType(content_type)
- , m_size(size), m_usedSize(0)
- , p_typeId(xbt_strdup(type_id))
- , p_writeActions(xbt_dynar_new(sizeof(Action*),NULL))
+ double bconnection, const char* type_id, const char *content_name,
+ const char *content_type, sg_size_t size, const char *attach)
+ : Storage(model, name, props, type_id, content_name, content_type, size)
{
- p_content = parseContent(content_name);
p_attach = xbt_strdup(attach);
- setState(SURF_RESOURCE_ON);
XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size);
p_constraintRead = lmm_constraint_new(maxminSystem, this, bread);
p_constraintWrite = lmm_constraint_new(maxminSystem, this, bwrite);
free(p_attach);
}
-xbt_dict_t Storage::parseContent(char *filename)
+xbt_dict_t Storage::parseContent(const char *filename)
{
m_usedSize = 0;
if ((!filename) || (strcmp(filename, "") == 0))
* @param size [description]
*/
Storage(Model *model, const char *name, xbt_dict_t props,
- const char* type_id, char *content_name, char *content_type,
+ const char* type_id, const char *content_name, const char *content_type,
sg_size_t size);
/**
Storage(Model *model, const char *name, xbt_dict_t props,
lmm_system_t maxminSystem, double bread, double bwrite,
double bconnection,
- const char* type_id, char *content_name, char *content_type,
- sg_size_t size, char *attach);
+ const char* type_id, const char *content_name, const char *content_type,
+ sg_size_t size, const char *attach);
~Storage();
sg_size_t m_size;
sg_size_t m_usedSize;
char * p_typeId;
- char* p_attach;
+ char* p_attach; //FIXME: this is the name of the host. Use the host directly
/**
* @brief Open a file
virtual sg_size_t getUsedSize();
- xbt_dict_t parseContent(char *filename);
+ xbt_dict_t parseContent(const char *filename);
xbt_dynar_t p_writeActions;