comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: Enforcing initialization protocol for protected type
Date: Mon, 07 Sep 2009 19:01:12 +0200
Date: 2009-09-07T19:01:13+02:00	[thread overview]
Message-ID: <4aa53c59$0$30237$9b4e6d93@newsspool1.arcor-online.net> (raw)
In-Reply-To: <1fcccc80-0142-4f07-8852-8d151ea96ee2@c37g2000yqi.googlegroups.com>

Maciej Sobczak schrieb:
> Consider the Needs_Constructor type from the code example in the Ada
> wikibook:
> 
> http://en.wikibooks.org/wiki/Ada_Programming/Types/limited#Initialisi...
> 
> Is it possible to ensure a given initialization protocol for protected
> types as well?

The following is not using, I guess, your original
idea directly.  But it requires that the a proper context
be set up.  Then, the PO will initialize itself from
the context.  Context is passed in via known discriminants:

   -- method A, function pointer



   type Status_A is private;
   type A_Maker is access function return Status_A;

   -- method B, O-O construction



   type Status_B is private;
   package OO is
      type B_Maker is tagged private;

      function Make_B(Context: B_Maker) return Status_B;
   private
      type B_Maker is tagged record
         null;
      end record;
   end OO;

   type B_Maker_Ref is access OO.B_Maker'Class;

   protected type PO
     (First_A : not null A_Maker;
      First_B : not null B_Maker_Ref)
   is
      entry One;
      entry Two;
   private
      Data_A: Status_A := First_A.all;
      Data_B: Status_B := First_B.Make_B;
   end PO;



  reply	other threads:[~2009-09-07 17:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-07 15:15 Enforcing initialization protocol for protected type Maciej Sobczak
2009-09-07 17:01 ` Georg Bauhaus [this message]
2009-09-07 20:19   ` Maciej Sobczak
2009-09-10 17:07     ` Georg Bauhaus
2009-09-11  5:01     ` AdaMagica
2009-09-11  9:03       ` Dmitry A. Kazakov
2009-09-11 15:25         ` AdaMagica
2009-09-11 16:27           ` Dmitry A. Kazakov
2009-09-11 22:24             ` Randy Brukardt
2009-09-12  8:44               ` Dmitry A. Kazakov
2009-09-10 16:39 ` Per Sandberg
2009-09-14 21:15   ` Adam Beneschan
2009-09-15  0:27     ` Randy Brukardt
replies disabled

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