/*!
  @header ECCacheItem
  @abstract Module of Encore
 
  @availability OS X, GNUstep
  @copyright 2004, 2005, 2006 Oliver Langer

  Author: Oliver Langer

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library 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
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA

  <pre>
  -------------------------------------------------------------------------
  Modification history

  24.02.05 ola     initial version
  07.11.05 ola     changed behaviour. -cachedObject will not increment the
                   internal reference counter any more.
  22.08.06 ola     license changed

  -------------------------------------------------------------------------
  </pre>
*/

#if !defined(__ECCacheItem_H)
#define __ECCacheItem_H

#include <Foundation/Foundation.h>
#include <Encore/ECObject.h>

/*!
 * @class ECCacheItem
 * @abstract Represents an item with the {@link ECCache}
 * @discussion In addition to the object to cache, this instance also
 *   contains statistic data. At present this is the cache reference count only.
 */
@interface ECCacheItem : ECObject <NSCoding>{
  @private 
    id cachedObject;
	unsigned int cacheReferenceCount;
}

- initWithObject: (id) objectToCache;
- (void) dealloc;


- (id) initWithCoder: (NSCoder *) decoder;
- (void) encodeWithCoder: (NSCoder *) encoder;


/*!
 * @method cachedObject
 * @result returns the cached object
 */
- cachedObject;


/*!
 * @method incrementCacheReferenceCount
 * @abstract increments the internal reference count
 */
- (void) incrementCacheReferenceCount;


/*!
 * @method decrementCacheReferenceCount
 * @abstract decrements the internal reference count.
 * @result returns the resulting reference count
 * @throws ECIllegalStateException if the internal reference count
 *   equals 0 when this method is being called
 */
- (unsigned int) decrementCacheReferenceCount;


/*!
 * @method cacheReferenceCount
 * @result returns the internal reference count
 */
- (unsigned int) cacheReferenceCount;
@end
#endif
