/*
 * Jakelib2 - General purpose C++ library
 * Copyright (C) 2001 Florian Wolff  (florian@donuz.de)
 *
 * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * $Id: Object.h,v 1.28 2003/02/03 23:08:58 florian Exp $
 */

#ifndef INCLUDE_JAKELIB2_LANG_OBJECT_H
# define INCLUDE_JAKELIB2_LANG_OBJECT_H


/**
 * Must be called before any other Jakelib2 class or
 * method can be used.
 *
 * @param argc The \c argc argument from the \c main() function.
 * @param argv The \c argv argument from the \c main() function.
 */
void initJakelib2(int argc = 0, char* argv[] = null);

namespace jakelib {
  namespace lang {

    class String;
    class Class;

    /**
     * @brief \c Object is the base class for all classes of jakelib.
     * Every inheriting class should at least override the \c getClass
     * method.
     *
     * @class Object
     * @version $Id: Object.h,v 1.28 2003/02/03 23:08:58 florian Exp $
     * @author Florian 'Overflo' Wolff (florian@donuz.de)
     */
    class Object : public gc_cleanup
      {
      public:
	Object();
	virtual ~Object();

	/**
	 * @brief Returns a hash code for this object. Should be overwritten by inheriting
	 * classes.
	 */
	virtual jint hashCode();

	/**
	 * @brief Returns a copy of this object. Should be overwritten by inheriting classes.
	 */
	virtual Object* clone();

	/**
	 * @brief Returns a string representation of this object. Should be overwritten by
	 * inheriting classes.
	 */
	virtual String* toString();


	/**
	 * @brief Compares this object to another <TT>Object</TT>. Returns <TT>TRUE</TT> if
	 * the objects are equal and <TT>FALSE</TT> otherwise.
	 * Should be overwritten by inheriting classes.
	 */
	virtual jboolean equals(Object* obj);

	/**
	 * @brief Returns the corresponding \c Class object.
	 */
	virtual Class* getClass() { return &_Object_Class; }
	static Class _Object_Class;

	/**
	 * @brief Determines whether this object is an instance of the class
	 * specified by a fully qualified class name like
	 * "\c jakelib.lang.Object".
	 */
	virtual jboolean instanceOf(String* name);

#ifdef JAKELIB_DEBUG
	static int newCounter;
	static int deleteCounter;
  
	static int getNewCounter();
	static int getDeleteCounter();

        static void methodCall(String* name, const char* filename, int line);
        static void methodCall(const char* name, const char* filename, int line);
#endif
      };
  }
}

#endif

