comp.lang.ada
 help / color / mirror / Atom feed
From: AdaMagica <christ-usch.grein@t-online.de>
Subject: Re: : Ada Utility Library 1.4.0 is available
Date: Mon, 16 Jan 2012 00:10:38 -0800 (PST)
Date: 2012-01-16T00:10:38-08:00	[thread overview]
Message-ID: <6c0b74d1-6d8d-4ef8-9132-c4e57b48f323@w4g2000vbc.googlegroups.com> (raw)
In-Reply-To: 4f13480d$0$5689$ba4acef3@reader.news.orange.fr

Hm, I looked at your beans, and I do not see the value of this.
What's the advantage of returning components with string names versus
returning them as usual?
First of all, the components are visible. If they aren't, why not just
use

function Radius (B: Compute_Bean) return Float;

--------------
with Util.Beans.Basic;
with Util.Beans.Objects;
...

   type Compute_Bean is new Util.Beans.Basic.Bean with record
      Height : My_Float := -1.0;
      Radius : My_Float := -1.0;
   end record;

   --  Get the value identified by the name.
   overriding
   function Get_Value (From : Compute_Bean;
                       Name : String) return
Util.Beans.Objects.Object;

   --  Set the value identified by the name.
   overriding
   procedure Set_Value (From  : in out Compute_Bean;
                        Name  : in String;
                        Value : in Util.Beans.Objects.Object);

Bean Implementation

The getter and setter will identify the property to get or set through
a name. The value is represented by an Object type that can hold
several data types (boolean, integer, floats, strings, dates, ...).
The getter looks for the name and returns the corresponding value in
an Object record. Several To_Object functions helps in creating the
result value.

   function Get_Value (From : Compute_Bean;
                       Name : String) return Util.Beans.Objects.Object
is
   begin
      if Name = "radius" and From.Radius >= 0.0 then
         return Util.Beans.Objects.To_Object (Float (From.Radius));

      elsif Name = "height" and From.Height >= 0.0 then
         return Util.Beans.Objects.To_Object (Float (From.Height));

      else
         return Util.Beans.Objects.Null_Object;
      end if;
   end Get_Value;



  reply	other threads:[~2012-01-16  8:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-15 21:41 [Ann]: Ada Utility Library 1.4.0 is available Stephane Carrez
2012-01-16  8:10 ` AdaMagica [this message]
2012-01-16 11:48   ` : " Georg Bauhaus
2012-01-16 20:31   ` Stephane Carrez
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox