/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
- indexing
- copyright: "[
- Copyright (C) 2007 Paolo Redaelli
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License
- as published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301 USA
- ]"
- deferred class FREEZABLE
- -- An object that can be made temporary or permanently unchangable.
- -- Note: this class is currently used only in G_VALUE. It is debatable if
- -- the behaviour it provides is actually useful or desiderable.
- insert ANY undefine copy, is_equal, fill_tagged_out_memory end
- feature
- freeze is
- -- Forbid further changes to Current until thaw is invoked
- do
- state := state.bit_set(freezed_bit)
- end
- thaw is
- -- Allow changes to Current
- do
- state := state.bit_reset(freezed_bit)
- end
- petrify is
- do
- state := state.bit_set(freezed_bit)
- state := state.bit_set(petrified_bit)
- end
- is_freezed: BOOLEAN is
- do
- Result := (state.bit_test(freezed_bit) or
- state.bit_test(petrified_bit))
- -- Oh yeah it could have been written a-la C.
- end
- is_petrified: BOOLEAN is
- do
- Result := state.bit_test(petrified_bit)
- end
- feature {}
- state: INTEGER_8
- freezed_bit: INTEGER_8 is 0
- petrified_bit: INTEGER_8 is 1
- end -- class FREEZABLE