/* 
 * © 2008-2009 Sun Microsystems, Inc.
 *
 * 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 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.
 */
#ifndef _MFORMS_BASE_H_
#define _MFORMS_BASE_H_

#include <string>
#include <list>

#ifdef _WIN32
# ifdef DECL_MFORMS_EXPORT
#  define MFORMS_EXPORT __declspec(dllexport)
# else
#  define MFORMS_EXPORT __declspec(dllimport)
# endif
#else
# define MFORMS_EXPORT
#endif

#ifndef _WIN32
#define __stdcall 
#endif

#ifdef __APPLE__
#ifdef nil
#undef nil
#endif 
#include <sigc++/sigc++.h>
#define nil __DARWIN_NULL
#include <objc/objc-runtime.h>
#endif

namespace mforms {
  class ControlFactory;
  
  //!
  //!
  //!
  class MFORMS_EXPORT Object
  {
    
    //! Note: set_data and get_data should be used exclusivelly by the implementation code
    //! for each platform.
#ifdef __APPLE__
  public:
    Object() : _data(nil) {}
    void set_data(id data) { objc_msgSend(data, sel_getUid("retain")); /* calls [data retain] */ _data= data; }
    id get_data() { return _data; }
    
    virtual ~Object() { /*objc_msgSend(_data, sel_getUid("release"));*/ /* calls [_data release] */ }
  private:
    id _data;
#else
  public:
    virtual ~Object() { }

    void set_data(void *data) { _data= data; }

    template<class C>
      C* get_data() { return reinterpret_cast<C*>(_data); }

    void *get_data_ptr() { return _data; }

  private:
    void *_data;
#endif
  };
};

#endif
