ftp.nice.ch/pub/next/developer/objc/preferences/DefaultsExample.NIHS.s.tar.gz#/DefaultsExample/FmsDefaultController.rtf

This is FmsDefaultController.rtf in view mode; [Download] [Up]

Copyright  ©1994 by Flying Monkey Software.  All Rights Reserved.





FmsDefaultController




Inherits From:	Object

Declared In:	FmsDefaultController.h





Class Description

Instances of  subclasses of FmsDefaultController encapsulate the access to values in the Next Defaults Database. Rather than accessing the function calls which access and manipulate the defaults directly, FmsDefaultController provides standard conversions and a framework on which applications may cleanly work with defaults and extend the default mechanism to complex types. Standard import and export of integers, floats, strings,  NXPoints, NXSizes, NXRects, and NXColors are provided.

The FmsDefaultController class may be extended easily through subclassing or through categories. Any class or type which can be written to a string can participate. To add a new type of default compatible with FmsDefaultController, let's say for instances of the class Foo, four methods would be provided, a convert method, a default method, a reveal (or get) method, and a set method.

- (char *)convertFooValue:(Foo *)theFoo to:(char *)value
- default:(char *)name toFooValue:(Foo *)theFoo
- (Foo *)get:(Foo *)foo fooValue:(char *)name
- setFooValue:(char *)name to:(Foo *)theFoo

The convert method would convert Foo instances into strings, and although generally used internally by the default and set methods, it could be used externally for general conversion. The default method would load the "registered default" which would be  used if no default value for the name was found in the target defaults database. The reveal method would return the current content of the defaults database at name as a Foo. The set method would set the Foo as the current content of the defaults database at name. These four methods work in concert to provided a generalized default method for any string-writable type.

Alternatively, the default methods may be installed directly into the individual classes as methods, like read and write. In some cases this would be a good approach, the defaults database possibly even being replaced directly by a data stream. However, given the "grouped" nature of the NXDefaultsVector, and the usual access to a set of defaults through a single database name, the convert/default/reveal/set approach seems more general.


Instance Variables

char *database;
List *defaultList;

database	the name of the defaults database being accessed.

defaultList	a list which holds defaults until registration.


Method Types

Initializing	- init

Bulk default manipulation	- registerDefaults

Assigning a defaults database	- database
- setDatabase:

Removing a default	- remove:

Manipulating strings	- default: toStringValue:
- setStringValue: to:
- stringValue:

Manipulating integers	- convertIntValue: to:
	- default: toIntValue:
- intValue:
- setIntValue: to:

Manipulating floats	- convertFloatValue: to:
	- default: toFloatValue:
- floatValue:
- setFloatValue: to:

Manipulating NXPoints	- convertPointValue: to:
	- default: toPointValue:
- get: pointValue:
- setPointValue: to:

Manipulating NXSizes	- convertSizeValue: to:
	- default: toSizeValue:
- get: sizeValue:
- setSizeValue: to:

Manipulating NXRects	- convertRectValue: to:
	- default: toRectValue:
- get: rectValue:
- setRectValue: to:

Manipulating NXColors	- colorValue:
	- convertColorValue: to:
	- default: toColorValue:
- setColorValue: to:





Instance Methods

colorValue:
- (NXColor)colorValue:(char *)name

Returns the default value at name as an NXColor.




convertColorValue: to:
- (char *)convertColorValue:(NXColor)theColor to:(char *)value

Converts the NXColor in theColor to a string value in value. Returns the address of value.




convertFloatValue: to:
- (char *)convertFloatValue:(float)theFloat to:(char *)value

Converts the float in theFloat to a string value in value. Returns the address of value.




convertIntValue: to:
- (char *)convertIntValue:(int)theInt to:(char *)value

Converts the int in theInt to a string value in value. Returns the address of value.




convertPointValue: to:
- (char *)convertPointValue:(NXPoint *)thePoint to:(char *)value

