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

/src/wrappers/common/library/enum.e

http://github.com/tybor/Liberty
Specman e | 57 lines | 43 code | 10 blank | 4 comment | 2 complexity | b0759911a1c0ee2784cee3f3eb755a1e MD5 | raw file
 1note
 2   description:
 3      "Generic enumeration"
 4   copyright:
 5      "[
 6               Copyright (C) 2008-2017: Paolo Redaelli
 7
 8               This library is free software; you can redistribute it and/or
 9               modify it under the terms of the GNU Lesser General Public License
10               as published by the Free Software Foundation; either version 2.1 of
11               the License, or (at your option) any later version.
12
13               This library is distributed in the hope that it will be useful, but
14               WITHOUT ANY WARRANTY; without even the implied warranty of
15               MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16               Lesser General Public License for more details.
17
18               You should have received a copy of the GNU Lesser General Public
19               License along with this library; if not, write to the Free Software
20               Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21               02110-1301 USA
22         ]"
23deferred class ENUM
24   -- A wrapper for an enumeration
25
26insert
27   ANY
28      undefine default_create
29      end
30
31feature {ANY}
32   is_valid_state: BOOLEAN
33         -- Is the value of the enumeration valid?
34      do
35         Result := is_valid_value(value)
36      end
37
38feature {WRAPPER_HANDLER}
39   value: INTEGER
40      -- The current value of the enumeration.
41
42   set, change_value (a_value: INTEGER)
43      require
44         is_valid_value(a_value)
45      do
46         value := a_value
47      end
48
49   is_valid_value (a_value: INTEGER): BOOLEAN
50         -- Can `a_value' be used in a `set_value' feature call?
51      deferred
52      end
53
54invariant
55   is_valid_state
56
57end -- class ENUM