<?php
/*
 * $RCSfile: GalleryLockSystem.class,v $
 *
 * Gallery - a web based photo album viewer and editor
 * Copyright (C) 2000-2005 Bharat Mediratta
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
 */
/**
 * @version $Revision: 1.4 $ $Date: 2005/08/23 03:49:03 $
 * @package GalleryCore
 * @author Bharat Mediratta <bharat@menalto.com>
 */

/**
 * This is an interface for all locking systems.  You must extend it and
 * implement all of its methods in order to introduce a new locking system.
 *
 * @package GalleryCore
 * @subpackage Classes
 * @abstract
 */
class GalleryLockSystem {

    /**
     * Read Lock one or more objects
     *
     * @access public
     * @param array ids to lock, or int single id
     * @param integer how long to wait for the lock before giving up
     * @return array object GalleryStatus a status code
     *               int the lock id
     * @static
     */
    function acquireReadLock($ids, $timeout=10) {
	return array(GalleryStatus::error(ERROR_UNIMPLEMENTED, __FILE__, __LINE__), null);
    }

    /**
     * Return true if the given id is read locked or write locked.
     *
     * @access public
     * @param int an entity id
     * @return boolean true if the entity is read locked
     * @static
     */
    function isReadLocked($id) {
	return false;
    }

    /**
     * Write lock one or more objects
     *
     * @access public
     * @param array ids to lock, or int single id
     * @param integer how long to wait for the lock before giving up
     * @return array object GalleryStatus a status code
     *               int the lock id
     * @abstract
     */
    function acquireWriteLock($ids, $timeout=10) {
	return array(GalleryStatus::error(ERROR_UNIMPLEMENTED, __FILE__, __LINE__), null);
    }

    /**
     * Return true if the given id is write locked
     *
     * @access public
     * @param int an entity id
     * @return boolean true if the entity is write locked
     * @abstract
     */
    function isWriteLocked($id) {
	return false;
    }

    /**
     * Release the given lock(s)
     *
     * @param array a list of lock ids, or a single lock id
     * @return object GalleryStatus a status code
     * @abstract
     */
    function releaseLocks($lockIds) {
	return GalleryStatus::error(ERROR_UNIMPLEMENTED, __FILE__, __LINE__);
    }

    /**
     * Release any locks that we're holding.
     * @return object GalleryStatus a status code
     * @abstract
     */
    function releaseAllLocks() {
	return GalleryStatus::error(ERROR_UNIMPLEMENTED, __FILE__, __LINE__);
    }

    /**
     * Refresh all the locks that we hold so that they aren't accidentally considered expired
     *
     * @param int the new "fresh until" timestamp
     * @return object GalleryStatus a status code
     * @abstract
     */
    function refreshLocks($freshUntil) {
	return GalleryStatus::error(ERROR_UNIMPLEMENTED, __FILE__, __LINE__);
    }

    /**
     * Return the ids of all the locks we hold
     *
     * @return array lock ids
     */
    function getLockIds() {
	return null;
    }
}
?>
