Hosts.h

Go to the documentation of this file.
00001 #ifndef _HOSTS_H
00002 #define _HOSTS_H
00003 #include "constants.h"
00004 
00005 
00006 // $Id: Hosts.h 607 2005-07-15 17:46:53Z coutinho $
00007 
00008 
00009 /// Host status
00010 #define NOTINIT         -2      ///< not initialized
00011 #define NOTAVAIL        -1      ///< not available
00012 #define AVAIL            0      ///< available, but not used
00013 // if used, status is a refcounter
00014 
00015 ///this struct defines a Host
00016 typedef struct {
00017         char name[MAX_HNAME_LENGTH+1]; ///< the hostname
00018         int numResources;
00019         char resources[MAXRESOURCES][MAX_RNAME_LENGTH+1]; ///< the resources this host uses, array of strings
00020         int status; ///< the status of this host
00021         int weight;
00022         int mem; ///< machine memory in MB
00023 } Host;
00024 
00025 ///this is the hosts array
00026 typedef struct {
00027         Host hosts[MAXHOSTS];
00028         int numHosts;
00029         int totalWeight;
00030 } HostsStruct;
00031 
00032 /// Constructor
00033 HostsStruct *hostsCreate();
00034 /// destroyer
00035 void hostsDestroy(HostsStruct *h);
00036 
00037 //add functions
00038 int hostsAdd(HostsStruct *h); //< adds a host to the struct HostsStruct, returns the index of the host
00039 int hostsAddResource(HostsStruct *h, int hostIndex, char *resourceName); //< adds a resource to the given host
00040 
00041 //set functions, argument can be released
00042 int hostsSetStatus(HostsStruct *h, int hostIndex, int status); //< sets status of a host
00043 int hostsSetWeight(HostsStruct *h, int hostIndex, int weight); //< sets host weight
00044 int hostsSetName(HostsStruct *h, int hostIndex, char *name); //< sets the host name
00045 int hostsSetMemory(HostsStruct *h, int hostIndex, int mem); //< how much memory this host can use, -1 for auto detect
00046 
00047 // get functions
00048 int hostsGetIndex(HostsStruct *h); //< returns a host index, based on weight
00049 int hostsGetIndexByName(HostsStruct *h,char *name); //< gets the host index, based on the name
00050 int hostsGetIndexByResource(HostsStruct *h, char *resourceName); //< gets the host index which has the resource
00051 int hostsGetStatus(HostsStruct *h, int hostIndex); //< returns the status of the given host
00052 int hostsGetWeight(HostsStruct *h, int hostIndex); //< returns the weight of the given host
00053 int hostsGetMemory(HostsStruct *h, int hostIndex); //< returns the declared memory qty this host can use
00054 char *hostsGetName(HostsStruct *h, int hostIndex); //< returns the name of the given host
00055 
00056 
00057 
00058 //resource stuff......
00059 int hostsGetNumResources(HostsStruct *h, int hostIndex); //< returns the resources used by this filter
00060 //char **hostsGetResources(HostsStruct *h, int hostIndex); //< returns the resources array
00061 int hostsHasResource(HostsStruct *h, int hostIndex, char *resourceName); //< does the host have the resource?
00062 //....................
00063 
00064 
00065 #endif

Generated on Tue Jan 17 19:18:38 2006 for Void by  doxygen 1.4.6