None of these types inherits from any other types; their whole purpose is just to package the definition of one or more messages. The type name is typically the same as a message declared by the type, only with the uppercase convention of a type name. These types may be freely mixed into the inheritance lists of other types to build whatever combinations of messages those other types need to define.
// // Copy -- copy all state defined as part of object // @deftype Copy - copy: aZone; @end
An object type that supplies the copy operation defines what it includes as the contents of an object copied. There is no global rule for what is considered "inside" a copied object vs. merely referenced by it. (There is no fixed notion of "shallow" vs. "deep" copy found in some object libraries.) After copying, the new object may still contain some references to other elements also referenced by the starting object, but in general the new object minimizes any dependencies shared with the starting object. Any object type supplying the copy message should also supply documentation on its rules for copied objects.
// // GetName -- get name which identifies object in its context of use // @deftype GetName - (char *) getName; @end
// // GetOwner - get object on which existence of object depends // @deftype GetOwner - getOwner; @end
Ownership hierarchies arrange themselves in a strict, single-rooted tree. The top-level node of an ownership hierarchy typically returns nil as its owner. If an object is regarded merely as one part of another object defined as its owner, then copying or dropping the owner object should copy or drop the member object as well. Owner and member are neutral terms for a generic relationship sometimes called parent vs. child, but it is up to a particular object type to define specifically what it means by a getOwner relationship.
// // SetInitialValue - create using initial value from an existing object // @deftype SetInitialValue CREATING + create: aZone setInitialValue: initialValue; + create: aZone setReadOnlyValue: readOnlyValue; - (void) setInitialValue: initialValue; - (void) setReadOnlyValue: readOnlyValue; SETTING - (void) setReadOnly: (BOOL)readOnly; USING - (BOOL) getReadOnly; @end
If an object has a value which can be established at create time, it is often useful (and can also enable significant optimization) to declare that no further modification will occur to this value during further use of the object. A restriction against modifying a value is referred to as a "read-only" restriction. This type supplies messages to declare a read-only restriction along with any initial value. For some object types, a read-only restriction can also be added or removed after an object has already been created.
The setInitialValue: message requires another object as its argument, from which the value of a newly created object is to be taken. Unlike a copy message, the object used as the source of the new value need not have the identical type as the new object to be created. A particular object type defines the types of initial value objects which it can accept, along with any special conversion or interpretation it might apply to such a value.
The ReadOnly flag specifies that the value of an object may not be modified further by other messages on an object. If such messages are attempted then an error is raised. If the ReadOnly flag is set at create time, the object is first created in read-only mode. Typically an initial value is always provided for an initial read-only object, since otherwise the created object would have only an empty or initial default value. The setReadOnlyValue: message is equivalent to a combination of a setInitialValue: message with an added ReadOnly restriction.
If a read-only restriction is established at create time, then for some object types this restriction may be required to remain for the entire lifetime of an object. For other object types, the read-only restriction may be added or removed any time after initial object creation. If a particular type does not support a change to read-only status, a request to do so raises an error.
Standard forms of create combination messages are provided to create an object in one message expression from the value of another object, with or without a read-only restriction.