visitor

package
v0.0.0-...-0a60d77 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageA

type MessageA struct {
	Msg    string
	Output io.Writer
}

MessageA is a message logger that will print a message

func (*MessageA) Accept

func (m *MessageA) Accept(v Visitor)

Accept add messageA to VisitA

func (*MessageA) Print

func (m *MessageA) Print()

Print prints the MessageA message

type MessageB

type MessageB struct {
	Msg    string
	Output io.Writer
}

MessageB is a message logger that will print a message

func (*MessageB) Accept

func (m *MessageB) Accept(v Visitor)

Accept add messageB to VisitB

func (*MessageB) Print

func (m *MessageB) Print()

Print prints the MessageB message

type MessageVisitor

type MessageVisitor struct{}

MessageVisitor implements Visitor and Visitable interfaceds

func (*MessageVisitor) VisitA

func (mv *MessageVisitor) VisitA(m *MessageA)

VisitA stores the modified message into messageA

func (*MessageVisitor) VisitB

func (mv *MessageVisitor) VisitB(m *MessageB)

VisitB stores the modified message into messageB

type Visitable

type Visitable interface {
	Accept(Visitor)
}

Visitable accepts the visitor that will execute the decoupled algorithm

type Visitor

type Visitor interface {
	VisitA(*MessageA)
	VisitB(*MessageB)
}

Visitor has two methods that able to modify the message to be printed using your Visit methods

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL