comp.lang.ada
 help / color / mirror / Atom feed
* Private area and child packages
@ 2004-12-29  4:05 danmcleran
  2004-12-29  4:47 ` tmoran
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: danmcleran @ 2004-12-29  4:05 UTC (permalink / raw)


Is there any way to hide implementation detail from child packages? An
example, say I have a parent package like this:

package Some_Package is
type Secret_Type is private;
private
type Secret_Type is record
Secret_Value : Integer := 0;
end record;
end Some_Package;

I don't want any other component to be able to manipulate the
Secret_Value record component, not even a child package of
Some_Package.

Is there any way to do this? In C++, there is something called the
PIMPL idiom, where you hide implementation detail by holding a pointer
to an incomplete class, like this:

//SecretClass.h

class Implementation;//Class not yet fully defined

class SecretClass
{
public:
//publicly visible stuff
private:
Implementation* pImplementation;
};

So, no component outside of the implementation of SecretClass, (not
even other classes that inherit SecretClass), has any knowledge of the
structure of the implementation class. The full definition of the
Implementation class is not provided in the header containing the
definition of SecretClass. The Implementation class can either be
defined in the cpp file that defines SecretClass, or seperately.

I'm trying to figure out the most elegant way to do something like this
is Ada and would like to read any ideas/suggestions.




^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2005-01-01  3:45 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-29  4:05 Private area and child packages danmcleran
2004-12-29  4:47 ` tmoran
2004-12-29 15:10   ` danmcleran
2004-12-30 18:51     ` tmoran
2005-01-01  3:45       ` danmcleran
2004-12-29  4:49 ` Jeffrey Carter
2004-12-29 15:27   ` danmcleran
2004-12-29 16:53     ` Samuel Tardieu
2004-12-30  4:07       ` Jeffrey Carter
2004-12-30 15:31   ` danmcleran
2004-12-30 18:14     ` Jeffrey Carter
2004-12-31 17:55   ` danmcleran
     [not found]   ` <1104515735.052116.248180@c13g2000cwb.googlegroups.com>
2004-12-31 19:02     ` Jeffrey Carter
2004-12-29 19:05 ` Martin Krischik
2004-12-29 21:44 ` Stephen Leake

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