PageRenderTime 4ms CodeModel.GetById 2ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/gobject/library/freezable.e

http://github.com/tybor/Liberty
Specman e | 67 lines | 46 code | 15 blank | 6 comment | 2 complexity | 22f16c4b16ca533fa78ae0a7800f3bb9 MD5 | raw file
 1indexing
 2	copyright: "[
 3		Copyright (C) 2007 Paolo Redaelli
 4
 5		This library is free software; you can redistribute it and/or
 6		modify it under the terms of the GNU Lesser General Public License
 7		as published by the Free Software Foundation; either version 2.1 of
 8		the License, or (at your option) any later version.
 9
10		This library is distributed in the hope that it will be useful, but
11		WITHOUT ANY WARRANTY; without even the implied warranty of
12		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13		Lesser General Public License for more details.
14
15		You should have received a copy of the GNU Lesser General Public
16		License along with this library; if not, write to the Free Software
17		Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18		02110-1301 USA
19	]"
20
21deferred class FREEZABLE
22	-- An object that can be made temporary or permanently unchangable.
23
24	-- Note: this class is currently used only in G_VALUE. It is debatable if
25	-- the behaviour it provides is actually useful or desiderable.
26
27insert ANY undefine copy, is_equal, fill_tagged_out_memory end
28
29feature
30	freeze is
31		-- Forbid further changes to Current until thaw is invoked
32	do
33		state := state.bit_set(freezed_bit)
34	end
35
36	thaw is
37		-- Allow changes to Current
38	do
39		state := state.bit_reset(freezed_bit)
40	end
41
42	petrify is
43		do
44			state := state.bit_set(freezed_bit)
45			state := state.bit_set(petrified_bit)
46		end
47
48	is_freezed: BOOLEAN is
49		do
50			Result := (state.bit_test(freezed_bit) or 
51			state.bit_test(petrified_bit))
52			-- Oh yeah it could have been written a-la C. 
53		end
54
55	is_petrified: BOOLEAN is
56		do
57			Result := state.bit_test(petrified_bit)
58		end
59
60feature {} 
61	state: INTEGER_8
62
63	freezed_bit: INTEGER_8 is 0
64	petrified_bit: INTEGER_8 is 1
65
66end -- class FREEZABLE
67