Converts the NXPoint referenced by thePoint to a string value in value. Returns the address of value.




convertRectValue: to:
- (char *)convertRectValue:(NXRect)theRect to:(char *)value

Converts the NXRect referenced by theRect to a string value in value. Returns the address of value.




convertSizeValue: to:
- (char *)convertSizeValue:(NXSize)theSize to:(char *)value

Converts the NXColor referenced by theSize to a string value in value. Returns the address of value.




database
- (const char *)database

Returns the name of the defaults database being accessed.




default: toColorValue:
- default:(char *)name toColorValue:(NXColor)theColor

Sets up the color value in theColor to be registered at name in a subsequent registerDefaults. Returns self.




default: toFloatValue:
- default:(char *)name toFloatValue:(float)theFloat

Sets up the float value in theFloat to be registered at name in a subsequent registerDefaults. Returns self.




default: toIntValue:
- default:(char *)name toIntValue:(int)theInt

Sets up the int value in theInt to be registered at name in a subsequent registerDefaults. Returns self.




default: toPointValue:
- default:(char *)name toPointValue:(NXPoint *)thePoint

Sets the point value referenced by thePoint to be registered at name in a subsequent registerDefaults. Returns self.




default: toRectValue:
- default:(char *)name toRectValue:(NXRect *)theRect

Sets up the rect value referenced by theRect to be registered at name in a subsequent registerDefaults. Returns self.




default: toSizeValue:
- default:(char *)name toSizeValue:(NXSize *)theSize

Sets up the size value referenced by theSize to be registered at name in a subsequent registerDefaults. Returns self.




default: toStringValue:
- default:(char *)name toStringValue:(char *)theString

Sets up the string value theString to be registered at name in a subsequent registerDefaults. Returns self.




floatValue:
- (float)floatValue:(char *)name

Returns the default value at name as a float.




free:
- free

Frees the FmsDefaultController.




get: pointValue:
- (NXPoint *)get:(NXPoint *)point pointValue:(char *)name

Returns a pointer to the default value at name copied into point.




get: rectValue:
- (NXRect *)get:(NXRect *)rect rectValue:(char *)name

Returns a pointer to the default value at name copied into rect.




get: sizeValue:
- (NXSize *)get:(NXSize *)size sizeValue:(char *)name

Returns a pointer to the default value at name copied into size.




init:
- init

Initializes a newly allocated instance of FmsDefaultController. Returns self.




intValue:
- (int)intValue:(char *)name

Returns the default value at name as an int.




registerDefaults
- registerDefaults

Registers all the defaults which have been accumulated by calls to the default-to methods. If subsequent calls to the default-to methods are made, a registerDefaults must be set again. Returns self.




remove:
- remove:(char *)name

Removes the default at name from the defaults database. Returns self.




setColorValue: to:
- setColorValue:(char *)name to:(NXColor)theColor

Sets the color value at name to theColor. Returns self.




setDatabase:
- setDatabase:(char *)theDatabase

Sets the name of the defaults database to theDatabase. Returns self.




setFloatValue: to:
- setFloatValue:(char *)name to:(float)theFloat

Sets the float value at name to theFloat. Returns self.




setIntValue: to:
- setIntValue:(char *)name to:(int)theInt

Sets the int value at name to theColor. Returns self.




setPointValue: to:
- setPointValue:(char *)name to:(NXPoint *)thePoint

Sets the point value at name to the NXPoint referenced by thePoint. Returns self.




setRectValue: to:
- setRectValue:(char *)name to:(NXRect *)theRect

Sets the rect value at name to the NXRect referenced by theRect. Returns self.




setSizeValue: to:
- setSizeValue:(char *)name to:(NXSize *)theSize

Sets the rect value at name to the NXSize referenced by theSize. Returns self.




setStringValue: to:
- setColorValue:(char *)name to:(char *)theString

Sets the string value at name to theString. Returns self.




stringValue:
- (char *)stringValue:(char *)name

Returns the default value at name as an string.




These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.