PageRenderTime 20ms CodeModel.GetById 13ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/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
  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/**
 23 * Zend_Memory_Container_Interface
 24 */
 25require_once 'Zend/Memory/Container/Interface.php';
 26
 27/**
 28 * Memory object container access controller.
 29 *
 30 * Memory manager stores a list of generated objects to control them.
 31 * So container objects always have at least one reference and can't be automatically destroyed.
 32 *
 33 * This class is intended to be an userland proxy to memory container object.
 34 * It's not referenced by memory manager and class destructor is invoked immidiately after gouing
 35 * out of scope or unset operation.
 36 *
 37 * Class also provides Zend_Memory_Container_Interface interface and works as proxy for such cases.
 38 *
 39 * @category   Zend
 40 * @package    Zend_Memory
 41 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 42 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 43 */
 44class Zend_Memory_AccessController implements Zend_Memory_Container_Interface
 45{
 46    /**
 47     * Memory container object
 48     *
 49     * @var Zend_Memory_Container
 50     */
 51    private $_memContainer;
 52
 53
 54    /**
 55     * Object constructor
 56     *
 57     * @param Zend_Memory_Container_Movable $memoryManager
 58     */
 59    public function __construct(Zend_Memory_Container_Movable $memContainer)
 60    {
 61        $this->_memContainer = $memContainer;
 62    }
 63
 64    /**
 65     * Object destructor
 66     */
 67    public function __destruct()
 68    {
 69        $this->_memContainer->destroy();
 70    }
 71
 72
 73    /**
 74     * Get string value reference
 75     *
 76     * _Must_ be used for value access before PHP v 5.2
 77     * or _may_ be used for performance considerations
 78     *
 79     * @return &string
 80     */
 81    public function &getRef()
 82    {
 83        return $this->_memContainer->getRef();
 84    }
 85
 86    /**
 87     * Signal, that value is updated by external code.
 88     *
 89     * Should be used together with getRef()
 90     */
 91    public function touch()
 92    {
 93        $this->_memContainer->touch();
 94    }
 95
 96    /**
 97     * Lock object in memory.
 98     */
 99    public function lock()
100    {
101        $this->_memContainer->lock();
102    }
103
104
105    /**
106     * Unlock object
107     */
108    public function unlock()
109    {
110        $this->_memContainer->unlock();
111    }
112
113    /**
114     * Return true if object is locked
115     *
116     * @return boolean
117     */
118    public function isLocked()
119    {
120        return $this->_memContainer->isLocked();
121    }
122
123    /**
124     * Get handler
125     *
126     * Loads object if necessary and moves it to the top of loaded objects list.
127     * Swaps objects from the bottom of loaded objects list, if necessary.
128     *
129     * @param string $property
130     * @return string
131     * @throws Zend_Memory_Exception
132     */
133    public function __get($property)
134    {
135        return $this->_memContainer->$property;
136    }
137
138    /**
139     * Set handler
140     *
141     * @param string $property
142     * @param  string $value
143     * @throws Zend_Exception
144     */
145    public function __set($property, $value)
146    {
147        $this->_memContainer->$property = $value;
148    }
149}