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

29 lines
995 B
Go

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")
)