/*!
  @header ECObject
  @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
  22.08.06 ola     license changed
  -------------------------------------------------------------------------
  </pre>
*/

#if !defined(__ECObject_H)
#define __ECObject_H

#include <Foundation/Foundation.h>

#if !defined(OBJC_WITH_GC)
#ifdef MACOSX

#if !defined(RETAIN)
/**
 * @macro RETAIN
 * @description [objc retain]
 */
#define RETAIN(__r_object) [(__r_object) retain]
#endif

#if !defined(RELEASE)
/**
 * @macro RELEASE
 * @description [objc release]
 */
#define RELEASE(__r_object) [(__r_object) release]
#endif


#if !defined(ASSIGN)
/**
 * @macro ASSIGN
 * @param __a_variable target variable
 * @param __a_object source object reference
 * assigns __a_object to __a_variable
 */
#define	ASSIGN(__a_variable,__a_object) ({\
  if( (__a_variable) != (__a_object)) {\
    id tmp = (__a_variable);\
    if( nil != (__a_object) ) {\
      [__a_object retain];\
    }\
    __a_variable = __a_object;\
    if( nil != tmp ) {\
      [tmp release];\
    }\
  }\
})
#endif 

#if !defined(DESTROY)
/**
 * @macro DESTROY
 * @param ___d_object 
 * @description releases the referred object and assigns nil to the
 *   given variable
 */
#define DESTROY(___d_object ) ({\
  if( nil != (___d_object) ) {\
    id toRelease = (___d_object);\
    (___d_object) = nil;\
    [toRelease release];\
})
#endif

#if !defined(AUTORELEASE)
/**
 * @macro AUTORELEASE
 * @param __ar_obj object to auto release
 * @description mark an object for auto releasing
 */
#define AUTORELEASE(__ar_obj) [(__ar_obj) autorelease]
#endif

#endif //defined(MACOSX)

#endif //!defined(OBJC_WITH_GC) 

/*!
 * @protocol ECObject
 * @abstract protocol of all ec based classes
 */
@protocol ECObject <NSObject>
@end


/*!
 * @class ECObject
 * @abstract base class of all ec related classes
 */
@interface ECObject : NSObject <ECObject> 
@end
#endif
