Author: rfm
Date: Mon Apr 28 08:40:03 2014
New Revision: 37817
URL: http://svn.gna.org/viewcvs/gnustep?rev=37817&view=rev
Log:
allow easier management of initial defaults by subclasses
Modified:
libs/ec/trunk/ChangeLog
libs/ec/trunk/EcProcess.h
libs/ec/trunk/EcProcess.m
Modified: libs/ec/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/ChangeLog?rev=37817&r1=37816&r2=37817&view=diff
==============================================================================
--- libs/ec/trunk/ChangeLog (original)
+++ libs/ec/trunk/ChangeLog Mon Apr 28 08:40:03 2014
@@ -1,3 +1,10 @@
+2014-04-27 Richard Frith-Macdonald <[email protected]>
+
+ * EcProcess.h:
+ * EcProcess.m:
+ Add +ecInitialDefaults to allow subclasses to easily set and
+ modify default configuration values.
+
2014-03-28 Richard Frith-Macdonald <[email protected]>
* EcTest.h:
Modified: libs/ec/trunk/EcProcess.h
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/EcProcess.h?rev=37817&r1=37816&r2=37817&view=diff
==============================================================================
--- libs/ec/trunk/EcProcess.h (original)
+++ libs/ec/trunk/EcProcess.h Mon Apr 28 08:40:03 2014
@@ -403,6 +403,20 @@
*/
@interface EcProcess : NSObject <CmdClient,EcAlarmDestination>
+/** Provides initial configuration.
+ * This method is used by -init and its return value is passed to
+ * -initWithDefaults: method.<br />
+ * The default implementation simply sets the ProgramName and
+ * HomeDirectory defaults (with the default prefix configured
+ * when the library was built) to the current program name and
+ * the current directory ('.').<br />
+ * Subclasses may override this method to provide additional
+ * default configuration for processes using them. The returned
+ * dictionary is mutable so that a subclass may simply modify
+ * the configuration provided by the superclass implementation.
+ */
++ (NSMutableDictionary*) ecInitialDefaults;
+
/** Convenience method to produce a generic configuration alarm and send
* it via the -alarm: method.<br />
* The managed object may be nil (in which case it's the default managed object
@@ -817,6 +831,11 @@
*/
- (void) cmdUpdate: (NSMutableDictionary*)info;
+/** This calls the designated initialiser (-initWithDefaults:) passing
+ * the results of a call to +ecInitialDefaults as its argument.
+ */
+- (id) init;
+
/** [-initWithDefaults:] is the Designated initialiser<br />
* It adds the defaults specified to the defaults system.<br />
* It sets the process name to be that specified in the
Modified: libs/ec/trunk/EcProcess.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/EcProcess.m?rev=37817&r1=37816&r2=37817&view=diff
==============================================================================
--- libs/ec/trunk/EcProcess.m (original)
+++ libs/ec/trunk/EcProcess.m Mon Apr 28 08:40:03 2014
@@ -1001,6 +1001,27 @@
DESTROY(userDir);
DESTROY(warningLogger);
}
+}
+
++ (NSMutableDictionary*) ecInitialDefaults
+{
+ id objects[2];
+ id keys[2];
+ NSString *prefix;
+
+ objects[0] = [[NSProcessInfo processInfo] processName];
+ objects[1] = @".";
+ prefix = EC_DEFAULTS_PREFIX;
+ if (nil == prefix)
+ {
+ prefix = @"";
+ }
+ keys[0] = [prefix stringByAppendingString: @"ProgramName"];
+ keys[1] = [prefix stringByAppendingString: @"HomeDirectory"];
+
+ return [NSMutableDictionary dictionaryWithObjects: objects
+ forKeys: keys
+ count: 2];
}
- (void) _commandRemove
@@ -3294,23 +3315,11 @@
- (id) init
{
- id objects[2];
- id keys[2];
- NSString *prefix;
-
- objects[0] = [[NSProcessInfo processInfo] processName];
- objects[1] = @".";
- prefix = EC_DEFAULTS_PREFIX;
- if (nil == prefix)
- {
- prefix = @"";
- }
- keys[0] = [prefix stringByAppendingString: @"ProgramName"];
- keys[1] = [prefix stringByAppendingString: @"HomeDirectory"];
-
- return [self initWithDefaults: [NSDictionary dictionaryWithObjects: objects
- forKeys: keys
- count: 2]];
+ CREATE_AUTORELEASE_POOL(pool);
+
+ self = [self initWithDefaults: [[self class] ecInitialDefaults]];
+ RELEASE(pool);
+ return self;
}
- (id) initWithDefaults: (NSDictionary*) defs
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs