From b01e18eaae7a5dba85eede6c5b086be0fcefb824 Mon Sep 17 00:00:00 2001 From: Janos Kovacs Date: Mon, 24 Sep 2012 03:48:35 +0300 Subject: [PATCH] resource: renamed resource-class => application class The difference between resource-definition and resource-class was apparently not clear for some folks and caused some confusion. The resource-definitions, like 'audio_playback', are indeed resource classes, while the former resource-classes like 'phone', 'navigator', 'camera', 'game', 'player' etc. are actually application classes. For better clarity the resource-class was renamed to application-class. --- src/Makefile.am | 2 +- .../{resource-class.c => application-class.c} | 71 +++++++++++----------- .../{resource-class.h => application-class.h} | 20 +++--- src/resource/client-api.h | 10 +-- src/resource/config-api.h | 6 +- src/resource/data-types.h | 2 +- src/resource/resource-owner.c | 42 ++++++------- src/resource/resource-owner.h | 8 +-- src/resource/resource-set.c | 8 +-- src/resource/resource-set.h | 2 +- 10 files changed, 86 insertions(+), 85 deletions(-) rename src/resource/{resource-class.c => application-class.c} (82%) rename src/resource/{resource-class.h => application-class.h} (76%) diff --git a/src/Makefile.am b/src/Makefile.am index 8234b7e..1dd2445 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -421,7 +421,7 @@ libmurphy_resource_la_REGULAR_SOURCES = \ resource/attribute.c \ resource/resource.c \ resource/resource-set.c \ - resource/resource-class.c \ + resource/application-class.c \ resource/resource-owner.c \ resource/resource-client.c \ resource/zone.c diff --git a/src/resource/resource-class.c b/src/resource/application-class.c similarity index 82% rename from src/resource/resource-class.c rename to src/resource/application-class.c index 5c5ffcc..03f6e67 100644 --- a/src/resource/resource-class.c +++ b/src/resource/application-class.c @@ -39,7 +39,7 @@ #include #include -#include "resource-class.h" +#include "application-class.h" #include "resource-set.h" #include "zone.h" @@ -80,15 +80,15 @@ static MRP_LIST_HOOK(class_list); static mrp_htbl_t *name_hash; static void init_name_hash(void); -static int add_to_name_hash(mrp_resource_class_t *); +static int add_to_name_hash(mrp_application_class_t *); #if 0 -static void remove_from_name_hash(mrp_resource_class_t *); +static void remove_from_name_hash(mrp_application_class_t *); #endif -mrp_resource_class_t *mrp_resource_class_create(const char *name, uint32_t pri) +mrp_application_class_t *mrp_resource_class_create(const char *name, uint32_t pri) { - mrp_resource_class_t *class; + mrp_application_class_t *class; mrp_list_hook_t *insert_before, *clhook, *n; uint32_t zone; @@ -100,7 +100,7 @@ mrp_resource_class_t *mrp_resource_class_create(const char *name, uint32_t pri) insert_before = &class_list; mrp_list_foreach_back(&class_list, clhook, n) { - class = mrp_list_entry(clhook, mrp_resource_class_t, list); + class = mrp_list_entry(clhook, mrp_application_class_t, list); if (!strcasecmp(name, class->name)) { mrp_log_warning("Multiple definitions for class '%s'", name); @@ -116,7 +116,7 @@ mrp_resource_class_t *mrp_resource_class_create(const char *name, uint32_t pri) insert_before = &class->list; } - if (!(class = mrp_allocz(sizeof(mrp_resource_class_t)))) { + if (!(class = mrp_allocz(sizeof(mrp_application_class_t)))) { mrp_log_error("Memory alloc failure. Can't create resource class '%s'", name); return NULL; @@ -138,9 +138,9 @@ mrp_resource_class_t *mrp_resource_class_create(const char *name, uint32_t pri) } -mrp_resource_class_t *mrp_resource_class_find(const char *name) +mrp_application_class_t *mrp_application_class_find(const char *name) { - mrp_resource_class_t *class = NULL; + mrp_application_class_t *class = NULL; if (name_hash && name) class = mrp_htbl_lookup(name_hash, (void *)name); @@ -148,7 +148,7 @@ mrp_resource_class_t *mrp_resource_class_find(const char *name) return class; } -mrp_resource_class_t *mrp_resource_class_iterate_classes(void **cursor) +mrp_application_class_t *mrp_application_class_iterate_classes(void **cursor) { mrp_list_hook_t *entry; @@ -161,13 +161,13 @@ mrp_resource_class_t *mrp_resource_class_iterate_classes(void **cursor) *cursor = entry->prev; - return mrp_list_entry(entry, mrp_resource_class_t, list); + return mrp_list_entry(entry, mrp_application_class_t, list); } mrp_resource_set_t * -mrp_resource_class_iterate_rsets(mrp_resource_class_t *class, - uint32_t zone, - void **cursor) +mrp_application_class_iterate_rsets(mrp_application_class_t *class, + uint32_t zone, + void **cursor) { mrp_list_hook_t *list, *entry; @@ -184,10 +184,11 @@ mrp_resource_class_iterate_rsets(mrp_resource_class_t *class, return mrp_list_entry(entry, mrp_resource_set_t, class.list); } -const char **mrp_resource_class_get_all_names(uint32_t buflen,const char **buf) +const char **mrp_application_class_get_all_names(uint32_t buflen, + const char **buf) { mrp_list_hook_t *entry, *n; - mrp_resource_class_t *class; + mrp_application_class_t *class; bool freeit = false; uint32_t i = 0; @@ -203,7 +204,7 @@ const char **mrp_resource_class_get_all_names(uint32_t buflen,const char **buf) } mrp_list_foreach(&class_list, entry, n) { - class = mrp_list_entry(entry, mrp_resource_class_t, list); + class = mrp_list_entry(entry, mrp_application_class_t, list); if (i >= buflen-1) { if (freeit) @@ -220,11 +221,11 @@ const char **mrp_resource_class_get_all_names(uint32_t buflen,const char **buf) } -int mrp_resource_class_add_resource_set(const char *class_name, - const char *zone_name, - mrp_resource_set_t *rset) +int mrp_application_class_add_resource_set(const char *class_name, + const char *zone_name, + mrp_resource_set_t *rset) { - mrp_resource_class_t *class; + mrp_application_class_t *class; mrp_zone_t *zone; @@ -232,7 +233,7 @@ int mrp_resource_class_add_resource_set(const char *class_name, MRP_ASSERT(!rset->class.ptr || !mrp_list_empty(&rset->class.list), "attempt to add multiple times the same resource set"); - if (!(class = mrp_resource_class_find(class_name))) + if (!(class = mrp_application_class_find(class_name))) return -1; if (!(zone = mrp_zone_find_by_name(zone_name))) @@ -241,14 +242,14 @@ int mrp_resource_class_add_resource_set(const char *class_name, rset->class.ptr = class; rset->zone = mrp_zone_get_id(zone); - mrp_resource_class_move_resource_set(rset); + mrp_application_class_move_resource_set(rset); return 0; } -void mrp_resource_class_move_resource_set(mrp_resource_set_t *rset) +void mrp_application_class_move_resource_set(mrp_resource_set_t *rset) { - mrp_resource_class_t *class; + mrp_application_class_t *class; mrp_list_hook_t *list, *lentry, *n, *insert_before; mrp_resource_set_t *rentry; uint32_t key; @@ -262,12 +263,12 @@ void mrp_resource_class_move_resource_set(mrp_resource_set_t *rset) zone = rset->zone; list = insert_before = class->resource_sets + zone; - key = mrp_resource_class_get_sorting_key(rset); + key = mrp_application_class_get_sorting_key(rset); mrp_list_foreach_back(list, lentry, n) { rentry = mrp_list_entry(lentry, mrp_resource_set_t, class.list); - if (key >= mrp_resource_class_get_sorting_key(rentry)) + if (key >= mrp_application_class_get_sorting_key(rentry)) break; insert_before = lentry; @@ -276,7 +277,7 @@ void mrp_resource_class_move_resource_set(mrp_resource_set_t *rset) mrp_list_append(insert_before, &rset->class.list); } -uint32_t mrp_resource_class_get_sorting_key(mrp_resource_set_t *rset) +uint32_t mrp_application_class_get_sorting_key(mrp_resource_set_t *rset) { uint32_t priority; uint32_t usage; @@ -297,12 +298,12 @@ uint32_t mrp_resource_class_get_sorting_key(mrp_resource_set_t *rset) } -int mrp_resource_class_print(char *buf, int len) +int mrp_application_class_print(char *buf, int len) { #define PRINT(fmt, args...) if (ppriority, class->name); for (zid = 0; zid < MRP_ZONE_MAX; zid++) { @@ -372,7 +373,7 @@ static void init_name_hash(void) } -static int add_to_name_hash(mrp_resource_class_t *class) +static int add_to_name_hash(mrp_application_class_t *class) { MRP_ASSERT(class && class->name, "invalid argument"); @@ -385,9 +386,9 @@ static int add_to_name_hash(mrp_resource_class_t *class) } #if 0 -static void remove_from_name_hash(mrp_resource_class_t *class) +static void remove_from_name_hash(mrp_application_class_t *class) { - mrp_resource_class_t *deleted; + mrp_application_class_t *deleted; if (class && class->name && name_hash) { deleted = mrp_htbl_remove(name_hash, (void *)class->name, false); diff --git a/src/resource/resource-class.h b/src/resource/application-class.h similarity index 76% rename from src/resource/resource-class.h rename to src/resource/application-class.h index 71f88ff..c6fff9d 100644 --- a/src/resource/resource-class.h +++ b/src/resource/application-class.h @@ -27,8 +27,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __MURPHY_RESOURCE_CLASS_H__ -#define __MURPHY_RESOURCE_CLASS_H__ +#ifndef __MURPHY_APPLICATION_CLASS_H__ +#define __MURPHY_APPLICATION_CLASS_H__ #include @@ -36,24 +36,24 @@ -struct mrp_resource_class_s { +struct mrp_application_class_s { mrp_list_hook_t list; const char *name; uint32_t priority; mrp_list_hook_t resource_sets[MRP_ZONE_MAX]; }; -mrp_resource_class_t *mrp_resource_class_find(const char *); -mrp_resource_class_t *mrp_resource_class_iterate_classes(void **); -mrp_resource_set_t *mrp_resource_class_iterate_rsets(mrp_resource_class_t *, - uint32_t, void **); +mrp_application_class_t *mrp_application_class_find(const char *); +mrp_application_class_t *mrp_application_class_iterate_classes(void **); +mrp_resource_set_t * +mrp_application_class_iterate_rsets(mrp_application_class_t*,uint32_t,void**); -void mrp_resource_class_move_resource_set(mrp_resource_set_t *); +void mrp_application_class_move_resource_set(mrp_resource_set_t *); -uint32_t mrp_resource_class_get_sorting_key(mrp_resource_set_t *); +uint32_t mrp_application_class_get_sorting_key(mrp_resource_set_t *); -#endif /* __MURPHY_RESOURCE_CLASS_H__ */ +#endif /* __MURPHY_APPLICATION_CLASS_H__ */ /* * Local Variables: diff --git a/src/resource/client-api.h b/src/resource/client-api.h index 24770e2..4bb0482 100644 --- a/src/resource/client-api.h +++ b/src/resource/client-api.h @@ -41,12 +41,12 @@ const char **mrp_zone_get_all_names(uint32_t buflen, const char **buf); const char **mrp_resource_definition_get_all_names(uint32_t buflen, const char **buf); -const char **mrp_resource_class_get_all_names(uint32_t buflen, - const char **buf); +const char **mrp_application_class_get_all_names(uint32_t buflen, + const char **buf); -int mrp_resource_class_add_resource_set(const char *class_name, - const char *zone_name, - mrp_resource_set_t *resource_set); +int mrp_application_class_add_resource_set(const char *class_name, + const char *zone_name, + mrp_resource_set_t *resource_set); mrp_resource_set_t *mrp_resource_set_create(mrp_resource_client_t *client, uint32_t priority, diff --git a/src/resource/config-api.h b/src/resource/config-api.h index c1d7e9e..d0de33d 100644 --- a/src/resource/config-api.h +++ b/src/resource/config-api.h @@ -35,10 +35,10 @@ int mrp_zone_definition_create(mrp_attr_def_t *attrdefs); uint32_t mrp_zone_create(const char *name, mrp_attr_t *attrs); -mrp_resource_class_t *mrp_resource_class_create(const char *name, - uint32_t priority); +mrp_application_class_t *mrp_resource_class_create(const char *name, + uint32_t priority); -int mrp_resource_class_print(char *buf, int len); +int mrp_application_class_print(char *buf, int len); int mrp_resource_owner_print(char *buf, int len); diff --git a/src/resource/data-types.h b/src/resource/data-types.h index 58cc85d..91fcc37 100644 --- a/src/resource/data-types.h +++ b/src/resource/data-types.h @@ -57,8 +57,8 @@ typedef struct mrp_attr_def_s mrp_attr_def_t; typedef struct mrp_attr_s mrp_attr_t; typedef struct mrp_zone_def_s mrp_zone_def_t; typedef struct mrp_zone_s mrp_zone_t; +typedef struct mrp_application_class_s mrp_application_class_t; typedef struct mrp_resource_owner_s mrp_resource_owner_t; -typedef struct mrp_resource_class_s mrp_resource_class_t; typedef struct mrp_resource_set_s mrp_resource_set_t; typedef struct mrp_resource_def_s mrp_resource_def_t; typedef struct mrp_resource_s mrp_resource_t; diff --git a/src/resource/resource-owner.c b/src/resource/resource-owner.c index 1546084..65465cc 100644 --- a/src/resource/resource-owner.c +++ b/src/resource/resource-owner.c @@ -41,7 +41,7 @@ #include #include "resource-owner.h" -#include "resource-class.h" +#include "application-class.h" #include "resource-set.h" #include "resource.h" #include "zone.h" @@ -68,19 +68,19 @@ static mqi_handle_t owner_tables[RESOURCE_MAX]; static mrp_resource_owner_t *get_owner(uint32_t, uint32_t); static void reset_owners(uint32_t, mrp_resource_owner_t *); static bool grant_ownership(mrp_resource_owner_t *, mrp_zone_t *, - mrp_resource_class_t *, mrp_resource_set_t *, + mrp_application_class_t *, mrp_resource_set_t *, mrp_resource_t *); static bool advice_ownership(mrp_resource_owner_t *, mrp_zone_t *, - mrp_resource_class_t *, mrp_resource_set_t *, + mrp_application_class_t *, mrp_resource_set_t *, mrp_resource_t *); static void manager_start_transaction(mrp_zone_t *); static void manager_end_transaction(mrp_zone_t *); static void delete_resource_owner(mrp_zone_t *, mrp_resource_t *); -static void insert_resource_owner(mrp_zone_t *, mrp_resource_class_t *, +static void insert_resource_owner(mrp_zone_t *, mrp_application_class_t *, mrp_resource_t *); -static void update_resource_owner(mrp_zone_t *, mrp_resource_class_t *, +static void update_resource_owner(mrp_zone_t *, mrp_application_class_t *, mrp_resource_t *); static void set_attr_descriptors(mqi_column_desc_t *, mrp_resource_t *); @@ -164,7 +164,7 @@ void mrp_resource_owner_update_zone(uint32_t zoneid, uint32_t reqid) mrp_resource_owner_t oldowners[RESOURCE_MAX]; mrp_resource_owner_t backup[RESOURCE_MAX]; mrp_zone_t *zone; - mrp_resource_class_t *class; + mrp_application_class_t *class; mrp_resource_set_t *rset; mrp_resource_t *res; mrp_resource_def_t *rdef; @@ -200,10 +200,10 @@ void mrp_resource_owner_update_zone(uint32_t zoneid, uint32_t reqid) rcnt = mrp_resource_definition_count(); clc = NULL; - while ((class = mrp_resource_class_iterate_classes(&clc))) { + while ((class = mrp_application_class_iterate_classes(&clc))) { rsc = NULL; - while ((rset = mrp_resource_class_iterate_rsets(class,zoneid,&rsc))) { + while ((rset=mrp_application_class_iterate_rsets(class,zoneid,&rsc))) { mandatory = rset->resource.mask.mandatory; grant = 0; advice = 0; @@ -319,7 +319,7 @@ int mrp_resource_owner_print(char *buf, int len) mrp_zone_t *zone; mrp_resource_owner_t *owner; - mrp_resource_class_t *class; + mrp_application_class_t *class; mrp_resource_set_t *rset; mrp_resource_t *res; mrp_resource_def_t *rdef; @@ -398,11 +398,11 @@ static void reset_owners(uint32_t zone, mrp_resource_owner_t *oldowners) memset(ptr, 0, size); } -static bool grant_ownership(mrp_resource_owner_t *owner, - mrp_zone_t *zone, - mrp_resource_class_t *class, - mrp_resource_set_t *rset, - mrp_resource_t *res) +static bool grant_ownership(mrp_resource_owner_t *owner, + mrp_zone_t *zone, + mrp_application_class_t *class, + mrp_resource_set_t *rset, + mrp_resource_t *res) { mrp_resource_def_t *rdef = res->def; mrp_resource_mgr_ftbl_t *ftbl = rdef->manager.ftbl; @@ -451,11 +451,11 @@ static bool grant_ownership(mrp_resource_owner_t *owner, return true; } -static bool advice_ownership(mrp_resource_owner_t *owner, - mrp_zone_t *zone, - mrp_resource_class_t *class, - mrp_resource_set_t *rset, - mrp_resource_t *res) +static bool advice_ownership(mrp_resource_owner_t *owner, + mrp_zone_t *zone, + mrp_application_class_t *class, + mrp_resource_set_t *rset, + mrp_resource_t *res) { mrp_resource_def_t *rdef = res->def; mrp_resource_mgr_ftbl_t *ftbl = rdef->manager.ftbl; @@ -548,7 +548,7 @@ static void delete_resource_owner(mrp_zone_t *zone, mrp_resource_t *res) } static void insert_resource_owner(mrp_zone_t *zone, - mrp_resource_class_t *class, + mrp_application_class_t *class, mrp_resource_t *res) { mrp_resource_def_t *rdef = res->def; @@ -588,7 +588,7 @@ static void insert_resource_owner(mrp_zone_t *zone, } static void update_resource_owner(mrp_zone_t *zone, - mrp_resource_class_t *class, + mrp_application_class_t *class, mrp_resource_t *res) { static uint32_t zone_id; diff --git a/src/resource/resource-owner.h b/src/resource/resource-owner.h index b564032..1043b54 100644 --- a/src/resource/resource-owner.h +++ b/src/resource/resource-owner.h @@ -35,10 +35,10 @@ struct mrp_resource_owner_s { - mrp_resource_class_t *class; /**< owner class */ - mrp_resource_set_t *rset; /**< owner resource set */ - mrp_resource_t *res; /**< owner resource */ - bool share; /**< do not use this */ + mrp_application_class_t *class; /**< owner application class */ + mrp_resource_set_t *rset; /**< owner resource set */ + mrp_resource_t *res; /**< owner resource */ + bool share; /**< do not use this */ }; diff --git a/src/resource/resource-set.c b/src/resource/resource-set.c index 7c32ef4..994c9cf 100644 --- a/src/resource/resource-set.c +++ b/src/resource/resource-set.c @@ -39,7 +39,7 @@ #include #include "resource-set.h" -#include "resource-class.h" +#include "application-class.h" #include "resource.h" #include "resource-client.h" #include "resource-owner.h" @@ -272,7 +272,7 @@ void mrp_resource_set_acquire(mrp_resource_set_t *rset, uint32_t reqid) rset->request.id = reqid; rset->request.stamp = get_request_stamp(); - mrp_resource_class_move_resource_set(rset); + mrp_application_class_move_resource_set(rset); mrp_resource_owner_update_zone(rset->zone, reqid); } } @@ -286,7 +286,7 @@ void mrp_resource_set_release(mrp_resource_set_t *rset, uint32_t reqid) rset->request.id = reqid; rset->request.stamp = get_request_stamp(); - mrp_resource_class_move_resource_set(rset); + mrp_application_class_move_resource_set(rset); mrp_resource_owner_update_zone(rset->zone, reqid); } } @@ -316,7 +316,7 @@ int mrp_resource_set_print(mrp_resource_set_t *rset, size_t indent, gap, rset->id, rset->resource.mask.all, mandatory, rset->resource.mask.grant, rset->resource.mask.advice, - mrp_resource_class_get_sorting_key(rset), rset->class.priority, + mrp_application_class_get_sorting_key(rset), rset->class.priority, rset->resource.share ? "shared ":"exclusive", state_str(rset->state)); diff --git a/src/resource/resource-set.h b/src/resource/resource-set.h index 668f372..b0a135d 100644 --- a/src/resource/resource-set.h +++ b/src/resource/resource-set.h @@ -57,7 +57,7 @@ struct mrp_resource_set_s { } client; struct { mrp_list_hook_t list; - mrp_resource_class_t *ptr; + mrp_application_class_t *ptr; uint32_t priority; } class; uint32_t zone; -- 2.7.4