PageRenderTime 45ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/framework/vendor/zend/Zend/Memory/AccessController.php

http://zoop.googlecode.com/
PHP | 149 lines | 42 code | 14 blank | 93 comment | 0 complexity | 6eac5dc87ef61ab2b20f9f8de357e3b5 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Memory
  17. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. * @version $Id: AccessController.php 20096 2010-01-06 02:05:09Z bkarwin $
  20. */
  21. /**
  22. * Zend_Memory_Container_Interface
  23. */
  24. require_once 'Zend/Memory/Container/Interface.php';
  25. /**
  26. * Memory object container access controller.
  27. *
  28. * Memory manager stores a list of generated objects to control them.
  29. * So container objects always have at least one reference and can't be automatically destroyed.
  30. *
  31. * This class is intended to be an userland proxy to memory container object.
  32. * It's not referenced by memory manager and class destructor is invoked immidiately after gouing
  33. * out of scope or unset operation.
  34. *
  35. * Class also provides Zend_Memory_Container_Interface interface and works as proxy for such cases.
  36. *
  37. * @category Zend
  38. * @package Zend_Memory
  39. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  40. * @license http://framework.zend.com/license/new-bsd New BSD License
  41. */
  42. class Zend_Memory_AccessController implements Zend_Memory_Container_Interface
  43. {
  44. /**
  45. * Memory container object
  46. *
  47. * @var Zend_Memory_Container
  48. */
  49. private $_memContainer;
  50. /**
  51. * Object constructor
  52. *
  53. * @param Zend_Memory_Container_Movable $memoryManager
  54. */
  55. public function __construct(Zend_Memory_Container_Movable $memContainer)
  56. {
  57. $this->_memContainer = $memContainer;
  58. }
  59. /**
  60. * Object destructor
  61. */
  62. public function __destruct()
  63. {
  64. $this->_memContainer->destroy();
  65. }
  66. /**
  67. * Get string value reference
  68. *
  69. * _Must_ be used for value access before PHP v 5.2
  70. * or _may_ be used for performance considerations
  71. *
  72. * @return &string
  73. */
  74. public function &getRef()
  75. {
  76. return $this->_memContainer->getRef();
  77. }
  78. /**
  79. * Signal, that value is updated by external code.
  80. *
  81. * Should be used together with getRef()
  82. */
  83. public function touch()
  84. {
  85. $this->_memContainer->touch();
  86. }
  87. /**
  88. * Lock object in memory.
  89. */
  90. public function lock()
  91. {
  92. $this->_memContainer->lock();
  93. }
  94. /**
  95. * Unlock object
  96. */
  97. public function unlock()
  98. {
  99. $this->_memContainer->unlock();
  100. }
  101. /**
  102. * Return true if object is locked
  103. *
  104. * @return boolean
  105. */
  106. public function isLocked()
  107. {
  108. return $this->_memContainer->isLocked();
  109. }
  110. /**
  111. * Get handler
  112. *
  113. * Loads object if necessary and moves it to the top of loaded objects list.
  114. * Swaps objects from the bottom of loaded objects list, if necessary.
  115. *
  116. * @param string $property
  117. * @return string
  118. * @throws Zend_Memory_Exception
  119. */
  120. public function __get($property)
  121. {
  122. return $this->_memContainer->$property;
  123. }
  124. /**
  125. * Set handler
  126. *
  127. * @param string $property
  128. * @param string $value
  129. * @throws Zend_Exception
  130. */
  131. public function __set($property, $value)
  132. {
  133. $this->_memContainer->$property = $value;
  134. }
  135. }