00001 #ifndef _HOSTS_H
00002 #define _HOSTS_H
00003 #include "constants.h"
00004
00005
00006
00007
00008
00009
00010 #define NOTINIT -2
00011 #define NOTAVAIL -1
00012 #define AVAIL 0
00013 // if used, status is a refcounter
00014
00015
00016 typedef struct {
00017 char name[MAX_HNAME_LENGTH+1];
00018 int numResources;
00019 char resources[MAXRESOURCES][MAX_RNAME_LENGTH+1];
00020 int status;
00021 int weight;
00022 int mem;
00023 } Host;
00024
00025
00026 typedef struct {
00027 Host hosts[MAXHOSTS];
00028 int numHosts;
00029 int totalWeight;
00030 } HostsStruct;
00031
00032
00033 HostsStruct *hostsCreate();
00034
00035 void hostsDestroy(HostsStruct *h);
00036
00037
00038 int hostsAdd(HostsStruct *h);
00039 int hostsAddResource(HostsStruct *h, int hostIndex, char *resourceName);
00040
00041
00042 int hostsSetStatus(HostsStruct *h, int hostIndex, int status);
00043 int hostsSetWeight(HostsStruct *h, int hostIndex, int weight);
00044 int hostsSetName(HostsStruct *h, int hostIndex, char *name);
00045 int hostsSetMemory(HostsStruct *h, int hostIndex, int mem);
00046
00047
00048 int hostsGetIndex(HostsStruct *h);
00049 int hostsGetIndexByName(HostsStruct *h,char *name);
00050 int hostsGetIndexByResource(HostsStruct *h, char *resourceName);
00051 int hostsGetStatus(HostsStruct *h, int hostIndex);
00052 int hostsGetWeight(HostsStruct *h, int hostIndex);
00053 int hostsGetMemory(HostsStruct *h, int hostIndex);
00054 char *hostsGetName(HostsStruct *h, int hostIndex);
00055
00056
00057
00058
00059 int hostsGetNumResources(HostsStruct *h, int hostIndex);
00060
00061 int hostsHasResource(HostsStruct *h, int hostIndex, char *resourceName);
00062
00063
00064
00065 #endif