/[eiffelstudio]/branches/eth/eve/Src/library/memory_analyzer/ma_memory_state_manager.e
ViewVC logotype

Contents of /branches/eth/eve/Src/library/memory_analyzer/ma_memory_state_manager.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 88507 - (show annotations)
Fri Apr 6 19:59:32 2012 UTC (7 years, 9 months ago) by jasonw
File size: 3287 byte(s)
<<Merged from trunk#88506.>>
1 note
2 description: "[
3 This is the managet of MEMORY_STATE which can save/open states from file
4
5 ]"
6 legal: "See notice at end of class."
7 status: "See notice at end of class."
8 date: "$Date$"
9 revision: "$Revision$"
10
11 class
12 MA_MEMORY_STATE_MANAGER
13
14 inherit
15 MA_SINGLETON_FACTORY
16
17 create
18 make
19
20 feature {NONE} -- Initialization
21
22 make (n: INTEGER)
23 -- creation method
24 do
25 create memory_states.make (1)
26
27 end
28
29
30 feature -- Access
31
32 states: like memory_states
33 -- Get the MEMORY_STATE's ARRAYED_LIST
34 do
35 Result := memory_states
36 ensure
37 result_not_void: Result /= Void
38 end
39
40 extend (a_state: MA_MEMORY_STATE)
41 -- Add a memory state to the array_list
42 do
43 memory_states.extend (a_state)
44 end
45
46 i_th alias "[]" (i: INTEGER): MA_MEMORY_STATE
47 -- The i_th memory state of the memory_states current hold.
48 do
49 Result := memory_states [i]
50 end
51
52
53 feature -- Status report
54
55 count: INTEGER
56 -- The memory states already contorl by the memory manager
57 do
58 Result := memory_states.count
59 end
60
61
62 -- is_user_click_ok: BOOLEAN is
63 -- -- Whether user click ok button on Open/Save file dialog.
64 -- do
65 -- Result := user_click_ok
66 -- end
67
68 feature -- Open/Save States
69
70 save_states
71 -- Save current states to a disk file.
72 local
73 l_dialog: EV_FILE_SAVE_DIALOG
74 do
75 -- user_click_ok := False
76 create l_dialog
77 l_dialog.filters.extend (state_file_suffix)
78 l_dialog.save_actions.extend (agent save_states_2_file (l_dialog))
79 l_dialog.show_modal_to_window (main_window)
80 end
81
82 open_states
83 -- Retreive the states from a disk file.
84 require
85 main_window_not_void: main_window /= Void
86 local
87 l_dialog: EV_FILE_OPEN_DIALOG
88 do
89 create l_dialog
90 l_dialog.filters.extend (state_file_suffix)
91 l_dialog.open_actions.extend (agent open_states_from_file (l_dialog))
92 l_dialog.show_modal_to_window (main_window)
93 end
94
95 feature {NONE} -- Implementation
96
97 save_states_2_file (a_dialog: EV_FILE_SAVE_DIALOG)
98 -- Save memory analyzer's datas to a file.
99 local
100 l_data_file: RAW_FILE
101 l_suffix: STRING
102 do
103 l_suffix := state_file_suffix.filter
104 l_suffix := l_suffix.substring (2, l_suffix.count)
105 create l_data_file.make_create_read_write (a_dialog.file_name + l_suffix)
106 memory_states.basic_store (l_data_file)
107 end
108
109 open_states_from_file (a_dialog: EV_FILE_OPEN_DIALOG)
110 -- Open memory analyzer's datas from a file
111 do
112 if attached {like memory_states} memory_states.retrieve_by_name (a_dialog.file_name) as l_states then
113 memory_states := l_states
114 else
115 --|FIXME: 2012/04/06 This should be removed when we handle corrupted files. See review#7644004.
116 check memory_states_not_retrieved: False end
117 end
118 ensure
119 states_not_void: memory_states /= Void
120 end
121
122 memory_states: MA_ARRAYED_LIST_STORABLE [MA_MEMORY_STATE]
123 -- The memory states this managers hold.
124 invariant
125 memory_states_not_void: memory_states /= Void
126
127 note
128 copyright: "Copyright (c) 1984-2012, Eiffel Software and others"
129 license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
130 source: "[
131 Eiffel Software
132 5949 Hollister Ave., Goleta, CA 93117 USA
133 Telephone 805-685-1006, Fax 805-685-6869
134 Website http://www.eiffel.com
135 Customer support http://support.eiffel.com
136 ]"
137
138
139
140
141 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23