This repository has been archived on 2024-04-10. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
elektron/def/sortingCriteria.go

30 lines
995 B
Go
Raw Normal View History

package def
// Creating an enumeration of the resources in def.Task.
var taskResourceNames []string
type sortCriteria int
// Map a task's resource name to the sorting criteria (an integer corresponding to the enumeration).
func resourceToSortCriteria(resourceName string) sortCriteria {
// Appending resourceName to TaskResourceNames.
taskResourceNames = append(taskResourceNames, resourceName)
// Considering index of resource in TaskResourceNames to be the int mapping.
return sortCriteria(len(taskResourceNames) - 1)
}
func (sc sortCriteria) String() string {
return taskResourceNames[int(sc)]
}
// Possible Sorting Criteria
// Note: the value of the string passed as argument to resourceToSortCriteria() should be the same (case-sensitive)
// as the name of the of the corresponding resource in the struct.
var (
CPU = resourceToSortCriteria("CPU")
RAM = resourceToSortCriteria("RAM")
Watts = resourceToSortCriteria("Watts")
Instances = resourceToSortCriteria("Instances")
)