mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-20 18:32:09 +00:00
allow easier management of initial defaults by subclasses
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/ec/trunk@37817 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
567e96a34d
commit
1f2d7f5f4a
3 changed files with 51 additions and 16 deletions
|
@ -1,3 +1,10 @@
|
|||
2014-04-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* EcProcess.h:
|
||||
* EcProcess.m:
|
||||
Add +ecInitialDefaults to allow subclasses to easily set and
|
||||
modify default configuration values.
|
||||
|
||||
2014-03-28 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* EcTest.h:
|
||||
|
|
19
EcProcess.h
19
EcProcess.h
|
@ -403,6 +403,20 @@ extern NSString* cmdVersion(NSString *ver);
|
|||
*/
|
||||
@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 @@ extern NSString* cmdVersion(NSString *ver);
|
|||
*/
|
||||
- (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
|
||||
|
|
41
EcProcess.m
41
EcProcess.m
|
@ -1003,6 +1003,27 @@ findMode(NSDictionary* d, NSString* s)
|
|||
}
|
||||
}
|
||||
|
||||
+ (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
|
||||
{
|
||||
id connection = [cmdServer connectionForProxy];
|
||||
|
@ -3294,23 +3315,11 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
|
|||
|
||||
- (id) init
|
||||
{
|
||||
id objects[2];
|
||||
id keys[2];
|
||||
NSString *prefix;
|
||||
CREATE_AUTORELEASE_POOL(pool);
|
||||
|
||||
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]];
|
||||
self = [self initWithDefaults: [[self class] ecInitialDefaults]];
|
||||
RELEASE(pool);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithDefaults: (NSDictionary*) defs
|
||||
|
|
Loading…
Reference in a new issue