4 this.objects = List.new;
8 if(this.objects.isNil) { this.init }; // lazy init
9 if(this.objects.includes(object).not) { this.objects.add(object) }
13 this.objects.remove(object)
21 *objects { ^this.shouldNotImplement(thisMethod) }
22 *objects_ { arg obj; ^this.shouldNotImplement(thisMethod) }
27 // things to clear when hitting cmd-.
29 CmdPeriod : AbstractSystemAction {
32 classvar <>clearClocks = true;
33 classvar <>freeServers = true;
34 classvar <>freeRemote = false;
39 var f = { this.remove(f); object.doOnCmdPeriod };
46 // TempoClock.default.clear;
49 objects.copy.do({ arg item; item.doOnCmdPeriod; });
52 Server.freeAll(freeRemote); // stop all sounds on local, or remote servers
64 TempoClock.default.clear;
66 objects.copy.do({ arg item; item.doOnCmdPeriod; });
70 Server.hardFreeAll; // stop all sounds on local servers
80 // things to do after startup file executed
82 StartUp : AbstractSystemAction {
85 classvar <>objects, <done=false;
90 objects.copy.do({ arg item; item.doOnStartUp });
91 // "StartUp done.".postln;
96 if(done) { object.doOnStartUp } { this.add(object) }
103 // things to do before system shuts down
105 ShutDown : AbstractSystemAction {
110 objects.copy.do({ arg item; item.doOnShutDown; });
111 // "ShutDown done.".postln;
116 // things to do on a system reset
117 OnError : AbstractSystemAction {
121 objects.copy.do({ arg item; item.doOnError; });
126 AbstractServerAction : AbstractSystemAction {
129 this.objects = IdentityDictionary.new;
132 *performFunction { arg server, function;
133 if (this.objects.notNil) {
134 this.objects.at(server).copy.do(function);
135 if(server === Server.default) {
136 this.objects.at(\default).copy.do(function)
138 this.objects.at(\all).copy.do(function);
143 var selector = this.functionSelector;
145 this.performFunction(server, { arg obj; obj.perform(selector, server) });
149 ^this.subclassResponsibility(thisMethod)
152 *add { arg object, server;
154 if (server.isNil) { server = \all };
155 if (this.objects.isNil) { this.init };
156 list = this.objects.at(server);
157 if (list.isNil) { list = List.new; this.objects.put(server, list) };
158 if (list.includes(object).not) { list.add(object) };
161 *addToAll { arg object;
162 Server.all.do({ arg s; this.add(object, s) });
165 *remove { arg object, server;
166 if(server.isNil) { server = \default };
167 this.objects !? { this.objects.at(server).remove(object) };
170 *removeServer { arg server;
171 this.objects.removeAt(server)
175 // things to do after server has booted
178 ServerBoot : AbstractServerAction {
187 // things to do after server has quit
190 ServerQuit : AbstractServerAction {
200 // things to do after server has booted and initialised
203 ServerTree : AbstractServerAction {