Difference between revisions of "Persistence code samples"

(PERSISTENCE_MANAGER)
(PERSISTENCE_MANAGER)
Line 17: Line 17:
  
 
store (an_object:ANY)
 
store (an_object:ANY)
--persists an_object using the format and medium stored by current object
+
-- persists an_object using the format and medium stored by current object
 
require
 
require
 
an_object_exists:an_object /= Void
 
an_object_exists:an_object /= Void
Line 26: Line 26:
  
 
retrieve:ANY
 
retrieve:ANY
--retrieves an_object using the medium and format stored by current object
+
-- retrieves an_object using the medium and format stored by current object
 
require
 
require
 
medium_exists: medium /= Void
 
medium_exists: medium /= Void

Revision as of 01:07, 19 August 2007

Here the main classes of the framework are sketched.

You can download the source code here (TODO: provide a link to the sources)

Simplified BON diagram

PERSISTENCE_MANAGER

class
	PERSISTENCE_MANAGER
 
feature -- Access
 
	medium: PERSISTENCE_MEDIUM -- the chosen medium
 
	format: PERSISTENCE_FORMAT	-- the chosen format
 
feature -- Basic operations
 
	store (an_object:ANY)
			-- persists an_object using the format and medium stored by current object
		require
			an_object_exists:an_object /= Void
			medium_exists: medium /= Void
		do
			format.store(an_object,medium)
		end
 
	retrieve:ANY
			-- retrieves an_object using the medium and format stored by current object
		require
			medium_exists: medium /= Void
		do
			Result:=format.retrieve(medium)
		end
end

SERIALIZATION_MANAGER

PERSISTENCE_FORMAT

BINARY_FORMAT

INDEPENDENT_BINARY_FORMAT

indexing
	description: "Objects that represent specific platform independent binary formats"
	author: ""
	date: "$Date$"
	revision: "$Revision$"
 
class
	INDEPENDENT_BINARY_FORMAT
 
inherit
	BINARY_FORMAT
 
feature -- Access
 
	optimized_for_retrieval:BOOLEAN
 
feature -- Status setting
 
	set_optimized_for_retrieval(is_optimized_for_retrieval:BOOLEAN)
	do
		optimized_for_retrieval:=is_optimized_for_retrieval
	ensure
		optimized_for_retrieval_set:optimized_for_retrieval=is_optimized_for_retrieval
	end
 
feature -- Basic operations
 
	store_now(object_to_store:ANY)
	do
		store_handler.independent_store(object_to_store,serializer,optimized_for_retrieval)
	end
 
end

PERSISTENCE_MEDIUM

FILE_MEDIUM