PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/glib/library/g_freezable.e

http://github.com/tybor/Liberty
Specman e | 82 lines | 55 code | 15 blank | 12 comment | 2 complexity | d44301d0a8bbd46906c7440c164a158e MD5 | raw file
 1indexing
 2	description: "An object that can be made  ."
 3	copyright: "[
 4					Copyright (C) 2007 Paolo Redaelli
 5					
 6					This library is free software; you can redistribute it and/or
 7					modify it under the terms of the GNU Lesser General Public License
 8					as published by the Free Software Foundation; either version 2.1 of
 9					the License, or (at your option) any later version.
10					
11					This library is distributed in the hope that it will be useful, but
12					WITHOUT ANY WARRANTY; without even the implied warranty of
13					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14					Lesser General Public License for more details.
15
16					You should have received a copy of the GNU Lesser General Public
17					License along with this library; if not, write to the Free Software
18					Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19					02110-1301 USA
20			]"
21
22deferred class G_FREEZABLE
23	-- An object that can be made temporary or permanently
24	-- unchangable.
25
26	-- Note for the developer: this behaviour is
27	-- currently only a hint to the end-user and
28	-- it is not enforced throught an invariant.
29
30	-- TODO: implement an invariant.
31insert ANY undefine copy, is_equal, fill_tagged_out_memory end
32
33feature
34	freeze is
35			-- Forbid further changes to Current until thaw is invoked
36		do
37			state := state.max(freezed_state)
38		end
39
40	thaw is
41			-- Allow changes to Current
42		require can_be_thawed
43		do
44			state := mutable_state
45		end
46
47	petrify is
48		do
49			state := petrified_state
50		end
51
52	is_mutable: BOOLEAN is
53		do
54			Result := state=mutable_state
55		end
56
57	is_freezed: BOOLEAN is
58		do
59			Result := state>=freezed_state
60		end
61
62	can_be_thawed: BOOLEAN is
63		do
64			Result := not is_petrified
65		end
66
67	is_petrified: BOOLEAN is
68		do
69			Result := state>=petrified_state
70		end
71
72feature {} 
73	state: INTEGER_8
74
75	mutable_state: INTEGER_8 is 0
76	-- The object can be changed
77	freezed_state: INTEGER_8 is 1
78	-- The object cannot currently be changed but can be
79	-- made changeable
80	petrified_state: INTEGER_8 is 2
81	-- The object cannot be changed anymore	
82end -- class G_FREEZABLE