facade

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package facade implements the Facade design pattern. HomeTheater provides a simplified interface for controlling a group of devices: Projector, MediaServer, Lights, and SoundSystem. It encapsulates the logic required to coordinate these components in the correct sequence, allowing viewers to prepare for, play, and shut down a movie session through a single high-level interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run()

Types

type HomeCinema

type HomeCinema struct {
	// contains filtered or unexported fields
}

HomeCinema is the facade for controlling all of the devices of home theater in the correct order

func NewHomeTheater

func NewHomeTheater(input uint8, projectorName, serverName, lightsName, soundSystemName string) *HomeCinema

NewHomeTheater is the factory function to create the new home theater facade

func (*HomeCinema) Close

func (c *HomeCinema) Close()

Close allows to turn off the devices and close the home theater until the next projection

func (*HomeCinema) EndMovie

func (c *HomeCinema) EndMovie()

EndMovie allows to stop the projection of the movie

func (*HomeCinema) PlayMovie

func (c *HomeCinema) PlayMovie(name string)

PlayMovie allows the devices to play the actual movie

func (*HomeCinema) Prepare

func (c *HomeCinema) Prepare()

Prepare allows to prepare home theater for the projection

type Lights

type Lights struct {
	// contains filtered or unexported fields
}

Lights describes the lighting equipment of the cinema

func (*Lights) Off

func (l *Lights) Off()

Off allows to turn off the lights

func (*Lights) On

func (l *Lights) On()

On allows to turn on the lights

func (*Lights) SetBrightness

func (l *Lights) SetBrightness(amount uint8)

SetBrightness allows to dim or brighten up the lights to the specific absolute percentage

type MediaServer

type MediaServer struct {
	OutputInterface uint8
	// contains filtered or unexported fields
}

MediaServer represents the devices that is able to broadcast the movie to the output interface

func (*MediaServer) Off

func (s *MediaServer) Off()

Off allows to turn off the media server

func (*MediaServer) On

func (s *MediaServer) On()

On allows to turn on the media server

func (*MediaServer) Play

func (s *MediaServer) Play(movieTitle string)

Play allows to start playing the movie

func (*MediaServer) Stop

func (s *MediaServer) Stop()

Stop allows to stop the movie

type Player

type Player interface {
	Play(string)
	Stop()
}

Player is the general interface for all the devices able to play the movies

type Projector

type Projector struct {
	// contains filtered or unexported fields
}

Projector represents the projection device of the home theater

func (*Projector) Off

func (p *Projector) Off()

Off allows to turn off the projector

func (*Projector) On

func (p *Projector) On()

On allows to turn on the projector

func (*Projector) SetInput

func (p *Projector) SetInput(input uint8)

SetInput allows to switch the active input of the projector

type SoundSystem

type SoundSystem struct {
	// contains filtered or unexported fields
}

SoundSystem represents the sound system of the home theater

func (*SoundSystem) Off

func (s *SoundSystem) Off()

Off allows to turn off the sound system

func (*SoundSystem) On

func (s *SoundSystem) On()

On allows to turn on the sound system

func (*SoundSystem) SetVolume

func (s *SoundSystem) SetVolume(volume uint8)

SetVolume allows to set the specific volume on the speakers

type Switcher

type Switcher interface {
	On()
	Off()
}

Switcher is the general interface for all the devices of Home Theater

Jump to

Keyboard shortcuts

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