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 UI.registerForShutdown({ this.run });
114 objects.copy.do({ arg item; item.doOnShutDown; });
115 // "ShutDown done.".postln;
121 AbstractServerAction : AbstractSystemAction {
124 this.objects = IdentityDictionary.new;
127 *performFunction { arg server, function;
128 this.objects.at(server).copy.do(function);
129 if(server === Server.default) {
130 this.objects.at(\default).copy.do(function)
132 this.objects.at(\all).copy.do(function);
136 var selector = this.functionSelector;
138 this.performFunction(server, { arg obj; obj.perform(selector, server) });
142 ^this.subclassResponsibility(thisMethod)
145 *add { arg object, server;
147 if(server.isNil) { server = \default };
148 list = this.objects.at(server);
149 if(list.isNil) { list = List.new; this.objects.put(server, list) };
150 if (list.includes(object).not) { list.add(object) };
154 *addToAll { arg object;
156 Server.set.do({ arg s; this.add(object, s) });
160 *remove { arg object, server;
162 if(server.isNil) { server = \default };
163 this.objects.at(server).remove(object);
167 *removeServer { arg server;
168 this.objects.removeAt(server)
173 // things to do after server has booted
176 ServerBoot : AbstractServerAction {
181 this.objects = IdentityDictionary.new;
190 // things to do after server has quit
193 ServerQuit : AbstractServerAction {
198 this.objects = IdentityDictionary.new;
208 // things to do after server has booted and initialised
211 ServerTree : AbstractServerAction {
218 this.objects = IdentityDictionary.new;