/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

  1. note
  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. 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. 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. deferred class CACHING_FACTORY[ITEM_ -> WRAPPER]
  21. -- A factory that retrieves wrappers from a cache, usually a
  22. -- dictionary; used to implement collection of wrapped objects
  23. inherit
  24. WRAPPER_FACTORY[ITEM_]
  25. feature {WRAPPER, WRAPPER_HANDLER}
  26. wrappers: HASHED_DICTIONARY[ITEM_, POINTER]
  27. -- Dictionary cache storing wrappers; usually used in
  28. -- WRAPPER_COLLECTIONs or WRAPPER_DICTIONARY
  29. -- Key is the address (pointer) to the wrapped C structure,
  30. -- value is the corresponding Eiffel wrapper. This way you
  31. -- can get back an already-created Eiffel wrapper. Heirs of
  32. -- SHARED_C_STRUCT, i.e. G_OBJECT could provide alternative
  33. -- implementation that will not rely on this dictionary.
  34. deferred
  35. end
  36. wrapper (a_pointer: POINTER): ITEM_
  37. deferred
  38. ensure then
  39. wrappers.has(a_pointer)
  40. end
  41. invariant
  42. dictionary_not_void: wrappers /= Void
  43. end -- class CACHING_FACTORY