diff --git a/docs/UML/diag_class_links.puml b/docs/UML/diag_class_links.puml new file mode 100644 index 0000000..8942c85 --- /dev/null +++ b/docs/UML/diag_class_links.puml @@ -0,0 +1,47 @@ +@startuml class_links + +class LinkGraph { + + + []Link links + + + void AddLinkToGraph(Link link) + + boolean,str HasPrevious(Link) + + boolean,str HasNext(Link) + +} + +class Link { + + str source + + str destination + + boolean DCLink + + + *Link NewLink(interface{} src, interface{} dst) + + void AddLinkToDataCenter() +} + + +note left of LinkGraph::HasPrevious + checks if the component whose ID is in src is the dst of + any other Link of the list on Link +end note + +note top of Link + Links need to be redefined in the sense that they are currently used + both : + - to connect a component to a DC + - to represent the interractions between components +end note + +note right of Link::DCLink + set at construction of the object and used to order the links +end note + + +note left of Link::NewLink + Must test if the parameters check the type constraints + and raise errors for the GUI if necessary +end note + +LinkGraph*--"links"Link + +@enduml \ No newline at end of file diff --git a/models/links.go b/models/links.go new file mode 100644 index 0000000..55bc8d9 --- /dev/null +++ b/models/links.go @@ -0,0 +1,26 @@ +package models + +import ( + "fmt" + "reflect" +) + +type Link struct { + source string + destination string + dcLink bool +} + +func NewLink(src interface{}, dst interface{}) (link Link) { + // Check type with reflect and get ID + typeSrc := reflect.TypeOf(src) + typeDst := reflect.TypeOf(dst) + + fmt.Println("src is %s\ndst is %s",typeSrc,typeDst) + return +} + +func (l *Link) AddLinkToDataCenter(component interface{}) { + // if the component has a DataCenter id attribute then add it (switch on type) +} +