------------------------------------------------------------------------------
--                                                                          --
--                An Ada2005 binding to the Qt C++ framework                --
--                                                                          --
------------------------------------------------------------------------------
--                                                                          --
-- Copyright © 2008, 2009 Vadim Godunko <vgodunko@gmail.com>                --
--                                                                          --
-- QtAda is free software;  you can  redistribute it and/or modify it under --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
-- sion. QtAda is distributed in the hope that it will be useful, but WITH- --
-- OUT 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 distributed with QtAda;  see file COPYING.  If not, write --
-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
-- Boston, MA 02110-1301, USA.                                              --
--                                                                          --
-- As a special exception,  if other files  instantiate  generics from this --
-- unit, or you link  this unit with other files  to produce an executable, --
-- this  unit  does not  by itself cause  the resulting  executable  to  be --
-- covered  by the  GNU  General  Public  License.  This exception does not --
-- however invalidate  any other reasons why  the executable file  might be --
-- covered by the  GNU Public License.                                      --
--                                                                          --
------------------------------------------------------------------------------
--  $Revision: 3239 $ $Date: 2009-04-10 15:48:51 +0400 (Fri, 10 Apr 2009) $
------------------------------------------------------------------------------
private with Ada.Finalization;

with Qt_Ada.Internals.Objects;

generic
   type Object_Type (<>) is
     abstract limited new Qt_Ada.Internals.Objects.Q_Object_Base with private;
   --  Note: In the documentation Object_Type is derived from the
   --  Qt4.Objects.Q_Object. This is because Q_Object_Base is an internal
   --  interface type and should never be used by the applications.
   type Object_Access is access all Object_Type'Class;

package Qt_Ada.Generic_Object_Pointers is

   type Q_Pointer is tagged private;

   function Is_Null (Self : Q_Pointer) return Boolean;

   function Get (Self : Q_Pointer) return Object_Access;

   procedure Set (Self : in out Q_Pointer; To : Object_Access);

   function "=" (Left : Q_Pointer; Right : Object_Access) return Boolean;

   function "=" (Left : Object_Access; Right : Q_Pointer) return Boolean;

private

   type Q_Pointer is new Ada.Finalization.Controlled with record
      Reference : aliased Qt_Ada.Internals.Objects.QObject_Access;
   end record;

   overriding procedure Finalize (Self : in out Q_Pointer);

   overriding procedure Adjust (Self : in out Q_Pointer);

   overriding function "="
    (Left  : Q_Pointer;
     Right : Q_Pointer)
       return Boolean;

end Qt_Ada.Generic_Object_Pointers;
