View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide

Transcript Component Step by Step

Here we describe how to build the Transcript component already specified. See Transcript Component Specification

1 Create the Implementation class TranscriptImpl

1.1 Create TranscriptImpl

For each client function interface, we should have an instance variable. Here, there is no client interface.
Object subclass: #TranscriptImpl
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'FracTalkTutorial-Chat'

1.2 Define TranscriptImpl methods

For each operation available in server functional interfaces, we should have a method with the same selector
TranscriptImpl>>cr
	"print a carriage-return into a Transcript"
	Transcript cr

TranscriptImpl>>show: aString
	"print aString into a Transcript"
	Transcript show: aString

2 Create the maker class TranscriptMaker

2.1 Define the maker class

The TranscriptMaker, as every maker, must inherit from AbstractComponentMaker.
AbstractComponentMaker subclass: #TranscriptMaker
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'FracTalkTutorial-Chat'

2.2 Define the behavior

There is 3 essential methods that must be redefined for each new component maker:

2.3 Define the interfaces

Each interface has a signature that tells what operations will be provided (in case of a server interface) or asked for (in case of a client interface). Here we have only one server interface:
TranscriptMaker>>createShowFunctionalType
	| server |
	server := typeFactory 
		createFcItfType: #show
		signature: ((FcSignature newNamed: #message)
			addSelector: #show:;
			addSelector: #cr;
			yourself)
		client: false
		optional: false
		collection: false.
	^server

3 Use the Transcript Component

3.1 Create a Transcript Component

transcriptCmp := self new newComponent.
(transcriptCmp getFcInterface: #'lifecycle-controller') startFc.

3.2 Retreive the Functional Server Interface 'show'

transcriptItf := transcriptCmp getFcInterface: #show.

3.3 Send Messages to the Interface 'show'

transcriptItf show: 'Coucou'.

3.4 So one can write the following class method:

TranscriptMaker class>>transcriptExample
	"TranscriptMaker transcriptExample"
	| transcriptCmp transcriptItf |
	transcriptCmp := self new newComponent.
	(transcriptCmp getFcInterface: #'lifecycle-controller') startFc.
	transcriptItf := transcriptCmp getFcInterface: #show.
	transcriptItf show: 'Coucou'.


Links to this Page