#!/usr/bin/perl # -*- mode: cperl; coding: utf-8; -*- use strict; use warnings; use utf8; use lib "/h/hamren/src/post/lib", "."; my $rval = do "common.pm" || die "$0: common.pm failed ($!) [$@]"; #--- Single-line common initializer my $MatcherUsingText = em("MatcherUsingText"); my $MessageBusTester = em("MessageBusTester"); my $MessageBusClient = em("MessageBusClient"); my $Figure = em("Figure"); my $MainView = em("MainView"); my $group = em("group"); my $key = em("key"); my $value = em("value"); #my $ = em(""); sub qqq($) { return i("@_"); } my $center_image = { style => "display: block; margin-left: auto; margin-right: auto; margin-top: 5pt; margin-bottom: 10pt; " }; sub description { my $arg1 = shift; p({style=>"padding-left:40pt; text-indent:-30pt;"}, "«$arg1»", " -- ", @_); } post( header(), read_main_tmb_article(), h3("Brief summary of components"), #----------------------------------------------------------------------------------------------------------------------------------------------------------- table({class => "components-table"}, trow(td("«common» (⊂library⊃)" ), td("A few common declarations." )), trow(td("«drawing» (⊂library⊃)" ), td("Create Bezier curves for circle, square and triangle." )), trow(td("«networking» (⊂library⊃)" ), td("Socket-level networking based on CFStream. Reads and writes data.")), trow(td("«class Figure»" ), td("NSView that draws a geometric figure." )), trow(td("«class MainView»" ), td("NSViewController for the main NSView. Singleton." )), trow(td("«class MessageBusTester»" ), td("Application delegate. Processes incoming messages. Singleton. " )), trow(td("«class MessageBusClient»" ), td("Message bus logic. Sends and receives messages. Singleton. " )), trow(td("User interface" ), td("Created with Interface Builder. " )), ), p("Each of the three singleton classes have a function «instance()» that returns the instance,", " and each use a static variable «the_instance»."), p("Libraries ⊂drawing⊃ and ⊂network⊃ offload some source from $Figure and $MessageBusClient respectively."), #----------------------------------------------------------------------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------------------------------------------------------------------- h1("Execution flow"), h3("Starting"), source_code(xx(<<'EOF')), ⊂in main() calls NSApplicationMain creates the complete main view from NIB does «[MainView awakeFromNib]» sets «the_instance» to «self» creates the the application delegate ($MessageBusTester) does «[MessageBusTester applicationDidFinishLaunching]» does «[self start]» sets «the_instance» to «self» create the single instance of $MessageBusClient by calling «+instance» sets «the_instance» to «self» calls «[MessageBusClient start]» calls «network_start()» creates client socket connects to server set «network_read_callback()» as read callback⊃ EOF #--------------------------------------------------------------------------------------------------- h3("Incoming message"), source_code(xx(< + (MessageBusTester *)instance; - (void) on_incoming_message: (char *)msg; ⊂-- Called by MessageBusClient⊃ @end EOF #----------------------------------------------------------------------------------------------------------------------------------------------------------- h3("networking"), source_codeq(xx(<<'EOF')), @class MessageBusClient; void network_start(NSString *host, int port, MessageBusClient *client); void network_stop (void); ⊂-- Called by MessageBusClient⊃ long network_write(char *buf); ⊂-- Called by MessageBusClient⊃ static void network_read_callback(...); ⊂-- Called by framework⊃ EOF p("Implements socket-level networking using CFStream.", "When data is available, network_read_callback() calls «[MessageBusClient on_incoming_data]».", "The instance to call is passed as a parameter to network_start()."), footer() ); __END__