Automatic generation produced by ISE Eiffel

Classes Clusters Cluster hierarchy Chart Relations Text Flat Contracts Flat contracts Go to:
indexing description: "Implementation of the STORABLE mechanism with streams." date: "$Date: 2001-11-16 20:32:23 +0000 (Fri, 16 Nov 2001) $" revision: "$Revision: 51435 $" class STREAM create make, make_with_size feature -- Initialization make is -- Create stream object with a default_size of 100 bytes do buffer_size := 200 create_c_buffer end make_with_size (n: INTEGER) is -- Create stream object with a default_size of n bytes do buffer_size := n create_c_buffer end feature -- Access buffer: POINTER -- C buffer correspond to the Eiffel STREAM. buffer_size: INTEGER -- Buffer's size. create_c_buffer is -- Create the C memory corresponding to the C -- buffer. do buffer := c_malloc (buffer_size) end object_stored_size: INTEGER -- Size of last stored object. retrieved: ANY is -- Retrieved object structure -- To access resulting object under correct type, -- use assignment attempt. -- Will raise an exception (code Retrieve_exception) -- if content is not a stored Eiffel structure. require -- from IO_MEDIUM exists: exists is_open_read: is_open_read support_storable: support_storable local size: INTEGER do Result := c_retrieved (buffer, buffer_size, 0, $size) object_stored_size := size ensure -- from IO_MEDIUM result_exists: Result /= void end feature {NONE} -- Access C_memory: INTEGER is 2 -- Code for the C memory managed -- by the garbage collector -- (from MEM_CONST) Eiffel_memory: INTEGER is 1 -- Code for the Eiffel memory managed -- by the garbage collector -- (from MEM_CONST) Full_collector: INTEGER is 0 -- Statistics for full collections -- (from MEM_CONST) Incremental_collector: INTEGER is 1 -- Statistics for incremental collections -- (from MEM_CONST) Total_memory: INTEGER is 0 -- Code for all the memory managed -- by the garbage collector -- (from MEM_CONST) feature {NONE} -- Measurement gc_statistics (collector_type: INTEGER): GC_INFO is -- Garbage collection information for collector_type. -- (from MEMORY) require -- from MEMORY type_ok: collector_type = full_collector or collector_type = incremental_collector do create Result.make (collector_type) end memory_statistics (memory_type: INTEGER): MEM_INFO is -- Memory usage information for memory_type -- (from MEMORY) require -- from MEMORY type_ok: memory_type = total_memory or memory_type = eiffel_memory or memory_type = c_memory do create Result.make (memory_type) end feature -- Status report Exists: BOOLEAN is True -- Stream exists in any cases. extendible: BOOLEAN is -- May new items be added? do Result := True end is_closed: BOOLEAN -- Is the I/O medium open is_executable: BOOLEAN is -- Is stream executable? require -- from IO_MEDIUM handle_exists: exists do Result := False end Is_open_read: BOOLEAN is True -- Stream opens for input. Is_open_write: BOOLEAN is True -- Stream opens for output. is_plain_text: BOOLEAN is -- Is file reserved for text (character sequences)? -- (from IO_MEDIUM) do end Is_readable: BOOLEAN is True Is_writable: BOOLEAN is True -- Stream is writable. last_character: CHARACTER -- Last character read by read_character -- (from IO_MEDIUM) last_double: DOUBLE -- Last double read by read_double -- (from IO_MEDIUM) last_integer: INTEGER -- Last integer read by read_integer -- (from IO_MEDIUM) last_real: REAL -- Last real read by read_real -- (from IO_MEDIUM) last_string: STRING -- Last string read -- (from IO_MEDIUM) readable: BOOLEAN is -- Is there a current item that may be read? require -- from IO_MEDIUM handle_exists: exists do end Support_storable: BOOLEAN is True -- Can medium be used to store an Eiffel structure? feature {NONE} -- Status report chunk_size: INTEGER is -- Minimal size of a memory chunk. The run-time always -- allocates a multiple of this size. -- If the environment variable EIF_MEMORY_CHUNK -- is defined, it is set to the closest reasonable -- value from it. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "eif_get_chunk_size" end coalesce_period: INTEGER is -- Period of full coalesce (in number of collections) -- If the environment variable EIF_FULL_COALESCE_PERIOD -- is defined, it is set to the closest reasonable -- value from it. -- If null, no full coalescing is launched. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "eif_coalesce_period" end collecting: BOOLEAN is -- Is garbage collection enabled? -- (from MEMORY) external "C | %"eif_memory.h%"" alias "gc_ison" end collection_period: INTEGER is -- Period of full collection. -- If the environment variable EIF_FULL_COLLECTION_PERIOD -- is defined, it is set to the closest reasonable -- value from it. -- If null, no full collection is launched. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "mem_pget" end generation_object_limit: INTEGER is -- Maximum size of object in generational scavenge zone. -- If the environment variable EIF_GS_LIMIT -- is defined, it is set to the closest reasonable -- value from it. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "eif_generation_object_limit" end largest_coalesced_block: INTEGER is -- Size of largest coalesced block since last call to -- largest_coalesced; 0 if none. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "mem_largest" end max_mem: INTEGER is -- Maximum amount of bytes the run-time can allocate. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "eif_get_max_mem" end memory_threshold: INTEGER is -- Minimum amount of bytes to be allocated before -- starting an automatic garbage collection. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "mem_tget" end referers (an_object: ANY): ARRAY [ANY] is -- Objects that refer to an_object. -- (from MEMORY) local a: ANY do create Result.make (0, 200) a := Result.area find_referers ($an_object, $a, Result.count) end scavenge_zone_size: INTEGER is -- Size of generational scavenge zone. -- If the environment variable EIF_MEMORY_SCAVENGE -- is defined, it is set to the closest reasonable -- value from it. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "eif_scavenge_zone_size" end tenure: INTEGER is -- Maximum age of object before being considered -- as old (old objects are not scanned during -- partial collection). -- If the environment variable EIF_TENURE_MAX -- is defined, it is set to the closest reasonable -- value from it. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "eif_tenure" end feature -- Status setting close is -- Close medium. require -- from IO_MEDIUM medium_is_open: not is_closed do is_closed := True c_free (buffer) buffer := default_pointer end feature {NONE} -- Status setting allocate_compact is -- Enter `memory' mode: will try to compact memory -- before requesting more from the operating system. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "mem_slow" end allocate_fast is -- Enter `speed' mode: will optimize speed of memory -- allocation rather than memory usage. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "mem_speed" end allocate_tiny is -- Enter `tiny' mode: will enter `memory' mode -- after having freed as much memory as possible. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "mem_tiny" end collection_off is -- Disable garbage collection. -- (from MEMORY) external "C | %"eif_garcol.h%"" alias "gc_stop" end collection_on is -- Enable garbage collection. -- (from MEMORY) external "C | %"eif_garcol.h%"" alias "gc_run" end disable_time_accounting is -- Disable GC time accounting (default). -- (from MEMORY) do gc_monitoring (False) end enable_time_accounting is -- Enable GC time accouting, accessible in gc_statistics. -- (from MEMORY) do gc_monitoring (True) end set_coalesce_period (value: INTEGER) is -- Set coalesce_period. Every value collection, -- the Garbage Collector will coalesce -- the whole memory. -- (from MEMORY) require -- from MEMORY positive_value: value >= 0 external "C | %"eif_memory.h%"" alias "eif_set_coalesce_period" end set_collection_period (value: INTEGER) is -- Set collection_period. Every value collection, -- the Garbage collector will perform a collection -- on the whole memory (full collection), otherwise -- a simple partial collection is done. -- (from MEMORY) require -- from MEMORY positive_value: value >= 0 external "C | %"eif_memory.h%"" alias "mem_pset" end set_max_mem (value: INTEGER) is -- Set the maximum amount of memory the run-time can allocate. -- (from MEMORY) require -- from MEMORY positive_value: value > 0 external "C | %"eif_memory.h%"" alias "eif_set_max_mem" end set_memory_threshold (value: INTEGER) is -- Set a new memory_threshold in bytes. Whenever the memory -- allocated for Eiffel reaches this value, an automatic -- collection is performed. -- (from MEMORY) require -- from MEMORY positive_value: value > 0 external "C | %"eif_memory.h%"" alias "mem_tset" end feature -- Element change basic_store (object: ANY) is -- Produce an external representation of the -- entire object structure reachable from object. -- Retrievable within current system only. require -- from IO_MEDIUM object_not_void: object /= void exists: exists is_open_write: is_open_write support_storable: support_storable local size: INTEGER do buffer_size := c_stream_basic_store (buffer, buffer_size, $object, $size) object_stored_size := size end general_store (object: ANY) is -- Produce an external representation of the -- entire object structure reachable from object. -- Retrievable from other systems for same platform -- (machine architecture). require -- from IO_MEDIUM object_not_void: object /= void exists: exists is_open_write: is_open_write support_storable: support_storable local size: INTEGER do buffer_size := c_stream_general_store (buffer, buffer_size, $object, $size) object_stored_size := size end independent_store (object: ANY) is -- Produce an external representation of the -- entire object structure reachable from object. -- Retrievable from other systems for the same or other -- platform (machine architecture). require -- from IO_MEDIUM object_not_void: object /= void exists: exists is_open_write: is_open_write support_storable: support_storable local size: INTEGER do buffer_size := c_stream_independent_store (buffer, buffer_size, $object, $size) object_stored_size := size end set_additional_size (new_size: INTEGER) is -- Set new_size to BUFFER_SIZE, internal value used to -- increment buffer_size during storable operations. external "C | %"eif_store.h%"" alias "set_buffer_size" end feature -- Removal dispose is -- Ensure this medium is closed when garbage collected. -- (from IO_MEDIUM) do if not is_closed then close end end feature {NONE} -- Removal collect is -- Force a partial collection cycle if garbage -- collection is enabled; do nothing otherwise. -- (from MEMORY) external "C | %"eif_eiffel.h%"" end free (object: ANY) is -- Free object, by-passing garbage collection. -- Erratic behavior will result if the object is still -- referenced. -- (from MEMORY) do mem_free ($object) end full_coalesce is -- Coalesce the whole memory: merge adjacent free -- blocks to reduce fragmentation. Useful, when -- a lot of memory is allocated with garbage collector off. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "mem_coalesc" end full_collect is -- Force a full collection cycle if garbage -- collection is enabled; do nothing otherwise. -- (from MEMORY) external "C | %"eif_garcol.h%"" alias "plsc" end mem_free (addr: POINTER) is -- Free memory of object at addr. -- (Preferred interface is free.) -- (from MEMORY) external "C | %"eif_memory.h%"" end feature -- Obsolete lastchar: CHARACTER is -- Last character read by read_character -- (from IO_MEDIUM) do Result := last_character end lastdouble: DOUBLE is -- Last double read by read_double -- (from IO_MEDIUM) do Result := last_double end lastint: INTEGER is -- Last integer read by read_integer -- (from IO_MEDIUM) do Result := last_integer end lastreal: REAL is -- Last real read by read_real -- (from IO_MEDIUM) do Result := last_real end laststring: STRING is -- Last string read -- (from IO_MEDIUM) do Result := last_string end feature {NONE} -- Implementation c_free (buf: POINTER) is external "C | %"eif_store.h%"" alias "stream_free" end c_malloc (size: INTEGER): POINTER is external "C | %"eif_store.h%"" alias "stream_malloc" end c_retrieved (stream_buffer: POINTER; stream_buffer_size: INTEGER; stream_buffer_position: INTEGER; c_real_size: POINTER): ANY is -- Object structured retrieved from stream of pointer -- stream_ptr external "C | %"eif_retrieve.h%"" alias "stream_eretrieve" end c_stream_basic_store (stream_buffer: POINTER; stream_buffer_size: INTEGER; object: POINTER; c_real_size: POINTER): INTEGER is -- Store object structure reachable form current object -- Return new size of buffer. external "C | %"eif_store.h%"" alias "stream_estore" end c_stream_general_store (stream_buffer: POINTER; stream_buffer_size: INTEGER; object: POINTER; c_real_size: POINTER): INTEGER is -- Store object structure reachable form current object -- Return new size of buffer. external "C | %"eif_store.h%"" alias "stream_eestore" end c_stream_independent_store (stream_buffer: POINTER; stream_buffer_size: INTEGER; object: POINTER; c_real_size: POINTER): INTEGER is -- Store object structure reachable form current object -- Return new size of buffer. external "C |%"eif_store.h%"" alias "stream_sstore" end find_referers (target: POINTER; esult: POINTER; result_size: INTEGER) is -- (from MEMORY) external "C | %"eif_traverse.h%"" end gc_monitoring (flag: BOOLEAN) is -- Set up GC monitoring according to flag -- (from MEMORY) external "C | %"eif_memory.h%"" alias "gc_mon" end feature -- Input read_character is -- Read a new character. -- Make result available in last_character. -- Was declared in STREAM as synonym of readchar. require -- from IO_MEDIUM is_readable: readable do end read_double is -- Read a new double. -- Make result available in last_double. -- Was declared in STREAM as synonym of readdouble. require -- from IO_MEDIUM is_readable: readable do end read_integer is -- Read a new integer. -- Make result available in last_integer. -- Was declared in STREAM as synonym of readint. require -- from IO_MEDIUM is_readable: readable do end read_line is -- Read characters until a new line or -- end of medium. -- Make result available in last_string. -- Was declared in STREAM as synonym of readline. require -- from IO_MEDIUM is_readable: readable do end read_real is -- Read a new real. -- Make result available in last_real. -- Was declared in STREAM as synonym of readreal. require -- from IO_MEDIUM is_readable: readable do end read_stream (nb_char: INTEGER) is -- Read a string of at most nb_char bound characters -- or until end of medium is encountered. -- Make result available in last_string. -- Was declared in STREAM as synonym of readstream. require -- from IO_MEDIUM is_readable: readable do end readchar is -- Read a new character. -- Make result available in last_character. -- Was declared in STREAM as synonym of read_character. require -- from IO_MEDIUM is_readable: readable do end readdouble is -- Read a new double. -- Make result available in last_double. -- Was declared in STREAM as synonym of read_double. require -- from IO_MEDIUM is_readable: readable do end readint is -- Read a new integer. -- Make result available in last_integer. -- Was declared in STREAM as synonym of read_integer. require -- from IO_MEDIUM is_readable: readable do end readline is -- Read characters until a new line or -- end of medium. -- Make result available in last_string. -- Was declared in STREAM as synonym of read_line. require -- from IO_MEDIUM is_readable: readable do end readreal is -- Read a new real. -- Make result available in last_real. -- Was declared in STREAM as synonym of read_real. require -- from IO_MEDIUM is_readable: readable do end readstream (nb_char: INTEGER) is -- Read a string of at most nb_char bound characters -- or until end of medium is encountered. -- Make result available in last_string. -- Was declared in STREAM as synonym of read_stream. require -- from IO_MEDIUM is_readable: readable do end feature {NONE} -- Not exported handle: INTEGER is -- Handle to medium require -- from IO_MEDIUM valid_handle: handle_available do end handle_available: BOOLEAN is -- Is the handle available after class has been -- created? do end name: STRING is -- Not meaningful do end feature -- Output new_line is -- Write a new line character to medium -- Was declared in STREAM as synonym of put_new_line. require -- from IO_MEDIUM extendible: extendible require else stream_exists: exists do put_character ('%N') end put_boolean (b: BOOLEAN) is -- Write b to medium. -- Was declared in STREAM as synonym of putbool. require -- from IO_MEDIUM extendible: extendible do end put_character (c: CHARACTER) is -- Write c to medium. -- Was declared in STREAM as synonym of putchar. require -- from IO_MEDIUM extendible: extendible do end put_double (d: DOUBLE) is -- Write d to medium. -- Was declared in STREAM as synonym of putdouble. require -- from IO_MEDIUM extendible: extendible do end put_integer (i: INTEGER) is -- Write i to medium. -- Was declared in STREAM as synonym of putint. require -- from IO_MEDIUM extendible: extendible do end put_new_line is -- Write a new line character to medium -- Was declared in STREAM as synonym of new_line. require -- from IO_MEDIUM extendible: extendible require else stream_exists: exists do put_character ('%N') end put_real (r: REAL) is -- Write r to medium. -- Was declared in STREAM as synonym of putreal. require -- from IO_MEDIUM extendible: extendible do end put_string (s: STRING) is -- Write s to medium. -- Was declared in STREAM as synonym of putstring. require -- from IO_MEDIUM extendible: extendible non_void: s /= void do end putbool (b: BOOLEAN) is -- Write b to medium. -- Was declared in STREAM as synonym of put_boolean. require -- from IO_MEDIUM extendible: extendible do end putchar (c: CHARACTER) is -- Write c to medium. -- Was declared in STREAM as synonym of put_character. require -- from IO_MEDIUM extendible: extendible do end putdouble (d: DOUBLE) is -- Write d to medium. -- Was declared in STREAM as synonym of put_double. require -- from IO_MEDIUM extendible: extendible do end putint (i: INTEGER) is -- Write i to medium. -- Was declared in STREAM as synonym of put_integer. require -- from IO_MEDIUM extendible: extendible do end putreal (r: REAL) is -- Write r to medium. -- Was declared in STREAM as synonym of put_real. require -- from IO_MEDIUM extendible: extendible do end putstring (s: STRING) is -- Write s to medium. -- Was declared in STREAM as synonym of put_string. require -- from IO_MEDIUM extendible: extendible non_void: s /= void do end invariant -- from ANY reflexive_equality: standard_is_equal (Current) reflexive_conformance: conforms_to (Current) indexing library: "[ EiffelBase: Library of reusable components for Eiffel. ]" status: "[ Copyright 1986-2001 Interactive Software Engineering (ISE). For ISE customers the original versions are an ISE product covered by the ISE Eiffel license and support agreements. ]" license: "[ EiffelBase may now be used by anyone as FREE SOFTWARE to develop any product, public-domain or commercial, without payment to ISE, under the terms of the ISE Free Eiffel Library License (IFELL) at http://eiffel.com/products/base/license.html. ]" source: "[ Interactive Software Engineering Inc. ISE Building 360 Storke Road, Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Electronic mail <info@eiffel.com> Customer support http://support.eiffel.com ]" info: "[ For latest info see award-winning pages: http://eiffel.com ]" end -- class STREAM
Classes Clusters Cluster hierarchy Chart Relations Text Flat Contracts Flat contracts Go to:

-- Generated by ISE Eiffel --
For more details: www.eiffel.com