Automatic generation produced by ISE Eiffel

Classes Clusters Cluster hierarchy Chart Relations Flat contracts Go to:
note description: "[ Utility class to traverse object graphs starting at a root object. When traversing a graph the class distinguishes four different types of references: (1) Normal references (2) References with copy-semantics, which are usually seen when attaching an expanded object to an ANY reference (3) User-defined expanded objects, embedded inside another object. Semantically this is a special case of a copy-semantics reference. (4) Language-defined expanded objects (INTEGER, POINTER etc) embedded inside another object. Semantically, this is a special case of a copy-semantics reference. This class will follow all reference types except (4). During traversal the agent `on_processing_object_action` will be called for each object and the agent `on_processing_reference_action` for each reference, if present. This includes references to objects that have already been processed. The algorighm has two output values: `visited_objects` and `visited_types`: Any standard object without copy-semantics (i.e. reference type (1)) will be stored by aliasing inside visited_object. For references of type (2) and (3) a copy will be stored. The `visited_types` hash table contains the dynamic type id of all types encountered during traversal. The key and value in the hashtable are the same. Setting `is_skip_copy_semantics_reference` to true means that references of (2) and (3) will not be stored in `visited_types`. Note that this is the only effect of this setting - i.e. the traversal algorithm will still follow the references, the agents will be called, and the `visited_types` array will be extended anyway. NOTE: Due to a limitation in the reflection library, references of type (2) and (3) within TUPLE and references of type (3) within SPECIAL cannot be handled without causing a copy. This is problematic for agents, especially when they want to change the object. Therefore the algorithm will raise an exception when an agent is attached. In read-only situations it may be acceptable to use a copy of an object. Therefore to disable the exception behaviour you can set `is_exception_on_copy_suppressed` to True. NOTE: To maintain backwards compatibility the traversal algorithm will silently ignore any kind of exception and just return normally, with traversed_objects set to whatever value it had before invoking `traverse`. In order to get exceptions you need to set `is_exception_propagated` to True. ]" library: "Free implementation of ELKS library" legal: "See notice at end of class." status: "See notice at end of class." author: "Stephanie Balzer" date: "$Date: 2017-03-23 11:18:26 -0800 (Thu, 23 Mar 2017) $" revision: "$Revision: 100033 $" deferred class interface OBJECT_GRAPH_TRAVERSABLE feature -- Access generating_type: TYPE [detachable OBJECT_GRAPH_TRAVERSABLE] -- Type of current object -- (type of which it is a direct instance) -- (from ANY) ensure -- from ANY generating_type_not_void: Result /= Void generator: STRING_8 -- Name of current object's generating class -- (base class of the type of which it is a direct instance) -- (from ANY) ensure -- from ANY generator_not_void: Result /= Void generator_not_empty: not Result.is_empty object_action: detachable PROCEDURE [separate ANY] -- Action called on every object in object graph on_processing_object_action: detachable PROCEDURE [REFLECTED_OBJECT] -- Action called on every object in the object graph. -- Note: The argument is reused later for a different object. Do not alias it. on_processing_reference_action: detachable PROCEDURE [REFLECTED_OBJECT, REFLECTED_OBJECT] -- Action called on every reference in the object graph. -- Note: The arguments are reused later for different objects. Do not alias them. root_object: detachable ANY -- Starting point of graph traversing visited_objects: detachable ARRAYED_LIST [separate ANY] -- List referencing objects of object graph that have been visited in `traverse`. visited_types: detachable HASH_TABLE [INTEGER_32, INTEGER_32] -- List of all types encountered during traversal feature -- Comparison frozen deep_equal (a: detachable ANY; b: like arg #1): BOOLEAN -- Are a and b either both void -- or attached to isomorphic object structures? -- (from ANY) ensure -- from ANY instance_free: class shallow_implies_deep: standard_equal (a, b) implies Result both_or_none_void: (a = Void) implies (Result = (b = Void)) same_type: (Result and (a /= Void)) implies (b /= Void and then a.same_type (b)) symmetric: Result implies deep_equal (b, a) frozen equal (a: detachable ANY; b: like arg #1): BOOLEAN -- Are a and b either both void or attached -- to objects considered equal? -- (from ANY) ensure -- from ANY instance_free: class definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.is_equal (b)) frozen is_deep_equal alias "≡≡≡" (other: OBJECT_GRAPH_TRAVERSABLE): BOOLEAN -- Are Current and other attached to isomorphic object structures? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY shallow_implies_deep: standard_is_equal (other) implies Result same_type: Result implies same_type (other) symmetric: Result implies other.is_deep_equal (Current) is_equal (other: OBJECT_GRAPH_TRAVERSABLE): BOOLEAN -- Is other attached to an object considered -- equal to current object? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY symmetric: Result implies other ~ Current consistent: standard_is_equal (other) implies Result frozen standard_equal (a: detachable ANY; b: like arg #1): BOOLEAN -- Are a and b either both void or attached to -- field-by-field identical objects of the same type? -- Always uses default object comparison criterion. -- (from ANY) ensure -- from ANY instance_free: class definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.standard_is_equal (b)) frozen standard_is_equal alias "" (other: OBJECT_GRAPH_TRAVERSABLE): BOOLEAN -- Is other attached to an object of the same type -- as current object, and field-by-field identical to it? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY same_type: Result implies same_type (other) symmetric: Result implies other.standard_is_equal (Current) feature -- Status report conforms_to (other: ANY): BOOLEAN -- Does type of current object conform to type -- of other (as per Eiffel: The Language, chapter 13)? -- (from ANY) require -- from ANY other_not_void: other /= Void has_failed: BOOLEAN -- Was the last traversal successful? has_reference_with_copy_semantics: BOOLEAN -- Does the traversed graph of objects contain reference with copy semantics? is_exception_on_copy_suppressed: BOOLEAN -- Do we suppress an exception when `object_action` is called on a copied object? -- A copy happens when encountering tuples containing copy-semantics references -- or with SPECIAL[XX], where XX is a user-defined expanded type. is_exception_propagated: BOOLEAN -- Does the algorithm propagate any exceptions to the user? is_object_action_set: BOOLEAN -- Is procedure to call on every object set? is_root_object_set: BOOLEAN -- Is starting point of graph traversing set? is_skip_copy_semantics_reference: BOOLEAN -- Do we skip copy semantics reference from `visited_objects` during traversal? is_skip_transient: BOOLEAN -- Do we skip transient attribute during traversal? same_type (other: ANY): BOOLEAN -- Is type of current object identical to type of other? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY definition: Result = (conforms_to (other) and other.conforms_to (Current)) feature -- Element change set_is_exception_on_copy_suppressed (v: like is_exception_on_copy_suppressed) -- Set `set_is_exception_on_copy_suppressed` with v. ensure is_exception_on_copy_suppressed_set: is_exception_on_copy_suppressed = v set_is_exception_propagated (v: like is_exception_propagated) -- Set `is_exception_propagated` with v. ensure is_exception_propagated_set: is_exception_propagated = v set_is_skip_copy_semantics_reference (v: like is_skip_copy_semantics_reference) -- Set `is_skip_copy_semantics_reference` with v. ensure is_skip_copy_semantics_reference_set: is_skip_copy_semantics_reference = v set_is_skip_transient (v: like is_skip_transient) -- Set `is_skip_transient` with v. ensure is_skip_transient_set: is_skip_transient = v set_on_processing_object_action (an_action: like on_processing_object_action) -- Set `on_processing_object_action` with an_action require an_action_not_void: an_action /= Void ensure on_processing_object_action_set: on_processing_object_action = an_action set_on_processing_reference_action (an_action: like on_processing_reference_action) -- Set `on_processing_object_action` with an_action require an_action_not_void: an_action /= Void ensure on_processing_reference_action_set: on_processing_reference_action = an_action set_root_object (an_object: like root_object) -- Set `root_object` with 'an_object'. require an_object_not_void: an_object /= Void ensure root_object_set: root_object = an_object and is_root_object_set feature -- Duplication copy (other: OBJECT_GRAPH_TRAVERSABLE) -- Update current object using fields of object attached -- to other, so as to yield equal objects. -- (from ANY) require -- from ANY other_not_void: other /= Void type_identity: same_type (other) ensure -- from ANY is_equal: Current ~ other frozen deep_copy (other: OBJECT_GRAPH_TRAVERSABLE) -- Effect equivalent to that of: -- `copy` (other . `deep_twin`) -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY deep_equal: deep_equal (Current, other) frozen deep_twin: OBJECT_GRAPH_TRAVERSABLE -- New object structure recursively duplicated from Current. -- (from ANY) ensure -- from ANY deep_twin_not_void: Result /= Void deep_equal: deep_equal (Current, Result) frozen standard_copy (other: OBJECT_GRAPH_TRAVERSABLE) -- Copy every field of other onto corresponding field -- of current object. -- (from ANY) require -- from ANY other_not_void: other /= Void type_identity: same_type (other) ensure -- from ANY is_standard_equal: standard_is_equal (other) frozen standard_twin: OBJECT_GRAPH_TRAVERSABLE -- New object field-by-field identical to other. -- Always uses default copying semantics. -- (from ANY) ensure -- from ANY standard_twin_not_void: Result /= Void equal: standard_equal (Result, Current) frozen twin: OBJECT_GRAPH_TRAVERSABLE -- New object equal to Current -- `twin` calls `copy`; to change copying/twinning semantics, redefine `copy`. -- (from ANY) ensure -- from ANY twin_not_void: Result /= Void is_equal: Result ~ Current feature -- Basic operations frozen default: detachable OBJECT_GRAPH_TRAVERSABLE -- Default value of object's type -- (from ANY) frozen default_pointer: POINTER -- Default value of type POINTER -- (Avoid the need to write p.`default` for -- some p of type POINTER.) -- (from ANY) ensure -- from ANY instance_free: class default_rescue -- Process exception for routines with no Rescue clause. -- (Default: do nothing.) -- (from ANY) frozen do_nothing -- Execute a null action. -- (from ANY) ensure -- from ANY instance_free: class frozen traverse -- Traverse object structure starting at 'root_object' and call object_action -- on every object in the graph. require root_object_available: is_root_object_set wipe_out -- Clear current to default values ensure visited_objects_reset: visited_objects = Void object_action_not_set: not is_object_action_set root_object_not_set: not is_root_object_set feature -- Output Io: STD_FILES -- Handle to standard file setup -- (from ANY) ensure -- from ANY instance_free: class io_not_void: Result /= Void out: STRING_8 -- New string containing terse printable representation -- of current object -- (from ANY) ensure -- from ANY out_not_void: Result /= Void print (o: detachable ANY) -- Write terse external representation of o -- on standard output. -- (from ANY) ensure -- from ANY instance_free: class frozen tagged_out: STRING_8 -- New string containing terse printable representation -- of current object -- (from ANY) ensure -- from ANY tagged_out_not_void: Result /= Void feature -- Platform Operating_environment: OPERATING_ENVIRONMENT -- Objects available from the operating system -- (from ANY) ensure -- from ANY instance_free: class operating_environment_not_void: Result /= Void invariant -- from ANY reflexive_equality: standard_is_equal (Current) reflexive_conformance: conforms_to (Current) note copyright: "Copyright (c) 1984-2017, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software 5949 Hollister Ave., Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com ]" end -- class OBJECT_GRAPH_TRAVERSABLE
Classes Clusters Cluster hierarchy Chart Relations Flat contracts Go to:

-- Generated by Eiffel Studio --
For more details: eiffel.org