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

/src/wrappers/common/library/caching_factory.e

http://github.com/tybor/Liberty
Specman e | 50 lines | 34 code | 7 blank | 9 comment | 2 complexity | d2486bb938b604c7674bf9c885392ff3 MD5 | raw file
 1note
 2   description:
 3      "A wrapper factory that "
 4   copyright:
 5      "[
 6               Copyright (C) 2006-2017: , 2007 Paolo Redaelli
 7               This library is free software; you can redistribute it and/or
 8               modify it under the terms of the GNU Lesser General Public License
 9               as published by the Free Software Foundation; either version 2.1 of
10               the License, or (at your option) any later version.
11
12               This library is distributed in the hope that it will be useful, but
13               WITHOUT ANY WARRANTY; without even the implied warranty of
14               MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15               Lesser General Public License for more details.
16
17               You should have received a copy of the GNU Lesser General Public
18               License along with this library; if not, write to the Free Software
19               Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20               02110-1301 USA
21         ]"
22deferred class CACHING_FACTORY[ITEM_ -> WRAPPER]
23   -- A factory that retrieves wrappers from a cache, usually a
24   -- dictionary; used to implement collection of wrapped objects
25
26inherit
27   WRAPPER_FACTORY[ITEM_]
28
29feature {WRAPPER, WRAPPER_HANDLER}
30   wrappers: HASHED_DICTIONARY[ITEM_, POINTER]
31         -- Dictionary cache storing wrappers; usually used in
32         -- WRAPPER_COLLECTIONs or WRAPPER_DICTIONARY
33         -- Key is the address (pointer) to the wrapped C structure,
34         -- value is the corresponding Eiffel wrapper. This way you
35         -- can get back an already-created Eiffel wrapper. Heirs of
36         -- SHARED_C_STRUCT, i.e. G_OBJECT could provide alternative
37         -- implementation that will not rely on this dictionary.
38      deferred
39      end
40
41   wrapper (a_pointer: POINTER): ITEM_
42      deferred
43      ensure then
44         wrappers.has(a_pointer)
45      end
46
47invariant
48   dictionary_not_void: wrappers /= Void
49
50end -- class CACHING_FACTORY